install/pm: turn hooks from copies to symlinks

This commit is contained in:
Sitaram Chamarty 2010-02-05 06:49:07 +05:30
parent 55a71f00e1
commit 85cc31c771
2 changed files with 17 additions and 3 deletions

View file

@ -78,6 +78,18 @@ sub check_ref {
die "$perm $ref $repo $ENV{GL_USER} DENIED by fallthru\n"; die "$perm $ref $repo $ENV{GL_USER} DENIED by fallthru\n";
} }
# ln -sf :-)
sub ln_sf
{
my($srcdir, $glob, $dstdir) = @_;
for my $hook ( glob("$srcdir/$glob") ) {
$hook =~ s/$srcdir\///;
unlink "$dstdir/$hook";
symlink "$srcdir/$hook", "$dstdir/$hook" or die "could not symlink $hook\n";
}
}
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# where is the rc file hiding? # where is the rc file hiding?
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@ -124,7 +136,7 @@ sub new_repo
wrap_chdir("$repo.git"); wrap_chdir("$repo.git");
system("git --bare init >&2"); system("git --bare init >&2");
# propagate our own, plus any local admin-defined, hooks # propagate our own, plus any local admin-defined, hooks
system("cp $hooks_dir/* hooks/"); ln_sf($hooks_dir, "*", "hooks");
chmod 0755, "hooks/update"; chmod 0755, "hooks/update";
} }

View file

@ -71,14 +71,16 @@ chdir("$repo_base_abs") or die "chdir $repo_base_abs failed: $!\n";
for my $repo (`find . -type d -name "*.git"`) { for my $repo (`find . -type d -name "*.git"`) {
chomp ($repo); chomp ($repo);
# propagate our own, plus any local admin-defined, hooks # propagate our own, plus any local admin-defined, hooks
system("cp $GL_ADMINDIR/src/hooks/* $repo/hooks/"); ln_sf("$GL_ADMINDIR/src/hooks", "*", "$repo/hooks");
chmod 0755, "$repo/hooks/update"; chmod 0755, "$repo/hooks/update";
} }
# oh and one of those repos is a bit more special and has an extra hook :) # oh and one of those repos is a bit more special and has an extra hook :)
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"); unlink "gitolite-admin.git/hooks/post-update";
symlink "$GL_ADMINDIR/src/ga-post-update-hook", "gitolite-admin.git/hooks/post-update"
or die "could not symlink post-update hook\n";
chmod 0755, "gitolite-admin.git/hooks/post-update"; chmod 0755, "gitolite-admin.git/hooks/post-update";
} }