michael@0: #!/usr/bin/perl -w michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # michael@0: # This tool unpacks a full update package generated by make_full_update.sh michael@0: # Author: Benjamin Smedberg michael@0: # michael@0: michael@0: # ----------------------------------------------------------------------------- michael@0: # By default just assume that these tools exist on our path michael@0: michael@0: use Getopt::Std; michael@0: michael@0: my ($MAR, $BZIP2, $archive, @marentries, @marfiles); michael@0: michael@0: if (defined($ENV{"MAR"})) { michael@0: $MAR = $ENV{"MAR"}; michael@0: } michael@0: else { michael@0: $MAR = "mar"; michael@0: } michael@0: michael@0: if (defined($ENV{"BZIP2"})) { michael@0: $BZIP2 = $ENV{"BZIP2"}; michael@0: } michael@0: else { michael@0: $BZIP2 = "bzip2"; michael@0: } michael@0: michael@0: sub print_usage michael@0: { michael@0: print "Usage: unwrap_full_update.pl [OPTIONS] ARCHIVE\n\n"; michael@0: print "The contents of ARCHIVE will be unpacked into the current directory.\n\n"; michael@0: print "Options:\n"; michael@0: print " -h show this help text\n"; michael@0: } michael@0: michael@0: my %opts; michael@0: getopts("h", \%opts); michael@0: michael@0: if (defined($opts{'h'}) || scalar(@ARGV) != 1) { michael@0: print_usage(); michael@0: exit 1; michael@0: } michael@0: michael@0: $archive = $ARGV[0]; michael@0: @marentries = `"$MAR" -t "$archive"`; michael@0: michael@0: $? && die("Couldn't run \"$MAR\" -t"); michael@0: michael@0: shift @marentries; michael@0: michael@0: system("$MAR -x \"$archive\"") == 0 || die "Couldn't run $MAR -x"; michael@0: michael@0: foreach (@marentries) { michael@0: tr/\n\r//d; michael@0: my @splits = split(/\t/,$_); michael@0: my $file = $splits[2]; michael@0: michael@0: system("mv \"$file\" \"$file.bz2\"") == 0 || michael@0: die "Couldn't mv \"$file\""; michael@0: system("\"$BZIP2\" -d \"$file.bz2\"") == 0 || michael@0: die "Couldn't decompress \"$file\""; michael@0: } michael@0: