auth/install/pu-hook: pass ADMINDIR and BINDIR via ENV
The admin repo's post-update hook needs to know where $GL_ADMINDIR is, and we had a weird way of doing that which depended on gl-install actually munging the hook code. We also always assumed the binaries are in GL_ADMINDIR/src. We now use an env var to pass both these values. This removes the weird dependency on gl-install that the post-update hook had, as well as make running other programs easier due to the new $GL_BINDIR env var.
This commit is contained in:
parent
ed2bf526f8
commit
b7404aa772
|
@ -1,10 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# get this from your .gitolite.conf; and don't forget this is shell, while
|
|
||||||
# that is perl :-)
|
|
||||||
export GL_ADMINDIR; GL_ADMINDIR=$HOME/.gitolite
|
|
||||||
|
|
||||||
# checkout the master branch to $GL_ADMINDIR
|
# checkout the master branch to $GL_ADMINDIR
|
||||||
|
# (the GL_ADMINDIR env var would have been set by gl-auth-command)
|
||||||
GIT_WORK_TREE=$GL_ADMINDIR git checkout -f master
|
GIT_WORK_TREE=$GL_ADMINDIR git checkout -f master
|
||||||
|
|
||||||
# remove all fragments. otherwise, you get spurious error messages when you
|
# remove all fragments. otherwise, you get spurious error messages when you
|
||||||
|
@ -31,4 +28,4 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
cd $GL_ADMINDIR
|
cd $GL_ADMINDIR
|
||||||
src/gl-compile-conf
|
$GL_BINDIR/gl-compile-conf
|
||||||
|
|
|
@ -39,6 +39,11 @@ require "$bindir/gitolite.pm";
|
||||||
&where_is_rc();
|
&where_is_rc();
|
||||||
die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC};
|
die "parse $ENV{GL_RC} failed: " . ($! or $@) unless do $ENV{GL_RC};
|
||||||
|
|
||||||
|
# we need to pass GL_ADMINDIR and the bindir to the child hooks (well only the
|
||||||
|
# admin repo's post-update hook but still...)
|
||||||
|
$ENV{GL_ADMINDIR} = $GL_ADMINDIR;
|
||||||
|
$ENV{GL_BINDIR} = $bindir;
|
||||||
|
|
||||||
# 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;
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ $ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH;
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
|
||||||
# command and options for authorized_keys
|
# command and options for authorized_keys
|
||||||
$AUTH_COMMAND="$GL_ADMINDIR/src/gl-auth-command";
|
$AUTH_COMMAND="$bindir/gl-auth-command";
|
||||||
$AUTH_OPTIONS="no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty";
|
$AUTH_OPTIONS="no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty";
|
||||||
|
|
||||||
# groups can now represent user groups or repo groups.
|
# groups can now represent user groups or repo groups.
|
||||||
|
|
|
@ -48,7 +48,7 @@ main() {
|
||||||
[[ $upgrade == 0 ]] && initial_conf_key
|
[[ $upgrade == 0 ]] && initial_conf_key
|
||||||
|
|
||||||
# MANUAL: cd to $GL_ADMINDIR and run "src/gl-compile-conf"
|
# MANUAL: cd to $GL_ADMINDIR and run "src/gl-compile-conf"
|
||||||
ssh -p $port $user@$host "cd $GL_ADMINDIR; src/gl-compile-conf $quiet"
|
ssh -p $port $user@$host "cd $GL_ADMINDIR; \$PWD/src/gl-compile-conf $quiet"
|
||||||
|
|
||||||
setup_pta
|
setup_pta
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,6 @@ for my $repo (`find . -type d -name "*.git"`) {
|
||||||
if ( -d "gitolite-admin.git/hooks" ) {
|
if ( -d "gitolite-admin.git/hooks" ) {
|
||||||
print "copying post-update hook to gitolite-admin repo...\n";
|
print "copying post-update hook to gitolite-admin repo...\n";
|
||||||
system("cp $GL_ADMINDIR/src/ga-post-update-hook gitolite-admin.git/hooks/post-update");
|
system("cp $GL_ADMINDIR/src/ga-post-update-hook gitolite-admin.git/hooks/post-update");
|
||||||
system("perl", "-i", "-p", "-e", "s(GL_ADMINDIR=.*)(GL_ADMINDIR=$GL_ADMINDIR)",
|
|
||||||
"gitolite-admin.git/hooks/post-update");
|
|
||||||
chmod 0755, "gitolite-admin.git/hooks/post-update";
|
chmod 0755, "gitolite-admin.git/hooks/post-update";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue