summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-01-23 11:50:20 +0000
committerMoonchild <moonchild@palemoon.org>2022-04-17 19:21:30 +0200
commit43165d9edb2f9ac5a65ff9507b462fc948a665ba (patch)
tree716caa222aa7c2e81282a2f3ae754a3af07e8e11 /tools
parent88624edc98456252fe3861dcc8c06f358819ae84 (diff)
downloaduxp-43165d9edb2f9ac5a65ff9507b462fc948a665ba.tar.gz
Issue #1859 - Part 5: Add format detection to unwrap_full_update.pl
Diffstat (limited to 'tools')
-rwxr-xr-xtools/update-packaging/unwrap_full_update.pl43
1 files changed, 30 insertions, 13 deletions
diff --git a/tools/update-packaging/unwrap_full_update.pl b/tools/update-packaging/unwrap_full_update.pl
index 7ecce019e0..90aa8ee726 100755
--- a/tools/update-packaging/unwrap_full_update.pl
+++ b/tools/update-packaging/unwrap_full_update.pl
@@ -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 {
+ $BZIP2 = "bzip2";
+}
+
+if (defined($ENV{"XZ"})) {
+ $XZ = $ENV{"XZ"};
}
else {
- $MAR_OLD_FORMAT = 0;
- if (defined($ENV{"XZ"})) {
- $XZ = $ENV{"XZ"};
+ 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";