1#!/usr/bin/perl
2#
3# dpkg-source
4#
5# Copyright © 1996 Ian Jackson <ijackson@chiark.greenend.org.uk>
6# Copyright © 1997 Klee Dienes <klee@debian.org>
7# Copyright © 1999-2003 Wichert Akkerman <wakkerma@debian.org>
8# Copyright © 1999 Ben Collins <bcollins@debian.org>
9# Copyright © 2000-2003 Adam Heath <doogie@debian.org>
10# Copyright © 2005 Brendan O'Dea <bod@debian.org>
11# Copyright © 2006-2008 Frank Lichtenheld <djpig@debian.org>
12# Copyright © 2006-2009,2012 Guillem Jover <guillem@debian.org>
13# Copyright © 2008-2011 Raphaël Hertzog <hertzog@debian.org>
14#
15# This program is free software; you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation; either version 2 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program.  If not, see <https://www.gnu.org/licenses/>.
27
28use strict;
29use warnings;
30
31use List::Util qw(any none);
32use Cwd;
33use File::Basename;
34use File::Spec;
35
36use Dpkg ();
37use Dpkg::Gettext;
38use Dpkg::ErrorHandling;
39use Dpkg::Arch qw(:operators);
40use Dpkg::Deps;
41use Dpkg::Compression;
42use Dpkg::Conf;
43use Dpkg::Control::Info;
44use Dpkg::Control::Tests;
45use Dpkg::Control::Fields;
46use Dpkg::Substvars;
47use Dpkg::Version;
48use Dpkg::Vars;
49use Dpkg::Changelog::Parse;
50use Dpkg::Source::Format;
51use Dpkg::Source::Package qw(get_default_diff_ignore_regex
52                             set_default_diff_ignore_regex
53                             get_default_tar_ignore_pattern);
54use Dpkg::Vendor qw(run_vendor_hook);
55
56textdomain('dpkg-dev');
57
58my $controlfile;
59my $changelogfile;
60my $changelogformat;
61
62my $build_format;
63my %options = (
64    # Ignore files
65    tar_ignore => [],
66    diff_ignore_regex => '',
67    # Misc options
68    copy_orig_tarballs => 1,
69    no_check => 0,
70    no_overwrite_dir => 1,
71    require_valid_signature => 0,
72    require_strong_checksums => 0,
73);
74
75# Fields to remove/override
76my %remove;
77my %override;
78
79my $substvars = Dpkg::Substvars->new();
80my $tar_ignore_default_pattern_done;
81my $diff_ignore_regex = get_default_diff_ignore_regex();
82
83my @options;
84my @cmdline_options;
85while (@ARGV && $ARGV[0] =~ m/^-/) {
86    my $arg = shift @ARGV;
87
88    if ($arg eq '-b' or $arg eq '--build') {
89        setopmode('build');
90    } elsif ($arg eq '-x' or $arg eq '--extract') {
91        setopmode('extract');
92    } elsif ($arg eq '--before-build') {
93        setopmode('before-build');
94    } elsif ($arg eq '--after-build') {
95        setopmode('after-build');
96    } elsif ($arg eq '--commit') {
97        setopmode('commit');
98    } elsif ($arg eq '--print-format') {
99        setopmode('print-format');
100	report_options(info_fh => \*STDERR); # Avoid clutter on STDOUT
101    } else {
102        push @options, $arg;
103    }
104}
105
106my $dir;
107if (defined($options{opmode}) &&
108    $options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) {
109    if (not scalar(@ARGV)) {
110	usageerr(g_('--%s needs a directory'), $options{opmode})
111	    unless $1 eq 'commit';
112	$dir = '.';
113    } else {
114	$dir = File::Spec->catdir(shift(@ARGV));
115    }
116    stat($dir) or syserr(g_('cannot stat directory %s'), $dir);
117    if (not -d $dir) {
118	error(g_('directory argument %s is not a directory'), $dir);
119    }
120    if ($dir eq '.') {
121	# . is never correct, adjust automatically
122	$dir = basename(getcwd());
123	chdir '..' or syserr(g_("unable to chdir to '%s'"), '..');
124    }
125    # --format options are not allowed, they would take precedence
126    # over real command line options, debian/source/format should be used
127    # instead
128    # --unapply-patches is only allowed in local-options as it's a matter
129    # of personal taste and the default should be to keep patches applied
130    my $forbidden_opts_re = {
131	'options' => qr/^--(?:format=|unapply-patches$|abort-on-upstream-changes$)/,
132	'local-options' => qr/^--format=/,
133    };
134    foreach my $filename ('local-options', 'options') {
135	my $conf = Dpkg::Conf->new();
136	my $optfile = File::Spec->catfile($dir, 'debian', 'source', $filename);
137	next unless -f $optfile;
138	$conf->load($optfile);
139	$conf->filter(remove => sub { $_[0] =~ $forbidden_opts_re->{$filename} });
140	if (@$conf) {
141	    info(g_('using options from %s: %s'), $optfile, join(' ', @$conf))
142		unless $options{opmode} eq 'print-format';
143	    unshift @options, @$conf;
144	}
145    }
146}
147
148while (@options) {
149    $_ = shift(@options);
150    if (m/^--format=(.*)$/) {
151	$build_format //= $1;
152    } elsif (m/^-(?:Z|-compression=)(.*)$/) {
153	my $compression = $1;
154	$options{compression} = $compression;
155	usageerr(g_('%s is not a supported compression'), $compression)
156	    unless compression_is_supported($compression);
157	compression_set_default($compression);
158    } elsif (m/^-(?:z|-compression-level=)(.*)$/) {
159	my $comp_level = $1;
160	$options{comp_level} = $comp_level;
161	usageerr(g_('%s is not a compression level'), $comp_level)
162	    unless compression_is_valid_level($comp_level);
163	compression_set_default_level($comp_level);
164    } elsif (m/^-c(.*)$/) {
165        $controlfile = $1;
166    } elsif (m/^-l(.*)$/) {
167        $changelogfile = $1;
168    } elsif (m/^-F([0-9a-z]+)$/) {
169        $changelogformat = $1;
170    } elsif (m/^-D([^\=:]+)[=:](.*)$/s) {
171        $override{$1} = $2;
172    } elsif (m/^-U([^\=:]+)$/) {
173        $remove{$1} = 1;
174    } elsif (m/^-(?:i|-diff-ignore(?:$|=))(.*)$/) {
175        $options{diff_ignore_regex} = $1 ? $1 : $diff_ignore_regex;
176    } elsif (m/^--extend-diff-ignore=(.+)$/) {
177	$diff_ignore_regex .= "|$1";
178	if ($options{diff_ignore_regex}) {
179	    $options{diff_ignore_regex} .= "|$1";
180	}
181	set_default_diff_ignore_regex($diff_ignore_regex);
182    } elsif (m/^-(?:I|-tar-ignore=)(.+)$/) {
183        push @{$options{tar_ignore}}, $1;
184    } elsif (m/^-(?:I|-tar-ignore)$/) {
185        unless ($tar_ignore_default_pattern_done) {
186            push @{$options{tar_ignore}}, get_default_tar_ignore_pattern();
187            # Prevent adding multiple times
188            $tar_ignore_default_pattern_done = 1;
189        }
190    } elsif (m/^--no-copy$/) {
191        $options{copy_orig_tarballs} = 0;
192    } elsif (m/^--no-check$/) {
193        $options{no_check} = 1;
194    } elsif (m/^--no-overwrite-dir$/) {
195        $options{no_overwrite_dir} = 1;
196    } elsif (m/^--require-valid-signature$/) {
197        $options{require_valid_signature} = 1;
198    } elsif (m/^--require-strong-checksums$/) {
199        $options{require_strong_checksums} = 1;
200    } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:](.*)$/s) {
201        $substvars->set($1, $2);
202    } elsif (m/^-T(.*)$/) {
203	$substvars->load($1) if -e $1;
204    } elsif (m/^-(?:\?|-help)$/) {
205        usage();
206        exit(0);
207    } elsif (m/^--version$/) {
208        version();
209        exit(0);
210    } elsif (m/^-[EW]$/) {
211        # Deprecated option
212        warning(g_('-E and -W are deprecated, they are without effect'));
213    } elsif (m/^-q$/) {
214        report_options(quiet_warnings => 1);
215        $options{quiet} = 1;
216    } elsif (m/^--$/) {
217        last;
218    } else {
219        push @cmdline_options, $_;
220    }
221}
222
223unless (defined($options{opmode})) {
224    usageerr(g_('need an action option'));
225}
226
227if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) {
228
229    $options{ARGV} = \@ARGV;
230
231    $changelogfile ||= "$dir/debian/changelog";
232    $controlfile ||= "$dir/debian/control";
233
234    my %ch_options = (file => $changelogfile);
235    $ch_options{changelogformat} = $changelogformat if $changelogformat;
236    my $changelog = changelog_parse(%ch_options);
237    my $control = Dpkg::Control::Info->new($controlfile);
238
239    # <https://reproducible-builds.org/specs/source-date-epoch/>
240    $ENV{SOURCE_DATE_EPOCH} ||= $changelog->{timestamp} || time;
241
242    # Select the format to use
243    if (not defined $build_format) {
244        my $format_file = "$dir/debian/source/format";
245        if (-e $format_file) {
246            my $format = Dpkg::Source::Format->new(filename => $format_file);
247            $build_format = $format->get();
248        } else {
249            warning(g_('no source format specified in %s, ' .
250                       'see dpkg-source(1)'), 'debian/source/format')
251                if $options{opmode} eq 'build';
252            $build_format = '1.0';
253        }
254    }
255
256    my $srcpkg = Dpkg::Source::Package->new(format => $build_format,
257                                            options => \%options);
258    my $fields = $srcpkg->{fields};
259
260    $srcpkg->parse_cmdline_options(@cmdline_options);
261
262    my @sourcearch;
263    my %archadded;
264    my @binarypackages;
265
266    # Scan control info of source package
267    my $src_fields = $control->get_source();
268    error(g_("%s doesn't contain any information about the source package"),
269          $controlfile) unless defined $src_fields;
270    my $src_sect = $src_fields->{'Section'} || 'unknown';
271    my $src_prio = $src_fields->{'Priority'} || 'unknown';
272    foreach (keys %{$src_fields}) {
273	my $v = $src_fields->{$_};
274	if (m/^Source$/i) {
275	    set_source_package($v);
276	    $fields->{$_} = $v;
277	} elsif (m/^Uploaders$/i) {
278	    ($fields->{$_} = $v) =~ s/\s*[\r\n]\s*/ /g; # Merge in a single-line
279	} elsif (m/^Build-(?:Depends|Conflicts)(?:-Arch|-Indep)?$/i) {
280	    my $dep;
281	    my $type = field_get_dep_type($_);
282	    $dep = deps_parse($v, build_dep => 1, union => $type eq 'union');
283	    error(g_('error occurred while parsing %s'), $_) unless defined $dep;
284	    my $facts = Dpkg::Deps::KnownFacts->new();
285	    $dep->simplify_deps($facts);
286	    $dep->sort() if $type eq 'union';
287	    $fields->{$_} = $dep->output();
288	} else {
289            field_transfer_single($src_fields, $fields);
290	}
291    }
292
293    # Scan control info of binary packages
294    my @pkglist;
295    foreach my $pkg ($control->get_packages()) {
296	my $p = $pkg->{'Package'};
297	my $sect = $pkg->{'Section'} || $src_sect;
298	my $prio = $pkg->{'Priority'} || $src_prio;
299	my $type = $pkg->{'Package-Type'} ||
300	        $pkg->get_custom_field('Package-Type') || 'deb';
301        my $arch = $pkg->{'Architecture'};
302        my $profile = $pkg->{'Build-Profiles'};
303
304        my $pkg_summary = sprintf('%s %s %s %s', $p, $type, $sect, $prio);
305
306        $pkg_summary .= ' arch=' . join ',', split ' ', $arch;
307
308        if (defined $profile) {
309            # If the string does not contain brackets then it is using the
310            # old syntax. Emit a fatal error.
311            if ($profile !~ m/^\s*<.*>\s*$/) {
312                error(g_('binary package stanza %s is using an obsolete ' .
313                         'Build-Profiles field syntax'), $p);
314            }
315
316            # Instead of splitting twice and then joining twice, we just do
317            # simple string replacements:
318
319            # Remove the enclosing <>
320            $profile =~ s/^\s*<(.*)>\s*$/$1/;
321            # Join lists with a plus (OR)
322            $profile =~ s/>\s+</+/g;
323            # Join their elements with a comma (AND)
324            $profile =~ s/\s+/,/g;
325            $pkg_summary .= " profile=$profile";
326        }
327
328        if (defined $pkg->{'Essential'} and $pkg->{'Essential'} eq 'yes') {
329            $pkg_summary .= ' essential=yes';
330        }
331
332        push @pkglist, $pkg_summary;
333	push @binarypackages, $p;
334	foreach (keys %{$pkg}) {
335	    my $v = $pkg->{$_};
336            if (m/^Architecture$/) {
337                # Gather all binary architectures in one set. 'any' and 'all'
338                # are special-cased as they need to be the only ones in the
339                # current stanza if present.
340                if (debarch_eq($v, 'any') || debarch_eq($v, 'all')) {
341                    push(@sourcearch, $v) unless $archadded{$v}++;
342                } else {
343                    for my $a (split(/\s+/, $v)) {
344                        error(g_("'%s' is not a legal architecture string"), $a)
345                            if debarch_is_illegal($a);
346                        error(g_('architecture %s only allowed on its ' .
347                                 "own (list for package %s is '%s')"),
348                              $a, $p, $a)
349                            if $a eq 'any' or $a eq 'all';
350                        push(@sourcearch, $a) unless $archadded{$a}++;
351                    }
352                }
353            } elsif (m/^(?:Homepage|Description)$/) {
354                # Do not overwrite the same field from the source entry
355            } else {
356                field_transfer_single($pkg, $fields);
357            }
358	}
359    }
360    unless (scalar(@pkglist)) {
361	error(g_("%s doesn't list any binary package"), $controlfile);
362    }
363    if (any { $_ eq 'any' } @sourcearch) {
364        # If we encounter one 'any' then the other arches become insignificant
365        # except for 'all' that must also be kept
366        if (any { $_ eq 'all' } @sourcearch) {
367            @sourcearch = qw(any all);
368        } else {
369            @sourcearch = qw(any);
370        }
371    } else {
372        # Minimize arch list, by removing arches already covered by wildcards
373        my @arch_wildcards = grep { debarch_is_wildcard($_) } @sourcearch;
374        my @mini_sourcearch = @arch_wildcards;
375        foreach my $arch (@sourcearch) {
376            if (none { debarch_is($arch, $_) } @arch_wildcards) {
377                push @mini_sourcearch, $arch;
378            }
379        }
380        @sourcearch = @mini_sourcearch;
381    }
382    $fields->{'Architecture'} = join(' ', @sourcearch);
383    $fields->{'Package-List'} = "\n" . join("\n", sort @pkglist);
384
385    # Check if we have a testsuite, and handle manual and automatic values.
386    set_testsuite_fields($fields, @binarypackages);
387
388    # Scan fields of dpkg-parsechangelog
389    foreach (keys %{$changelog}) {
390        my $v = $changelog->{$_};
391
392	if (m/^Source$/) {
393	    set_source_package($v);
394	    $fields->{$_} = $v;
395	} elsif (m/^Version$/) {
396	    my ($ok, $error) = version_check($v);
397            error($error) unless $ok;
398	    $fields->{$_} = $v;
399	} elsif (m/^Binary-Only$/) {
400	    error(g_('building source for a binary-only release'))
401	        if $v eq 'yes' and $options{opmode} eq 'build';
402	} elsif (m/^Maintainer$/i) {
403            # Do not replace the field coming from the source entry
404	} else {
405            field_transfer_single($changelog, $fields);
406	}
407    }
408
409    $fields->{'Binary'} = join(', ', @binarypackages);
410    # Avoid overly long line by splitting over multiple lines
411    if (length($fields->{'Binary'}) > 980) {
412	$fields->{'Binary'} =~ s/(.{0,980}), ?/$1,\n/g;
413    }
414
415    if ($options{opmode} eq 'print-format') {
416	print $fields->{'Format'} . "\n";
417	exit(0);
418    } elsif ($options{opmode} eq 'before-build') {
419	$srcpkg->before_build($dir);
420	exit(0);
421    } elsif ($options{opmode} eq 'after-build') {
422	$srcpkg->after_build($dir);
423	exit(0);
424    } elsif ($options{opmode} eq 'commit') {
425	$srcpkg->commit($dir);
426	exit(0);
427    }
428
429    # Verify pre-requisites are met
430    my ($res, $msg) = $srcpkg->can_build($dir);
431    error(g_("can't build with source format '%s': %s"), $build_format, $msg) unless $res;
432
433    # Only -b left
434    info(g_("using source format '%s'"), $fields->{'Format'});
435    run_vendor_hook('before-source-build', $srcpkg);
436    # Build the files (.tar.gz, .diff.gz, etc)
437    $srcpkg->build($dir);
438
439    # Write the .dsc
440    my $dscname = $srcpkg->get_basename(1) . '.dsc';
441    info(g_('building %s in %s'), get_source_package(), $dscname);
442    $srcpkg->write_dsc(filename => $dscname,
443		       remove => \%remove,
444		       override => \%override,
445		       substvars => $substvars);
446    exit(0);
447
448} elsif ($options{opmode} eq 'extract') {
449
450    # Check command line
451    unless (scalar(@ARGV)) {
452        usageerr(g_('--%s needs at least one argument, the .dsc'),
453                 $options{opmode});
454    }
455    if (scalar(@ARGV) > 2) {
456        usageerr(g_('--%s takes no more than two arguments'), $options{opmode});
457    }
458    my $dsc = shift(@ARGV);
459    if (-d $dsc) {
460        usageerr(g_('--%s needs the .dsc file as first argument, not a directory'),
461                 $options{opmode});
462    }
463
464    # Create the object that does everything
465    my $srcpkg = Dpkg::Source::Package->new(filename => $dsc,
466					    options => \%options);
467
468    # Parse command line options
469    $srcpkg->parse_cmdline_options(@cmdline_options);
470
471    # Decide where to unpack
472    my $newdirectory = $srcpkg->get_basename();
473    $newdirectory =~ s/_/-/g;
474    if (@ARGV) {
475	$newdirectory = File::Spec->catdir(shift(@ARGV));
476	if (-e $newdirectory) {
477	    error(g_('unpack target exists: %s'), $newdirectory);
478	}
479    }
480
481    # Various checks before unpacking
482    unless ($options{no_check}) {
483        if ($srcpkg->is_signed()) {
484            $srcpkg->check_signature();
485        } else {
486            if ($options{require_valid_signature}) {
487                error(g_("%s doesn't contain a valid OpenPGP signature"), $dsc);
488            } else {
489                warning(g_('extracting unsigned source package (%s)'), $dsc);
490            }
491        }
492        $srcpkg->check_checksums();
493    }
494
495    # Unpack the source package (delegated to Dpkg::Source::Package::*)
496    info(g_('extracting %s in %s'), $srcpkg->{fields}{'Source'}, $newdirectory);
497    $srcpkg->extract($newdirectory);
498
499    exit(0);
500}
501
502sub set_testsuite_fields
503{
504    my ($fields, @binarypackages) = @_;
505
506    my $testsuite_field = $fields->{'Testsuite'} // '';
507    my %testsuite = map { $_ => 1 } split /\s*,\s*/, $testsuite_field;
508    if (-e "$dir/debian/tests/control") {
509        error(g_('test control %s is not a regular file'),
510              'debian/tests/control') unless -f _;
511        $testsuite{autopkgtest} = 1;
512
513        my $tests = Dpkg::Control::Tests->new();
514        $tests->load("$dir/debian/tests/control");
515
516        set_testsuite_triggers_field($tests, $fields, @binarypackages);
517    } elsif ($testsuite{autopkgtest}) {
518        warning(g_('%s field contains value %s, but no tests control file %s'),
519                'Testsuite', 'autopkgtest', 'debian/tests/control');
520        delete $testsuite{autopkgtest};
521    }
522    $fields->{'Testsuite'} = join ', ', sort keys %testsuite;
523}
524
525sub set_testsuite_triggers_field
526{
527    my ($tests, $fields, @binarypackages) = @_;
528    my %testdeps;
529
530    # Never overwrite a manually defined field.
531    return if $fields->{'Testsuite-Triggers'};
532
533    foreach my $test ($tests->get()) {
534        next unless $test->{Depends};
535
536        my $deps = deps_parse($test->{Depends}, use_arch => 0, tests_dep => 1);
537        deps_iterate($deps, sub { $testdeps{$_[0]->{package}} = 1 });
538    }
539
540    # Remove our own binaries and its meta-depends variant.
541    foreach my $pkg (@binarypackages, qw(@)) {
542        delete $testdeps{$pkg};
543    }
544    $fields->{'Testsuite-Triggers'} = join ', ', sort keys %testdeps;
545}
546
547sub setopmode {
548    my $opmode = shift;
549
550    if (defined($options{opmode})) {
551        usageerr(g_('two commands specified: --%s and --%s'),
552                 $options{opmode}, $opmode);
553    }
554    $options{opmode} = $opmode;
555}
556
557sub print_option {
558    my $opt = shift;
559    my $help;
560
561    if (length $opt->{name} > 25) {
562        $help .= sprintf "  %-25s\n%s%s.\n", $opt->{name}, ' ' x 27, $opt->{help};
563    } else {
564        $help .= sprintf "  %-25s%s.\n", $opt->{name}, $opt->{help};
565    }
566}
567
568sub get_format_help {
569    $build_format //= '1.0';
570
571    my $srcpkg = Dpkg::Source::Package->new(format => $build_format);
572
573    my @cmdline = $srcpkg->describe_cmdline_options();
574    return '' unless @cmdline;
575
576    my $help_build = my $help_extract = '';
577    my $help;
578
579    foreach my $opt (@cmdline) {
580        $help_build .= print_option($opt) if $opt->{when} eq 'build';
581        $help_extract .= print_option($opt) if $opt->{when} eq 'extract';
582    }
583
584    if ($help_build) {
585        $help .= "\n";
586        $help .= "Build format $build_format options:\n";
587        $help .= $help_build || C_('source options', '<none>');
588    }
589    if ($help_extract) {
590        $help .= "\n";
591        $help .= "Extract format $build_format options:\n";
592        $help .= $help_extract || C_('source options', '<none>');
593    }
594
595    return $help;
596}
597
598sub version {
599    printf g_("Debian %s version %s.\n"), $Dpkg::PROGNAME, $Dpkg::PROGVERSION;
600
601    print g_('
602This is free software; see the GNU General Public License version 2 or
603later for copying conditions. There is NO warranty.
604');
605}
606
607sub usage {
608    printf g_(
609'Usage: %s [<option>...] <command>')
610    . "\n\n" . g_(
611'Commands:
612  -x, --extract <filename>.dsc [<output-dir>]
613                           extract source package.
614  -b, --build <dir>        build source package.
615      --print-format <dir> print the format to be used for the source package.
616      --before-build <dir> run the corresponding source package format hook.
617      --after-build <dir>  run the corresponding source package format hook.
618      --commit [<dir> [<patch-name>]]
619                           store upstream changes in a new patch.')
620    . "\n\n" . g_(
621"Build options:
622  -c<control-file>         get control info from this file.
623  -l<changelog-file>       get per-version info from this file.
624  -F<changelog-format>     force changelog format.
625  --format=<source-format> set the format to be used for the source package.
626  -V<name>=<value>         set a substitution variable.
627  -T<substvars-file>       read variables here.
628  -D<field>=<value>        override or add a .dsc field and value.
629  -U<field>                remove a field.
630  -i, --diff-ignore[=<regex>]
631                           filter out files to ignore diffs of
632                             (defaults to: '%s').
633  -I, --tar-ignore[=<pattern>]
634                           filter out files when building tarballs
635                             (defaults to: %s).
636  -Z, --compression=<compression>
637                           select compression to use (defaults to '%s',
638                             supported are: %s).
639  -z, --compression-level=<level>
640                           compression level to use (defaults to '%d',
641                             supported are: '1'-'9', 'best', 'fast')")
642    . "\n\n" . g_(
643"Extract options:
644  --no-copy                don't copy .orig tarballs
645  --no-check               don't check signature and checksums before unpacking
646  --no-overwrite-dir       do not overwrite directory on extraction
647  --require-valid-signature abort if the package doesn't have a valid signature
648  --require-strong-checksums
649                           abort if the package contains no strong checksums
650  --ignore-bad-version     allow bad source package versions.")
651    . "\n" .
652    get_format_help()
653    . "\n" . g_(
654'General options:
655  -q                       quiet mode.
656  -?, --help               show this help message.
657      --version            show the version.')
658    . "\n\n" . g_(
659'Source format specific build and extract options are available;
660use --format with --help to see them.') . "\n",
661    $Dpkg::PROGNAME,
662    get_default_diff_ignore_regex(),
663    join(' ', map { "-I$_" } get_default_tar_ignore_pattern()),
664    compression_get_default(),
665    join(' ', compression_get_list()),
666    compression_get_default_level();
667}
668