From ebd00d9ca3a5aaf26a3ea0849c149a12170083c1 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 7 Oct 2007 21:11:03 +0200 Subject: [PATCH] dpkg-source: Change -C option to -Z and support -z, too dpkg-deb uses -Z for the same purpose (and -C is already used by dpkg-genchanges and passed through by dpkg-buildpackage), so use that. Also support the -z option that specifies the compression level. --- ChangeLog | 6 ++++-- scripts/dpkg-source.pl | 27 +++++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f362e13..525c2661 100644 --- a/ChangeLog +++ b/ChangeLog @@ -68,8 +68,10 @@ wig&pen (aka Format: 2.0) on build: Use .orig.tar.(bz2|lzma) if they are available and no .gz can be found. Also let the user specify - via -C(gz|bz2|lzma) how files that need to be - generated should be compressed. + via -Z(gz|bz2|lzma) how files that need to be + generated should be compressed. -z([1-9]|best|fast) + can be used to specify the compression level + to use. 2007-09-29 Frank Lichtenheld diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 87d3faa1..b12d5d36 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -76,6 +76,7 @@ my $def_dscformat = "1.0"; # default format for -b my $expectprefix; my $compression = 'gz'; +my $comp_level = '9'; my @comp_supported = qw(gz bz2 lzma); my %comp_supported = map { $_ => 1 } @comp_supported; my $comp_regex = '(?:gz|bz2|lzma)'; @@ -175,8 +176,10 @@ Build options: -ss trust packed & unpacked orig src are same. -sn there is no diff, do main tarfile only. -sA,-sK,-sP,-sU,-sR like -sa,-sk,-sp,-su,-sr but may overwrite. - -C select compression to use (defaults to 'gz', + -Z select compression to use (defaults to 'gz', supported are: %s). + -z compression level to use (defaults to '9', + supported are: '1'-'9', 'best', 'fast') Extract options: -sp (default) leave orig source packed in current dir. @@ -208,10 +211,14 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { &setopmode('build'); } elsif (m/^-x$/) { &setopmode('extract'); - } elsif (m/^-C/) { + } elsif (m/^-Z/) { $compression = $POSTMATCH; usageerr(sprintf(_g("%s is not a supported compression"), $compression)) unless $comp_supported{$compression}; + } elsif (m/^-z/) { + $comp_level = $POSTMATCH; + usageerr(sprintf(_g("%s is not a compression level"), $comp_level)) + unless $comp_level =~ /^([1-9]|fast|best)$/; } elsif (m/^-s([akpursnAKPUR])$/) { warning(sprintf(_g("-s%s option overrides earlier -s%s option"), $1, $sourcestyle)) if $sourcestyle ne 'X'; @@ -821,7 +828,7 @@ if ($opmode eq 'build') { &error(sprintf(_g("Files field contains invalid filename `%s'"), $file)) unless s/^\Q$sourcepackage\E_\Q$baseversion\E(?=[.-])// and - s/\.(gz|bz2|lzma)$//; + s/\.$comp_regex$//; s/^-\Q$revision\E(?=\.)// if length $revision; &error(sprintf(_g("repeated file type - files `%s' and `%s'"), $seen{$_}, $file)) if $seen{$_}; @@ -982,7 +989,7 @@ if ($opmode eq 'build') { for my $patch (@patches) { printf(_g("%s: applying %s")."\n", $progname, $patch); - if ($patch =~ /\.(gz|bz2|lzma)$/) { + if ($patch =~ /\.$comp_regex$/) { &forkgzipread($patch); *DIFF = *GZIP; } else { @@ -1002,7 +1009,7 @@ if ($opmode eq 'build') { $c2 == waitpid($c2,0) || &syserr(_g("wait for patch")); $? && subprocerr("patch"); - &reapgzip if $patch =~ /\.(gz|bz2|lzma)$/; + &reapgzip if $patch =~ /\.$comp_regex$/; } my $now = time; @@ -1285,7 +1292,7 @@ sub checktarsane { sub checkdiff { my $diff = shift; - if ($diff =~ /\.(gz|bz2|lzma)$/) { + if ($diff =~ /\.$comp_regex$/) { &forkgzipread($diff); *DIFF = *GZIP; } else { @@ -1361,7 +1368,7 @@ sub checkdiff } close(DIFF); - &reapgzip if $diff =~ /\.(gz|bz2|lzma)$/; + &reapgzip if $diff =~ /\.$comp_regex$/; } sub extracttar { @@ -1482,7 +1489,7 @@ sub forkgzipwrite { my @prog; if ($_[0] =~ /\.gz\.new\..{6}$/) { - @prog = qw(gzip -9); + @prog = qw(gzip); } elsif ($_[0] =~ /\.bz2\.new\..{6}$/) { @prog = qw(bzip2); } elsif ($_[0] =~ /\.lzma\.new\..{6}$/) { @@ -1490,6 +1497,10 @@ sub forkgzipwrite { } else { &error(sprintf(_g("unknown compression type on file %s"), $_[0])); } + my $level = "-$comp_level"; + $level = "--$comp_level" + if $comp_level =~ /best|fast/; + push @prog, $level; open(GZIPFILE,">", $_[0]) || &syserr(sprintf(_g("create file %s"), $_[0])); pipe(GZIPREAD,GZIP) || &syserr(_g("pipe for gzip")); -- 2.39.5