install and compile: learnt a '-q' flag (not for manual use!)

...only for easy install to use in "quiet" mode
This commit is contained in:
Sitaram Chamarty 2009-10-25 17:33:06 +05:30
parent 78d02e1437
commit 2f6ed42fcd
2 changed files with 17 additions and 11 deletions

View file

@ -47,6 +47,9 @@ $Data::Dumper::Indent = 1;
# common definitions # common definitions
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# setup quiet mode if asked; please do not use this when running manually
open STDOUT, ">", "/dev/null" if (@ARGV and shift eq '-q');
our ($GL_ADMINDIR, $GL_CONF, $GL_KEYDIR, $GL_CONF_COMPILED, $REPO_BASE, $REPO_UMASK, $PROJECTS_LIST, $GIT_PATH); our ($GL_ADMINDIR, $GL_CONF, $GL_KEYDIR, $GL_CONF_COMPILED, $REPO_BASE, $REPO_UMASK, $PROJECTS_LIST, $GIT_PATH);
# now that this thing *may* be run via "push to admin", any errors have to # now that this thing *may* be run via "push to admin", any errors have to
@ -343,12 +346,12 @@ for my $repo (sort keys %repos) {
if ($repos{$repo}{'R'}{'daemon'}) { if ($repos{$repo}{'R'}{'daemon'}) {
unless (-f $export_ok) { unless (-f $export_ok) {
system("touch $export_ok"); system("touch $export_ok");
print STDERR "daemon add $repo.git\n"; print "daemon add $repo.git\n";
} }
} else { } else {
if (-f $export_ok) { if (-f $export_ok) {
unlink($export_ok); unlink($export_ok);
print STDERR "daemon del $repo.git\n"; print "daemon del $repo.git\n";
} }
} }
} }
@ -360,21 +363,21 @@ for my $repo (sort keys %repos) {
# not in the old list; add it to the new one # not in the old list; add it to the new one
$projlist{"$repo.git"} = 1; $projlist{"$repo.git"} = 1;
$projlist_changed = 1; $projlist_changed = 1;
print STDERR "gitweb add $repo.git\n"; print "gitweb add $repo.git\n";
} }
} else { } else {
if ($projlist{"$repo.git"}) { if ($projlist{"$repo.git"}) {
# delete it from new list # delete it from new list
delete $projlist{"$repo.git"}; delete $projlist{"$repo.git"};
$projlist_changed = 1; $projlist_changed = 1;
print STDERR "gitweb del $repo.git\n"; print "gitweb del $repo.git\n";
} }
} }
} }
# has there been a change in the gitweb projects list? # has there been a change in the gitweb projects list?
if ($projlist_changed) { if ($projlist_changed) {
print STDERR "updating gitweb project list $PROJECTS_LIST\n"; print "updating gitweb project list $PROJECTS_LIST\n";
my $projlist_fh = wrap_open( ">", $PROJECTS_LIST); my $projlist_fh = wrap_open( ">", $PROJECTS_LIST);
print $projlist_fh join("\n", sort keys %projlist), "\n" if %projlist; print $projlist_fh join("\n", sort keys %projlist), "\n" if %projlist;
close $projlist_fh; close $projlist_fh;

View file

@ -5,17 +5,20 @@ use warnings;
our ($REPO_BASE, $GL_ADMINDIR, $GL_CONF, $GIT_PATH); our ($REPO_BASE, $GL_ADMINDIR, $GL_CONF, $GIT_PATH);
# setup quiet mode if asked; please do not use this when running manually
open STDOUT, ">", "/dev/null" if (@ARGV and shift eq '-q');
# wrapper around mkdir; it's not an error if the directory exists, but it is # wrapper around mkdir; it's not an error if the directory exists, but it is
# an error if it doesn't exist and we can't create it # an error if it doesn't exist and we can't create it
sub wrap_mkdir sub wrap_mkdir
{ {
my $dir = shift; my $dir = shift;
if ( -d $dir ) { if ( -d $dir ) {
print STDERR "$dir already exists\n"; print "$dir already exists\n";
return; return;
} }
mkdir($dir) or die "mkdir $dir failed: $!\n"; mkdir($dir) or die "mkdir $dir failed: $!\n";
print STDERR "created $dir\n"; print "created $dir\n";
} }
# the common setup module is in the same directory as this running program is # the common setup module is in the same directory as this running program is
@ -29,8 +32,8 @@ 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"; 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 "created $glrc\n";
print STDERR "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n"; print "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n";
exit; exit;
} }
@ -54,7 +57,7 @@ system("cp -R src doc $GL_ADMINDIR");
unless (-f $GL_CONF) { unless (-f $GL_CONF) {
system("cp conf/example.conf $GL_CONF"); system("cp conf/example.conf $GL_CONF");
print STDERR <<EOF; print <<EOF;
created $GL_CONF created $GL_CONF
please edit it, then run these two commands: please edit it, then run these two commands:
cd $GL_ADMINDIR cd $GL_ADMINDIR
@ -74,7 +77,7 @@ for my $repo (`find . -type d -name "*.git"`) {
# 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 STDERR "copying post-update hook to gitolite-admin repo...\n"; print "copying post-update hook to gitolite-admin repo...\n";
system("cp -v $GL_ADMINDIR/src/pta-hook.sh gitolite-admin.git/hooks/post-update"); system("cp -v $GL_ADMINDIR/src/pta-hook.sh gitolite-admin.git/hooks/post-update");
system("perl", "-i", "-p", "-e", "s(export GL_ADMINDIR=.*)(export GL_ADMINDIR=$GL_ADMINDIR)", system("perl", "-i", "-p", "-e", "s(export GL_ADMINDIR=.*)(export GL_ADMINDIR=$GL_ADMINDIR)",
"gitolite-admin.git/hooks/post-update"); "gitolite-admin.git/hooks/post-update");