From fd85ee2c9169b9d684120199e5121bfcbb9ad90f Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 21 May 2010 14:08:05 +0530 Subject: [PATCH] *try* to make upgrades resilient to format changes (pkg maintainers please read) the commits leading up to v1.5 caused the data format to change (we added a rule sequence number). This in turn caused a problem for people who may have installed using the "system install / user setup" mode of install (which includes people who used RPM/DEB to install it) -- they would now have to *manually* run "gl-setup" once after the rpm/deb upgrade. This commit *tries* to mitigate this problem by recording a data format version number in the compiled output file. On any access to that file, if the version number is not found or is found to be not equal to the current version, gl-setup is run again. The reason I say "*tries*" is that the exact command used to do this is a bit of a hack for now. However, if it works for Fedora and Debian, I'm going to leave it at that :) --- doc/0-INSTALL.mkd | 8 -------- doc/CHANGELOG | 13 ++++++++----- src/gitolite.pm | 9 +++++++++ src/gl-compile-conf | 4 ++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/doc/0-INSTALL.mkd b/doc/0-INSTALL.mkd index 37c81cc..a110431 100644 --- a/doc/0-INSTALL.mkd +++ b/doc/0-INSTALL.mkd @@ -173,14 +173,6 @@ just work without any change; you should not normally have to do anything special. However, some new features may require additional settings in your `~/.gitolite.rc` file. -> [The only exception to this is when there is a change in the format of the -"compiler" output -- then *each* gitolite hosting user must run "`gl-setup` -again (no arguments needed this time), to fix up the compiled file format. - -> Such a change will be clearly marked with "upgrade notes" both in the -CHANGELOG and in the commit message. For example, this applies when upgrading -to v1.5 or later from any version before it.] - Finally, in the rare case that you managed to lose your keys to the admin repo and want to supply a new pubkey, you can use this command to replace any such key. Could be useful in an emergency -- just get your new "yourname.pub" to diff --git a/doc/CHANGELOG b/doc/CHANGELOG index de1cd01..fdfd39f 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -2,13 +2,16 @@ Major changes to gitolite, master branch only, most recent first, no dates but the tags can help you position stuff approximately [NYD = not yet documented due to lack of time...] + - v1.5.1 -- tries to eliminate the need to run gl-setup on data version + change, thus hopefully obsoleting the upgrade note for v1.5 (just below). + - v1.5 -- IMPORTANT UPGRADE NOTES below -Upgrading to v1.5 from any version prior to v1.5 requires an extra step for -people who installed gitolite using the "system install / user setup" method -described in doc/0-INSTALL.mkd. For such installations, after the -administrator has upgraded gitolite system-wide, each "gitolite host" user -must run `gl-setup` once (this time without any arguments). + Upgrading to v1.5 from any version prior to v1.5 requires an extra step + for people who installed gitolite using the "system install / user setup" + method described in doc/0-INSTALL.mkd. For such installations, after the + administrator has upgraded gitolite system-wide, each "gitolite host" user + must run `gl-setup` once (this time without any arguments). - "deny" rules should now work even in "big-config" due to previous change - proper rule sequencing (required major format change) diff --git a/src/gitolite.pm b/src/gitolite.pm index fcc122f..bdc0db8 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -40,6 +40,8 @@ our $REPOPATT_PATT=qr(^\@?[0-9a-zA-Z][\\^.$|()[\]*+?{}0-9a-zA-Z._\@/-]*$); our ($REPO_UMASK, $GL_WILDREPOS, $GL_PACKAGE_CONF, $GL_PACKAGE_HOOKS, $REPO_BASE, $GL_CONF_COMPILED, $GL_BIG_CONFIG); our %repos; our %groups; +our $data_version; +our $current_data_version = '1.5'; # ---------------------------------------------------------------------------- # convenience subs @@ -253,6 +255,13 @@ sub parse_acl our $gl_user = $ENV{GL_USER}; die "parse $GL_CONF_COMPILED failed: " . ($! or $@) unless do $GL_CONF_COMPILED; + unless (defined($data_version) and $data_version eq $current_data_version) { + # this cannot happen for 'easy-install' cases, by the way... + print STDERR "(INTERNAL: $data_version -> $current_data_version; running gl-setup)\n"; + system("$ENV{SHELL} -l gl-setup >&2"); + + die "parse $GL_CONF_COMPILED failed: " . ($! or $@) unless do $GL_CONF_COMPILED; + } # basic access reporting doesn't send $repo, and doesn't need to; you just # want the config dumped as is, really diff --git a/src/gl-compile-conf b/src/gl-compile-conf index 63a677c..1d910db 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -103,6 +103,8 @@ my $rule_seq = 0; # multiple times for the same repo+user. So... my %rurp_seen = (); +our $current_data_version; # this comes from gitolite.pm + # catch usernames<->pubkeys mismatches; search for "lint" below my %user_list = (); @@ -372,6 +374,8 @@ for my $fragment_file (glob("conf/fragments/*.conf")) } my $compiled_fh = wrap_open( ">", $GL_CONF_COMPILED ); +my $data_version = $current_data_version; +print $compiled_fh Data::Dumper->Dump([$data_version], [qw(*data_version)]); my $dumped_data = Data::Dumper->Dump([\%repos], [qw(*repos)]); # the dump uses single quotes, but we convert any strings containing $creator, # $readers, $writers, to double quoted strings. A wee bit sneaky, but not too