mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Issue #1859 - Part 5: Add format detection to unwrap_full_update.pl
This commit is contained in:
parent
121d56e082
commit
b0e0cd7f92
1 changed files with 30 additions and 13 deletions
|
|
@ -22,19 +22,19 @@ 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) {
|
||||
die("The xz executable must be in the path.");
|
||||
}
|
||||
else {
|
||||
$XZ = "xz";
|
||||
|
|
@ -62,15 +62,31 @@ $archive = $ARGV[0];
|
|||
|
||||
$? && die("Couldn't run \"$MAR\" -t");
|
||||
|
||||
shift @marentries;
|
||||
if (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];
|
||||
|
||||
print "Decompressing: " . $file . "\n";
|
||||
if ($MAR_OLD_FORMAT == 1) {
|
||||
system("mv \"$file\" \"$file.bz2\"") == 0 ||
|
||||
die "Couldn't mv \"$file\"";
|
||||
|
|
@ -85,3 +101,4 @@ foreach (@marentries) {
|
|||
}
|
||||
}
|
||||
|
||||
print "Finished\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue