{"thread":{"id":"12877","subject":"[PATCH] gitweb: fallback to system-wide config file if default config does not exist","startedAt":"2008-03-26T18:11:19Z","lastAt":"2008-04-05T16:37:18Z","messageCount":3,"participants":["Gerrit Pape","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"73148","messageId":"20080326181119.25618.qmail@065038ef0fc11c.315fe32.mid.smarden.org","threadId":"12877","inReplyTo":null,"subject":"[PATCH] gitweb: fallback to system-wide config file if default config does not exist","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2008-03-26T18:11:19Z","receivedAt":"2008-03-26T18:11:19Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":">From a distribution point of view, configuration files for applications\nshould reside in /etc/.  On the other hand it's convenient for multiple\ninstances of gitweb (e.g. virtual web servers on a single machine) to have\na per-instance configuration file, just as gitweb currently supports\nthrough the file gitweb_config.perl next to the cgi.\n\nTo support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as\na system-wide configuration file which will be used as a fallback if the\nconfig file sprecified throug GITWEB_CONFIG does not exist.\n\nSee also\n http://bugs.debian.org/450592\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n Makefile           |    1 +\n gitweb/INSTALL     |    6 +++++-\n gitweb/README      |    9 ++++++++-\n gitweb/gitweb.perl |    7 ++++++-\n 4 files changed, 20 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7c70b00..a88acf6 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -189,6 +189,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig\n \n # default configuration for gitweb\n GITWEB_CONFIG = gitweb_config.perl\n+GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf\n GITWEB_HOME_LINK_STR = projects\n GITWEB_SITENAME =\n GITWEB_PROJECTROOT = /pub/git\ndiff --git a/gitweb/INSTALL b/gitweb/INSTALL\nindex 9cd5b0a..743f2d4 100644\n--- a/gitweb/INSTALL\n+++ b/gitweb/INSTALL\n@@ -95,7 +95,11 @@ for gitweb (in gitweb/README).\n   by default it is file named gitweb_config.perl in the same place as\n   gitweb.cgi script. You can control default place for config file\n   using GITWEB_CONFIG build configuration variable, and you can set it\n-  using GITWEB_CONFIG environmental variable.\n+  using GITWEB_CONFIG environmental variable. If this file does not\n+  exist, gitweb looks for a system-wide configuration file, normally\n+  /etc/gitweb.conf. You can change the default using the\n+  GITWEB_CONFIG_SYSTEM build configuration variable, and override it\n+  through GITWEB_CONFIG_SYSTEM environmental variable.\n \n - Gitweb config file is [fragment] of perl code. You can set variables\n   using \"our $variable = value\"; text from \"#\" character until the end\ndiff --git a/gitweb/README b/gitweb/README\nindex 2163071..8dfe335 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:\n    is set when gitweb.cgi is executed, then the file specified in the\n    environment variable will be loaded instead of the file specified\n    when gitweb.cgi was created.  [Default: gitweb_config.perl]\n+ * GITWEB_CONFIG_SYSTEM\n+   This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG\n+   does not exist.  If the environment variable GITWEB_CONFIG_SYSTEM is set\n+   when gitweb.cgi is executed, then the file specified in the environment\n+   variable will be loaded instead of the file specified when gitweb.cgi was\n+   created.  [Default: /etc/gitweb.conf]\n \n \n Runtime gitweb configuration\n ----------------------------\n \n You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`\n-(defaults to 'gitweb_config.perl' in the same directory as the CGI).\n+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and\n+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).\n The most notable thing that is not configurable at compile time are the\n optional features, stored in the '%features' variable.\n \ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex ec73cb1..f73cfca 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -369,7 +369,12 @@ sub filter_snapshot_fmts {\n }\n \n our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || \"++GITWEB_CONFIG++\";\n-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n+if (-e $GITWEB_CONFIG) {\n+\tdo $GITWEB_CONFIG;\n+} else {\n+\tour $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || \"++GITWEB_CONFIG_SYSTEM++\";\n+\tdo $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;\n+}\n \n # version of the core git binary\n our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n-- \n1.5.4.4\n"},{"id":"73153","messageId":"fse7mi$pop$1@ger.gmane.org","threadId":"12877","inReplyTo":"20080326181119.25618.qmail@065038ef0fc11c.315fe32.mid.smarden.org","subject":"Re: [PATCH] gitweb: fallback to system-wide config file if default config does not exist","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-03-26T19:20:52Z","receivedAt":"2008-03-26T19:20:52Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Gerrit Pape wrote:\n\n> From a distribution point of view, configuration files for applications\n> should reside in /etc/.  On the other hand it's convenient for multiple\n> instances of gitweb (e.g. virtual web servers on a single machine) to have\n> a per-instance configuration file, just as gitweb currently supports\n> through the file gitweb_config.perl next to the cgi.\n> \n> To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as\n> a system-wide configuration file which will be used as a fallback if the\n> config file sprecified throug GITWEB_CONFIG does not exist.\n> \n> See also\n>  http://bugs.debian.org/450592\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"73699","messageId":"20080405163718.29160.qmail@35bac5cfc5e1b8.315fe32.mid.smarden.org","threadId":"12877","inReplyTo":"20080326181119.25618.qmail@065038ef0fc11c.315fe32.mid.smarden.org","subject":"[PATCH amend] gitweb: fallback to system-wide config file if default config does not exist","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2008-04-05T16:37:18Z","receivedAt":"2008-04-05T16:37:18Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":">From a distribution point of view, configuration files for applications\nshould reside in /etc/.  On the other hand it's convenient for multiple\ninstances of gitweb (e.g. virtual web servers on a single machine) to have\na per-instance configuration file, just as gitweb currently supports\nthrough the file gitweb_config.perl next to the cgi.\n\nTo support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as\na system-wide configuration file which will be used as a fallback if the\nconfig file sprecified throug GITWEB_CONFIG does not exist.\n\nSee also\n http://bugs.debian.org/450592\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n\nI amended the patch to properly apply GITWEB_CONFIG_SYSTEM set through\nmake to gitweb.cgi.\n\n Makefile           |    2 ++\n gitweb/INSTALL     |    6 +++++-\n gitweb/README      |    9 ++++++++-\n gitweb/gitweb.perl |    7 ++++++-\n 4 files changed, 21 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7c70b00..78b7738 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -189,6 +189,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig\n \n # default configuration for gitweb\n GITWEB_CONFIG = gitweb_config.perl\n+GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf\n GITWEB_HOME_LINK_STR = projects\n GITWEB_SITENAME =\n GITWEB_PROJECTROOT = /pub/git\n@@ -1034,6 +1035,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \t    -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \\\n \t    -e 's|++GIT_BINDIR++|$(bindir)|g' \\\n \t    -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \\\n+\t    -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \\\n \t    -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \\\n \t    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \\\n \t    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \\\ndiff --git a/gitweb/INSTALL b/gitweb/INSTALL\nindex 9cd5b0a..743f2d4 100644\n--- a/gitweb/INSTALL\n+++ b/gitweb/INSTALL\n@@ -95,7 +95,11 @@ for gitweb (in gitweb/README).\n   by default it is file named gitweb_config.perl in the same place as\n   gitweb.cgi script. You can control default place for config file\n   using GITWEB_CONFIG build configuration variable, and you can set it\n-  using GITWEB_CONFIG environmental variable.\n+  using GITWEB_CONFIG environmental variable. If this file does not\n+  exist, gitweb looks for a system-wide configuration file, normally\n+  /etc/gitweb.conf. You can change the default using the\n+  GITWEB_CONFIG_SYSTEM build configuration variable, and override it\n+  through GITWEB_CONFIG_SYSTEM environmental variable.\n \n - Gitweb config file is [fragment] of perl code. You can set variables\n   using \"our $variable = value\"; text from \"#\" character until the end\ndiff --git a/gitweb/README b/gitweb/README\nindex 2163071..8dfe335 100644\n--- a/gitweb/README\n+++ b/gitweb/README\n@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:\n    is set when gitweb.cgi is executed, then the file specified in the\n    environment variable will be loaded instead of the file specified\n    when gitweb.cgi was created.  [Default: gitweb_config.perl]\n+ * GITWEB_CONFIG_SYSTEM\n+   This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG\n+   does not exist.  If the environment variable GITWEB_CONFIG_SYSTEM is set\n+   when gitweb.cgi is executed, then the file specified in the environment\n+   variable will be loaded instead of the file specified when gitweb.cgi was\n+   created.  [Default: /etc/gitweb.conf]\n \n \n Runtime gitweb configuration\n ----------------------------\n \n You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`\n-(defaults to 'gitweb_config.perl' in the same directory as the CGI).\n+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and\n+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).\n The most notable thing that is not configurable at compile time are the\n optional features, stored in the '%features' variable.\n \ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex ec73cb1..f73cfca 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -369,7 +369,12 @@ sub filter_snapshot_fmts {\n }\n \n our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || \"++GITWEB_CONFIG++\";\n-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n+if (-e $GITWEB_CONFIG) {\n+\tdo $GITWEB_CONFIG;\n+} else {\n+\tour $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || \"++GITWEB_CONFIG_SYSTEM++\";\n+\tdo $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;\n+}\n \n # version of the core git binary\n our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n-- \n1.5.5.rc3\n"}]}