[PATCH] Replace hard-coded path with one configurable at make time
From: Chris Webb <hidden>
Date: 2016-06-15 22:48:33
Subsystem:
kernel build + files below scripts/ (unless maintained elsewhere), the rest · Maintainers:
Nathan Chancellor, Nicolas Schier, Linus Torvalds
In exec_cmd.c and git-instaweb.sh, git hard-codes a default path of /usr/local/bin:/usr/bin:/bin. Introduce a make variable allowing this to be overridden by passing defpath to make. --- I haven't worked out the capitalisation convention in the makefile, so I'm not sure if this should be DEFPATH or defpath. (For example, prefix is lower-case but DESTDIR is all-caps.) Makefile | 6 +++++- exec_cmd.c | 2 +- git-instaweb.sh | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 11ec3e2..2f4b39e 100644
--- a/Makefile
+++ b/Makefile@@ -278,6 +278,7 @@ endif lib = lib # DESTDIR= pathsep = : +defpath = /usr/local/bin:/usr/bin:/bin # JavaScript minifier invocation that can function as filter JSMIN =
@@ -1426,6 +1427,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) template_dir_SQ = $(subst ','\'',$(template_dir)) htmldir_SQ = $(subst ','\'',$(htmldir)) prefix_SQ = $(subst ','\'',$(prefix)) +defpath_SQ = $(subst ','\'',$(defpath)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -1588,6 +1590,7 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb. -e '/@@GITWEB_JS@@/r gitweb/gitweb.js' \ -e '/@@GITWEB_JS@@/d' \ -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ + -e 's|@@DEFPATH@@|$(defpath_SQ)|g' \ $@.sh > $@+ && \ chmod +x $@+ && \ mv $@+ $@
@@ -1774,7 +1777,8 @@ endif exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \ '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \ '-DBINDIR="$(bindir_relative_SQ)"' \ - '-DPREFIX="$(prefix_SQ)"' + '-DPREFIX="$(prefix_SQ)"' \ + '-DDEFPATH="$(defpath_SQ)"' builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
diff --git a/exec_cmd.c b/exec_cmd.c
index b2c07c7..39c6a59 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c@@ -107,7 +107,7 @@ void setup_path(void) if (old_path) strbuf_addstr(&new_path, old_path); else - strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin"); + strbuf_addstr(&new_path, DEFPATH); setenv("PATH", new_path.buf, 1);
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 6a65f25..72d8b12 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh@@ -212,7 +212,7 @@ server.errorlog = "$fqgitdir/gitweb/error.log" # variable above and uncomment this #accesslog.filename = "$fqgitdir/gitweb/access.log" -setenv.add-environment = ( "PATH" => "/usr/local/bin:/usr/bin:/bin" ) +setenv.add-environment = ( "PATH" => "@@DEFPATH@@" ) cgi.assign = ( ".cgi" => "" )
@@ -361,7 +361,7 @@ error_log $fqgitdir/gitweb/error.log access_log $fqgitdir/gitweb/access.log #cgi setup -cgi_env PATH=/usr/local/bin:/usr/bin:/bin,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH +cgi_env PATH=@@DEFPATH@@,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH cgi_interp $PERL cgi_ext cgi,pl
--
1.7.0.3