[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nix-dev
Subject:    [Nix-dev] Re: Re: Re: git-gui: require not using ttk
From:       marco-oweber () gmx ! de (Marc Weber)
Date:       2010-05-26 19:34:57
Message-ID: 1274900589-sup-5215 () nixos
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic