utils: Change 'wrap-program' to preserve the original argv[0].
Suggested by Mark H Weaver <mhw@netris.org> in <http://bugs.gnu.org/19138>. * guix/build/utils.scm (wrap-program): Change wrapper to use "exec -a PROG" instead of just "exec".
This commit is contained in:
		
							parent
							
								
									c809ec94d1
								
							
						
					
					
						commit
						2ed11b3a3e
					
				
					 1 changed files with 4 additions and 2 deletions
				
			
		|  | @ -762,7 +762,7 @@ contents: | ||||||
|   #!location/of/bin/bash |   #!location/of/bin/bash | ||||||
|   export PATH=\"/gnu/.../bar/bin\" |   export PATH=\"/gnu/.../bar/bin\" | ||||||
|   export CERT_PATH=\"$CERT_PATH${CERT_PATH:+:}/gnu/.../baz/certs:/qux/certs\" |   export CERT_PATH=\"$CERT_PATH${CERT_PATH:+:}/gnu/.../baz/certs:/qux/certs\" | ||||||
|   exec location/of/.foo-real |   exec -a location/of/foo location/of/.foo-real \"$@\" | ||||||
| 
 | 
 | ||||||
| This is useful for scripts that expect particular programs to be in $PATH, for | This is useful for scripts that expect particular programs to be in $PATH, for | ||||||
| programs that expect particular shared libraries to be in $LD_LIBRARY_PATH, or | programs that expect particular shared libraries to be in $LD_LIBRARY_PATH, or | ||||||
|  | @ -786,6 +786,7 @@ the previous wrapper." | ||||||
|           (copy-file prog prog-real) |           (copy-file prog prog-real) | ||||||
|           prog-real) |           prog-real) | ||||||
|         (wrapper-file-name number))) |         (wrapper-file-name number))) | ||||||
|  | 
 | ||||||
|   (let* ((number   (next-wrapper-number)) |   (let* ((number   (next-wrapper-number)) | ||||||
|          (target   (wrapper-target number)) |          (target   (wrapper-target number)) | ||||||
|          (wrapper  (wrapper-file-name (1+ number))) |          (wrapper  (wrapper-file-name (1+ number))) | ||||||
|  | @ -815,10 +816,11 @@ the previous wrapper." | ||||||
|     (with-output-to-file prog-tmp |     (with-output-to-file prog-tmp | ||||||
|       (lambda () |       (lambda () | ||||||
|         (format #t |         (format #t | ||||||
|                 "#!~a~%~a~%exec \"~a\" \"$@\"~%" |                 "#!~a~%~a~%exec -a \"~a\" \"~a\" \"$@\"~%" | ||||||
|                 (which "bash") |                 (which "bash") | ||||||
|                 (string-join (map export-variable vars) |                 (string-join (map export-variable vars) | ||||||
|                              "\n") |                              "\n") | ||||||
|  |                 (canonicalize-path prog) | ||||||
|                 (canonicalize-path target)))) |                 (canonicalize-path target)))) | ||||||
| 
 | 
 | ||||||
|     (chmod prog-tmp #o755) |     (chmod prog-tmp #o755) | ||||||
|  |  | ||||||
		Reference in a new issue