dpkg-source.pl 21 KB

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