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 | } | |
54 | } elsif (/^File: (.*?)\s+Status: / && $1 ne '.cvsignore') { | |
55 | push(@files, $dir . $1); | |
56 | } | |
57 | } | |
58 | close CVS; | |
59 | ||
60 | print "Creating $unpacked/$name.tar.gz\n"; | |
61 | chdir('..') or die $!; | |
62 | rename($unpacked, $name) or die $!; | |
60414e5b | 63 | open(TAR, '|-', "fakeroot tar --files-from=- --no-recursion --mode=g-w -czf $nightly/$name.tar.gz $name") or die $!; |
920071e2 WD |
64 | foreach (@files) { |
65 | print TAR "$name/$_\n"; | |
66 | } | |
67 | close TAR; | |
68 | rename($name, $unpacked) or die $!; | |
69 | } | |
70 | ||
71 | chdir($nightly) or die $!; | |
72 | ||
73 | foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) { | |
74 | my $html_fn = $fn; | |
75 | $html_fn =~ s/\.yo/.html/; | |
76 | ||
77 | open(IN, '<', "$unpacked/$fn") or die $!; | |
78 | undef $/; $_ = <IN>; $/ = "\n"; | |
79 | close IN; | |
80 | ||
81 | s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m; | |
82 | #s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m; | |
83 | ||
84 | open(OUT, '>', $fn) or die $!; | |
85 | print OUT $_; | |
86 | close OUT; | |
87 | ||
88 | system "yodl2html -o $html_fn $fn"; | |
89 | ||
90 | unlink($fn); | |
91 | } | |
92 | ||
93 | system "find . -name 'rsync-HEAD-*' -daystart -mtime +14 | xargs rm -f"; | |
94 | system 'ls -ltr'; | |
95 | ||
96 | if ($upload) { | |
97 | $ENV{RSYNC_PARTIAL_DIR} = ''; # The rsync on samba.org is OLD. | |
af40c7d6 | 98 | system "rsync -aviHP --delete . samba.org:/home/ftp/pub/rsync/nightly"; |
920071e2 WD |
99 | } |
100 | ||
101 | exit; | |
102 | ||
103 | sub usage | |
104 | { | |
105 | die <<EOT; | |
106 | Usage: nightly-rsync [OPTIONS] | |
107 | ||
108 | -c, --cvs-update update $unpacked via CVS. | |
109 | -t, --make-tar create a new tar file in $nightly | |
110 | -u, --upload upload the revised nightly dir to samba.org | |
111 | -h, --help display this help | |
112 | EOT | |
113 | } |