dpkg-source.pl 21 KB

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