@matheusbsbs / matheus-bagliano / commits / c0cb4ed3e6
Fork 0

git-instaweb: Configure it to work with new gitweb structure

git-instaweb in its current form (re)creates gitweb.cgi and (some of) required static files in $GIT_DIR/gitweb/ directory. Splitting gitweb would make it difficult for git-instaweb to continue with this method. Use the instaweb.gitwebdir config variable to point git-instaweb script to a global directory which contains gitweb files as server root and the httpd.conf along with server logs and pid go into '$(GIT_DIR)/gitweb' directory. Signed-off-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Petr Baudis <pasky@ucw.cz> Acked-by: Jakub Narebski <jnareb@gmail.com> Acked-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pavan Kumar Sunkara committed May 28, 2010 at 11:55 UTC c0cb4ed3e653a37a53ef3a1e08daa42ac9cbc3fc
2 files changed +27 -52
Makefile
+3 -8
@@ -1443,6 +1443,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
1443 template_dir_SQ = $(subst ','\'',$(template_dir))
1444 htmldir_SQ = $(subst ','\'',$(htmldir))
1445 prefix_SQ = $(subst ','\'',$(prefix))
1446 +gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
1447
1448 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
1449 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -1609,15 +1610,8 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/static/gitweb.css gitweb/
1610 sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
1611 -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
1612 -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
1612 - -e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
1613 - -e '/@@GITWEB_CGI@@/d' \
1614 - -e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
1615 - -e '/@@GITWEB_CSS@@/d' \
1616 - -e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
1617 - -e '/@@GITWEB_JS@@/d' \
1613 + -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
1614 -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
1619 - -e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \
1620 - -e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \
1615 $@.sh > $@+ && \
1616 chmod +x $@+ && \
1617 mv $@+ $@
@@ -1984,6 +1978,7 @@ install: all
1978 $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
1979 ifndef NO_PERL
1980 $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
1981 + $(MAKE) -C gitweb gitwebdir=$(gitwebdir_SQ) install
1982 endif
1983 ifndef NO_PYTHON
1984 $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
git-instaweb.sh
+24 -44
@@ -24,6 +24,7 @@ restart restart the web server
24 fqgitdir="$GIT_DIR"
25 local="$(git config --bool --get instaweb.local)"
26 httpd="$(git config --get instaweb.httpd)"
27 +root="$(git config --get instaweb.gitwebdir)"
28 port=$(git config --get instaweb.port)
29 module_path="$(git config --get instaweb.modulepath)"
30
@@ -34,6 +35,9 @@ conf="$GIT_DIR/gitweb/httpd.conf"
35 # if installed, it doesn't need further configuration (module_path)
36 test -z "$httpd" && httpd='lighttpd -f'
37
38 +# Default is @@GITWEBDIR@@
39 +test -z "$root" && root='@@GITWEBDIR@@'
40 +
41 # any untaken local port will do...
42 test -z "$port" && port=1234
43
@@ -57,7 +61,7 @@ resolve_full_httpd () {
61 # these days and those are not in most users $PATHs
62 # in addition, we may have generated a server script
63 # in $fqgitdir/gitweb.
60 - for i in /usr/local/sbin /usr/sbin "$fqgitdir/gitweb"
64 + for i in /usr/local/sbin /usr/sbin "$root" "$fqgitdir/gitweb"
65 do
66 if test -x "$i/$httpd_only"
67 then
@@ -159,8 +163,8 @@ done
163 mkdir -p "$GIT_DIR/gitweb/tmp"
164 GIT_EXEC_PATH="$(git --exec-path)"
165 GIT_DIR="$fqgitdir"
162 -export GIT_EXEC_PATH GIT_DIR
163 -
166 +GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
167 +export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
168
169 webrick_conf () {
170 # generate a standalone server script in $fqgitdir/gitweb.
@@ -192,7 +196,7 @@ EOF
196
197 cat >"$conf" <<EOF
198 :Port: $port
195 -:DocumentRoot: "$fqgitdir/gitweb"
199 +:DocumentRoot: "$root"
200 :DirectoryIndex: ["gitweb.cgi"]
201 :PidFile: "$fqgitdir/pid"
202 EOF
@@ -201,7 +205,7 @@ EOF
205
206 lighttpd_conf () {
207 cat > "$conf" <<EOF
204 -server.document-root = "$fqgitdir/gitweb"
208 +server.document-root = "$root"
209 server.port = $port
210 server.modules = ( "mod_setenv", "mod_cgi" )
211 server.indexfiles = ( "gitweb.cgi" )
@@ -212,7 +216,7 @@ server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
216 # variable above and uncomment this
217 #accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log"
218
215 -setenv.add-environment = ( "PATH" => env.PATH )
219 +setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
220
221 cgi.assign = ( ".cgi" => "" )
222
@@ -282,8 +286,8 @@ apache2_conf () {
286 echo 'text/css css' > "$fqgitdir/mime.types"
287 cat > "$conf" <<EOF
288 ServerName "git-instaweb"
285 -ServerRoot "$fqgitdir/gitweb"
286 -DocumentRoot "$fqgitdir/gitweb"
289 +ServerRoot "$root"
290 +DocumentRoot "$root"
291 ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log"
292 CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined
293 PidFile "$fqgitdir/pid"
@@ -304,13 +308,14 @@ EOF
308 # check to see if Dennis Stosberg's mod_perl compatibility patch
309 # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
310 if test -f "$module_path/mod_perl.so" &&
307 - sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null
311 + sane_grep 'MOD_PERL' "$root/gitweb.cgi" >/dev/null
312 then
313 # favor mod_perl if available
314 cat >> "$conf" <<EOF
315 LoadModule perl_module $module_path/mod_perl.so
316 PerlPassEnv GIT_DIR
317 PerlPassEnv GIT_EXEC_DIR
318 +PerlPassEnv GITWEB_CONFIG
319 <Location /gitweb.cgi>
320 SetHandler perl-script
321 PerlResponseHandler ModPerl::Registry
@@ -354,7 +359,7 @@ mongoose_conf() {
359 # For detailed description of every option, visit
360 # http://code.google.com/p/mongoose/wiki/MongooseManual
361
357 -root $fqgitdir/gitweb
362 +root $root
363 ports $port
364 index_files gitweb.cgi
365 #ssl_cert $fqgitdir/gitweb/ssl_cert.pem
@@ -362,7 +367,7 @@ error_log $fqgitdir/gitweb/$httpd_only/error.log
367 access_log $fqgitdir/gitweb/$httpd_only/access.log
368
369 #cgi setup
365 -cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH
370 +cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH,GITWEB_CONFIG=$GITWEB_CONFIG
371 cgi_interp $PERL
372 cgi_ext cgi,pl
373
@@ -371,41 +376,16 @@ mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-t
376 EOF
377 }
378
374 -
375 -script='
376 -s#^(my|our) \$projectroot =.*#$1 \$projectroot = "'$(dirname "$fqgitdir")'";#;
377 -s#(my|our) \$gitbin =.*#$1 \$gitbin = "'$GIT_EXEC_PATH'";#;
378 -s#(my|our) \$projects_list =.*#$1 \$projects_list = \$projectroot;#;
379 -s#(my|our) \$git_temp =.*#$1 \$git_temp = "'$fqgitdir/gitweb/tmp'";#;'
380 -
381 -gitweb_cgi () {
382 - cat > "$1.tmp" <<\EOFGITWEB
383 -@@GITWEB_CGI@@
384 -EOFGITWEB
385 - # Use the configured full path to perl to match the generated
386 - # scripts' 'hashpling' line
387 - "$PERL" -p -e "$script" "$1.tmp" > "$1"
388 - chmod +x "$1"
389 - rm -f "$1.tmp"
390 -}
391 -
392 -gitweb_css () {
393 - cat > "$1" <<\EOFGITWEB
394 -@@GITWEB_CSS@@
395 -
396 -EOFGITWEB
397 -}
398 -
399 -gitweb_js () {
400 - cat > "$1" <<\EOFGITWEB
401 -@@GITWEB_JS@@
402 -
403 -EOFGITWEB
379 +gitweb_conf() {
380 + cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
381 +#!/usr/bin/perl
382 +our \$projectroot = "$(dirname "$fqgitdir")";
383 +our \$git_temp = "$fqgitdir/gitweb/tmp";
384 +our \$projects_list = \$projectroot;
385 +EOF
386 }
387
406 -gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
407 -gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
408 -gitweb_js "$GIT_DIR/@@GITWEB_JS_NAME@@"
388 +gitweb_conf
389
390 resolve_full_httpd
391 mkdir -p "$fqgitdir/gitweb/$httpd_only"