Rename configure.in to configure.ac, the current autoconf standard.
[rsync/rsync.git] / packaging / nightly-rsync
index 1a5d0d0..3aaabcb 100755 (executable)
@@ -3,8 +3,8 @@ use strict;
 
 # This script expects the directory ~/samba-rsync-ftp to exist and to be a
 # copy of the /home/ftp/pub/rsync dir on samba.org.  It also requires a
-# pristine CVS checkout of rsync (don't use your normal rsync build dir
-# unless you're 100% sure that there are not unchecked-in changes).
+# git checkout of rsync (feel free to use your normal rsync build dir as
+# long as it doesn't have any uncommitted changes).
 #
 # If this is run with -ctu, it will make an updated "nightly" tar file in
 # the nightly dir.  It will also remove any old tar files, regenerate the
@@ -14,8 +14,8 @@ use strict;
 use Getopt::Long;
 use Date::Format;
 
-# Where the local copy of /home/ftp/pub/rsync/nightly should be updated.
-our $dest = $ENV{HOME} . '/samba-rsync-ftp/nightly';
+# Where the local copy of /home/ftp/pub/rsync/dev/nightly should be updated.
+our $dest = $ENV{HOME} . '/samba-rsync-ftp/dev/nightly';
 our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
 
 our($make_tar, $upload, $help_opt);
@@ -29,31 +29,91 @@ our($make_tar, $upload, $help_opt);
 our $name = time2str('rsync-HEAD-%Y%m%d-%H%M%Z', time, 'GMT');
 our $ztoday = time2str('%d %b %Y', time);
 our $today = $ztoday;
+our $gen_target = $upload ? 'gensend' : 'gen';
 
 die "$dest does not exist\n" unless -d $dest;
 die "There is no .git dir in the current directory.\n" unless -d '.git';
 die "There is no rsync checkout in the current directory.\n" unless -f 'rsyncd.conf.yo';
 
 if ($make_tar) {
-    open(IN, '-|', 'git-status') or die $!;
+    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/;
-
-    open(IN, '<', 'prepare-source.mak') or die "Couldn't open prepare-source.mak: $!\n";
-    $_ = join('', <IN>);
+    system "make $gen_target" and die "make $gen_target failed!\n";
+
+    my @extra_files;
+    open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
+    while (<IN>) {
+       if (s/^GENFILES=//) {
+           while (s/\\$//) {
+               $_ .= <IN>;
+           }
+           @extra_files = split(' ', $_);
+           last;
+       }
+    }
     close IN;
 
-    my @extra_files = m{\n([^\s:]+):.*\n\t\S}g;
-    map { s#^#$name/# } @extra_files;
+    my $confversion;
+    open(IN, '<', 'configure.ac') or die "Unable to open configure.ac: $!\n";
+    while (<IN>) {
+       if (/^RSYNC_VERSION=(.*)/) {
+           $confversion = $1;
+           last;
+       }
+    }
+    close IN;
+    die "Unable to find RSYNC_VERSION in configure.ac\n" unless defined $confversion;
+
+    open(IN, '<', 'OLDNEWS') or die "Unable to open OLDNEWS: $!\n";
+    $_ = <IN>;
+    my($lastversion) = /(\d+\.\d+\.\d+)/;
+    my $last_protocol_version;
+    while (<IN>) {
+       if (my($ver,$pdate,$pver) = /^\s+\S\S\s\S\S\S\s\d\d\d\d\s+(\d+\.\d+\.\d+)\s+(\d\d \w\w\w \d\d\d\d\s+)?(\d+)$/) {
+           $last_protocol_version = $pver if $ver eq $lastversion;
+       }
+    }
+    close IN;
+    die "Unable to determine protocol_version for $lastversion.\n" unless defined $last_protocol_version;
+
+    my($protocol_version,$subprotocol_version);
+    open(IN, '<', 'rsync.h') or die "Unable to open rsync.h: $!\n";
+    while (<IN>) {
+       if (/^#define\s+PROTOCOL_VERSION\s+(\d+)/) {
+           $protocol_version = $1;
+       } elsif (/^#define\s+SUBPROTOCOL_VERSION\s+(\d+)/) {
+           $subprotocol_version = $1;
+       }
+    }
+    close IN;
+    die "Unable to determine the current PROTOCOL_VERSION.\n" unless defined $protocol_version;
+    die "Unable to determine the current SUBPROTOCOL_VERSION.\n" unless defined $subprotocol_version;
+
+    if ($confversion =~ /dev|pre/) {
+       if ($last_protocol_version ne $protocol_version) {
+           if ($subprotocol_version == 0) {
+               die "SUBPROTOCOL_VERSION must not be 0 for a non-final release with a changed PROTOCOL_VERSION.\n";
+           }
+       } else {
+           if ($subprotocol_version != 0) {
+               die "SUBPROTOCOL_VERSION must be 0 when the PROTOCOL_VERSION hasn't changed from the last release.\n";
+           }
+       }
+    } else {
+       if ($subprotocol_version != 0) {
+           die "SUBPROTOCOL_VERSION must be 0 for a final release.\n";
+       }
+    }
 
     print "Creating $name.tar.gz\n";
-    system "./prepare-source && touch proto.h";
-    symlink('.', $name);
-    system "git-archive --format=tar --prefix=$name/ HEAD >$dest/$name.tar";
-    system "fakeroot tar rf $dest/$name.tar @extra_files; gzip -9 $dest/$name.tar";
-    unlink($name);
+    system "rsync -a @extra_files $name/";
+    system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
+    system "support/git-set-file-times --prefix=$name/";
+    system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
+
     unlink($nightly_symlink);
     symlink("$name.tar.gz", $nightly_symlink);
 }
@@ -96,7 +156,7 @@ if ($upload) {
     if (defined $ENV{RSYNC_PARTIAL_DIR}) {
        $opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
     }
-    system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/nightly";
+    system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/dev/nightly";
 }
 
 exit;