Selaa lähdekoodia

dpkg-source: make sure the source package format is respected

* scripts/Dpkg/Source/Package.pm (extract): If we extract a
source package that uses a non-standard source package format (!= 1.0)
then we create debian/source/format to remember it.
* scripts/dpkg-source.pl: Use debian/source/format as a new source
of format to try when building the package. Prioritize it lower than
command line and debian/control but higher than the default build
formats.
* man/dpkg-source.1: Document the above changes.
Raphael Hertzog 18 vuotta sitten
vanhempi
commit
6f2c6d4470
4 muutettua tiedostoa jossa 47 lisäystä ja 6 poistoa
  1. 11 0
      ChangeLog
  2. 10 3
      man/dpkg-source.1
  3. 10 0
      scripts/Dpkg/Source/Package.pm
  4. 16 3
      scripts/dpkg-source.pl

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+2008-05-28  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Source/Package.pm (extract): If we extract a
+	source package that uses a non-standard (!= 1.0) source package
+	then we create debian/source/format to remember it.
+	* scripts/dpkg-source.pl: Use debian/source/format as a new source
+	of format to try when building the package. Prioritize it lower than
+	command line and debian/control but higher than the default build
+	formats.
+	* man/dpkg-source.1: Document the above changes.
+
 2008-05-28  Raphael Hertzog  <hertzog@debian.org>
 2008-05-28  Raphael Hertzog  <hertzog@debian.org>
 
 
 	* scripts/Dpkg/Source/Package/V3/quilt.pm: Factorize calls to
 	* scripts/Dpkg/Source/Package/V3/quilt.pm: Factorize calls to

+ 10 - 3
man/dpkg-source.1

@@ -41,6 +41,12 @@ files will be 0777 and plain files will be 0666, both modified by the
 extractors' umask; if the parent directory is setgid then the
 extractors' umask; if the parent directory is setgid then the
 extracted directories will be too, and all the files and directories
 extracted directories will be too, and all the files and directories
 will inherit its group ownership.
 will inherit its group ownership.
+
+If the source package uses a non-standard format (currently this means all
+formats except "1.0"), its name will be stored in
+\fBdebian/source/format\fP so that the following builds of the source
+package use the same format by default.
+
 .TP
 .TP
 .RI "\fB\-b\fP " directory " [" format-specific-parameters ]
 .RI "\fB\-b\fP " directory " [" format-specific-parameters ]
 Build a source package. The first non-option argument is taken as the
 Build a source package. The first non-option argument is taken as the
@@ -53,6 +59,7 @@ additional parameters might be accepted.
 that works from this ordered list:
 that works from this ordered list:
 the format indicated in the \fIFormat\fP field of \fBdebian/control\fP,
 the format indicated in the \fIFormat\fP field of \fBdebian/control\fP,
 the format(s) indicated with the \fI\-\-format\fP command-line option(s),
 the format(s) indicated with the \fI\-\-format\fP command-line option(s),
+the format indicated in \fBdebian/source/format\fP,
 "1.0", "3.0 (native)". See below for an extensive description of
 "1.0", "3.0 (native)". See below for an extensive description of
 various source package formats.
 various source package formats.
 
 
@@ -86,9 +93,9 @@ defaults to the debian standard format.
 .TP
 .TP
 .BI \-\-format= value
 .BI \-\-format= value
 Try first the given format for building the source package. If used
 Try first the given format for building the source package. If used
-multiple times, the last value is tried first and the first one is
-tried last just before trying the default formats. It doesn't override
-any explicit \fIFormat\fP field in \fBdebian/control\fP.
+multiple times, they are tried in order. It doesn't override
+any explicit \fIFormat\fP field in \fBdebian/control\fP but it does
+override any format given in \fBdebian/source/format\fP.
 .TP
 .TP
 .BI \-V name = value
 .BI \-V name = value
 \fBDeprecated\fP. Set an output substitution variable.
 \fBDeprecated\fP. Set an output substitution variable.

+ 10 - 0
scripts/Dpkg/Source/Package.pm

@@ -325,6 +325,16 @@ sub extract {
         die $@;
         die $@;
     }
     }
 
 
+    # Store format if non-standard so that next build keeps the same format
+    if ($self->{'fields'}{'Format'} ne "1.0") {
+        my $srcdir = File::Spec->catdir($newdirectory, "debian", "source");
+        my $format_file = File::Spec->catfile($srcdir, "format");
+        mkdir($srcdir) unless -e $srcdir;
+        open(FORMAT, ">", $format_file) || syserr(_g("can't write %s"), $format_file);
+        print FORMAT $self->{'fields'}{'Format'} . "\n";
+        close(FORMAT);
+    }
+
     # Make sure debian/rules is executable
     # Make sure debian/rules is executable
     my $rules = File::Spec->catfile($newdirectory, "debian", "rules");
     my $rules = File::Spec->catfile($newdirectory, "debian", "rules");
     my @s = lstat($rules);
     my @s = lstat($rules);

+ 16 - 3
scripts/dpkg-source.pl

@@ -52,6 +52,7 @@ my $substvars = Dpkg::Substvars->new();
 my $tar_ignore_default_pattern_done;
 my $tar_ignore_default_pattern_done;
 
 
 my @cmdline_options;
 my @cmdline_options;
+my @cmdline_formats;
 while (@ARGV && $ARGV[0] =~ m/^-/) {
 while (@ARGV && $ARGV[0] =~ m/^-/) {
     $_ = shift(@ARGV);
     $_ = shift(@ARGV);
     if (m/^-b$/) {
     if (m/^-b$/) {
@@ -59,7 +60,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
     } elsif (m/^-x$/) {
     } elsif (m/^-x$/) {
         setopmode('extract');
         setopmode('extract');
     } elsif (m/^--format=(.*)$/) {
     } elsif (m/^--format=(.*)$/) {
-        unshift @build_formats, $1;
+        push @cmdline_formats, $1;
     } elsif (m/^-Z/) {
     } elsif (m/^-Z/) {
 	my $compression = $POSTMATCH;
 	my $compression = $POSTMATCH;
 	$options{'compression'} = $compression;
 	$options{'compression'} = $compression;
@@ -247,9 +248,21 @@ if ($options{'opmode'} eq 'build') {
     
     
     $fields->{'Binary'} = join(', ', @binarypackages);
     $fields->{'Binary'} = join(', ', @binarypackages);
 
 
-    unshift @build_formats, $fields->{'Format'} if exists $fields->{'Format'};
+    # Generate list of formats to try
+    my @try_formats;
+    push @try_formats, $fields->{'Format'} if exists $fields->{'Format'};
+    push @try_formats, @cmdline_formats;
+    if (-e "$dir/debian/source/format") {
+        open(FORMAT, "<", "$dir/debian/source/format") ||
+            syserr(_g("cannot read %s"), "$dir/debian/source/format");
+        my $format = <FORMAT>;
+        chomp($format);
+        close(FORMAT);
+        push @try_formats, $format;
+    }
+    push @try_formats, @build_formats;
     # Try all suggested formats until one is acceptable
     # Try all suggested formats until one is acceptable
-    foreach my $format (@build_formats) {
+    foreach my $format (@try_formats) {
         $fields->{'Format'} = $format;
         $fields->{'Format'} = $format;
         $srcpkg->upgrade_object_type(); # Fails if format is unsupported
         $srcpkg->upgrade_object_type(); # Fails if format is unsupported
         my ($res, $msg) = $srcpkg->can_build($dir);
         my ($res, $msg) = $srcpkg->can_build($dir);