* [PATCH] gitweb: fallback to system-wide config file if default config does not exist
@ 2008-03-26 18:11 Gerrit Pape
2008-03-26 19:20 ` Jakub Narebski
2008-04-05 16:37 ` [PATCH amend] " Gerrit Pape
0 siblings, 2 replies; 3+ messages in thread
From: Gerrit Pape @ 2008-03-26 18:11 UTC (permalink / raw)
To: git, Junio C Hamano
>From a distribution point of view, configuration files for applications
should reside in /etc/. On the other hand it's convenient for multiple
instances of gitweb (e.g. virtual web servers on a single machine) to have
a per-instance configuration file, just as gitweb currently supports
through the file gitweb_config.perl next to the cgi.
To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as
a system-wide configuration file which will be used as a fallback if the
config file sprecified throug GITWEB_CONFIG does not exist.
See also
http://bugs.debian.org/450592
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
Makefile | 1 +
gitweb/INSTALL | 6 +++++-
gitweb/README | 9 ++++++++-
gitweb/gitweb.perl | 7 ++++++-
4 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 7c70b00..a88acf6 100644
--- a/Makefile
+++ b/Makefile
@@ -189,6 +189,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig
# default configuration for gitweb
GITWEB_CONFIG = gitweb_config.perl
+GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
GITWEB_HOME_LINK_STR = projects
GITWEB_SITENAME =
GITWEB_PROJECTROOT = /pub/git
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index 9cd5b0a..743f2d4 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -95,7 +95,11 @@ for gitweb (in gitweb/README).
by default it is file named gitweb_config.perl in the same place as
gitweb.cgi script. You can control default place for config file
using GITWEB_CONFIG build configuration variable, and you can set it
- using GITWEB_CONFIG environmental variable.
+ using GITWEB_CONFIG environmental variable. If this file does not
+ exist, gitweb looks for a system-wide configuration file, normally
+ /etc/gitweb.conf. You can change the default using the
+ GITWEB_CONFIG_SYSTEM build configuration variable, and override it
+ through GITWEB_CONFIG_SYSTEM environmental variable.
- Gitweb config file is [fragment] of perl code. You can set variables
using "our $variable = value"; text from "#" character until the end
diff --git a/gitweb/README b/gitweb/README
index 2163071..8dfe335 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:
is set when gitweb.cgi is executed, then the file specified in the
environment variable will be loaded instead of the file specified
when gitweb.cgi was created. [Default: gitweb_config.perl]
+ * GITWEB_CONFIG_SYSTEM
+ This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
+ does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set
+ when gitweb.cgi is executed, then the file specified in the environment
+ variable will be loaded instead of the file specified when gitweb.cgi was
+ created. [Default: /etc/gitweb.conf]
Runtime gitweb configuration
----------------------------
You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
-(defaults to 'gitweb_config.perl' in the same directory as the CGI).
+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
The most notable thing that is not configurable at compile time are the
optional features, stored in the '%features' variable.
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ec73cb1..f73cfca 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -369,7 +369,12 @@ sub filter_snapshot_fmts {
}
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+if (-e $GITWEB_CONFIG) {
+ do $GITWEB_CONFIG;
+} else {
+ our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+ do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
+}
# version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
--
1.5.4.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: fallback to system-wide config file if default config does not exist
2008-03-26 18:11 [PATCH] gitweb: fallback to system-wide config file if default config does not exist Gerrit Pape
@ 2008-03-26 19:20 ` Jakub Narebski
2008-04-05 16:37 ` [PATCH amend] " Gerrit Pape
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Narebski @ 2008-03-26 19:20 UTC (permalink / raw)
To: git
Gerrit Pape wrote:
> From a distribution point of view, configuration files for applications
> should reside in /etc/. On the other hand it's convenient for multiple
> instances of gitweb (e.g. virtual web servers on a single machine) to have
> a per-instance configuration file, just as gitweb currently supports
> through the file gitweb_config.perl next to the cgi.
>
> To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as
> a system-wide configuration file which will be used as a fallback if the
> config file sprecified throug GITWEB_CONFIG does not exist.
>
> See also
> http://bugs.debian.org/450592
Acked-by: Jakub Narebski <jnareb@gmail.com>
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH amend] gitweb: fallback to system-wide config file if default config does not exist
2008-03-26 18:11 [PATCH] gitweb: fallback to system-wide config file if default config does not exist Gerrit Pape
2008-03-26 19:20 ` Jakub Narebski
@ 2008-04-05 16:37 ` Gerrit Pape
1 sibling, 0 replies; 3+ messages in thread
From: Gerrit Pape @ 2008-04-05 16:37 UTC (permalink / raw)
To: git, Junio C Hamano
>From a distribution point of view, configuration files for applications
should reside in /etc/. On the other hand it's convenient for multiple
instances of gitweb (e.g. virtual web servers on a single machine) to have
a per-instance configuration file, just as gitweb currently supports
through the file gitweb_config.perl next to the cgi.
To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as
a system-wide configuration file which will be used as a fallback if the
config file sprecified throug GITWEB_CONFIG does not exist.
See also
http://bugs.debian.org/450592
Signed-off-by: Gerrit Pape <pape@smarden.org>
---
I amended the patch to properly apply GITWEB_CONFIG_SYSTEM set through
make to gitweb.cgi.
Makefile | 2 ++
gitweb/INSTALL | 6 +++++-
gitweb/README | 9 ++++++++-
gitweb/gitweb.perl | 7 ++++++-
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index 7c70b00..78b7738 100644
--- a/Makefile
+++ b/Makefile
@@ -189,6 +189,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig
# default configuration for gitweb
GITWEB_CONFIG = gitweb_config.perl
+GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
GITWEB_HOME_LINK_STR = projects
GITWEB_SITENAME =
GITWEB_PROJECTROOT = /pub/git
@@ -1034,6 +1035,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-e 's|++GIT_BINDIR++|$(bindir)|g' \
-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
+ -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
diff --git a/gitweb/INSTALL b/gitweb/INSTALL
index 9cd5b0a..743f2d4 100644
--- a/gitweb/INSTALL
+++ b/gitweb/INSTALL
@@ -95,7 +95,11 @@ for gitweb (in gitweb/README).
by default it is file named gitweb_config.perl in the same place as
gitweb.cgi script. You can control default place for config file
using GITWEB_CONFIG build configuration variable, and you can set it
- using GITWEB_CONFIG environmental variable.
+ using GITWEB_CONFIG environmental variable. If this file does not
+ exist, gitweb looks for a system-wide configuration file, normally
+ /etc/gitweb.conf. You can change the default using the
+ GITWEB_CONFIG_SYSTEM build configuration variable, and override it
+ through GITWEB_CONFIG_SYSTEM environmental variable.
- Gitweb config file is [fragment] of perl code. You can set variables
using "our $variable = value"; text from "#" character until the end
diff --git a/gitweb/README b/gitweb/README
index 2163071..8dfe335 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:
is set when gitweb.cgi is executed, then the file specified in the
environment variable will be loaded instead of the file specified
when gitweb.cgi was created. [Default: gitweb_config.perl]
+ * GITWEB_CONFIG_SYSTEM
+ This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
+ does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set
+ when gitweb.cgi is executed, then the file specified in the environment
+ variable will be loaded instead of the file specified when gitweb.cgi was
+ created. [Default: /etc/gitweb.conf]
Runtime gitweb configuration
----------------------------
You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
-(defaults to 'gitweb_config.perl' in the same directory as the CGI).
+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
The most notable thing that is not configurable at compile time are the
optional features, stored in the '%features' variable.
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ec73cb1..f73cfca 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -369,7 +369,12 @@ sub filter_snapshot_fmts {
}
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+if (-e $GITWEB_CONFIG) {
+ do $GITWEB_CONFIG;
+} else {
+ our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+ do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
+}
# version of the core git binary
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
--
1.5.5.rc3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-04-05 16:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-26 18:11 [PATCH] gitweb: fallback to system-wide config file if default config does not exist Gerrit Pape
2008-03-26 19:20 ` Jakub Narebski
2008-04-05 16:37 ` [PATCH amend] " Gerrit Pape
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).