Annotation of embedaddon/rsync/packaging/nightly-rsync, revision 1.1.1.1

1.1       misho       1: #!/usr/bin/perl
                      2: use strict;
                      3: 
                      4: # This script expects the directory ~/samba-rsync-ftp to exist and to be a
                      5: # copy of the /home/ftp/pub/rsync dir on samba.org.  It also requires a
                      6: # git checkout of rsync (feel free to use your normal rsync build dir as
                      7: # long as it doesn't have any uncommitted changes).
                      8: #
                      9: # If this is run with -ctu, it will make an updated "nightly" tar file in
                     10: # the nightly dir.  It will also remove any old tar files, regenerate the
                     11: # HTML man pages in the nightly dir, and then rsync the changes to the
                     12: # samba.org server.
                     13: 
                     14: use Getopt::Long;
                     15: use Date::Format;
                     16: 
                     17: # Where the local copy of /home/ftp/pub/rsync/dev/nightly should be updated.
                     18: our $dest = $ENV{HOME} . '/samba-rsync-ftp/dev/nightly';
                     19: our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
                     20: 
                     21: our($make_tar, $upload, $help_opt);
                     22: &Getopt::Long::Configure('bundling');
                     23: &usage if !&GetOptions(
                     24:     'make-tar|t' => \$make_tar,
                     25:     'upload|u' => \$upload,
                     26:     'help|h' => \$help_opt,
                     27: ) || $help_opt;
                     28: 
                     29: our $name = time2str('rsync-HEAD-%Y%m%d-%H%M%Z', time, 'GMT');
                     30: our $ztoday = time2str('%d %b %Y', time);
                     31: our $today = $ztoday;
                     32: our $gen_target = $upload ? 'gensend' : 'gen';
                     33: 
                     34: die "$dest does not exist\n" unless -d $dest;
                     35: die "There is no .git dir in the current directory.\n" unless -d '.git';
                     36: die "There is no rsync checkout in the current directory.\n" unless -f 'rsyncd.conf.yo';
                     37: 
                     38: if ($make_tar) {
                     39:     open(IN, '-|', 'git status') or die $!;
                     40:     my $status = join('', <IN>);
                     41:     close IN;
                     42:     die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
                     43:     die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
                     44:     system "make $gen_target" and die "make $gen_target failed!\n";
                     45: 
                     46:     my @extra_files;
                     47:     open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
                     48:     while (<IN>) {
                     49:        if (s/^GENFILES=//) {
                     50:            while (s/\\$//) {
                     51:                $_ .= <IN>;
                     52:            }
                     53:            @extra_files = split(' ', $_);
                     54:            last;
                     55:        }
                     56:     }
                     57:     close IN;
                     58: 
                     59:     my $confversion;
                     60:     open(IN, '<', 'configure.ac') or die "Unable to open configure.ac: $!\n";
                     61:     while (<IN>) {
                     62:        if (/^RSYNC_VERSION=(.*)/) {
                     63:            $confversion = $1;
                     64:            last;
                     65:        }
                     66:     }
                     67:     close IN;
                     68:     die "Unable to find RSYNC_VERSION in configure.ac\n" unless defined $confversion;
                     69: 
                     70:     open(IN, '<', 'OLDNEWS') or die "Unable to open OLDNEWS: $!\n";
                     71:     $_ = <IN>;
                     72:     my($lastversion) = /(\d+\.\d+\.\d+)/;
                     73:     my $last_protocol_version;
                     74:     while (<IN>) {
                     75:        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+)$/) {
                     76:            $last_protocol_version = $pver if $ver eq $lastversion;
                     77:        }
                     78:     }
                     79:     close IN;
                     80:     die "Unable to determine protocol_version for $lastversion.\n" unless defined $last_protocol_version;
                     81: 
                     82:     my($protocol_version,$subprotocol_version);
                     83:     open(IN, '<', 'rsync.h') or die "Unable to open rsync.h: $!\n";
                     84:     while (<IN>) {
                     85:        if (/^#define\s+PROTOCOL_VERSION\s+(\d+)/) {
                     86:            $protocol_version = $1;
                     87:        } elsif (/^#define\s+SUBPROTOCOL_VERSION\s+(\d+)/) {
                     88:            $subprotocol_version = $1;
                     89:        }
                     90:     }
                     91:     close IN;
                     92:     die "Unable to determine the current PROTOCOL_VERSION.\n" unless defined $protocol_version;
                     93:     die "Unable to determine the current SUBPROTOCOL_VERSION.\n" unless defined $subprotocol_version;
                     94: 
                     95:     if ($confversion =~ /dev|pre/) {
                     96:        if ($last_protocol_version ne $protocol_version) {
                     97:            if ($subprotocol_version == 0) {
                     98:                die "SUBPROTOCOL_VERSION must not be 0 for a non-final release with a changed PROTOCOL_VERSION.\n";
                     99:            }
                    100:        } else {
                    101:            if ($subprotocol_version != 0) {
                    102:                die "SUBPROTOCOL_VERSION must be 0 when the PROTOCOL_VERSION hasn't changed from the last release.\n";
                    103:            }
                    104:        }
                    105:     } else {
                    106:        if ($subprotocol_version != 0) {
                    107:            die "SUBPROTOCOL_VERSION must be 0 for a final release.\n";
                    108:        }
                    109:     }
                    110: 
                    111:     print "Creating $name.tar.gz\n";
                    112:     system "rsync -a @extra_files $name/";
                    113:     system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
                    114:     system "support/git-set-file-times --prefix=$name/";
                    115:     system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
                    116: 
                    117:     unlink($nightly_symlink);
                    118:     symlink("$name.tar.gz", $nightly_symlink);
                    119: }
                    120: 
                    121: foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) {
                    122:     my $yo_tmp = "$dest/$fn";
                    123:     (my $html_fn = "$dest/$fn") =~ s/\.yo/.html/;
                    124: 
                    125:     open(IN, '<', $fn) or die $!;
                    126:     undef $/; $_ = <IN>; $/ = "\n";
                    127:     close IN;
                    128: 
                    129:     s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
                    130:     #s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
                    131: 
                    132:     open(OUT, '>', $yo_tmp) or die $!;
                    133:     print OUT $_;
                    134:     close OUT;
                    135: 
                    136:     system 'yodl2html', '-o', $html_fn, $yo_tmp;
                    137: 
                    138:     unlink($yo_tmp);
                    139: }
                    140: 
                    141: chdir($dest) or die $!;
                    142: 
                    143: my $cnt = 0;
                    144: open(PIPE, '-|', 'ls -1t rsync-HEAD-*') or die $!;
                    145: while (<PIPE>) {
                    146:     chomp;
                    147:     next if $cnt++ < 10;
                    148:     unlink($_);
                    149: }
                    150: close PIPE;
                    151: 
                    152: system 'ls -ltr';
                    153: 
                    154: if ($upload) {
                    155:     my $opt = '';
                    156:     if (defined $ENV{RSYNC_PARTIAL_DIR}) {
                    157:        $opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
                    158:     }
                    159:     system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/dev/nightly";
                    160: }
                    161: 
                    162: exit;
                    163: 
                    164: sub usage
                    165: {
                    166:     die <<EOT;
                    167: Usage: nightly-rsync [OPTIONS]
                    168: 
                    169:  -t, --make-tar    create a new tar file in $dest
                    170:  -u, --upload      upload the revised nightly dir to samba.org
                    171:  -h, --help        display this help
                    172: EOT
                    173: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>