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

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

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