The following commit has been merged in the master branch:
commit 61ab00f675dff4837c386075a0b835de263702fd
Author: Raphaël Hertzog <[email protected]>
Date: Sun Feb 21 11:58:40 2010 +0100
dpkg-source: new option --create-empty-orig in formats "2.0" and "3.0
(quilt)"
With this option, dpkg-source will auto-create the main original tarball
when it's missing and when there are supplementary tarballs. This makes it
easier to bundle multiple software together.
dpkg-source needs to be modified since the options have to be parsed
before can_build() is called.
diff --git a/debian/changelog b/debian/changelog
index 33ff3bf..4e0b964 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -49,6 +49,10 @@ dpkg (1.15.6) UNRELEASED; urgency=low
* The -T option of dpkg-{source,gencontrol,genchanges} can now be used
multiple times to read substitution variables from multiple files.
Closes: #363323
+ * dpkg-source now supports an option --create-empty-orig in formats
+ "2.0" and "3.0 (quilt)" to auto-create the main original tarball when
+ there are supplementary tarballs. This makes it easier to bundle
+ multiple software together. Closes: #554488
[ Guillem Jover ]
* Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages
diff --git a/man/dpkg-source.1 b/man/dpkg-source.1
index 42f0ab0..61daae7 100644
--- a/man/dpkg-source.1
+++ b/man/dpkg-source.1
@@ -476,6 +476,12 @@ be generated. Instead the current diff with upstream
should be stored in a
single patch. When using this option, it is recommended to create
a debian/source/patch-header file explaining how the Debian changes can be
best reviewed, for example in the VCS that is used.
+.TP
+.B \-\-create\-empty\-orig
+Automatically create the main original tarball as empty if it's missing
+and if there are supplementary original tarballs. This option is meant to
+be used when the source package is just a bundle of multiple upstream
+software and where there's no "main" software.
.PP
.B Extract options
diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm
index 6bcf4b2..f6c9f72 100644
--- a/scripts/Dpkg/Source/Package.pm
+++ b/scripts/Dpkg/Source/Package.pm
@@ -241,16 +241,21 @@ sub get_basename {
}
sub find_original_tarballs {
- my ($self, $ext) = @_;
- $ext ||= $compression_re_file_ext;
+ my ($self, %opts) = @_;
+ $opts{extension} = $compression_re_file_ext unless exists $opts{extension};
+ $opts{include_main} = 1 unless exists $opts{include_main};
+ $opts{include_supplementary} = 1 unless exists
$opts{include_supplementary};
my $basename = $self->get_basename();
my @tar;
foreach my $dir (".", $self->{'basedir'},
$self->{'options'}{'origtardir'}) {
next unless defined($dir) and -d $dir;
opendir(DIR, $dir) || syserr(_g("cannot opendir %s"), $dir);
- push @tar, map { "$dir/$_" }
- grep { /^\Q$basename\E\.orig(-[\w-]+)?\.tar\.$ext$/ }
- readdir(DIR);
+ push @tar, map { "$dir/$_" } grep {
+ ($opts{include_main} and
+ /^\Q$basename\E\.orig\.tar\.$opts{extension}$/) or
+ ($opts{include_supplementary} and
+ /^\Q$basename\E\.orig-[\w-]+\.tar\.$opts{extension}$/)
+ } readdir(DIR);
closedir(DIR);
}
return @tar;
diff --git a/scripts/Dpkg/Source/Package/V2.pm
b/scripts/Dpkg/Source/Package/V2.pm
index 594cc42..ab9b33a 100644
--- a/scripts/Dpkg/Source/Package/V2.pm
+++ b/scripts/Dpkg/Source/Package/V2.pm
@@ -55,6 +55,8 @@ sub init_options {
unless exists $self->{'options'}{'skip_patches'};
$self->{'options'}{'skip_debianization'} = 0
unless exists $self->{'options'}{'skip_debianization'};
+ $self->{'options'}{'create_empty_orig'} = 0
+ unless exists $self->{'options'}{'create_empty_orig'};
}
sub parse_cmdline_option {
@@ -77,6 +79,9 @@ sub parse_cmdline_option {
} elsif ($opt =~ /^--skip-debianization$/) {
$self->{'options'}{'skip_debianization'} = 1;
return 1;
+ } elsif ($opt =~ /^--create-empty-orig$/) {
+ $self->{'options'}{'create_empty_orig'} = 1;
+ return 1;
}
return 0;
}
@@ -203,9 +208,9 @@ sub apply_patches {
sub can_build {
my ($self, $dir) = @_;
- foreach ($self->find_original_tarballs()) {
- return 1 if /\.orig\.tar\.$compression_re_file_ext$/;
- }
+ return 1 if $self->find_original_tarballs(include_supplementary => 0);
+ return 1 if $self->{'options'}{'create_empty_orig'} and
+ $self->find_original_tarballs(include_main => 0);
return (0, _g("no orig.tar file found"));
}
@@ -219,6 +224,16 @@ sub prepare_build {
};
push @{$self->{'options'}{'tar_ignore'}},
"debian/patches/.dpkg-source-applied";
$self->check_patches_applied($dir) if $self->{'options'}{'preparation'};
+ if ($self->{'options'}{'create_empty_orig'} and
+ not $self->find_original_tarballs(include_supplementary => 0))
+ {
+ # No main orig.tar, create a dummy one
+ my $filename = $self->get_basename() . ".orig.tar." .
+ $self->{'options'}{'comp_ext'};
+ my $tar = Dpkg::Source::Archive->new(filename => $filename);
+ $tar->create();
+ $tar->finish();
+ }
}
sub check_patches_applied {
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index 16745ef..b6c89bf 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -303,6 +303,9 @@ if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
foreach my $format (@try_formats) {
$fields->{'Format'} = $format;
$srcpkg->upgrade_object_type(); # Fails if format is unsupported
+ # Parse command line options
+ $srcpkg->init_options();
+ $srcpkg->parse_cmdline_options(@cmdline_options);
my ($res, $msg) = $srcpkg->can_build($dir);
last if $res;
info(_g("source format `%s' discarded: %s"), $format, $msg);
@@ -313,10 +316,6 @@ if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
}
info(_g("using source format `%s'"), $fields->{'Format'});
- # Parse command line options
- $srcpkg->init_options();
- $srcpkg->parse_cmdline_options(@cmdline_options);
-
run_vendor_hook("before-source-build", $srcpkg);
# Build the files (.tar.gz, .diff.gz, etc)
$srcpkg->build($dir);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]