nightly-rsync 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/usr/bin/perl
  2. use strict;
  3. # This script expects the directory ~/samba-rsync-ftp to exist and to be a
  4. # copy of the /home/ftp/pub/rsync dir on samba.org. It also requires a
  5. # pristine CVS checkout of rsync (don't use your normal rsync build dir
  6. # unless you're 100% sure that there are not unchecked-in changes).
  7. #
  8. # If this is run with -ctu, it will make an updated "nightly" tar file in
  9. # the nightly dir. It will also remove any old tar files, regenerate the
  10. # HTML man pages in the nightly dir, and then rsync the changes to the
  11. # samba.org server.
  12. use Getopt::Long;
  13. use Date::Format;
  14. # Where the local copy of /home/ftp/pub/rsync/dev/nightly should be updated.
  15. our $dest = $ENV{HOME} . '/samba-rsync-ftp/dev/nightly';
  16. our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
  17. our($make_tar, $upload, $help_opt);
  18. &Getopt::Long::Configure('bundling');
  19. &usage if !&GetOptions(
  20. 'make-tar|t' => \$make_tar,
  21. 'upload|u' => \$upload,
  22. 'help|h' => \$help_opt,
  23. ) || $help_opt;
  24. our $name = time2str('rsync-HEAD-%Y%m%d-%H%M%Z', time, 'GMT');
  25. our $ztoday = time2str('%d %b %Y', time);
  26. our $today = $ztoday;
  27. our $gen_target = $upload ? 'gensend' : 'gen';
  28. die "$dest does not exist\n" unless -d $dest;
  29. die "There is no .git dir in the current directory.\n" unless -d '.git';
  30. die "There is no rsync checkout in the current directory.\n" unless -f 'rsyncd.conf.yo';
  31. if ($make_tar) {
  32. open(IN, '-|', 'git status') or die $!;
  33. my $status = join('', <IN>);
  34. close IN;
  35. die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
  36. die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
  37. system "make $gen_target" and die "make $gen_target failed!\n";
  38. my @extra_files;
  39. open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
  40. while (<IN>) {
  41. if (s/^GENFILES=//) {
  42. while (s/\\$//) {
  43. $_ .= <IN>;
  44. }
  45. @extra_files = split(' ', $_);
  46. last;
  47. }
  48. }
  49. close IN;
  50. print "Creating $name.tar.gz\n";
  51. system "rsync -a @extra_files $name/";
  52. system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
  53. system "support/git-set-file-times --prefix=$name/";
  54. system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
  55. unlink($nightly_symlink);
  56. symlink("$name.tar.gz", $nightly_symlink);
  57. }
  58. foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) {
  59. my $yo_tmp = "$dest/$fn";
  60. (my $html_fn = "$dest/$fn") =~ s/\.yo/.html/;
  61. open(IN, '<', $fn) or die $!;
  62. undef $/; $_ = <IN>; $/ = "\n";
  63. close IN;
  64. s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
  65. #s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
  66. open(OUT, '>', $yo_tmp) or die $!;
  67. print OUT $_;
  68. close OUT;
  69. system 'yodl2html', '-o', $html_fn, $yo_tmp;
  70. unlink($yo_tmp);
  71. }
  72. chdir($dest) or die $!;
  73. my $cnt = 0;
  74. open(PIPE, '-|', 'ls -1t rsync-HEAD-*') or die $!;
  75. while (<PIPE>) {
  76. chomp;
  77. next if $cnt++ < 10;
  78. unlink($_);
  79. }
  80. close PIPE;
  81. system 'ls -ltr';
  82. if ($upload) {
  83. my $opt = '';
  84. if (defined $ENV{RSYNC_PARTIAL_DIR}) {
  85. $opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
  86. }
  87. system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/dev/nightly";
  88. }
  89. exit;
  90. sub usage
  91. {
  92. die <<EOT;
  93. Usage: nightly-rsync [OPTIONS]
  94. -t, --make-tar create a new tar file in $dest
  95. -u, --upload upload the revised nightly dir to samba.org
  96. -h, --help display this help
  97. EOT
  98. }