tools/update-packaging/unwrap_full_update.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/update-packaging/unwrap_full_update.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +#!/usr/bin/perl -w
     1.5 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +
     1.9 +#
    1.10 +# This tool unpacks a full update package generated by make_full_update.sh
    1.11 +# Author: Benjamin Smedberg
    1.12 +#
    1.13 +
    1.14 +# -----------------------------------------------------------------------------
    1.15 +# By default just assume that these tools exist on our path
    1.16 +
    1.17 +use Getopt::Std;
    1.18 +
    1.19 +my ($MAR, $BZIP2, $archive, @marentries, @marfiles);
    1.20 +
    1.21 +if (defined($ENV{"MAR"})) {
    1.22 +    $MAR = $ENV{"MAR"};
    1.23 +}
    1.24 +else {
    1.25 +    $MAR = "mar";
    1.26 +}
    1.27 +
    1.28 +if (defined($ENV{"BZIP2"})) {
    1.29 +    $BZIP2 = $ENV{"BZIP2"};
    1.30 +}
    1.31 +else {
    1.32 +    $BZIP2 = "bzip2";
    1.33 +}
    1.34 +
    1.35 +sub print_usage
    1.36 +{
    1.37 +    print "Usage: unwrap_full_update.pl [OPTIONS] ARCHIVE\n\n";
    1.38 +    print "The contents of ARCHIVE will be unpacked into the current directory.\n\n";
    1.39 +    print "Options:\n";
    1.40 +    print "  -h show this help text\n";
    1.41 +}
    1.42 +
    1.43 +my %opts;
    1.44 +getopts("h", \%opts);
    1.45 +
    1.46 +if (defined($opts{'h'}) || scalar(@ARGV) != 1) {
    1.47 +    print_usage();
    1.48 +    exit 1;
    1.49 +}
    1.50 +
    1.51 +$archive = $ARGV[0];
    1.52 +@marentries = `"$MAR" -t "$archive"`;
    1.53 +
    1.54 +$? && die("Couldn't run \"$MAR\" -t");
    1.55 +
    1.56 +shift @marentries;
    1.57 +
    1.58 +system("$MAR -x \"$archive\"") == 0 || die "Couldn't run $MAR -x";
    1.59 +
    1.60 +foreach (@marentries) {
    1.61 +    tr/\n\r//d;
    1.62 +    my @splits = split(/\t/,$_);
    1.63 +    my $file = $splits[2];
    1.64 +
    1.65 +    system("mv \"$file\" \"$file.bz2\"") == 0 ||
    1.66 +      die "Couldn't mv \"$file\"";
    1.67 +    system("\"$BZIP2\" -d \"$file.bz2\"") == 0 ||
    1.68 +      die "Couldn't decompress \"$file\"";
    1.69 +}
    1.70 +

mercurial