The following commit has been merged in the master branch:
commit f22c0f006ffd9d9ba39c56b0072ddcb6af96d0ad
Author: Raphaël Hertzog <[email protected]>
Date: Mon Nov 9 20:50:55 2009 +0100
dpkg-source: add new --print-format command
This new command prints the source format that would be used to build the
source package if "dpkg-source -b directory" was called (in the same
conditions and with the same options).
diff --git a/debian/changelog b/debian/changelog
index b15579f..7c067b1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -76,6 +76,8 @@ dpkg (1.15.5) UNRELEASED; urgency=low
Thanks to Courtney Bane for the patch. Closes: #551829
* Optimize dpkg-source -b by avoiding many diff calls when not required.
Thanks to Mike Hommey for the idea. Closes: #554689
+ * Add new option --print-format to dpkg-source to be able to know by advance
+ the source format that would be used during a build.
[ Updated dpkg translations ]
* Czech (Miroslav Kure).
diff --git a/man/dpkg-source.1 b/man/dpkg-source.1
index 7900cdb..4815cea 100644
--- a/man/dpkg-source.1
+++ b/man/dpkg-source.1
@@ -63,6 +63,12 @@ the format indicated in \fBdebian/source/format\fP,
extensive description of the various source package formats.
.TP
+.RI "\fB\-\-print\-format\fP " directory
+Print the source format that would be used to build the source package if
+\fBdpkg\-source \-b \fIdirectory\fR was called (in the same conditions and
+with the same options).
+
+.TP
.BR \-h ", " \-\-help
Show the usage message and exit.
.TP
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index c0e37d0..609c74b 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -71,9 +71,11 @@ my @cmdline_formats;
while (@ARGV && $ARGV[0] =~ m/^-/) {
$_ = shift(@ARGV);
if (m/^-b$/) {
- setopmode('build');
+ setopmode('-b');
} elsif (m/^-x$/) {
- setopmode('extract');
+ setopmode('-x');
+ } elsif (m/^--print-format$/) {
+ setopmode('--print-format');
} elsif (m/^--format=(.*)$/) {
push @cmdline_formats, $1;
} elsif (m/^-Z(.*)$/) {
@@ -142,10 +144,10 @@ unless (defined($options{'opmode'})) {
usageerr(_g("need -x or -b"));
}
-if ($options{'opmode'} eq 'build') {
+if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
if (not scalar(@ARGV)) {
- usageerr(_g("-b needs a directory"));
+ usageerr(_g("%s needs a directory"), $options{'opmode'});
}
my $dir = File::Spec->catdir(shift(@ARGV));
stat($dir) || syserr(_g("cannot stat directory %s"), $dir);
@@ -268,7 +270,12 @@ if ($options{'opmode'} eq 'build') {
$srcpkg->upgrade_object_type(); # Fails if format is unsupported
my ($res, $msg) = $srcpkg->can_build($dir);
last if $res;
- info(_g("source format `%s' discarded: %s"), $format, $msg);
+ info(_g("source format `%s' discarded: %s"), $format, $msg)
+ unless $options{'opmode'} eq "--print-format";
+ }
+ if ($options{'opmode'} eq "--print-format") {
+ print $fields->{'Format'} . "\n";
+ exit(0);
}
info(_g("using source format `%s'"), $fields->{'Format'});
@@ -290,7 +297,7 @@ if ($options{'opmode'} eq 'build') {
substvars => $substvars);
exit(0);
-} elsif ($options{'opmode'} eq 'extract') {
+} elsif ($options{'opmode'} eq '-x') {
# Check command line
unless (scalar(@ARGV)) {
@@ -344,7 +351,7 @@ if ($options{'opmode'} eq 'build') {
sub setopmode {
if (defined($options{'opmode'})) {
- usageerr(_g("only one of -x or -b allowed, and only once"));
+ usageerr(_g("only one of -x, -b or --print-format allowed, and only
once"));
}
$options{'opmode'} = $_[0];
}
@@ -369,8 +376,9 @@ sub usage {
Commands:
-x <filename>.dsc [<output-dir>]
extract source package.
- -b <dir>
- build source package.
+ -b <dir> build source package.
+ --print-format <dir> print the source format that would be
+ used to build the source package.
Build options:
-c<controlfile> get control info from this file.
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]