2006-02-13 23:44:38 +03:00
|
|
|
#!/usr/bin/perl -w
|
2012-05-21 15:12:37 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2006-02-13 23:44:38 +03:00
|
|
|
#
|
|
|
|
# This tool unpacks a full update package generated by make_full_update.sh
|
|
|
|
# Author: Benjamin Smedberg
|
|
|
|
#
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# By default just assume that these tools exist on our path
|
|
|
|
|
|
|
|
use Getopt::Std;
|
|
|
|
|
2020-06-12 01:23:10 +03:00
|
|
|
my ($MAR, $XZ, $archive, @marentries, @marfiles);
|
2006-02-13 23:44:38 +03:00
|
|
|
|
|
|
|
if (defined($ENV{"MAR"})) {
|
|
|
|
$MAR = $ENV{"MAR"};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$MAR = "mar";
|
|
|
|
}
|
|
|
|
|
2017-07-31 20:34:30 +03:00
|
|
|
if (defined($ENV{"XZ"})) {
|
|
|
|
$XZ = $ENV{"XZ"};
|
2006-02-13 23:44:38 +03:00
|
|
|
}
|
|
|
|
else {
|
2017-07-31 20:34:30 +03:00
|
|
|
if (system("xz --version > /dev/null 2>&1") != 0) {
|
|
|
|
# Some of the Windows build systems have xz.exe in topsrcdir/xz/.
|
2017-10-02 21:25:05 +03:00
|
|
|
my $xzwinpath = __FILE__;
|
2017-07-31 20:34:30 +03:00
|
|
|
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
|
|
|
|
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
|
|
|
|
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
|
2017-10-02 21:25:05 +03:00
|
|
|
my $xzwin = $xzwinpath . "/xz/xz.exe";
|
|
|
|
if (-e $xzwin) {
|
|
|
|
$XZ = $xzwin;
|
2017-07-31 20:34:30 +03:00
|
|
|
}
|
|
|
|
else {
|
2017-10-02 21:25:05 +03:00
|
|
|
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
|
|
|
|
$xzwin = $xzwinpath . "/xz/xz.exe";
|
|
|
|
if (-e $xzwin) {
|
|
|
|
$XZ = $xzwin;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# If the xz executable was not found fallback to trying to execute
|
|
|
|
# xz and follow the normal failure path if it isn't found.
|
|
|
|
$XZ = "xz";
|
|
|
|
}
|
2017-07-31 20:34:30 +03:00
|
|
|
}
|
2017-07-31 20:34:22 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$XZ = "xz";
|
|
|
|
}
|
2006-02-13 23:44:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sub print_usage
|
|
|
|
{
|
|
|
|
print "Usage: unwrap_full_update.pl [OPTIONS] ARCHIVE\n\n";
|
|
|
|
print "The contents of ARCHIVE will be unpacked into the current directory.\n\n";
|
|
|
|
print "Options:\n";
|
|
|
|
print " -h show this help text\n";
|
|
|
|
}
|
|
|
|
|
2007-05-17 00:59:43 +04:00
|
|
|
my %opts;
|
|
|
|
getopts("h", \%opts);
|
2006-02-13 23:44:38 +03:00
|
|
|
|
2007-05-17 00:59:43 +04:00
|
|
|
if (defined($opts{'h'}) || scalar(@ARGV) != 1) {
|
2006-02-13 23:44:38 +03:00
|
|
|
print_usage();
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$archive = $ARGV[0];
|
|
|
|
@marentries = `"$MAR" -t "$archive"`;
|
|
|
|
$? && die("Couldn't run \"$MAR\" -t");
|
|
|
|
|
2017-10-02 21:21:55 +03:00
|
|
|
system($MAR, "-x", $archive) == 0 ||
|
2017-07-31 20:34:30 +03:00
|
|
|
die "Couldn't run $MAR -x";
|
|
|
|
|
|
|
|
shift @marentries;
|
2006-02-13 23:44:38 +03:00
|
|
|
|
|
|
|
foreach (@marentries) {
|
|
|
|
tr/\n\r//d;
|
|
|
|
my @splits = split(/\t/,$_);
|
|
|
|
my $file = $splits[2];
|
|
|
|
|
2017-07-31 20:34:30 +03:00
|
|
|
print "Decompressing: " . $file . "\n";
|
2020-06-12 01:23:10 +03:00
|
|
|
system("mv", $file, "$file.xz") == 0 ||
|
|
|
|
die "Couldn't mv \"$file\"";
|
|
|
|
system($XZ, "-d", "$file.xz") == 0 ||
|
|
|
|
die "Couldn't decompress \"$file\"";
|
2006-02-13 23:44:38 +03:00
|
|
|
}
|
2017-07-31 20:34:30 +03:00
|
|
|
|
|
|
|
print "Finished\n";
|
|
|
|
|