Enhanced the release scripts to be able to handle a branch release.
[rsync/rsync.git] / packaging / release-rsync
index b0c9f45..6fa4213 100755 (executable)
@@ -7,6 +7,7 @@ use strict;
 # ~/samba-rsync-ftp dir will be ready to be rsynced to samba.org.
 
 use Cwd;
+use Getopt::Long;
 use Term::ReadKey;
 use Date::Format;
 
@@ -14,6 +15,13 @@ my $dest = $ENV{HOME} . '/samba-rsync-ftp';
 my $passfile = $ENV{HOME} . '/.rsyncpass';
 my $path = $ENV{PATH};
 
+&Getopt::Long::Configure('bundling');
+&usage if !&GetOptions(
+    'branch|b=s' => \( my $master_branch = 'master' ),
+    'help|h' => \( my $help_opt ),
+);
+&usage if $help_opt;
+
 my $now = time;
 my $cl_today = time2str('* %a %b %d %Y', $now);
 my $year = time2str('%Y', $now);
@@ -56,7 +64,7 @@ open(IN, '-|', 'git status') or die $!;
 my $status = join('', <IN>);
 close IN;
 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
-die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
+die "The checkout is not on the $master_branch branch.\n" unless $status =~ /^# On branch $master_branch\n/;
 
 my $confversion;
 open(IN, '<', 'configure.in') or die $!;
@@ -151,7 +159,8 @@ $_ = <STDIN>;
 
 (my $finalversion = $version) =~ s/pre\d+//;
 my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
-                '%define fullversion' => "\%{version}$pre", 'Released' => "$version." );
+                '%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
+                '%define srcdir' => $srcdir );
 my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
                    qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
 
@@ -220,7 +229,7 @@ print $break, <<EOT;
 
 About to:
     - commit all version changes
-    - merge the master branch into the patch/* branches
+    - merge the $master_branch branch into the patch/* branches
     - update the files in the "patches" dir and OPTIONALLY
       (if you type 'y') to launch a shell for each patch
 
@@ -231,11 +240,11 @@ my $ans = <STDIN>;
 system "git commit -a -m 'Preparing for release of $version'" and exit 1;
 
 print "Updating files in \"patches\" dir ...\n";
-system "support/patch-update";
+system "packaging/patch-update --branch=$master_branch";
 
 if ($ans =~ /^y/i) {
     print "\nVisiting all \"patch/*\" branches ...\n";
-    system "support/patch-update --shell";
+    system "packaging/patch-update --branch=$master_branch --shell";
 }
 
 print $break, <<EOT;
@@ -304,7 +313,7 @@ system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
 print "Updating files in \"rsync-$version/patches\" dir ...\n";
 mkdir("rsync-$version", 0755);
 mkdir("rsync-$version/patches", 0755);
-system "support/patch-update --skip-check --gen=rsync-$version/patches";
+system "packaging/patch-update --skip-check --branch=$master_branch --gen=rsync-$version/patches";
 
 print "Creating $pattar_file ...\n";
 system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
@@ -326,7 +335,7 @@ foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
 }
 
 if (!$pre) {
-    system "rm $dest/rsync-*{.tar.gz,.asc,-NEWS} $dest/src-preview/rsync-*diffs.gz";
+    system "rm $dest/rsync-*.gz $dest/rsync-*.asc $dest/rsync-*-NEWS $dest/src-previews/rsync-*diffs.gz*";
 
     foreach my $fn ($srctar_file, "$srctar_file.asc",
                    $pattar_file, "$pattar_file.asc",
@@ -342,3 +351,15 @@ Local changes are done.  When you're satisfied, push the git repository
 and rsync the release files.  Remember to announce the release on *BOTH*
 rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
 EOT
+
+exit;
+
+sub usage
+{
+    die <<EOT;
+Usage: release-rsync [OPTIONS]
+
+-b, --branch=BRANCH   The branch to release (default: master)
+-h, --help            Display this help message
+EOT
+}