[Nix-dev] Re: Re: Re: git-gui: require not using ttk

Marc Weber marco-oweber at gmx.de
Wed May 26 21:34:57 CEST 2010


Excerpts from Yury G. Kudryashov's message of Wed May 26 20:20:05 +0200 2010:
> Marc Weber wrote:
> 
> > Excerpts from Yury G. Kudryashov's message of Wed May 26 19:35:22 +0200
> > 2010:
> >> I'd propose to change wrapProgram globally to move original program to
> >> .orig/originalName instead of .original-name-wrapped. In this case we
> >> shall not have such problems (progs assert that they know $0) in the
> >> future.
> > 
> > 
> > Which will not work for all cases because some apss might be using
> > something like this: Calling apps relative to current bin directory:
> > 
> > exec $(dirname $0)/other-app
> > 
> > So you may fix git-gui but you may break others.
> > So should an option be created eg:
> > 
> >   wrap --keep-name # use .orig/name
> >   wrap --keep-path # use .name-wrapped
> OK for me

Is this all worth the effort? The git patch seems trivial to me.

There is another reason: The mv code in wrapProgram can be moved into a
utility function. I had to duplicate it once.

So this patch does:

- move code of wrapProgram into doWrapProgam adding the mkdir command in
  case the hidden location is a new path. Also adding new arg receiving
  hidden name.

- add new function wrapProgramKeeepBasename

side effect: omit passing $prog twice to makeWrapper which didn't hurt because it
  was ignored by the for loop


diff --git a/pkgs/build-support/make-wrapper/make-wrapper.sh b/pkgs/build-support/make-wrapper/make-wrapper.sh
index 08146f3..843bac0 100644
--- a/pkgs/build-support/make-wrapper/make-wrapper.sh
+++ b/pkgs/build-support/make-wrapper/make-wrapper.sh
@@ -93,10 +93,22 @@ filterExisting() {
     done
 }
 
+# doWrapProgam <HIDDEN_NAME> <PROGRAM> <MAKE-WRAPPER FLAGS...>
+doWrapProgam() {
+    local hidden="$1"
+    local prog="$2"
+    mkdir -p "$(dirname $hidden)"
+    mv $prog $hidden
+    makeWrapper "$@"
+}
+
 # Syntax: wrapProgram <PROGRAM> <MAKE-WRAPPER FLAGS...>
+# bin/foo -> bin/.foo-wrapped
 wrapProgram() {
-    local prog="$1"
-    local hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped
-    mv $prog $hidden
-    makeWrapper $hidden $prog "$@"
+    doWrapProgam "$(dirname "$1")/.$(basename "$1")"-wrapped "$@"
+}
+
+# bin/foo -> bin/.wrapped/foo (servers special case git-gui)
+wrapProgramKeeepBasename(){
+    doWrapProgam "$(dirname "$1")/.wrapped/$(basename "$1")" "$@"
 }


Should it be comitted to stdenv-updates? Does someone know how much will
be rebuild?

Caution: I didn't test this patch yet - Just wondering whether its
important enough to be comitted at all.

Marc Weber



More information about the nix-dev mailing list