Commit | Line | Data |
---|---|---|
920071e2 WD |
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 | # 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 | ||
14 | use Getopt::Long; | |
15 | use Date::Format; | |
16 | ||
17 | # Choose any dir where a pristine rsync has been checked out of CVS. | |
18 | our $unpacked = $ENV{HOME} . '/release/nightly'; | |
19 | # Where the local copy of /home/ftp/pub/rsync/nightly should be updated. | |
20 | our $nightly = $ENV{HOME} . '/samba-rsync-ftp/nightly'; | |
21 | ||
22 | our($cvs_update, $make_tar, $upload, $help_opt); | |
23 | &Getopt::Long::Configure('bundling'); | |
24 | &usage if !&GetOptions( | |
25 | 'cvs-update|c' => \$cvs_update, | |
26 | 'make-tar|t' => \$make_tar, | |
27 | 'upload|u' => \$upload, | |
28 | 'help|h' => \$help_opt, | |
29 | ) || $help_opt; | |
30 | ||
31 | our $name = time2str('rsync-HEAD-%Y%m%d-%H%M%Z', time, 'GMT'); | |
32 | our $ztoday = time2str('%d %b %Y', time); | |
33 | our $today = $ztoday; | |
34 | ||
35 | chdir($unpacked) or die $!; | |
36 | ||
37 | if ($cvs_update) { | |
38 | print "Updating from cvs...\n"; | |
39 | system 'cvs -q up' and die $!; | |
40 | } | |
41 | ||
42 | if ($make_tar) { | |
43 | print "Generating list of active CVS files...\n"; | |
44 | my($dir, @files); | |
45 | open(CVS, '-|', 'cvs status 2>&1') or die $!; | |
46 | while (<CVS>) { | |
47 | if (/^cvs status: Examining (.*)/) { | |
48 | if ($1 eq '.') { | |
49 | $dir = ''; | |
50 | } else { | |
51 | push(@files, $1); | |
52 | $dir = $1 . '/'; | |
53 | } | |
55d24e5f | 54 | } elsif (/^File: (.*?)\s+Status: (.*)/ && $1 ne '.cvsignore') { |
920071e2 | 55 | push(@files, $dir . $1); |
55d24e5f | 56 | if ($2 ne 'Up-to-date') { |
7f20af46 | 57 | print "*** Not up-to-date: $dir$1\n"; |
55d24e5f | 58 | } |
920071e2 WD |
59 | } |
60 | } | |
61 | close CVS; | |
62 | ||
63 | print "Creating $unpacked/$name.tar.gz\n"; | |
64 | chdir('..') or die $!; | |
65 | rename($unpacked, $name) or die $!; | |
60414e5b | 66 | open(TAR, '|-', "fakeroot tar --files-from=- --no-recursion --mode=g-w -czf $nightly/$name.tar.gz $name") or die $!; |
920071e2 WD |
67 | foreach (@files) { |
68 | print TAR "$name/$_\n"; | |
69 | } | |
70 | close TAR; | |
71 | rename($name, $unpacked) or die $!; | |
72 | } | |
73 | ||
74 | chdir($nightly) or die $!; | |
75 | ||
76 | foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) { | |
77 | my $html_fn = $fn; | |
78 | $html_fn =~ s/\.yo/.html/; | |
79 | ||
80 | open(IN, '<', "$unpacked/$fn") or die $!; | |
81 | undef $/; $_ = <IN>; $/ = "\n"; | |
82 | close IN; | |
83 | ||
84 | s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m; | |
85 | #s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m; | |
86 | ||
87 | open(OUT, '>', $fn) or die $!; | |
88 | print OUT $_; | |
89 | close OUT; | |
90 | ||
91 | system "yodl2html -o $html_fn $fn"; | |
92 | ||
93 | unlink($fn); | |
94 | } | |
95 | ||
96 | system "find . -name 'rsync-HEAD-*' -daystart -mtime +14 | xargs rm -f"; | |
97 | system 'ls -ltr'; | |
98 | ||
99 | if ($upload) { | |
100 | $ENV{RSYNC_PARTIAL_DIR} = ''; # The rsync on samba.org is OLD. | |
af40c7d6 | 101 | system "rsync -aviHP --delete . samba.org:/home/ftp/pub/rsync/nightly"; |
920071e2 WD |
102 | } |
103 | ||
104 | exit; | |
105 | ||
106 | sub usage | |
107 | { | |
108 | die <<EOT; | |
109 | Usage: nightly-rsync [OPTIONS] | |
110 | ||
111 | -c, --cvs-update update $unpacked via CVS. | |
112 | -t, --make-tar create a new tar file in $nightly | |
113 | -u, --upload upload the revised nightly dir to samba.org | |
114 | -h, --help display this help | |
115 | EOT | |
116 | } |