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