/
synctree.pl
executable file
·202 lines (136 loc) · 5.05 KB
/
synctree.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#! /usr/bin/perl -w
use strict;
use Getopt::Long;
use File::Spec;
use FindBin;
use lib File::Spec->catdir( $FindBin::Bin, 'lib' );
use Test::Smoke::Syncer;
use Test::Smoke;
use vars qw( $VERSION );
$VERSION = '0.008';
my %opt = (
type => undef,
ddir => undef,
v => undef,
config => undef,
help => 0,
man => 0,
);
my $defaults = Test::Smoke::Syncer->config( 'all_defaults' );
my %valid_type = map { $_ => 1 } qw( rsync snapshot copy hardlink forest );
=head1 NAME
synctree.pl - Cleanup and sync the perl-current source-tree
=head1 SYNOPSIS
$ ./synctree.pl -t rsync -d ../perl-current [--help | more options]
or
$ ./synctree.pl -c [smokecurrent_config]
=head1 OPTIONS
Options depend on the B<type> option, exept for some.
=over 4
=item * B<Configuration file>
-c | --config <configfile> Use the settings from the configfile
F<synctree.pl> can use the configuration file created by F<configsmoke.pl>.
Other options can override the settings from the configuration file.
=item * B<General options>
-d | --ddir <directory> Set the directory for the source-tree
-v | --verbose Be verbose
-t | --type <type> 'rsync', 'snapshot', 'copy' [mandatory]
=item * B<options for> -t rsync
--source <rsync-src> (ftp.linux.activestate.com::perl-current)
--rsync <path/to/rsync> (rsync)
--opts <rsync-opts> (-az --delete)
=item * B<options for> -t snapshot
--server <ftp-server> (ftp.funet.fi)
--sdir <directory> (/pub/languages/perl/snap)
--sfile <file> ('')
--snapext <ext> (tgz)
--tar <un-tar-gz> (gzip -dc %s | tar -xf -)
--patchup patch a snapshot [needs the patch program]
--pserver <ftp-server> (ftp2.activestate.com)
--pdir <directory> (/pub/staff/gsar/APC/perl-current-diffs)
--unzip <command> (gzip -dc)
--patch <command> (patch)
--cleanup <level> (0) none; (1) snapshot; (2) diffs; (3) both
=item * B<options for> -t copy
--cdir <directory> Source directory for copy_from_MANIFEST()
=item * B<options for> -t hardlink
--hdir <directory> Source directory to hardlink from
=item * B<options for> -t forest
--fsync <synctype> Master sync-type (One of the above)
--mdir <directory> Master directory for primary sync
--fdir <directory> Intermediate directory (pass to mktest.pl)
All options that are needed for the master sync-type
=back
=cut
GetOptions( \%opt,
'type|t=s', 'ddir|d=s', 'v|verbose:i',
'source=s', 'rsync=s', 'opts',
'server=s', 'sdir=s', 'sfile=s', 'snapext=s', 'tar=s',
'patchup!', 'pserver=s', 'pdir=s', 'unzip=s', 'patch=s', 'cleanup=i',
'cdir=s',
'ftype=s', 'fdir=s', 'hdir=s',
'help|h', 'man|m',
'config|c:s',
) or do_pod2usage( verbose => 1 );
$opt{man} and do_pod2usage( verbose => 2, exitval => 0 );
$opt{help} and do_pod2usage( verbose => 1, exitval => 0 );
if ( defined $opt{config} ) {
$opt{config} eq "" and $opt{config} = 'smokecurrent_config';
read_config( $opt{config} ) or do {
my $config_name = File::Spec->catfile( $FindBin::Bin, $opt{config} );
read_config( $config_name );
};
unless ( Test::Smoke->config_error ) {
foreach my $option ( keys %opt ) {
next if defined $opt{ $option };
if ( $option eq 'type' ) {
$opt{type} ||= $conf->{sync_type};
} elsif ( exists $conf->{ $option } ) {
$opt{ $option } ||= $conf->{ $option }
}
}
} else {
warn "WARNING: Could not process '$opt{config}': " .
Test::Smoke->config_error . "\n";
}
}
foreach ( keys %$defaults ) {
next if defined $opt{ $_ };
$opt{ $_ } = exists $conf->{ $_ } ? $conf->{ $_ } : $defaults->{ $_ };
}
exists $valid_type{ $opt{type} } or do_pod2usage( verbose => 0 );
$opt{ddir} or do_pod2usage( verbose => 0 );
my $patchlevel;
my $syncer = Test::Smoke::Syncer->new( $opt{type} => \%opt );
$patchlevel = $syncer->sync;
$opt{v} and print "$opt{ddir} now up to patchlevel $patchlevel\n";
sub do_pod2usage {
eval { require Pod::Usage };
if ( $@ ) {
print <<EO_MSG;
Usage: $0 -t <type> -d <directory> [options]
Use 'perldoc $0' for the documentation.
Please install 'Pod::Usage' for easy access to the docs.
EO_MSG
my %p2u_opt = @_;
exit( exists $p2u_opt{exitval} ? $p2u_opt{exitval} : 1 );
} else {
Pod::Usage::pod2usage( @_ );
}
}
=head1 SEE ALSO
L<perlhack/"Keeping in sync">, L<Test::Smoke::Syncer>
=head1 COPYRIGHT
(c) 2002-2003, All rights reserved.
* Abe Timmerman <abeltje@cpan.org>
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
See:
=over 4
=item * L<http://www.perl.com/perl/misc/Artistic.html>
=item * L<http://www.gnu.org/copyleft/gpl.html>
=back
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=cut