tools/update-packaging/unwrap_full_update.pl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial