Blob Blame History Raw
From 2818abcfc20a198c6fa56c1dbc3c34c6d03b1610 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Thu, 7 Jan 2010 16:52:45 +0100
Subject: [PATCH 1/2] Make Gitolite instllation friendly installable system-wide

---
 src/ga-post-update-hook |    2 +-
 src/gitolite.pm         |    2 +-
 src/gl-auth-command     |    4 +-
 src/gl-compile-conf     |    6 ++--
 src/gl-easy-install     |   62 ++++++++++++++++++++++++----------------------
 src/gl-install          |   24 +++++++++---------
 6 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/src/ga-post-update-hook b/src/ga-post-update-hook
index 8090b8a..312560f 100755
--- a/src/ga-post-update-hook
+++ b/src/ga-post-update-hook
@@ -31,4 +31,4 @@ do
 done
 
 cd $GL_ADMINDIR
-src/gl-compile-conf
+gl-compile-conf
diff --git a/src/gitolite.pm b/src/gitolite.pm
index ee0fc77..8878786 100644
--- a/src/gitolite.pm
+++ b/src/gitolite.pm
@@ -116,7 +116,7 @@ sub report_basic
 
     # send back some useful info if no command was given
     print "hello $user, the gitolite version here is ";
-    system("cat", "$GL_ADMINDIR/src/VERSION");
+    system("rpm", "-q", "--qf", '%{version}-%{release}', 'gitolite');
     print "\ryou have the following permissions:\n\r";
     for my $r (sort keys %repos) {
         my $perm .= ( $repos{$r}{R}{'@all'} ? '  @' : ( $repos{$r}{R}{$user} ? '  R' : '' ) );
diff --git a/src/gl-auth-command b/src/gl-auth-command
index 86fec88..f77e493 100755
--- a/src/gl-auth-command
+++ b/src/gl-auth-command
@@ -33,7 +33,7 @@ our %repos;
 # the common setup module is in the same directory as this running program is
 my $bindir = $0;
 $bindir =~ s/\/[^\/]+$//;
-require "$bindir/gitolite.pm";
+require gitolite;
 
 # ask where the rc file is, get it, and "do" it
 &where_is_rc();
@@ -93,7 +93,7 @@ my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE"
 if ( not -d "$repo_base_abs/$repo.git" ) {
     if ( $repos{$repo}{W}{$user} or $repos{$repo}{W}{'@all'} ) {
         wrap_chdir("$repo_base_abs");
-        new_repo($repo, "$GL_ADMINDIR/src/hooks");
+        new_repo($repo, "/usr/share/gitolite/hooks");
         wrap_chdir($ENV{HOME});
     }
 }
diff --git a/src/gl-compile-conf b/src/gl-compile-conf
index 138249d..fe3ed00 100755
--- a/src/gl-compile-conf
+++ b/src/gl-compile-conf
@@ -59,7 +59,7 @@ our ($REPONAME_PATT, $USERNAME_PATT, $AUTH_COMMAND, $AUTH_OPTIONS, $ABRT, $WARN)
 # the common setup module is in the same directory as this running program is
 my $bindir = $0;
 $bindir =~ s/\/[^\/]+$//;
-require "$bindir/gitolite.pm";
+require gitolite;
 
 # ask where the rc file is, get it, and "do" it
 &where_is_rc();
@@ -73,7 +73,7 @@ $ENV{PATH} .= ":$GIT_PATH" if $GIT_PATH;
 # ----------------------------------------------------------------------------
 
 # command and options for authorized_keys
-$AUTH_COMMAND="$GL_ADMINDIR/src/gl-auth-command";
+$AUTH_COMMAND="/usr/bin/gl-auth-command";
 $AUTH_OPTIONS="no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty";
 
 # groups can now represent user groups or repo groups.
@@ -339,7 +339,7 @@ wrap_chdir("$repo_base_abs");
 
 for my $repo (sort keys %repos) {
     unless (-d "$repo.git") {
-        new_repo($repo, "$GL_ADMINDIR/src/hooks");
+        new_repo($repo, "/usr/share/gitolite/hooks");
         # new_repo would have chdir'd us away; come back
         wrap_chdir("$repo_base_abs");
     }
diff --git a/src/gl-easy-install b/src/gl-easy-install
index db20e2f..3f53f48 100755
--- a/src/gl-easy-install
+++ b/src/gl-easy-install
@@ -48,7 +48,7 @@ main() {
     [[ $upgrade == 0 ]] && initial_conf_key
 
     # 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; gl-compile-conf $quiet"
 
     setup_pta
 
@@ -60,13 +60,12 @@ main() {
 # ----------------------------------------------------------------------
 
 setup_tempdir() {
-    export tmpgli=tmp-gl-install
     trap cleanup 0
-    mkdir -p $tmpgli
+    export tmpgli=$(mktemp -d)
 }
 
 cleanup() {
-    rm -rf $tmpgli
+    [ -d $tmpgli ] && rm -rf $tmpgli
 }
 
 # ----------------------------------------------------------------------
@@ -169,15 +168,15 @@ basic_sanity() {
     # MANUAL: make sure you're in the gitolite directory, at the top level.
     # The following files should all be visible:
 
-    ls  src/ga-post-update-hook     \
-        src/gitolite.pm             \
-        src/gl-install              \
-        src/gl-auth-command         \
-        src/gl-compile-conf         \
-        src/hooks/update            \
-        conf/example.conf           \
-        conf/example.gitolite.rc    >/dev/null ||
-        die "cant find at least some files in gitolite sources/config; aborting"
+#    ls  src/ga-post-update-hook     \
+#        src/gitolite.pm             \
+#        src/gl-install              \
+#        src/gl-auth-command         \
+#        src/gl-compile-conf         \
+#        src/hooks/update            \
+#        conf/example.conf           \
+#        conf/example.gitolite.rc    >/dev/null ||
+#        die "cant find at least some files in gitolite sources/config; aborting"
 
     # MANUAL: make sure you have password-less (pubkey) auth on the server.
     # That is, running "ssh git@server" should log in straight away, without
@@ -195,13 +194,15 @@ version_info() {
 
     # MANUAL: if needed, make a note of the version you are upgrading from, and to
 
-    # record which version is being sent across; we assume it's HEAD
-    git describe --tags --long HEAD 2>/dev/null > src/VERSION || echo '(unknown)' > src/VERSION
+    LOCAL=$(rpm -qf --qf '%{version}-%{release}' $0 2>/dev/null |
+        awk 'BEGIN {n="(unknown)"} {n=$0} END {print n}')
+    REMOTE=$(rpm -q --qf '%{version}-%{release}' gitolite) || FAIL=1
+
+    [ "$FAIL" ] && die "Could not determine version of gitolite installed on remote: $REMOTE"
 
     # what was the old version there?
     export upgrade_details="you are upgrading from \
-    $(ssh -p $port $user@$host cat gitolite-install/src/VERSION 2>/dev/null || echo '(unknown)' ) \
-    to $(cat src/VERSION)"
+        $REMOTE to $LOCAL"
 
     prompt "$upgrade_details" "$v_upgrade_details"
 }
@@ -281,9 +282,9 @@ copy_gl() {
     # server, to a directory called (for example) "gitolite-install".  You may
     # have to create the directory first.
 
-    ssh -p $port $user@$host mkdir -p gitolite-install
-    scp $quiet -P $port -r src conf doc $user@$host:gitolite-install/
-    rm -f src/VERSION
+    #ssh -p $port $user@$host mkdir -p gitolite-install
+    #scp $quiet -P $port -r src conf doc $user@$host:gitolite-install/
+    #rm -f src/VERSION
 
     # MANUAL: now log on to the server (ssh git@server) and get a command
     # line.  This step is for your convenience; the script does it all from
@@ -297,13 +298,14 @@ copy_gl() {
     prompt "finding/creating gitolite rc..." "$v_edit_glrc"
 
     # lets try and get the file from there first
+    scp -P $port $user@$host:/usr/share/gitolite/conf/example.gitolite.rc $tmpgli &>/dev/null
     if scp -P $port $user@$host:.gitolite.rc $tmpgli &>/dev/null
     then
         prompt "    ...trying to reuse existing rc" \
         "Oh hey... you already had a '.gitolite.rc' file on the server.
 Let's see if we can use that instead of the default one..."
         sort < $tmpgli/.gitolite.rc     | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > $tmpgli/glrc.old
-        sort < conf/example.gitolite.rc | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > $tmpgli/glrc.new
+        sort < $tmpgli/example.gitolite.rc | perl -ne 'print "$1\n" if /^\s*(\$\w+) *=/' > $tmpgli/glrc.new
         if diff -u $tmpgli/glrc.old $tmpgli/glrc.new
         then
             [[ $quiet == -q ]] || ${VISUAL:-${EDITOR:-vi}} $tmpgli/.gitolite.rc
@@ -313,10 +315,10 @@ Let's see if we can use that instead of the default one..."
             # customisations as well as any new variables that the new version of
             # gitolite has introduced
             prompt "" "$v_upgrade_glrc"
-            ${VISUAL:-${EDITOR:-vi}} conf/example.gitolite.rc $tmpgli/.gitolite.rc
+            ${VISUAL:-${EDITOR:-vi}} $tmpgli/example.gitolite.rc $tmpgli/.gitolite.rc
         fi
     else
-        cp conf/example.gitolite.rc $tmpgli/.gitolite.rc
+        cp $tmpgli/example.gitolite.rc $tmpgli/.gitolite.rc
         [[ $quiet == -q ]] || ${VISUAL:-${EDITOR:-vi}} $tmpgli/.gitolite.rc
     fi
 
@@ -347,7 +349,7 @@ run_install() {
     # MANUAL: still in the "gitolite-install" directory?  Good.  Run
     # "src/gl-install"
 
-    ssh -p $port $user@$host "cd gitolite-install; src/gl-install $quiet"
+    ssh -p $port $user@$host "gl-install $quiet"
 
     # MANUAL: if you're upgrading, run "src/gl-compile-conf" and you're done!
     # -- ignore the rest of this file for the purposes of an upgrade
@@ -408,7 +410,7 @@ GIT_WORK_TREE=$GL_ADMINDIR git diff --cached --quiet || GIT_WORK_TREE=$GL_ADMIND
     # properly.  The install program does this.  So cd back to the
     # "gitolite-install" directory and run "src/gl-install"
 
-    ssh -p $port $user@$host "cd gitolite-install; src/gl-install $quiet"
+    ssh -p $port $user@$host "gl-install $quiet"
 
     # MANUAL: you're done!  Log out of the server, come back to your
     # workstation, and clone the admin repo using "git clone
@@ -443,11 +445,11 @@ clone_it()
 v_upgrade_details="
 \$upgrade_details
 
-Note: getting '(unknown)' for the 'from' version should only happen once.
-Getting '(unknown)' for the 'to' version means you are probably installing
-from a tar file dump, not a real clone.  This is not an error but it's nice to
-have those version numbers in case you need support.  Try and install from a
-clone
+Note: You should have same versions of gitolite RPM packages installed both
+on server and locally.
+
+Please report problems with RPM packaged version of gitolite to Bugzilla:
+https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=gitolite
 "
 
 v_setting_up_keypair="
diff --git a/src/gl-install b/src/gl-install
index a4dc729..79c5249 100755
--- a/src/gl-install
+++ b/src/gl-install
@@ -24,14 +24,14 @@ sub wrap_mkdir
 # the common setup module is in the same directory as this running program is
 my $bindir = $0;
 $bindir =~ s/\/[^\/]+$//;
-require "$bindir/gitolite.pm";
+require gitolite;
 
 # ask where the rc file is, get it, and "do" it
 &where_is_rc();
 unless ($ENV{GL_RC}) {
     # 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 /usr/share/gitolite/conf/example.gitolite.rc $glrc");
     print "created $glrc\n";
     print "please edit it, change the paths if you wish to, and RERUN THIS SCRIPT\n";
     exit;
@@ -48,20 +48,20 @@ my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE"
 wrap_mkdir($repo_base_abs);
 wrap_mkdir($GL_ADMINDIR);
 # mkdir $GL_ADMINDIR's subdirs
-for my $dir qw(conf doc keydir logs src) {
+for my $dir qw(conf keydir logs) {
     wrap_mkdir("$GL_ADMINDIR/$dir");
 }
 
 # "src" and "doc" will be overwritten on each install, but not conf
-system("cp -R src doc $GL_ADMINDIR");
+#system("cp -R src doc $GL_ADMINDIR");
 
 unless (-f $GL_CONF) {
-    system("cp conf/example.conf $GL_CONF");
+    system("cp /usr/share/gitolite/conf/example.conf $GL_CONF");
     print <<EOF;
     created $GL_CONF
     please edit it, then run these two commands:
         cd $GL_ADMINDIR
-        src/gl-compile-conf
+        gl-compile-conf
     (the "admin" document should help here...)
 EOF
 }
@@ -71,21 +71,21 @@ chdir("$repo_base_abs") or die "chdir $repo_base_abs failed: $!\n";
 for my $repo (`find . -type d -name "*.git"`) {
     chomp ($repo);
     # propagate our own, plus any local admin-defined, hooks
-    system("cp $GL_ADMINDIR/src/hooks/* $repo/hooks/");
+    system("cp /usr/share/gitolite/hooks/* $repo/hooks/");
     chmod 0755, "$repo/hooks/update";
 }
 
 # oh and one of those repos is a bit more special and has an extra hook :)
 if ( -d "gitolite-admin.git/hooks" ) {
     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 /usr/share/gitolite/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";
 }
 
 # fixup program renames
-for my $oldname qw(pta-hook.sh conf-convert.pl 00-easy-install.sh 99-emergency-addkey.sh install.pl update-hook.pl) {
-    unlink "$GL_ADMINDIR/src/$oldname";
-    unlink "$ENV{HOME}/gitolite-install/src/$oldname";
-}
+#for my $oldname qw(pta-hook.sh conf-convert.pl 00-easy-install.sh 99-emergency-addkey.sh install.pl update-hook.pl) {
+#    unlink "$GL_ADMINDIR/src/$oldname";
+#    unlink "$ENV{HOME}/gitolite-install/src/$oldname";
+#}
-- 
1.6.5.2