Bug 1385780 - Update mar file generation scripts for lzma. r=bhearsum

Adds support to unwrap_full_update.pl to detect if the mar file's contents were compressed using bzip2 and if not to default to lzma, a=app_update_lzma
This commit is contained in:
Robert Strong 2017-07-31 10:34:30 -07:00
Родитель 8644543020
Коммит 77e64d46e5
1 изменённых файлов: 46 добавлений и 15 удалений

Просмотреть файл

@ -12,6 +12,7 @@
# By default just assume that these tools exist on our path
use Getopt::Std;
use Cwd 'abs_path';
my ($MAR, $XZ, $BZIP2, $MAR_OLD_FORMAT, $archive, @marentries, @marfiles);
@ -22,19 +23,32 @@ else {
$MAR = "mar";
}
if (defined($ENV{"MAR_OLD_FORMAT"})) {
$MAR_OLD_FORMAT = 1;
if (defined($ENV{"BZIP2"})) {
$BZIP2 = $ENV{"BZIP2"};
}
else {
$BZIP2 = "bzip2";
}
if (defined($ENV{"BZIP2"})) {
$BZIP2 = $ENV{"BZIP2"};
}
else {
$MAR_OLD_FORMAT = 0;
if (defined($ENV{"XZ"})) {
$XZ = $ENV{"XZ"};
$BZIP2 = "bzip2";
}
if (defined($ENV{"XZ"})) {
$XZ = $ENV{"XZ"};
}
else {
if (system("xz --version > /dev/null 2>&1") != 0) {
# Some of the Windows build systems have xz.exe in topsrcdir/xz/.
my $xzwinpath = abs_path(__FILE__);
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
$xzwinpath = substr($xzwinpath, 0, rindex($xzwinpath, '/'));
$xzwinpath = $xzwinpath . "/xz/xz.exe";
if (-e $xzwinpath) {
$XZ = $xzwinpath;
}
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";
}
}
else {
$XZ = "xz";
@ -59,19 +73,33 @@ if (defined($opts{'h'}) || scalar(@ARGV) != 1) {
$archive = $ARGV[0];
@marentries = `"$MAR" -t "$archive"`;
$? && die("Couldn't run \"$MAR\" -t");
shift @marentries;
system("$MAR -x \"$archive\"") == 0 ||
die "Couldn't run $MAR -x";
system("$MAR -x \"$archive\"") == 0 || die "Couldn't run $MAR -x";
# Try to determine if the mar file contains bzip2 compressed files and if not
# assume that the mar file contains lzma compressed files. The updatev3.manifest
# file is checked since a valid mar file must have this file in the root path.
open(my $testfilename, "updatev3.manifest") or die $!;
binmode($testfilename);
read($testfilename, my $bytes, 3);
if ($bytes eq "BZh") {
$MAR_OLD_FORMAT = 1;
} else {
undef $MAR_OLD_FORMAT;
}
close $testfilename;
shift @marentries;
foreach (@marentries) {
tr/\n\r//d;
my @splits = split(/\t/,$_);
my $file = $splits[2];
if ($MAR_OLD_FORMAT == 1) {
print "Decompressing: " . $file . "\n";
if ($MAR_OLD_FORMAT) {
system("mv \"$file\" \"$file.bz2\"") == 0 ||
die "Couldn't mv \"$file\"";
system("\"$BZIP2\" -d \"$file.bz2\"") == 0 ||
@ -84,3 +112,6 @@ foreach (@marentries) {
die "Couldn't decompress \"$file\"";
}
}
print "Finished\n";