blob: af9f53a331f6e102c47b64ef80166c994d9f7aea [file] [log] [blame]
Wayne Davison920071e2006-02-18 21:26:48 +00001#!/usr/bin/perl
2use 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# pristine CVS checkout of rsync (don't use your normal rsync build dir
7# unless you're 100% sure that there are not unchecked-in 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
14use Getopt::Long;
15use Date::Format;
16
Wayne Davison7c217762008-03-07 16:25:05 -080017# Where the local copy of /home/ftp/pub/rsync/dev/nightly should be updated.
18our $dest = $ENV{HOME} . '/samba-rsync-ftp/dev/nightly';
Wayne Davison20c7d7f2007-11-15 07:48:13 -080019our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
Wayne Davison920071e2006-02-18 21:26:48 +000020
Wayne Davison20c7d7f2007-11-15 07:48:13 -080021our($make_tar, $upload, $help_opt);
Wayne Davison920071e2006-02-18 21:26:48 +000022&Getopt::Long::Configure('bundling');
23&usage if !&GetOptions(
Wayne Davison920071e2006-02-18 21:26:48 +000024 'make-tar|t' => \$make_tar,
25 'upload|u' => \$upload,
26 'help|h' => \$help_opt,
27) || $help_opt;
28
29our $name = time2str('rsync-HEAD-%Y%m%d-%H%M%Z', time, 'GMT');
30our $ztoday = time2str('%d %b %Y', time);
31our $today = $ztoday;
Wayne Davison9217ce32007-11-28 11:52:16 -080032our $gen_target = $upload ? 'gensend' : 'gen';
Wayne Davison920071e2006-02-18 21:26:48 +000033
Wayne Davison20c7d7f2007-11-15 07:48:13 -080034die "$dest does not exist\n" unless -d $dest;
35die "There is no .git dir in the current directory.\n" unless -d '.git';
36die "There is no rsync checkout in the current directory.\n" unless -f 'rsyncd.conf.yo';
Wayne Davison920071e2006-02-18 21:26:48 +000037
38if ($make_tar) {
Wayne Davison6a2456c2007-11-27 15:53:43 -080039 open(IN, '-|', 'git status') or die $!;
Wayne Davison20c7d7f2007-11-15 07:48:13 -080040 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/;
Wayne Davison555a0812008-01-11 13:20:14 -080044 system "make $gen_target" and die "make $gen_target failed!\n";
Wayne Davison920071e2006-02-18 21:26:48 +000045
Wayne Davison67b9b262007-11-25 14:36:30 -080046 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 }
Wayne Davison20c7d7f2007-11-15 07:48:13 -080057 close IN;
Wayne Davison20c7d7f2007-11-15 07:48:13 -080058
59 print "Creating $name.tar.gz\n";
Wayne Davison555a0812008-01-11 13:20:14 -080060 system "rsync -a @extra_files $name/";
Wayne Davison9217ce32007-11-28 11:52:16 -080061 system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
62 system "support/git-set-file-times --prefix=$name/";
63 system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
64
Wayne Davison80aff932006-05-10 16:37:07 +000065 unlink($nightly_symlink);
66 symlink("$name.tar.gz", $nightly_symlink);
Wayne Davison920071e2006-02-18 21:26:48 +000067}
68
Wayne Davison920071e2006-02-18 21:26:48 +000069foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) {
Wayne Davison20c7d7f2007-11-15 07:48:13 -080070 my $yo_tmp = "$dest/$fn";
71 (my $html_fn = "$dest/$fn") =~ s/\.yo/.html/;
Wayne Davison920071e2006-02-18 21:26:48 +000072
Wayne Davison20c7d7f2007-11-15 07:48:13 -080073 open(IN, '<', $fn) or die $!;
Wayne Davison920071e2006-02-18 21:26:48 +000074 undef $/; $_ = <IN>; $/ = "\n";
75 close IN;
76
77 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
78 #s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
79
Wayne Davison20c7d7f2007-11-15 07:48:13 -080080 open(OUT, '>', $yo_tmp) or die $!;
Wayne Davison920071e2006-02-18 21:26:48 +000081 print OUT $_;
82 close OUT;
83
Wayne Davison20c7d7f2007-11-15 07:48:13 -080084 system 'yodl2html', '-o', $html_fn, $yo_tmp;
Wayne Davison920071e2006-02-18 21:26:48 +000085
Wayne Davison20c7d7f2007-11-15 07:48:13 -080086 unlink($yo_tmp);
Wayne Davison920071e2006-02-18 21:26:48 +000087}
88
Wayne Davison20c7d7f2007-11-15 07:48:13 -080089chdir($dest) or die $!;
90
Wayne Davison085e2fd2007-03-08 02:00:48 +000091my $cnt = 0;
92open(PIPE, '-|', 'ls -1t rsync-HEAD-*') or die $!;
93while (<PIPE>) {
94 chomp;
95 next if $cnt++ < 10;
96 unlink($_);
97}
98close PIPE;
99
Wayne Davison920071e2006-02-18 21:26:48 +0000100system 'ls -ltr';
101
102if ($upload) {
Wayne Davison230328a2006-10-18 05:14:10 +0000103 my $opt = '';
104 if (defined $ENV{RSYNC_PARTIAL_DIR}) {
105 $opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
106 }
Wayne Davison7c217762008-03-07 16:25:05 -0800107 system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/dev/nightly";
Wayne Davison920071e2006-02-18 21:26:48 +0000108}
109
110exit;
111
112sub usage
113{
114 die <<EOT;
115Usage: nightly-rsync [OPTIONS]
116
Wayne Davison20c7d7f2007-11-15 07:48:13 -0800117 -t, --make-tar create a new tar file in $dest
Wayne Davison920071e2006-02-18 21:26:48 +0000118 -u, --upload upload the revised nightly dir to samba.org
119 -h, --help display this help
120EOT
121}