Adding a support script that can be used to make the checked-out
[rsync/rsync.git] / packaging / nightly-rsync
CommitLineData
920071e2
WD
1#!/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
920071e2 17# Where the local copy of /home/ftp/pub/rsync/nightly should be updated.
20c7d7fd
WD
18our $dest = $ENV{HOME} . '/samba-rsync-ftp/nightly';
19our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
920071e2 20
20c7d7fd 21our($make_tar, $upload, $help_opt);
920071e2
WD
22&Getopt::Long::Configure('bundling');
23&usage if !&GetOptions(
920071e2
WD
24 '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;
32
20c7d7fd
WD
33die "$dest does not exist\n" unless -d $dest;
34die "There is no .git dir in the current directory.\n" unless -d '.git';
35die "There is no rsync checkout in the current directory.\n" unless -f 'rsyncd.conf.yo';
920071e2
WD
36
37if ($make_tar) {
20c7d7fd
WD
38 open(IN, '-|', 'git-status') or die $!;
39 my $status = join('', <IN>);
40 close IN;
41 die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
42 die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
43
44 open(IN, '<', 'prepare-source.mak') or die "Couldn't open prepare-source.mak: $!\n";
45 $_ = join('', <IN>);
46 close IN;
47
48 my @extra_files = m{\n([^\s:]+):.*\n\t\S}g;
49 map { s#^#$name/# } @extra_files;
50
51 print "Creating $name.tar.gz\n";
52 system "./prepare-source && touch proto.h";
53 symlink('.', $name);
54 system "git-archive --format=tar --prefix=$name/ HEAD >$dest/$name.tar";
55 system "fakeroot tar rf $dest/$name.tar @extra_files; gzip -9 $dest/$name.tar";
56 unlink($name);
80aff93b
WD
57 unlink($nightly_symlink);
58 symlink("$name.tar.gz", $nightly_symlink);
920071e2
WD
59}
60
920071e2 61foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) {
20c7d7fd
WD
62 my $yo_tmp = "$dest/$fn";
63 (my $html_fn = "$dest/$fn") =~ s/\.yo/.html/;
920071e2 64
20c7d7fd 65 open(IN, '<', $fn) or die $!;
920071e2
WD
66 undef $/; $_ = <IN>; $/ = "\n";
67 close IN;
68
69 s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
70 #s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
71
20c7d7fd 72 open(OUT, '>', $yo_tmp) or die $!;
920071e2
WD
73 print OUT $_;
74 close OUT;
75
20c7d7fd 76 system 'yodl2html', '-o', $html_fn, $yo_tmp;
920071e2 77
20c7d7fd 78 unlink($yo_tmp);
920071e2
WD
79}
80
20c7d7fd
WD
81chdir($dest) or die $!;
82
085e2fd5
WD
83my $cnt = 0;
84open(PIPE, '-|', 'ls -1t rsync-HEAD-*') or die $!;
85while (<PIPE>) {
86 chomp;
87 next if $cnt++ < 10;
88 unlink($_);
89}
90close PIPE;
91
920071e2
WD
92system 'ls -ltr';
93
94if ($upload) {
230328a3
WD
95 my $opt = '';
96 if (defined $ENV{RSYNC_PARTIAL_DIR}) {
97 $opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
98 }
99 system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/nightly";
920071e2
WD
100}
101
102exit;
103
104sub usage
105{
106 die <<EOT;
107Usage: nightly-rsync [OPTIONS]
108
20c7d7fd 109 -t, --make-tar create a new tar file in $dest
920071e2
WD
110 -u, --upload upload the revised nightly dir to samba.org
111 -h, --help display this help
112EOT
113}