-
Notifications
You must be signed in to change notification settings - Fork 0
/
archiverpt.pl
executable file
·187 lines (138 loc) · 4.81 KB
/
archiverpt.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
#!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
use strict;
$| = 1;
# $Id: archiverpt.pl 1217 2008-12-30 08:51:27Z abeltje $
use vars qw( $VERSION );
$VERSION = '0.005';
use Cwd;
use File::Spec::Functions;
use File::Path;
use File::Copy;
use FindBin;
use lib File::Spec->catdir( $FindBin::Bin, 'lib' );
use lib $FindBin::Bin;
use Test::Smoke;
use Test::Smoke::Util qw( get_patch do_pod2usage );
my $myusage = "Usage: $0 -d <builddir> -a <archivedir> -l <logfile> [options]";
use Getopt::Long;
my %opt = (
ddir => undef,
adir => undef,
lfile => undef,
force => undef,
v => undef,
config => undef,
help => 0,
man => 0,
);
=head1 NAME
archiverpt.pl - Patch the sourcetree
=head1 SYNOPSIS
$ ./archiverpt.pl -a archive -d ../perl-current -l smokecurrent.log
or
$ ./patchtree.pl -c [smokecurrent_config]
=head1 OPTIONS
=over 4
=item * B<Configuration file>
-c | --config <configfile> Use the settings from the configfile
F<patchtree.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 (cwd)
-a | --adir <directory> Set the direcory for the archive
-l | --lfile <logfile> Set the (optional) logfile
--[no]force Overwrite existsing archives
-v | --verbose <0..2> Set verbose level
-h | --help Show help message (needs Pod::Usage)
--man Show the perldoc (needs Pod::Usage)
=back
=head1 DESCRIPTION
This is a small program that archives the smokereport and logfile like:
report -> <adir>/rpt<patchlevel>.rpt
logfile -> <adir>/log<patchlevel>.log
=cut
GetOptions( \%opt,
'adir|a=s', 'ddir|d=s', 'lfile|l=s',
'force!', 'v|verbose=i',
'help|h', 'man',
'config|c:s',
) or do_pod2usage( verbose => 1, myusage => $myusage );
$opt{ man} and do_pod2usage( verbose => 2, exitval => 0, myusage => $myusage );
$opt{help} and do_pod2usage( verbose => 1, exitval => 0, myusage => $myusage );
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->{patch_type};
} elsif ( exists $conf->{ $option } ) {
$opt{ $option } ||= $conf->{ $option }
}
}
} else {
warn "WARNING: Could not process '$opt{config}': " .
Test::Smoke->config_error . "\n";
}
}
$opt{ddir} && -d $opt{ddir} or do_pod2usage(verbose => 0, myusage => $myusage);
$opt{adir} && -d $opt{adir} or do {
mkpath( $opt{adir}, 0, 0775 ) or die "Cannot create '$opt{adir}': $!";
};
my $patch_level = get_patch( $opt{ddir} )->[0];
$patch_level =~ tr/ //sd;
SKIP_RPT: {
my $archived_rpt = catfile( $opt{adir}, "rpt${patch_level}.rpt" );
# Do not archive if it is already done
last SKIP_RPT
if -f $archived_rpt && !$opt{force};
my $mktest_rpt = catfile( $opt{ddir}, 'mktest.rpt' );
if ( -f $mktest_rpt ) {
copy( $mktest_rpt, $archived_rpt ) or
die "Cannot copy to '$archived_rpt': $!";
}
}
SKIP_OUT: {
my $archived_out = catfile( $opt{adir}, "out${patch_level}.out" );
# Do not archive if it is already done
last SKIP_OUT
if -f $archived_out && !$opt{force};
my $mktest_out = catfile( $opt{ddir}, 'mktest.out' );
if ( -f $mktest_out ) {
copy( $mktest_out, $archived_out ) or
die "Cannot copy to '$archived_out': $!";
}
}
SKIP_LOG: {
my $archived_log = "log${patch_level}.log";
unless ( defined $opt{lfile} ) {
$opt{v} and print "No logfile defined!\n";
last SKIP_LOG;
}
unless ( -f $opt{lfile} ) {
$opt{v} and print "Logfile '$opt{lfile}' not found!\n";
last SKIP_LOG;
}
copy( $opt{lfile}, File::Spec->catfile( $opt{adir}, $archived_log ) ) or
die "Cannot copy to '$archived_log': $!";
}
=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