Permalink
Browse files

(mostly) doc changes

  - minor typo fixes, clarifications, etc.

  - keep sts.html url consistent, because many people link to
    http://sitaramc.github.com/gitolite/sts.html

  - create a common migration doc, so the old 'migr.html' does not 404
    when g3 docs become "main"

  - progit doc done

  - add gitosis convert script (FWIW)

  - a minor comment fix to Sugar.pm
  • Loading branch information...
1 parent c5e0e92 commit bbaacfaee72f1f6b58defa0a0f64a56b504222ec @sitaramc committed Apr 9, 2012
View
@@ -0,0 +1,124 @@
+#!/usr/bin/perl -w
+#
+# migrate gitosis.conf to gitolite.conf format
+#
+# Based on gl-conf-convert by: Sitaram Chamarty
+# Rewritten by: Behan Webster <behanw@websterwood.com>
+#
+
+use strict;
+use warnings;
+
+if (not @ARGV and -t or @ARGV and $ARGV[0] eq '-h') {
+ print "Usage:\n gl-conf-convert < gitosis.conf > gitolite.conf\n(please see the documentation for details)\n";
+ exit 1;
+}
+
+my @comments = ();
+my $groupname;
+my %groups;
+my $reponame;
+my %repos;
+
+while (<>)
+{
+ # not supported
+ if (/^repositories *=/ or /^map /) {
+ print STDERR "not supported: $_";
+ s/^/NOT SUPPORTED: /;
+ print;
+ next;
+ }
+
+ # normalise whitespace to help later regexes
+ chomp;
+ s/\s+/ /g;
+ s/ ?= ?/ = /;
+ s/^ //;
+ s/ $//;
+
+ if (/^\s*$/ and @comments > 1) {
+ @{$repos{$reponame}{comments}} = @comments if $reponame;
+ @{$groups{$groupname}{comments}} = @comments if $groupname;
+ @comments = ();
+ } elsif (/^\s*#/) {
+ push @comments, $_;
+ } elsif (/^\[repo\s+(.*?)\]$/) {
+ $groupname = '';
+ $reponame = $1;
+ $reponame =~ s/\.git$//;
+ } elsif (/^gitweb\s*=\s*yes/i) {
+ push @{$repos{$reponame}{R}}, 'gitweb';
+ } elsif (/^daemon\s*=\s*yes/i) {
+ push @{$repos{$reponame}{R}}, 'daemon';
+ } elsif (/^description\s*=\s*(.+?)$/) {
+ $repos{$reponame}{desc} = $1;
+ } elsif (/^owner\s*=\s*(.+?)$/) {
+ $repos{$reponame}{owner} = $1;
+ } elsif (/^\[group\s+(.*)\]$/) {
+ $reponame = '';
+ $groupname = $1;
+ } elsif (/^members\s*=\s*(.*)/) {
+ push @{$groups{$groupname}{users}}, map {s/\@([^.]+)$/_$1/g; $_} split(' ', $1);
+ } elsif (/^write?able\s*=\s*(.*)/) {
+ foreach my $repo (split(' ', $1)) {
+ $repo =~ s/\.git$//;
+ push @{$repos{$repo}{RW}}, "\@$groupname";
+ }
+ } elsif (/^readonly\s*=\s*(.*)/) {
+ foreach my $repo (split(' ', $1)) {
+ $repo =~ s/\.git$//;
+ push @{$repos{$repo}{R}}, "\@$groupname";
+ }
+ }
+}
+
+#use Data::Dumper;
+#print Dumper(\%repos);
+#print Dumper(\%groups);
+
+# Groups
+print "#\n# Groups\n#\n\n";
+foreach my $grp (sort keys %groups) {
+ next unless @{$groups{$grp}{users}};
+ printf join("\n", @{$groups{$grp}{comments}})."\n" if $groups{$grp}{comments};
+ printf "\@%-19s = %s\n", $grp, join(' ', @{$groups{$grp}{users}});
+}
+
+# Gitweb
+print "\n#\n# Gitweb\n#\n\n";
+foreach my $repo (sort keys %repos) {
+ if ($repos{$repo}{desc}) {
+ @{$repos{$repo}{R}} = grep(!/^gitweb$/, @{$repos{$repo}{R}});
+ print $repo;
+ print " \"$repos{$repo}{owner}\"" if $repos{$repo}{owner};
+ print " = \"$repos{$repo}{desc}\"\n";
+ }
+}
+
+# Repos
+print "\n#\n# Repos\n#\n";
+foreach my $repo (sort keys %repos) {
+ print "\n";
+ printf join("\n", @{$repos{$repo}{comments}})."\n" if $repos{$repo}{comments};
+ #if ($repos{$repo}{desc}) {
+ # @{$repos{$repo}{R}} = grep(!/^gitweb$/, @{$repos{$repo}{R}});
+ #}
+ print "repo\t$repo\n";
+ foreach my $access (qw(RW+ RW R)) {
+ next unless $repos{$repo}{$access};
+ my @keys;
+ foreach my $key (@{$repos{$repo}{$access}}) {
+ if ($key =~ /^\@(.*)/) {
+ next unless defined $groups{$1} and @{$groups{$1}{users}};
+ }
+ push @keys, $key;
+ }
+ printf "\t$access\t= %s\n", join(' ', @keys) if @keys;
+ }
+ #if ($repos{$repo}{desc}) {
+ # print $repo;
+ # print " \"$repos{$repo}{owner}\"" if $repos{$repo}{owner};
+ # print " = \"$repos{$repo}{desc}\"\n";
+ #}
+}
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,126 @@
+# migrating from gitosis to gitolite
+
+[2012-04-09] Modified for gitolite g3. These instructions have not really
+been tested with g3, but are expected to work.
+
+Migrating from gitosis to gitolite is fairly easy, because the basic design is
+the same.
+
+There's only one thing that might trip up people: the userid. Gitosis uses
+`gitosis`. Gitolite can use any userid you want; most of the documentation
+uses `git`, while DEB/RPM packages use `gitolite`.
+
+Here are the steps on the server:
+
+ * (as 'gitosis' on the server) **Rename** `~/.ssh/authorized_keys` to
+ something else so that no one can accidentally push while you're doing
+ this.
+
+ * (as 'gitosis' on the server) For added safety, **delete** the post-update
+ hook that gitosis-admin installed
+
+ rm ~/repositories/gitosis-admin.git/hooks/post-update
+
+ or at least rename it to `.sample` like all the other hooks hanging
+ around, or edit it and comment out the line that calls `gitosis-run-hook
+ post-update`.
+
+ * (as 'gitosis' on the server) If you already use the `update` hook for some
+ reason, you'll have to make that a [VREF][vref]. This is because gitolite
+ uses the update hook for checking write access.
+
+ * (as 'root' on the server) copy all of `~/repositories` to the gitolite
+ hosting user's home directory. Something like
+
+ cp -a /home/gitosis/repositories /home/git
+ chown -R git.git /home/git/repositories
+
+ * (as 'root' and/or 'git' on the server) Follow instructions to install
+ gitolite; see the [install document][install].
+
+ This will give you a gitolite config that has the required entries for the
+ "gitolite-admin" repo.
+
+Now, log off the server and get back to the client. All subsequent
+instructions are to be read as "on gitolite admin's workstation".
+
+ * **clone** the new gitolite-admin repo to your workstation. (You already
+ have a clone of the gitosis-admin repo so now you have both).
+
+ * **convert** your gitosis config file and append it to your gitolite config
+ file. Substitute the path for your gitosis-admin clone in `$GSAC` below,
+ and similarly the path for your gito**lite**-admin clone in `$GLAC`. (The
+ convert-gitosis-conf program is a standalone program that you can bring
+ over from any gitolite clone; you don't have to install all of gitolite on
+ your workstation to use this):
+
+ ./convert-gitosis-conf < $GSAC/gitosis.conf >> $GLAC/conf/gitolite.conf
+
+ **Be sure to check the file to make sure it converted correctly** -- due
+ it's "I only need it once" nature, this program has not received too much
+ attention from anyone!
+
+ * Remove the entry for the 'gitosis-admin' repo. You do not need it here
+ and it may cause confusion.
+
+ * **copy** the keys from gitosis's keydir (same meanings for GSAC and GLAC)
+
+ cp $GSAC/keydir/* $GLAC/keydir
+
+ If your gitosis-admin key was `you@machine.pub`, and you supplied the same
+ one to gitolite's gl-setup program as `you.pub` when you installed
+ gitolite, then you should remove `you@machine.pub` from the new keydir
+ now. Otherwise you will have 2 pubkey files (`you.pub` and
+ `you@machine.pub`) which are identical, which is *not* a good idea.
+
+ Similarly, you should replace all occurrences of `you@machine.pub` with
+ `you` in the `conf/gitolite.conf` file.
+
+ * **IMPORTANT**: if you have any users with names like `user@foo`, where the
+ part after the `@` does *not* have a `.` in it (i.e., does not look like
+ an email address), you need to change them, because gitolite uses that
+ syntax for [enabling multi keys][multi-key].
+
+ You have two choices in how to fix this. You can change the gitolite
+ config so that all mention of `user@foo` is changed to just `user`.
+
+ Or you can change each occurrence of `user@foo` to, say, `user_foo` *and*
+ change the pubkey filename in keydir/ also the same way (`user_foo.pub`).
+
+ Just to repeat, you do NOT need to do this if the username was like
+ `user@foo.bar`, i.e., the part after the `@` had a `.` in it, because then
+ it looks like an email address.
+
+ * **IMPORTANT: expand any multi-key files you may have**. Gitosis is happy
+ to accept files containing more than one public key (one per line) and
+ assign all the keys to the same user. Gitolite does not allow that; see
+ [here][multi-key]'s for how gitolite handles multi-keys.
+
+ So if you had any multi-keys in gitosis, they need to be carefully split
+ into individual keys.
+
+ You can split the keys manually, or use the following code (just
+ copy-paste it into your xterm after "cd"-ing to your gitolite-admin repo
+ clone):
+
+ wc -l keydir/*.pub | grep -v total | grep -v -w 1 | while read a b
+ do
+ i=1
+ cat $b|while read l
+ do
+ echo "$l" > ${b%.pub}@$i.pub
+ (( i++ ))
+ done
+ mv $b $b.done
+ done
+
+ This will split each multi-key file (say "sitaram.pub") into individual
+ files called "sitaram@1.pub", "sitaram@2.pub", etc., and rename the
+ original to "sitaram.pub.done" so gitolite won't pick it up.
+
+ At this point you can rename the split parts more appropriately, like
+ "sitaram@laptop.pub" and "sitaram@desktop.pub" or whatever. *Please check
+ the files to make sure this worked properly*
+
+ * Check all your changes to your gitolite-admin clone, commit, and push
+
View
@@ -0,0 +1,6 @@
+# migrating to gitolite
+
+If you're an existing (gitolite v1.x or v2.x) user, start with the [g2
+migration][g2migr] page.
+
+If you're migrating from gitosis, [this][gsmigr] is what you want.
View
@@ -170,7 +170,7 @@ second one trusts only some slaves.
Note that you cannot redirect gitolite commands (like perms, etc).
-## manually synchronising a slave repo
+## #sync manually synchronising a slave repo
You can use the `gitolite mirror push` command on a master to manually
synchronise any of its slaves. Try it with `-h` to get usage info.
View
@@ -9,6 +9,15 @@ remote user running `ssh git@host help`.
All the commands that ship with gitolite will respond to `-h`; please report a
bug to me if they don't.
+Here's a list of remote commands that are shipped:
+
+ * 'desc' -- get/set the 'description' file for a repo
+ * 'info' -- already documented [here][info]
+ * 'mirror' -- documented [here][sync]
+ * 'perms' -- get/set the gl-perms file; see [perms][] for more
+ * 'sskm' -- self-service key management
+ * 'writable' -- disabling pushes to take backups etc
+
## syntactic sugar
The following "sugar" programs are available:
Oops, something went wrong.

0 comments on commit bbaacfa

Please sign in to comment.