|
1 #!/usr/bin/perl -w |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 # |
|
7 # This tool unpacks a full update package generated by make_full_update.sh |
|
8 # Author: Benjamin Smedberg |
|
9 # |
|
10 |
|
11 # ----------------------------------------------------------------------------- |
|
12 # By default just assume that these tools exist on our path |
|
13 |
|
14 use Getopt::Std; |
|
15 |
|
16 my ($MAR, $BZIP2, $archive, @marentries, @marfiles); |
|
17 |
|
18 if (defined($ENV{"MAR"})) { |
|
19 $MAR = $ENV{"MAR"}; |
|
20 } |
|
21 else { |
|
22 $MAR = "mar"; |
|
23 } |
|
24 |
|
25 if (defined($ENV{"BZIP2"})) { |
|
26 $BZIP2 = $ENV{"BZIP2"}; |
|
27 } |
|
28 else { |
|
29 $BZIP2 = "bzip2"; |
|
30 } |
|
31 |
|
32 sub print_usage |
|
33 { |
|
34 print "Usage: unwrap_full_update.pl [OPTIONS] ARCHIVE\n\n"; |
|
35 print "The contents of ARCHIVE will be unpacked into the current directory.\n\n"; |
|
36 print "Options:\n"; |
|
37 print " -h show this help text\n"; |
|
38 } |
|
39 |
|
40 my %opts; |
|
41 getopts("h", \%opts); |
|
42 |
|
43 if (defined($opts{'h'}) || scalar(@ARGV) != 1) { |
|
44 print_usage(); |
|
45 exit 1; |
|
46 } |
|
47 |
|
48 $archive = $ARGV[0]; |
|
49 @marentries = `"$MAR" -t "$archive"`; |
|
50 |
|
51 $? && die("Couldn't run \"$MAR\" -t"); |
|
52 |
|
53 shift @marentries; |
|
54 |
|
55 system("$MAR -x \"$archive\"") == 0 || die "Couldn't run $MAR -x"; |
|
56 |
|
57 foreach (@marentries) { |
|
58 tr/\n\r//d; |
|
59 my @splits = split(/\t/,$_); |
|
60 my $file = $splits[2]; |
|
61 |
|
62 system("mv \"$file\" \"$file.bz2\"") == 0 || |
|
63 die "Couldn't mv \"$file\""; |
|
64 system("\"$BZIP2\" -d \"$file.bz2\"") == 0 || |
|
65 die "Couldn't decompress \"$file\""; |
|
66 } |
|
67 |