From: Riku Voipio Date: Thu, 19 Oct 2017 08:59:43 +0000 (+0300) Subject: deb: Generalize ungzip to uncompress X-Git-Tag: accepted/tizen/devbase/tools/20190927.044855~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e21121d4262b713f1b0b5280531bd5292a24690b;p=tools%2Fbuild.git deb: Generalize ungzip to uncompress In preparation fot xz support Change-Id: Icf0d2d36970cac4ea02eda1d381858ed173ad006 --- 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");