diff options
author | Riku Voipio <riku.voipio@linaro.org> | 2017-10-19 11:59:43 +0300 |
---|---|---|
committer | Yonghee Han <onstudy@samsung.com> | 2019-01-17 10:39:04 +0900 |
commit | 51be98c9409eb785f07aaa2a7ce626f47c45f3d3 (patch) | |
tree | efb3d52ea1bf2d1f42ae902b7eb921dc1c915fc9 | |
parent | f4983fdb06558cffc27500c653cf9f5c3568e985 (diff) | |
download | build-51be98c9409eb785f07aaa2a7ce626f47c45f3d3.tar.gz build-51be98c9409eb785f07aaa2a7ce626f47c45f3d3.tar.bz2 build-51be98c9409eb785f07aaa2a7ce626f47c45f3d3.zip |
deb: Generalize ungzip to uncompress
In preparation fot xz support
Change-Id: Icf0d2d36970cac4ea02eda1d381858ed173ad006
-rw-r--r-- | Build/Deb.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Build/Deb.pm b/Build/Deb.pm index e723b58..5713de8 100644 --- a/Build/Deb.pm +++ b/Build/Deb.pm @@ -178,8 +178,9 @@ sub parse { return $ret; } -sub ungzip { +sub uncompress { my $data = shift; + my $tool = shift; local (*TMP, *TMP2); open(TMP, "+>", undef) or die("could not open tmpfile\n"); syswrite TMP, $data; @@ -188,13 +189,13 @@ sub ungzip { die("fork: $!\n") unless defined $pid; if (!$pid) { open(STDIN, "<&TMP"); - exec 'gunzip'; - die("gunzip: $!\n"); + exec($tool); + die("$tool: $!\n"); } close(TMP); $data = ''; 1 while sysread(TMP2, $data, 1024, length($data)) > 0; - close(TMP2) || die("gunzip error"); + close(TMP2) || die("$tool error"); return $data; } @@ -229,6 +230,7 @@ sub debq { return (); } my $data = ''; + my $decompressor = "gunzip"; sysread(DEBF, $data, 4096); if (length($data) < 8+60) { warn("$fn: not a debian package - header too short\n"); @@ -270,10 +272,10 @@ sub debq { close DEBF unless ref($fn); $data = substr($data, 60, $len); my $controlmd5 = Digest::MD5::md5_hex($data); # our header signature - if ($have_zlib) { + if ($have_zlib && $decompressor eq "gunzip") { $data = Compress::Zlib::memGunzip($data); } else { - $data = ungzip($data); + $data = uncompress($data, $decompressor); } if (!$data) { warn("$fn: corrupt control.tar.gz file\n"); |