Commit | Line | Data |
687d3573 |
1 | #!perl |
2 | use strict; |
3 | use Getopt::Std; |
4 | |
5 | my $opts = {}; |
6 | getopts('uch', $opts ); |
7 | |
8 | die usage() if $opts->{'h'} or ( not $opts->{'u'} and not $opts->{'c'} ); |
9 | |
10 | my $Pack = 'pack.pl'; |
11 | die "Could not find $Pack" unless -e $Pack; |
12 | |
13 | open my $fh, "MANIFEST" or die "Could not open MANIFEST"; |
14 | |
15 | while( my $line = <$fh> ) { |
16 | chomp $line; |
17 | my ($file) = split /\s+/, $line; |
18 | |
19 | next unless $file =~ /\.packed/; |
20 | |
21 | my $out = $file; |
22 | $out =~ s/\.packed//; |
23 | |
24 | ### unpack |
25 | if( $opts->{'u'} ) { |
26 | |
27 | my $cmd = "$^X -Ilib $Pack -u -v $file $out"; |
28 | system( $cmd ) and die "Could not unpack $file: $?"; |
29 | |
30 | ### clean up |
31 | } else { |
32 | |
33 | ### file exists? |
34 | unless( -e $out ) { |
35 | print "File $file was not unpacked into $out. Can not remove.\n"; |
36 | |
37 | ### remove it |
38 | } else { |
39 | print "Removing $out\n"; |
40 | 1 while unlink $out; |
41 | } |
42 | } |
43 | } |
44 | |
45 | sub usage { |
46 | return qq[ |
47 | Usage: $^X $0 -u | -c | -h |
48 | |
49 | Unpack or clean up .packed files from the source tree. |
50 | This program is just a wrapper around $Pack. |
51 | |
52 | Options: |
53 | -u Unpack all files in this source tree |
54 | -c Clean up all unpacked files from this source tree |
55 | -h Display this help text |
56 | |
57 | ]; |
58 | } |