the rc file can now be in one of 2 places...
Packaging gitolite for debian requires the rc file to be in /etc/gitolite. But non-root installs must still be supported, and they need it in $HOME. This means the rc file is no longer in a fixed place, which needs code to find the rc file first. See comments inside new file 'gitolite.pm' for details. The rest of the changes are in the other programs, to replace the hard-coded rc filename with a call to this new code.
This commit is contained in:
parent
8eefc036e0
commit
78d02e1437
45
src/gitolite.pm
Normal file
45
src/gitolite.pm
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# this file is commonly used using "require". It is not required to use "use"
|
||||||
|
# (because it doesn't live in a different package)
|
||||||
|
|
||||||
|
# warning: preceding para requires 4th attribute of a programmer after
|
||||||
|
# laziness, impatience, and hubris: sense of humour :-)
|
||||||
|
|
||||||
|
# WARNING
|
||||||
|
# -------
|
||||||
|
# the name of this file will change as soon as its function/feature set
|
||||||
|
# stabilises enough ;-)
|
||||||
|
|
||||||
|
# right now all it does is define a function that tells you where to find the
|
||||||
|
# rc file
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
# where is the rc file hiding?
|
||||||
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub where_is_rc
|
||||||
|
{
|
||||||
|
# till now, the rc file was in one fixed place: .gitolite.rc in $HOME of
|
||||||
|
# the user hosting the gitolite repos. This was fine, because gitolite is
|
||||||
|
# all about empowering non-root users :-)
|
||||||
|
|
||||||
|
# then we wanted to make a debian package out of it (thank you, Rhonda!)
|
||||||
|
# which means (a) it's going to be installed by root anyway and (b) any
|
||||||
|
# config files have to be in /etc/<something>
|
||||||
|
|
||||||
|
# the only way to resolve this in a backward compat way is to look for the
|
||||||
|
# $HOME one, and if you don't find it look for the /etc one
|
||||||
|
|
||||||
|
# this common routine does that, setting an env var for the first one it
|
||||||
|
# finds
|
||||||
|
|
||||||
|
return if $ENV{GL_RC};
|
||||||
|
|
||||||
|
for my $glrc ( $ENV{HOME} . "/.gitolite.rc", "/etc/gitolite/gitolite.rc" ) {
|
||||||
|
if (-f $glrc) {
|
||||||
|
$ENV{GL_RC} = $glrc;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -27,8 +27,15 @@ use warnings;
|
||||||
our ($GL_LOGT, $GL_CONF_COMPILED, $REPO_BASE, $GIT_PATH);
|
our ($GL_LOGT, $GL_CONF_COMPILED, $REPO_BASE, $GIT_PATH);
|
||||||
our %repos;
|
our %repos;
|
||||||
|
|
||||||
my $glrc = $ENV{HOME} . "/.gitolite.rc";
|
# the common setup module is in the same directory as this running program is
|
||||||
die "parse $glrc failed: " . ($! or $@) unless do $glrc;
|
my $bindir = $0;
|
||||||
|
$bindir =~ s/\/[^\/]+$//;
|
||||||
|
require "$bindir/gitolite.pm";
|
||||||
|
|
||||||
|
# ask where the rc file is, get it, and "do" it
|
||||||
|
&where_is_rc();
|
||||||
|
die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC};
|
||||||
|
# then "do" the compiled config file, whose name we now know
|
||||||
die "parse $GL_CONF_COMPILED failed: " . ($! or $@) unless do $GL_CONF_COMPILED;
|
die "parse $GL_CONF_COMPILED failed: " . ($! or $@) unless do $GL_CONF_COMPILED;
|
||||||
|
|
||||||
# add a custom path for git binaries, if specified
|
# add a custom path for git binaries, if specified
|
||||||
|
|
|
@ -54,8 +54,14 @@ our ($GL_ADMINDIR, $GL_CONF, $GL_KEYDIR, $GL_CONF_COMPILED, $REPO_BASE, $REPO_UM
|
||||||
# typical push generates
|
# typical push generates
|
||||||
my $ATTN = "\n\t\t***** ERROR *****\n ";
|
my $ATTN = "\n\t\t***** ERROR *****\n ";
|
||||||
|
|
||||||
my $glrc = $ENV{HOME} . "/.gitolite.rc";
|
# the common setup module is in the same directory as this running program is
|
||||||
die "$ATTN parse $glrc failed: " . ($! or $@) unless do $glrc;
|
my $bindir = $0;
|
||||||
|
$bindir =~ s/\/[^\/]+$//;
|
||||||
|
require "$bindir/gitolite.pm";
|
||||||
|
|
||||||
|
# ask where the rc file is, get it, and "do" it
|
||||||
|
&where_is_rc();
|
||||||
|
die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC};
|
||||||
|
|
||||||
# add a custom path for git binaries, if specified
|
# add a custom path for git binaries, if specified
|
||||||
$ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH;
|
$ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH;
|
||||||
|
|
|
@ -18,20 +18,24 @@ sub wrap_mkdir
|
||||||
print STDERR "created $dir\n";
|
print STDERR "created $dir\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# the only path that is *fixed* (can't be changed without changing all 3
|
# the common setup module is in the same directory as this running program is
|
||||||
# programs) is ~/.gitolite.rc
|
my $bindir = $0;
|
||||||
|
$bindir =~ s/\/[^\/]+$//;
|
||||||
|
require "$bindir/gitolite.pm";
|
||||||
|
|
||||||
my $glrc = $ENV{HOME} . "/.gitolite.rc";
|
# ask where the rc file is, get it, and "do" it
|
||||||
unless (-f $glrc) {
|
&where_is_rc();
|
||||||
|
unless ($ENV{GL_RC}) {
|
||||||
# doesn't exist. Copy it across, tell user to edit it and come back
|
# doesn't exist. Copy it across, tell user to edit it and come back
|
||||||
|
my $glrc = $ENV{HOME} . "/.gitolite.rc";
|
||||||
system("cp conf/example.gitolite.rc $glrc");
|
system("cp conf/example.gitolite.rc $glrc");
|
||||||
print STDERR "created $glrc\n";
|
print STDERR "created $glrc\n";
|
||||||
print STDERR "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n";
|
print STDERR "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ok now $glrc exists; read it to get the other paths
|
# ok now the rc file exists; read it to get the other paths
|
||||||
die "parse $glrc failed: " . ($! or $@) unless do $glrc;
|
die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC};
|
||||||
|
|
||||||
# add a custom path for git binaries, if specified
|
# add a custom path for git binaries, if specified
|
||||||
$ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH;
|
$ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH;
|
||||||
|
|
|
@ -28,8 +28,9 @@ use warnings;
|
||||||
our ($GL_CONF_COMPILED, $PERSONAL);
|
our ($GL_CONF_COMPILED, $PERSONAL);
|
||||||
our %repos;
|
our %repos;
|
||||||
|
|
||||||
my $glrc = $ENV{HOME} . "/.gitolite.rc";
|
# we should already have the GL_RC env var set when we enter this hook
|
||||||
die "parse $glrc failed: " . ($! or $@) unless do $glrc;
|
die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC};
|
||||||
|
# then "do" the compiled config file, whose name we now know
|
||||||
die "parse $GL_CONF_COMPILED failed: " . ($! or $@) unless do $GL_CONF_COMPILED;
|
die "parse $GL_CONF_COMPILED failed: " . ($! or $@) unless do $GL_CONF_COMPILED;
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue