{"thread":{"id":"24080","subject":"[RFC/PATCH] gitweb: Prepare for splitting gitweb","startedAt":"2010-06-11T10:25:59Z","lastAt":"2010-06-12T22:54:33Z","messageCount":2,"participants":["Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143497","messageId":"1276251959-7948-1-git-send-email-jnareb@gmail.com","threadId":"24080","inReplyTo":null,"subject":"[RFC/PATCH] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-06-11T10:25:59Z","receivedAt":"2010-06-11T10:25:59Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Prepare gitweb for having been split into modules that are to be\ninstalled alongside gitweb in 'lib/' subdirectory, by adding\n\n  use lib __DIR__.'/lib';\n\nto gitweb.perl (to main gitweb script), and preparing for putting\nmodules (relative path) in $(GITWEB_MODULES) in gitweb/Makefile.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis patch is based on commit c0cb4ed (git-instaweb: Configure it to\nwork with new gitweb structure, 2010-05-28), which is top commit of\n'ps/gitweb-soc' branch merged into next on 2010-06-03 (as commit\n5db4adf).\n\nIt is an RFC patch adding infrastructure for splitting gitweb, or\nadding new functionality to gitweb via gitweb modules, without adding\nany gitweb module.\n\nIt is an RFC because:\n1. I'm not sure if having such separate preparatory patch is good\n   idea.  It would allow me to move gitweb output caching to proper\n   modules, without waiting for gitweb splitting part of GSoC 2010\n   project to stabilize.\n\n2. I don't know if what I have written in gitweb/Makefile is portable\n   enough.  In particular it uses $(sort WORDLIST), which is not used\n   otherwise in git Makefiles.\n\n3. Should there be information added to gitweb/INSTALL that one can\n   put Perl modules in 'lib/' subdirectory?  This is why 'use lib ...'\n   is moved earlier compared to original patch by Pavan..\n\n gitweb/Makefile    |    3 +++\n gitweb/gitweb.perl |    9 +++++++++\n 2 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex d2584fe..4694959 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -55,6 +55,7 @@ PERL_PATH  ?= /usr/bin/perl\n bindir_SQ = $(subst ','\\'',$(bindir))#'\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))#'\n gitwebstaticdir_SQ = $(subst ','\\'',$(gitwebdir)/static)#'\n+gitweblibdir_SQ = $(subst ','\\'',$(gitwebdir)/lib)#'\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))#'\n PERL_PATH_SQ  = $(subst ','\\'',$(PERL_PATH))#'\n DESTDIR_SQ    = $(subst ','\\'',$(DESTDIR))#'\n@@ -150,6 +151,8 @@ install: all\n \t$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n \t$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n+\t$(foreach dir,$(sort $(dir $(GITWEB_MODULES))),test -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$dir' || $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$dir')\n+\t$(foreach mod,$(GITWEB_MODULES),$(INSTALL) -m 644 $mod '$(DESTDIR_SQ)$(gitwebdir_SQ)/$mod')\n \n ### Cleaning rules\n \ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 934aacb..023698f 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -9,6 +9,14 @@\n \n use strict;\n use warnings;\n+\n+use File::Spec;\n+# __DIR__ is taken from Dir::Self __DIR__ fragment\n+sub __DIR__ () {\n+\tFile::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n+}\n+use lib __DIR__ . '/lib';\n+\n use CGI qw(:standard :escapeHTML -nosticky);\n use CGI::Util qw(unescape);\n use CGI::Carp qw(fatalsToBrowser set_message);\n@@ -16,6 +24,7 @@ use Encode;\n use Fcntl ':mode';\n use File::Find qw();\n use File::Basename qw(basename);\n+\n binmode STDOUT, ':utf8';\n \n our $t0;\n-- \n1.7.0.1\n"},{"id":"143594","messageId":"20100612225047.19225.81022.stgit@localhost.localdomain","threadId":"24080","inReplyTo":"1276251959-7948-1-git-send-email-jnareb@gmail.com","subject":"[RFC/PATCHv2] gitweb: Prepare for splitting gitweb","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-06-12T22:54:33Z","receivedAt":"2010-06-12T22:54:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Prepare gitweb for having been split into modules that are to be\ninstalled alongside gitweb in 'lib/' subdirectory, by adding\n\n  use lib __DIR__.'/lib';\n\nto gitweb.perl (to main gitweb script), and preparing for putting\nmodules (relative path) in $(GITWEB_MODULES) in gitweb/Makefile.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThis one actually works: tested with gitweb caching series, with\ngitweb caching support split into modules.\n\nThe generated command is not very elegant, but perhaps it doesn't\nmatter:\n\n  install -d -m 755 '/home/local/gitweb'\n  install -m 755 gitweb.cgi '/home/local/gitweb'\n  install -d -m 755 '/home/local/gitweb/static'\n  install -m 644 static/gitweb.js static/gitweb.css static/git-logo.png static/git-favicon.png '/home/local/gitweb/static'\n  test -d '/home/local/gitweb/lib/GitwebCache/' || install -d -m 755 '/home/local/gitweb/lib/GitwebCache/'; test -d '/home/local/gitweb/lib/GitwebCache/Capture/' || install -d -m 755 '/home/local/gitweb/lib/GitwebCache/Capture/';\n  install -m 644 lib/GitwebCache/CacheOutput.pm '/home/local/gitweb/lib/GitwebCache/CacheOutput.pm'; install -m 644 lib/GitwebCache/SimpleFileCache.pm '/home/local/gitweb/lib/GitwebCache/SimpleFileCache.pm'; install -m 644 lib/GitwebCache/Capture.pm '/home/local/gitweb/lib/GitwebCache/Capture.pm'; install -m 644 lib/GitwebCache/Capture/SelectFH.pm '/home/local/gitweb/lib/GitwebCache/Capture/SelectFH.pm';\n\nThis patch is based on commit c0cb4ed (git-instaweb: Configure it to\nwork with new gitweb structure, 2010-05-28), which is top commit of\n'ps/gitweb-soc' branch merged into next on 2010-06-03 (as commit\n5db4adf).\n\n gitweb/Makefile    |    3 +++\n gitweb/gitweb.perl |    9 +++++++++\n 2 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/Makefile b/gitweb/Makefile\nindex d2584fe..d2401e1 100644\n--- a/gitweb/Makefile\n+++ b/gitweb/Makefile\n@@ -55,6 +55,7 @@ PERL_PATH  ?= /usr/bin/perl\n bindir_SQ = $(subst ','\\'',$(bindir))#'\n gitwebdir_SQ = $(subst ','\\'',$(gitwebdir))#'\n gitwebstaticdir_SQ = $(subst ','\\'',$(gitwebdir)/static)#'\n+gitweblibdir_SQ = $(subst ','\\'',$(gitwebdir)/lib)#'\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))#'\n PERL_PATH_SQ  = $(subst ','\\'',$(PERL_PATH))#'\n DESTDIR_SQ    = $(subst ','\\'',$(DESTDIR))#'\n@@ -150,6 +151,8 @@ install: all\n \t$(INSTALL) -m 755 $(GITWEB_PROGRAMS) '$(DESTDIR_SQ)$(gitwebdir_SQ)'\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n \t$(INSTALL) -m 644 $(GITWEB_FILES) '$(DESTDIR_SQ)$(gitwebstaticdir_SQ)'\n+\t$(foreach dir,$(sort $(dir $(GITWEB_MODULES))),test -d '$(DESTDIR_SQ)$(gitwebdir_SQ)/$(dir)' || $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitwebdir_SQ)/$(dir)';)\n+\t$(foreach mod,$(GITWEB_MODULES),$(INSTALL) -m 644 $(mod) '$(DESTDIR_SQ)$(gitwebdir_SQ)/$(mod)';)\n \n ### Cleaning rules\n \ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex e108bbc..dd65943 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -9,6 +9,14 @@\n \n use strict;\n use warnings;\n+\n+use File::Spec;\n+# __DIR__ is taken from Dir::Self __DIR__ fragment\n+sub __DIR__ () {\n+\tFile::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);\n+}\n+use lib __DIR__ . '/lib';\n+\n use CGI qw(:standard :escapeHTML -nosticky);\n use CGI::Util qw(unescape);\n use CGI::Carp qw(fatalsToBrowser set_message);\n@@ -16,6 +24,7 @@ use Encode;\n use Fcntl ':mode';\n use File::Find qw();\n use File::Basename qw(basename);\n+\n binmode STDOUT, ':utf8';\n \n our $t0;\n"}]}