dpkg-source.pl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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 debarch_is_illegal);
  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"), $a)
  289. if debarch_is_illegal($a);
  290. error(g_('architecture %s only allowed on its ' .
  291. "own (list for package %s is '%s')"),
  292. $a, $p, $a)
  293. if $a eq 'any' or $a eq 'all';
  294. push(@sourcearch, $a) unless $archadded{$a}++;
  295. }
  296. }
  297. } elsif (m/^Homepage$/) {
  298. # Do not overwrite the same field from the source entry
  299. } else {
  300. field_transfer_single($pkg, $fields);
  301. }
  302. }
  303. }
  304. unless (scalar(@pkglist)) {
  305. error(g_("%s doesn't list any binary package"), $controlfile);
  306. }
  307. if (any { $_ eq 'any' } @sourcearch) {
  308. # If we encounter one 'any' then the other arches become insignificant
  309. # except for 'all' that must also be kept
  310. if (any { $_ eq 'all' } @sourcearch) {
  311. @sourcearch = qw(any all);
  312. } else {
  313. @sourcearch = qw(any);
  314. }
  315. } else {
  316. # Minimize arch list, by removing arches already covered by wildcards
  317. my @arch_wildcards = grep { debarch_is_wildcard($_) } @sourcearch;
  318. my @mini_sourcearch = @arch_wildcards;
  319. foreach my $arch (@sourcearch) {
  320. if (none { debarch_is($arch, $_) } @arch_wildcards) {
  321. push @mini_sourcearch, $arch;
  322. }
  323. }
  324. @sourcearch = @mini_sourcearch;
  325. }
  326. $fields->{'Architecture'} = join(' ', @sourcearch);
  327. $fields->{'Package-List'} = "\n" . join("\n", sort @pkglist);
  328. # Check if we have a testsuite, and handle manual and automatic values.
  329. set_testsuite_field($fields);
  330. # Scan fields of dpkg-parsechangelog
  331. foreach (keys %{$changelog}) {
  332. my $v = $changelog->{$_};
  333. if (m/^Source$/) {
  334. set_source_package($v);
  335. $fields->{$_} = $v;
  336. } elsif (m/^Version$/) {
  337. my ($ok, $error) = version_check($v);
  338. error($error) unless $ok;
  339. $fields->{$_} = $v;
  340. } elsif (m/^Binary-Only$/) {
  341. error(g_('building source for a binary-only release'))
  342. if $v eq 'yes' and $options{opmode} eq 'build';
  343. } elsif (m/^Maintainer$/i) {
  344. # Do not replace the field coming from the source entry
  345. } else {
  346. field_transfer_single($changelog, $fields);
  347. }
  348. }
  349. $fields->{'Binary'} = join(', ', @binarypackages);
  350. # Avoid overly long line by splitting over multiple lines
  351. if (length($fields->{'Binary'}) > 980) {
  352. $fields->{'Binary'} =~ s/(.{0,980}), ?/$1,\n/g;
  353. }
  354. # Select the format to use
  355. if (not defined $build_format) {
  356. if (-e "$dir/debian/source/format") {
  357. open(my $format_fh, '<', "$dir/debian/source/format")
  358. or syserr(g_('cannot read %s'), "$dir/debian/source/format");
  359. $build_format = <$format_fh>;
  360. chomp($build_format) if defined $build_format;
  361. error(g_('%s is empty'), "$dir/debian/source/format")
  362. unless defined $build_format and length $build_format;
  363. close($format_fh);
  364. } else {
  365. warning(g_('no source format specified in %s, ' .
  366. 'see dpkg-source(1)'), 'debian/source/format')
  367. if $options{opmode} eq 'build';
  368. $build_format = '1.0';
  369. }
  370. }
  371. $fields->{'Format'} = $build_format;
  372. $srcpkg->upgrade_object_type(); # Fails if format is unsupported
  373. # Parse command line options
  374. $srcpkg->init_options();
  375. $srcpkg->parse_cmdline_options(@cmdline_options);
  376. if ($options{opmode} eq 'print-format') {
  377. print $fields->{'Format'} . "\n";
  378. exit(0);
  379. } elsif ($options{opmode} eq 'before-build') {
  380. $srcpkg->before_build($dir);
  381. exit(0);
  382. } elsif ($options{opmode} eq 'after-build') {
  383. $srcpkg->after_build($dir);
  384. exit(0);
  385. } elsif ($options{opmode} eq 'commit') {
  386. $srcpkg->commit($dir);
  387. exit(0);
  388. }
  389. # Verify pre-requisites are met
  390. my ($res, $msg) = $srcpkg->can_build($dir);
  391. error(g_("can't build with source format '%s': %s"), $build_format, $msg) unless $res;
  392. # Only -b left
  393. info(g_("using source format '%s'"), $fields->{'Format'});
  394. run_vendor_hook('before-source-build', $srcpkg);
  395. # Build the files (.tar.gz, .diff.gz, etc)
  396. $srcpkg->build($dir);
  397. # Write the .dsc
  398. my $dscname = $srcpkg->get_basename(1) . '.dsc';
  399. info(g_('building %s in %s'), get_source_package(), $dscname);
  400. $srcpkg->write_dsc(filename => $dscname,
  401. remove => \%remove,
  402. override => \%override,
  403. substvars => $substvars);
  404. exit(0);
  405. } elsif ($options{opmode} eq 'extract') {
  406. # Check command line
  407. unless (scalar(@ARGV)) {
  408. usageerr(g_('--%s needs at least one argument, the .dsc'),
  409. $options{opmode});
  410. }
  411. if (scalar(@ARGV) > 2) {
  412. usageerr(g_('--%s takes no more than two arguments'), $options{opmode});
  413. }
  414. my $dsc = shift(@ARGV);
  415. if (-d $dsc) {
  416. usageerr(g_('--%s needs the .dsc file as first argument, not a directory'),
  417. $options{opmode});
  418. }
  419. # Create the object that does everything
  420. my $srcpkg = Dpkg::Source::Package->new(filename => $dsc,
  421. options => \%options);
  422. # Parse command line options
  423. $srcpkg->parse_cmdline_options(@cmdline_options);
  424. # Decide where to unpack
  425. my $newdirectory = $srcpkg->get_basename();
  426. $newdirectory =~ s/_/-/g;
  427. if (@ARGV) {
  428. $newdirectory = File::Spec->catdir(shift(@ARGV));
  429. if (-e $newdirectory) {
  430. error(g_('unpack target exists: %s'), $newdirectory);
  431. }
  432. }
  433. # Various checks before unpacking
  434. unless ($options{no_check}) {
  435. if ($srcpkg->is_signed()) {
  436. $srcpkg->check_signature();
  437. } else {
  438. if ($options{require_valid_signature}) {
  439. error(g_("%s doesn't contain a valid OpenPGP signature"), $dsc);
  440. } else {
  441. warning(g_('extracting unsigned source package (%s)'), $dsc);
  442. }
  443. }
  444. $srcpkg->check_checksums();
  445. }
  446. # Unpack the source package (delegated to Dpkg::Source::Package::*)
  447. info(g_('extracting %s in %s'), $srcpkg->{fields}{'Source'}, $newdirectory);
  448. $srcpkg->extract($newdirectory);
  449. exit(0);
  450. }
  451. sub set_testsuite_field
  452. {
  453. my $fields = shift;
  454. my $testsuite_field = $fields->{'Testsuite'} // '';
  455. my %testsuite = map { $_ => 1 } split /\s*,\s*/, $testsuite_field;
  456. if (-e "$dir/debian/tests/control") {
  457. $testsuite{autopkgtest} = 1;
  458. } elsif ($testsuite{autopkgtest}) {
  459. warning(g_('%s field contains value %s, but no tests control file %s'),
  460. 'Testsuite', 'autopkgtest', 'debian/tests/control');
  461. delete $testsuite{autopkgtest};
  462. }
  463. $fields->{'Testsuite'} = join ', ', sort keys %testsuite;
  464. }
  465. sub setopmode {
  466. my $opmode = shift;
  467. if (defined($options{opmode})) {
  468. usageerr(g_('two commands specified: --%s and --%s'),
  469. $options{opmode}, $opmode);
  470. }
  471. $options{opmode} = $opmode;
  472. }
  473. sub print_option {
  474. my $opt = shift;
  475. my $help;
  476. if (length $opt->{name} > 25) {
  477. $help .= sprintf " %-25s\n%s%s.\n", $opt->{name}, ' ' x 27, $opt->{help};
  478. } else {
  479. $help .= sprintf " %-25s%s.\n", $opt->{name}, $opt->{help};
  480. }
  481. }
  482. sub get_format_help {
  483. $build_format //= '1.0';
  484. my $srcpkg = Dpkg::Source::Package->new();
  485. $srcpkg->{fields}->{'Format'} = $build_format;
  486. $srcpkg->upgrade_object_type(); # Fails if format is unsupported
  487. my @cmdline = $srcpkg->describe_cmdline_options();
  488. my $help_build = my $help_extract = '';
  489. my $help;
  490. foreach my $opt (@cmdline) {
  491. $help_build .= print_option($opt) if $opt->{when} eq 'build';
  492. $help_extract .= print_option($opt) if $opt->{when} eq 'extract';
  493. }
  494. if ($help_build) {
  495. $help .= "\n";
  496. $help .= "Build format $build_format options:\n";
  497. $help .= $help_build || g_('<none>');
  498. }
  499. if ($help_extract) {
  500. $help .= "\n";
  501. $help .= "Extract format $build_format options:\n";
  502. $help .= $help_extract || g_('<none>');
  503. }
  504. return $help;
  505. }
  506. sub version {
  507. printf g_("Debian %s version %s.\n"), $Dpkg::PROGNAME, $Dpkg::PROGVERSION;
  508. print g_('
  509. This is free software; see the GNU General Public License version 2 or
  510. later for copying conditions. There is NO warranty.
  511. ');
  512. }
  513. sub usage {
  514. printf g_(
  515. 'Usage: %s [<option>...] <command>')
  516. . "\n\n" . g_(
  517. 'Commands:
  518. -x, --extract <filename>.dsc [<output-dir>]
  519. extract source package.
  520. -b, --build <dir> build source package.
  521. --print-format <dir> print the format to be used for the source package.
  522. --commit [<dir> [<patch-name>]]
  523. store upstream changes in a new patch.')
  524. . "\n\n" . g_(
  525. "Build options:
  526. -c<control-file> get control info from this file.
  527. -l<changelog-file> get per-version info from this file.
  528. -F<changelog-format> force changelog format.
  529. --format=<source-format> set the format to be used for the source package.
  530. -V<name>=<value> set a substitution variable.
  531. -T<substvars-file> read variables here.
  532. -D<field>=<value> override or add a .dsc field and value.
  533. -U<field> remove a field.
  534. -q quiet mode.
  535. -i[<regex>] filter out files to ignore diffs of
  536. (defaults to: '%s').
  537. -I[<pattern>] filter out files when building tarballs
  538. (defaults to: %s).
  539. -Z<compression> select compression to use (defaults to '%s',
  540. supported are: %s).
  541. -z<level> compression level to use (defaults to '%d',
  542. supported are: '1'-'9', 'best', 'fast')")
  543. . "\n\n" . g_(
  544. "Extract options:
  545. --no-copy don't copy .orig tarballs
  546. --no-check don't check signature and checksums before unpacking
  547. --require-valid-signature abort if the package doesn't have a valid signature
  548. --ignore-bad-version allow bad source package versions.")
  549. . "\n" .
  550. get_format_help()
  551. . "\n" . g_(
  552. 'General options:
  553. -?, --help show this help message.
  554. --version show the version.')
  555. . "\n\n" . g_(
  556. 'Source format specific build and extract options are available;
  557. use --format with --help to see them.') . "\n",
  558. $Dpkg::PROGNAME,
  559. get_default_diff_ignore_regex(),
  560. join(' ', map { "-I$_" } get_default_tar_ignore_pattern()),
  561. compression_get_default(),
  562. join(' ', compression_get_list()),
  563. compression_get_default_level();
  564. }