All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Replace hard-coded path with one configurable at make time
@ 2010-04-04 20:48 Chris Webb
  2010-04-04 21:38 ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Chris Webb @ 2010-04-04 20:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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

^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2010-04-15 19:15 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-04 20:48 [PATCH] Replace hard-coded path with one configurable at make time Chris Webb
2010-04-04 21:38 ` Junio C Hamano
2010-04-04 22:28   ` Chris Webb
2010-04-06 16:35     ` Chris Webb
2010-04-06 16:36       ` [PATCH] Replace hard-coded path with one from <paths.h> Chris Webb
2010-04-07 10:57         ` Erik Faye-Lund
2010-04-08 10:58           ` Chris Webb
2010-04-08 11:26             ` Erik Faye-Lund
2010-04-08 11:57               ` [PATCH v2] " Chris Webb
2010-04-08 12:08                 ` Erik Faye-Lund
2010-04-09  5:45                   ` Chris Webb
2010-04-13  9:06                     ` Chris Webb
2010-04-13  9:07                       ` [PATCH v3] " Chris Webb
2010-04-13 20:01                         ` Junio C Hamano
2010-04-14  7:22                           ` Chris Webb
2010-04-15 12:27                           ` Jakub Narebski
2010-04-15 19:15                             ` Junio C Hamano
2010-04-15 12:25                         ` Jakub Narebski
2010-04-15 12:40                           ` Chris Webb
2010-04-15 12:57                             ` Jakub Narebski
2010-04-15 13:01                               ` Chris Webb
2010-04-15 13:21                                 ` [PATCH v4] " Chris Webb
2010-04-09 23:54             ` [PATCH] " Tait
2010-04-06 16:57       ` [PATCH] git-instaweb: pass through invoking user's path to gitweb CGI script Chris Webb

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.