From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: John 'Warthog9' Hawley <warthog9@kernel.org>,
John 'Warthog9' Hawley <warthog9@eaglescrag.net>,
Junio C Hamano <gitster@pobox.com>, Petr Baudis <pasky@ucw.cz>,
admin@repo.or.cz
Subject: [PATCHv7.3 1/4 (bugfix)] gitweb: Prepare for splitting gitweb
Date: Thu, 2 Dec 2010 11:17:14 +0100 [thread overview]
Message-ID: <201012021117.16183.jnareb@gmail.com> (raw)
In-Reply-To: <201011130041.22918.jnareb@gmail.com>
Prepare gitweb for having been split into modules that are to be
installed alongside gitweb in 'lib/' subdirectory, by adding
use lib __DIR__.'/lib';
to gitweb.perl (to main gitweb script), and preparing for putting
modules (relative path) in $(GITWEB_MODULES) in gitweb/Makefile.
This preparatory work allows to add new module to gitweb by simply
adding
GITWEB_MODULES += <module>
to gitweb/Makefile (assuming that the module is in 'gitweb/lib/'
directory).
While at it pass GITWEBLIBDIR in addition to GITWEB_TEST_INSTALLED to
allow testing installed version of gitweb and installed version of
modules (for future tests which would check individual (sub)modules).
Using __DIR__ from Dir::Self module (not in core, that's why currently
gitweb includes excerpt of code from Dir::Self defining __DIR__) was
chosen over using FindBin-based solution (in core since perl 5.00307,
while gitweb itself requires at least perl 5.8.0) because FindBin uses
BEGIN block, which is a problem under mod_perl and other persistent
Perl environments (thought there are workarounds).
At Pavan Kumar Sankara suggestion gitweb/Makefile uses
install [OPTION]... SOURCE... DIRECTORY
format (2nd format) with single SOURCE rather than
install [OPTION]... SOURCE DEST
format (1st format) because of security reasons (race conditions).
Modern GNU install has `-T' / `--no-target-directory' option, but we
cannot rely that the $(INSTALL) we are using supports this option.
The install-modules target in gitweb/Makefile uses shell 'for' loop,
instead of make's $(foreach) function, to avoid possible problem with
generating a command line that exceeded the maximum argument list
length.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
BUGFIX: shell variables should not be in single quotes
I am very sorry about this bug...
gitweb/Makefile | 18 +++++++++++++++---
gitweb/gitweb.perl | 8 ++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/gitweb/Makefile b/gitweb/Makefile
index 0a6ac00..ad5a282 100644
--- a/gitweb/Makefile
+++ b/gitweb/Makefile
@@ -57,6 +57,7 @@ PERL_PATH ?= /usr/bin/perl
bindir_SQ = $(subst ','\'',$(bindir))#'
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))#'
gitwebstaticdir_SQ = $(subst ','\'',$(gitwebdir)/static)#'
+gitweblibdir_SQ = $(subst ','\'',$(gitwebdir)/lib)#'
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))#'
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))#'
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))#'
@@ -153,20 +154,31 @@ test:
test-installed:
GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
+ GITWEBLIBDIR='$(DESTDIR_SQ)$(gitweblibdir_SQ)' \
$(MAKE) -C ../t gitweb-test
### Installation rules
-install: all
+install: all install-modules
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)'
$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'
+install-modules:
+ install_dirs="$(sort $(dir $(GITWEB_MODULES)))" && \
+ for dir in $$install_dirs; do \
+ test -d '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir" || \
+ $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$dir"; \
+ done
+ gitweb_modules="$(GITWEB_MODULES)" && \
+ for mod in $$gitweb_modules; do \
+ $(INSTALL) -m 644 "lib/$$mod" '$(DESTDIR_SQ)$(gitweblibdir_SQ)'/"$$(dirname $$mod)"; \
+ done
+
### Cleaning rules
clean:
$(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
-.PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
-
+.PHONY: all clean install install-modules test test-installed .FORCE-GIT-VERSION-FILE FORCE
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 679f2da..cfa511c 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -10,6 +10,14 @@
use 5.008;
use strict;
use warnings;
+
+use File::Spec;
+# __DIR__ is taken from Dir::Self __DIR__ fragment
+sub __DIR__ () {
+ File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
+}
+use lib __DIR__ . '/lib';
+
use CGI qw(:standard :escapeHTML -nosticky);
use CGI::Util qw(unescape);
use CGI::Carp qw(fatalsToBrowser set_message);
--
1.7.3
next prev parent reply other threads:[~2010-12-02 10:17 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 0:42 [PATCH 0/3] Gitweb caching v7 John 'Warthog9' Hawley
2010-10-28 0:42 ` [PATCH 1/3] gitweb: Add option to force version match John 'Warthog9' Hawley
2010-10-28 9:52 ` Jakub Narebski
2010-10-28 22:08 ` Junio C Hamano
2010-10-28 0:42 ` [PATCH 2/3] gitweb: add output buffering and associated functions John 'Warthog9' Hawley
2010-10-28 9:56 ` Jakub Narebski
2010-10-28 0:42 ` [PATCH 3/3] gitweb: File based caching layer (from git.kernel.org) John 'Warthog9' Hawley
2010-10-28 16:10 ` Jakub Narebski
2010-10-28 22:29 ` [PATCH 0/3] Gitweb caching v7 Junio C Hamano
2010-10-29 22:25 ` Junio C Hamano
2010-10-30 8:58 ` Jakub Narebski
2010-10-31 4:24 ` Junio C Hamano
2010-10-31 9:21 ` Jakub Narebski
2010-11-01 10:24 ` [PATCHv7.1 0/4] Gitweb caching v7.1 Jakub Narebski
2010-11-12 23:35 ` [RFC/PATCHv7.2 0/4] Gitweb caching v7.2 Jakub Narebski
2010-11-12 23:41 ` [PATCHv7.2 1/4] gitweb: Prepare for splitting gitweb Jakub Narebski
2010-11-17 23:10 ` Junio C Hamano
2010-11-18 13:37 ` Jakub Narebski
2010-12-02 10:17 ` Jakub Narebski [this message]
2010-12-02 17:37 ` [PATCHv7.3 1/4 (bugfix)] " Junio C Hamano
2010-12-02 19:01 ` Jakub Narebski
2010-12-02 19:21 ` Junio C Hamano
2010-12-02 19:36 ` Jakub Narebski
2010-11-12 23:44 ` [PATCHv7.1 2/4] gitweb: add output buffering and associated functions Jakub Narebski
2010-11-12 23:56 ` [PATCHv7.1 3/4] gitweb: File based caching layer (from git.kernel.org) Jakub Narebski
2010-11-28 11:22 ` [PATCHv7.1 3/4 (amend)] " Jakub Narebski
2010-11-28 11:31 ` Jakub Narebski
2010-11-29 22:13 ` Junio C Hamano
2010-11-29 22:20 ` Junio C Hamano
2010-11-29 23:09 ` [PATCHv7.1 3/4 (amend v2)] " Jakub Narebski
2010-11-30 0:51 ` Junio C Hamano
2010-11-30 10:21 ` Jakub Narebski
2010-11-29 23:07 ` [PATCHv7.1 3/4] " demerphq
2010-11-29 23:26 ` demerphq
2010-11-29 23:54 ` Jakub Narebski
2010-11-13 0:01 ` [PATCHv7.2 4/4] gitweb: Minimal testing of gitweb caching Jakub Narebski
2010-11-17 22:37 ` Junio C Hamano
2010-11-17 23:12 ` Jakub Narebski
2010-11-01 10:24 ` [PATCHv7.1 1/4] gitweb: Prepare for splitting gitweb Jakub Narebski
2010-11-01 18:50 ` [PATCHv7.1b " Jakub Narebski
2010-11-01 10:24 ` [PATCHv7.1 2/4] gitweb: add output buffering and associated functions Jakub Narebski
2010-11-01 10:24 ` [PATCHv7.1 3/4] gitweb: File based caching layer (from git.kernel.org) Jakub Narebski
2010-11-01 10:24 ` [PATCHv7.1 4/4] gitweb: Minimal testing of gitweb caching Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201012021117.16183.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=admin@repo.or.cz \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pasky@ucw.cz \
--cc=warthog9@eaglescrag.net \
--cc=warthog9@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).