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>
This commit is contained in:
Pavan Kumar Sunkara 2010-05-28 11:55:52 +05:30 коммит произвёл Junio C Hamano
Родитель be5347b398
Коммит c0cb4ed3e6
2 изменённых файлов: 27 добавлений и 52 удалений

Просмотреть файл

@ -1443,6 +1443,7 @@ gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
template_dir_SQ = $(subst ','\'',$(template_dir)) template_dir_SQ = $(subst ','\'',$(template_dir))
htmldir_SQ = $(subst ','\'',$(htmldir)) htmldir_SQ = $(subst ','\'',$(htmldir))
prefix_SQ = $(subst ','\'',$(prefix)) prefix_SQ = $(subst ','\'',$(prefix))
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@ -1609,15 +1610,8 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/static/gitweb.css gitweb/
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
-e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \ -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
-e '/@@GITWEB_CGI@@/d' \
-e '/@@GITWEB_CSS@@/r $(GITWEB_CSS)' \
-e '/@@GITWEB_CSS@@/d' \
-e '/@@GITWEB_JS@@/r $(GITWEB_JS)' \
-e '/@@GITWEB_JS@@/d' \
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-e 's|@@GITWEB_CSS_NAME@@|$(GITWEB_CSS)|' \
-e 's|@@GITWEB_JS_NAME@@|$(GITWEB_JS)|' \
$@.sh > $@+ && \ $@.sh > $@+ && \
chmod +x $@+ && \ chmod +x $@+ && \
mv $@+ $@ mv $@+ $@
@ -1984,6 +1978,7 @@ install: all
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
ifndef NO_PERL ifndef NO_PERL
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
$(MAKE) -C gitweb gitwebdir=$(gitwebdir_SQ) install
endif endif
ifndef NO_PYTHON ifndef NO_PYTHON
$(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install $(MAKE) -C git_remote_helpers prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install

Просмотреть файл

@ -24,6 +24,7 @@ restart restart the web server
fqgitdir="$GIT_DIR" fqgitdir="$GIT_DIR"
local="$(git config --bool --get instaweb.local)" local="$(git config --bool --get instaweb.local)"
httpd="$(git config --get instaweb.httpd)" httpd="$(git config --get instaweb.httpd)"
root="$(git config --get instaweb.gitwebdir)"
port=$(git config --get instaweb.port) port=$(git config --get instaweb.port)
module_path="$(git config --get instaweb.modulepath)" module_path="$(git config --get instaweb.modulepath)"
@ -34,6 +35,9 @@ conf="$GIT_DIR/gitweb/httpd.conf"
# if installed, it doesn't need further configuration (module_path) # if installed, it doesn't need further configuration (module_path)
test -z "$httpd" && httpd='lighttpd -f' test -z "$httpd" && httpd='lighttpd -f'
# Default is @@GITWEBDIR@@
test -z "$root" && root='@@GITWEBDIR@@'
# any untaken local port will do... # any untaken local port will do...
test -z "$port" && port=1234 test -z "$port" && port=1234
@ -57,7 +61,7 @@ resolve_full_httpd () {
# these days and those are not in most users $PATHs # these days and those are not in most users $PATHs
# in addition, we may have generated a server script # in addition, we may have generated a server script
# in $fqgitdir/gitweb. # in $fqgitdir/gitweb.
for i in /usr/local/sbin /usr/sbin "$fqgitdir/gitweb" for i in /usr/local/sbin /usr/sbin "$root" "$fqgitdir/gitweb"
do do
if test -x "$i/$httpd_only" if test -x "$i/$httpd_only"
then then
@ -159,8 +163,8 @@ done
mkdir -p "$GIT_DIR/gitweb/tmp" mkdir -p "$GIT_DIR/gitweb/tmp"
GIT_EXEC_PATH="$(git --exec-path)" GIT_EXEC_PATH="$(git --exec-path)"
GIT_DIR="$fqgitdir" GIT_DIR="$fqgitdir"
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG="$fqgitdir/gitweb/gitweb_config.perl"
export GIT_EXEC_PATH GIT_DIR GITWEB_CONFIG
webrick_conf () { webrick_conf () {
# generate a standalone server script in $fqgitdir/gitweb. # generate a standalone server script in $fqgitdir/gitweb.
@ -192,7 +196,7 @@ EOF
cat >"$conf" <<EOF cat >"$conf" <<EOF
:Port: $port :Port: $port
:DocumentRoot: "$fqgitdir/gitweb" :DocumentRoot: "$root"
:DirectoryIndex: ["gitweb.cgi"] :DirectoryIndex: ["gitweb.cgi"]
:PidFile: "$fqgitdir/pid" :PidFile: "$fqgitdir/pid"
EOF EOF
@ -201,7 +205,7 @@ EOF
lighttpd_conf () { lighttpd_conf () {
cat > "$conf" <<EOF cat > "$conf" <<EOF
server.document-root = "$fqgitdir/gitweb" server.document-root = "$root"
server.port = $port server.port = $port
server.modules = ( "mod_setenv", "mod_cgi" ) server.modules = ( "mod_setenv", "mod_cgi" )
server.indexfiles = ( "gitweb.cgi" ) server.indexfiles = ( "gitweb.cgi" )
@ -212,7 +216,7 @@ server.errorlog = "$fqgitdir/gitweb/$httpd_only/error.log"
# variable above and uncomment this # variable above and uncomment this
#accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log" #accesslog.filename = "$fqgitdir/gitweb/$httpd_only/access.log"
setenv.add-environment = ( "PATH" => env.PATH ) setenv.add-environment = ( "PATH" => env.PATH, "GITWEB_CONFIG" => env.GITWEB_CONFIG )
cgi.assign = ( ".cgi" => "" ) cgi.assign = ( ".cgi" => "" )
@ -282,8 +286,8 @@ apache2_conf () {
echo 'text/css css' > "$fqgitdir/mime.types" echo 'text/css css' > "$fqgitdir/mime.types"
cat > "$conf" <<EOF cat > "$conf" <<EOF
ServerName "git-instaweb" ServerName "git-instaweb"
ServerRoot "$fqgitdir/gitweb" ServerRoot "$root"
DocumentRoot "$fqgitdir/gitweb" DocumentRoot "$root"
ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log" ErrorLog "$fqgitdir/gitweb/$httpd_only/error.log"
CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined CustomLog "$fqgitdir/gitweb/$httpd_only/access.log" combined
PidFile "$fqgitdir/pid" PidFile "$fqgitdir/pid"
@ -304,13 +308,14 @@ EOF
# check to see if Dennis Stosberg's mod_perl compatibility patch # check to see if Dennis Stosberg's mod_perl compatibility patch
# (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied # (<20060621130708.Gcbc6e5c@leonov.stosberg.net>) has been applied
if test -f "$module_path/mod_perl.so" && if test -f "$module_path/mod_perl.so" &&
sane_grep 'MOD_PERL' "$GIT_DIR/gitweb/gitweb.cgi" >/dev/null sane_grep 'MOD_PERL' "$root/gitweb.cgi" >/dev/null
then then
# favor mod_perl if available # favor mod_perl if available
cat >> "$conf" <<EOF cat >> "$conf" <<EOF
LoadModule perl_module $module_path/mod_perl.so LoadModule perl_module $module_path/mod_perl.so
PerlPassEnv GIT_DIR PerlPassEnv GIT_DIR
PerlPassEnv GIT_EXEC_DIR PerlPassEnv GIT_EXEC_DIR
PerlPassEnv GITWEB_CONFIG
<Location /gitweb.cgi> <Location /gitweb.cgi>
SetHandler perl-script SetHandler perl-script
PerlResponseHandler ModPerl::Registry PerlResponseHandler ModPerl::Registry
@ -354,7 +359,7 @@ mongoose_conf() {
# For detailed description of every option, visit # For detailed description of every option, visit
# http://code.google.com/p/mongoose/wiki/MongooseManual # http://code.google.com/p/mongoose/wiki/MongooseManual
root $fqgitdir/gitweb root $root
ports $port ports $port
index_files gitweb.cgi index_files gitweb.cgi
#ssl_cert $fqgitdir/gitweb/ssl_cert.pem #ssl_cert $fqgitdir/gitweb/ssl_cert.pem
@ -362,7 +367,7 @@ error_log $fqgitdir/gitweb/$httpd_only/error.log
access_log $fqgitdir/gitweb/$httpd_only/access.log access_log $fqgitdir/gitweb/$httpd_only/access.log
#cgi setup #cgi setup
cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH cgi_env PATH=$PATH,GIT_DIR=$GIT_DIR,GIT_EXEC_PATH=$GIT_EXEC_PATH,GITWEB_CONFIG=$GITWEB_CONFIG
cgi_interp $PERL cgi_interp $PERL
cgi_ext cgi,pl cgi_ext cgi,pl
@ -371,41 +376,16 @@ mime_types .gz=application/x-gzip,.tar.gz=application/x-tgz,.tgz=application/x-t
EOF EOF
} }
gitweb_conf() {
script=' cat > "$fqgitdir/gitweb/gitweb_config.perl" <<EOF
s#^(my|our) \$projectroot =.*#$1 \$projectroot = "'$(dirname "$fqgitdir")'";#; #!/usr/bin/perl
s#(my|our) \$gitbin =.*#$1 \$gitbin = "'$GIT_EXEC_PATH'";#; our \$projectroot = "$(dirname "$fqgitdir")";
s#(my|our) \$projects_list =.*#$1 \$projects_list = \$projectroot;#; our \$git_temp = "$fqgitdir/gitweb/tmp";
s#(my|our) \$git_temp =.*#$1 \$git_temp = "'$fqgitdir/gitweb/tmp'";#;' our \$projects_list = \$projectroot;
EOF
gitweb_cgi () {
cat > "$1.tmp" <<\EOFGITWEB
@@GITWEB_CGI@@
EOFGITWEB
# Use the configured full path to perl to match the generated
# scripts' 'hashpling' line
"$PERL" -p -e "$script" "$1.tmp" > "$1"
chmod +x "$1"
rm -f "$1.tmp"
} }
gitweb_css () { gitweb_conf
cat > "$1" <<\EOFGITWEB
@@GITWEB_CSS@@
EOFGITWEB
}
gitweb_js () {
cat > "$1" <<\EOFGITWEB
@@GITWEB_JS@@
EOFGITWEB
}
gitweb_cgi "$GIT_DIR/gitweb/gitweb.cgi"
gitweb_css "$GIT_DIR/@@GITWEB_CSS_NAME@@"
gitweb_js "$GIT_DIR/@@GITWEB_JS_NAME@@"
resolve_full_httpd resolve_full_httpd
mkdir -p "$fqgitdir/gitweb/$httpd_only" mkdir -p "$fqgitdir/gitweb/$httpd_only"