summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-10-13 10:03:26 +0200
committerGuillem Jover <guillem@debian.org>2019-01-15 03:42:39 +0100
commite989be905db9b9c4761124ce6ee75d4b8903c246 (patch)
tree70e135a967ffe36a4da60f0bbc49c75b26ab031b /scripts
parentd1d35a56e401181b6d15baf474a7db21d3372a65 (diff)
downloaddpkg-e989be905db9b9c4761124ce6ee75d4b8903c246.tar.gz
dpkg-source: Move source format selection earlier in the build
This move it at the beginning were it belongs, as the later code can change behavior based on the format selected. This also will make it possible to delegate the source format object selection to the Dpkg::Source::Package class.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dpkg-source.pl39
1 files changed, 20 insertions, 19 deletions
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index 2e5f41d31..e1124496c 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -238,9 +238,29 @@ if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) {
# <https://reproducible-builds.org/specs/source-date-epoch/>
$ENV{SOURCE_DATE_EPOCH} ||= $changelog->{timestamp} || time;
+ # Select the format to use
+ if (not defined $build_format) {
+ my $format_file = "$dir/debian/source/format";
+ if (-e $format_file) {
+ my $format = Dpkg::Source::Format->new(filename => $format_file);
+ $build_format = $format->get();
+ } else {
+ warning(g_('no source format specified in %s, ' .
+ 'see dpkg-source(1)'), 'debian/source/format')
+ if $options{opmode} eq 'build';
+ $build_format = '1.0';
+ }
+ }
+
my $srcpkg = Dpkg::Source::Package->new(options => \%options);
my $fields = $srcpkg->{fields};
+ $fields->{'Format'} = $build_format;
+ $srcpkg->upgrade_object_type(); # Fails if format is unsupported
+ # Parse command line options
+ $srcpkg->init_options();
+ $srcpkg->parse_cmdline_options(@cmdline_options);
+
my @sourcearch;
my %archadded;
my @binarypackages;
@@ -394,25 +414,6 @@ if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) {
$fields->{'Binary'} =~ s/(.{0,980}), ?/$1,\n/g;
}
- # Select the format to use
- if (not defined $build_format) {
- my $format_file = "$dir/debian/source/format";
- if (-e $format_file) {
- my $format = Dpkg::Source::Format->new(filename => $format_file);
- $build_format = $format->get();
- } else {
- warning(g_('no source format specified in %s, ' .
- 'see dpkg-source(1)'), 'debian/source/format')
- if $options{opmode} eq 'build';
- $build_format = '1.0';
- }
- }
- $fields->{'Format'} = $build_format;
- $srcpkg->upgrade_object_type(); # Fails if format is unsupported
- # Parse command line options
- $srcpkg->init_options();
- $srcpkg->parse_cmdline_options(@cmdline_options);
-
if ($options{opmode} eq 'print-format') {
print $fields->{'Format'} . "\n";
exit(0);