Просмотр исходного кода

dpkg-source: change the logic to find the object used to unpack/build

* scripts/Dpkg/Source/Package.pm (upgrade_object_type): Instead
of using the full Format: version to deduce the perl object name
use only the major part of the version. The minor part is under
control of the corresponding object, that way they can evolve
and indicate that the source package has changed in a backwards
compatible way. See
http://lists.debian.org/debian-dpkg/2008/04/msg00045.html
Also add a new parameter to disable update of the minor version in
the Format field.
(initialize): Don't let the Format field be updated by
upgrade_object_type() as this function only loads information from
the .dsc into the object.
* scripts/Dpkg/Source/Package/**: Rename V1_0.pm into V1.pm,
V2_0.pm into V2.pm and V3_0/ into V3/. Fix perl package names
accordingly. Integrated a $CURRENT_MINOR_VERSION set to "0"
in all packages.
* scripts/Makefile.am, scripts/po/POTFILES.in: Update the lists
according to above file renames.
Raphael Hertzog лет назад: 18
Родитель
Сommit
864dc76ed2

+ 21 - 0
ChangeLog

@@ -1,3 +1,24 @@
+2008-04-26  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Source/Package.pm (upgrade_object_type): Instead
+	of using the full Format: version to deduce the perl object name
+	use only the major part of the version. The minor part is under
+	control of the corresponding object, that way they can evolve
+	and indicate that the source package has changed in a backwards
+	compatible way. See
+	http://lists.debian.org/debian-dpkg/2008/04/msg00045.html
+	Also add a new parameter to disable update of the minor version in
+	the Format field.
+	(initialize): Don't let the Format field be updated by
+	upgrade_object_type() as this function only loads information from
+	the .dsc into the object.
+	* scripts/Dpkg/Source/Package/**: Rename V1_0.pm into V1.pm,
+	V2_0.pm into V2.pm and V3_0/ into V3/. Fix perl package names
+	accordingly. Integrated a $CURRENT_MINOR_VERSION set to "0"
+	in all packages.
+	* scripts/Makefile.am, scripts/po/POTFILES.in: Update the lists
+	according to above file renames.
+
 2008-04-25  Raphael Hertzog  <hertzog@debian.org>
 2008-04-25  Raphael Hertzog  <hertzog@debian.org>
 
 
 	* scripts/Dpkg/Source/Package/V3_0/quilt.pm: Parse correctly
 	* scripts/Dpkg/Source/Package/V3_0/quilt.pm: Parse correctly

+ 5 - 0
debian/changelog

@@ -27,6 +27,11 @@ dpkg (1.14.19) UNRELEASED; urgency=low
     in a single Conflicts: dpkg-dev (<< 1.14.16).
     in a single Conflicts: dpkg-dev (<< 1.14.16).
   * The "3.0 (quilt)" source package format now parses correctly series files
   * The "3.0 (quilt)" source package format now parses correctly series files
     with patch options and warn if something else than -p1 is used.
     with patch options and warn if something else than -p1 is used.
+  * Change the way dpkg-source finds the perl object to use to unpack/build
+    a source package to ignore the minor part of the Format: version.
+    For example "1.0" and "1.1" would both map to Dpkg::Source::Package::V1
+    instead of ::V1_0 and ::V1_1 before. Similarly "3.0 (quilt)" now maps to
+    ::V3::quilt instead of ::V3_0::quilt.
   
   
   [ Helge Kreutzmann ]
   [ Helge Kreutzmann ]
   * Minor fixes and clarifications to man pages.
   * Minor fixes and clarifications to man pages.

+ 12 - 6
scripts/Dpkg/Source/Package.pm

@@ -150,19 +150,25 @@ sub initialize {
 
 
     $self->parse_files();
     $self->parse_files();
 
 
-    $self->upgrade_object_type();
+    $self->upgrade_object_type(0);
 }
 }
 
 
 sub upgrade_object_type {
 sub upgrade_object_type {
-    my ($self) = @_;
+    my ($self, $update_format) = @_;
+    $update_format = 1 unless defined $update_format;
     my $format = $self->{'fields'}{'Format'};
     my $format = $self->{'fields'}{'Format'};
 
 
     if ($format =~ /^([\d\.]+)(?:\s+\((.*)\))?$/) {
     if ($format =~ /^([\d\.]+)(?:\s+\((.*)\))?$/) {
-        my ($version, $variant) = ($1, $2);
-        $version =~ s/\./_/;
-        my $module = "Dpkg::Source::Package::V$version";
+        my ($version, $variant, $major, $minor) = ($1, $2, $1, undef);
+        $major =~ s/\.[\d\.]+$//;
+        my $module = "Dpkg::Source::Package::V$major";
         $module .= "::$variant" if defined $variant;
         $module .= "::$variant" if defined $variant;
-        eval "require $module";
+        eval "require $module; \$minor = \$${module}::CURRENT_MINOR_VERSION;";
+        $minor = 0 unless defined $minor;
+        if ($update_format) {
+            $self->{'fields'}{'Format'} = "$major.$minor";
+            $self->{'fields'}{'Format'} .= " ($variant)" if defined $variant;
+        }
         if ($@) {
         if ($@) {
 	    error(_g("source package format `%s' is not supported (Perl module %s is required)"), $format, $module);
 	    error(_g("source package format `%s' is not supported (Perl module %s is required)"), $format, $module);
         }
         }

+ 7 - 5
scripts/Dpkg/Source/Package/V1_0.pm

@@ -14,7 +14,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
-package Dpkg::Source::Package::V1_0;
+package Dpkg::Source::Package::V1;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -30,13 +30,15 @@ use Dpkg::Source::Patch;
 use Dpkg::Version qw(check_version);
 use Dpkg::Version qw(check_version);
 use Dpkg::Exit;
 use Dpkg::Exit;
 use Dpkg::Source::Functions qw(erasedir);
 use Dpkg::Source::Functions qw(erasedir);
-use Dpkg::Source::Package::V3_0::native;
+use Dpkg::Source::Package::V3::native;
 
 
 use POSIX;
 use POSIX;
 use File::Basename;
 use File::Basename;
 use File::Temp qw(tempfile);
 use File::Temp qw(tempfile);
 use File::Spec;
 use File::Spec;
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 sub init_options {
 sub init_options {
     my ($self) = @_;
     my ($self) = @_;
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
@@ -92,11 +94,11 @@ sub do_extract {
     my $native = $difffile ? 0 : 1;
     my $native = $difffile ? 0 : 1;
     if ($native and ($tarfile =~ /\.orig\.tar\.gz$/)) {
     if ($native and ($tarfile =~ /\.orig\.tar\.gz$/)) {
         warning(_g("native package with .orig.tar"));
         warning(_g("native package with .orig.tar"));
-        $native = 0; # V3_0::native doesn't handle orig.tar
+        $native = 0; # V3::native doesn't handle orig.tar
     }
     }
 
 
     if ($native) {
     if ($native) {
-        Dpkg::Source::Package::V3_0::native::do_extract($self, $newdirectory);
+        Dpkg::Source::Package::V3::native::do_extract($self, $newdirectory);
     } else {
     } else {
         my $expectprefix = $newdirectory;
         my $expectprefix = $newdirectory;
         $expectprefix .= '.orig';
         $expectprefix .= '.orig';
@@ -268,7 +270,7 @@ sub do_build {
 
 
     if ($sourcestyle eq "n") {
     if ($sourcestyle eq "n") {
         $self->{'options'}{'ARGV'} = []; # ensure we have no error
         $self->{'options'}{'ARGV'} = []; # ensure we have no error
-        Dpkg::Source::Package::V3_0::native::do_build($self, $dir);
+        Dpkg::Source::Package::V3::native::do_build($self, $dir);
     } elsif ($sourcestyle =~ m/[nurUR]/) {
     } elsif ($sourcestyle =~ m/[nurUR]/) {
         if (stat($tarname)) {
         if (stat($tarname)) {
             unless ($sourcestyle =~ m/[nUR]/) {
             unless ($sourcestyle =~ m/[nUR]/) {

+ 3 - 1
scripts/Dpkg/Source/Package/V2_0.pm

@@ -14,7 +14,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
-package Dpkg::Source::Package::V2_0;
+package Dpkg::Source::Package::V2;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -38,6 +38,8 @@ use File::Path;
 use File::Spec;
 use File::Spec;
 use File::Find;
 use File::Find;
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 sub init_options {
 sub init_options {
     my ($self) = @_;
     my ($self) = @_;
     $self->SUPER::init_options();
     $self->SUPER::init_options();

+ 3 - 1
scripts/Dpkg/Source/Package/V3_0/bzr.pm

@@ -20,7 +20,7 @@
 # You should have received a copy of the GNU General Public License
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-package Dpkg::Source::Package::V3_0::bzr;
+package Dpkg::Source::Package::V3::bzr;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -41,6 +41,8 @@ use Dpkg::Source::Archive;
 use Dpkg::Exit;
 use Dpkg::Exit;
 use Dpkg::Source::Functions qw(erasedir);
 use Dpkg::Source::Functions qw(erasedir);
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 sub import {
 sub import {
     foreach my $dir (split(/:/, $ENV{PATH})) {
     foreach my $dir (split(/:/, $ENV{PATH})) {
         if (-x "$dir/bzr") {
         if (-x "$dir/bzr") {

+ 3 - 1
scripts/Dpkg/Source/Package/V3_0/custom.pm

@@ -14,7 +14,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
-package Dpkg::Source::Package::V3_0::custom;
+package Dpkg::Source::Package::V3::custom;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -25,6 +25,8 @@ use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(error);
 use Dpkg::ErrorHandling qw(error);
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 sub parse_cmdline_option {
 sub parse_cmdline_option {
     my ($self, $opt) = @_;
     my ($self, $opt) = @_;
     if ($opt =~ /^--target-format=(.*)$/) {
     if ($opt =~ /^--target-format=(.*)$/) {

+ 3 - 1
scripts/Dpkg/Source/Package/V3_0/git.pm

@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-package Dpkg::Source::Package::V3_0::git;
+package Dpkg::Source::Package::V3::git;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -39,6 +39,8 @@ use Dpkg::Source::Archive;
 use Dpkg::Exit;
 use Dpkg::Exit;
 use Dpkg::Source::Functions qw(erasedir);
 use Dpkg::Source::Functions qw(erasedir);
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 # Remove variables from the environment that might cause git to do
 # Remove variables from the environment that might cause git to do
 # something unexpected.
 # something unexpected.
 delete $ENV{GIT_DIR};
 delete $ENV{GIT_DIR};

+ 3 - 6
scripts/Dpkg/Source/Package/V3_0/native.pm

@@ -14,7 +14,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
-package Dpkg::Source::Package::V3_0::native;
+package Dpkg::Source::Package::V3::native;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
@@ -32,6 +32,8 @@ use POSIX;
 use File::Basename;
 use File::Basename;
 use File::Temp qw(tempfile);
 use File::Temp qw(tempfile);
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 sub do_extract {
 sub do_extract {
     my ($self, $newdirectory) = @_;
     my ($self, $newdirectory) = @_;
     my $sourcestyle = $self->{'options'}{'sourcestyle'};
     my $sourcestyle = $self->{'options'}{'sourcestyle'};
@@ -96,11 +98,6 @@ sub do_build {
         syserr(_g("unable to change permission of `%s'"), $tarname);
         syserr(_g("unable to change permission of `%s'"), $tarname);
 
 
     $self->add_file($tarname);
     $self->add_file($tarname);
-
-    # For backward compatibility, drop version to 1.0 if we can
-    if ($self->{'options'}{'compression'} eq "gzip") {
-        $self->{'fields'}{'Format'} = "1.0";
-    }
 }
 }
 
 
 # vim: set et sw=4 ts=8
 # vim: set et sw=4 ts=8

+ 4 - 2
scripts/Dpkg/Source/Package/V3_0/quilt.pm

@@ -14,13 +14,13 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 
-package Dpkg::Source::Package::V3_0::quilt;
+package Dpkg::Source::Package::V3::quilt;
 
 
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
 # Based on wig&pen implementation
 # Based on wig&pen implementation
-use base 'Dpkg::Source::Package::V2_0';
+use base 'Dpkg::Source::Package::V2';
 
 
 use Dpkg;
 use Dpkg;
 use Dpkg::Gettext;
 use Dpkg::Gettext;
@@ -32,6 +32,8 @@ use POSIX;
 use File::Basename;
 use File::Basename;
 use File::Spec;
 use File::Spec;
 
 
+our $CURRENT_MINOR_VERSION = "0";
+
 sub init_options {
 sub init_options {
     my ($self) = @_;
     my ($self) = @_;
     $self->SUPER::init_options();
     $self->SUPER::init_options();

+ 7 - 7
scripts/Makefile.am

@@ -112,13 +112,13 @@ nobase_dist_perllib_DATA = \
 	Dpkg/Source/Compressor.pm \
 	Dpkg/Source/Compressor.pm \
 	Dpkg/Source/Functions.pm \
 	Dpkg/Source/Functions.pm \
 	Dpkg/Source/Package.pm \
 	Dpkg/Source/Package.pm \
-	Dpkg/Source/Package/V1_0.pm \
-	Dpkg/Source/Package/V2_0.pm \
-	Dpkg/Source/Package/V3_0/bzr.pm \
-	Dpkg/Source/Package/V3_0/custom.pm \
-	Dpkg/Source/Package/V3_0/native.pm \
-	Dpkg/Source/Package/V3_0/git.pm \
-	Dpkg/Source/Package/V3_0/quilt.pm \
+	Dpkg/Source/Package/V1.pm \
+	Dpkg/Source/Package/V2.pm \
+	Dpkg/Source/Package/V3/bzr.pm \
+	Dpkg/Source/Package/V3/custom.pm \
+	Dpkg/Source/Package/V3/native.pm \
+	Dpkg/Source/Package/V3/git.pm \
+	Dpkg/Source/Package/V3/quilt.pm \
 	Dpkg/Source/Patch.pm \
 	Dpkg/Source/Patch.pm \
 	Dpkg.pm
 	Dpkg.pm
 
 

+ 7 - 7
scripts/po/POTFILES.in

@@ -33,13 +33,13 @@ scripts/Dpkg/Source/Compressor.pm
 scripts/Dpkg/Source/Functions.pm
 scripts/Dpkg/Source/Functions.pm
 scripts/Dpkg/Source/Patch.pm
 scripts/Dpkg/Source/Patch.pm
 scripts/Dpkg/Source/Package.pm
 scripts/Dpkg/Source/Package.pm
-scripts/Dpkg/Source/Package/V1_0.pm
-scripts/Dpkg/Source/Package/V2_0.pm
-scripts/Dpkg/Source/Package/V3_0/bzr.pm
-scripts/Dpkg/Source/Package/V3_0/custom.pm
-scripts/Dpkg/Source/Package/V3_0/native.pm
-scripts/Dpkg/Source/Package/V3_0/git.pm
-scripts/Dpkg/Source/Package/V3_0/quilt.pm
+scripts/Dpkg/Source/Package/V1.pm
+scripts/Dpkg/Source/Package/V2.pm
+scripts/Dpkg/Source/Package/V3/bzr.pm
+scripts/Dpkg/Source/Package/V3/custom.pm
+scripts/Dpkg/Source/Package/V3/native.pm
+scripts/Dpkg/Source/Package/V3/git.pm
+scripts/Dpkg/Source/Package/V3/quilt.pm
 scripts/Dpkg/Substvars.pm
 scripts/Dpkg/Substvars.pm
 scripts/Dpkg/Vars.pm
 scripts/Dpkg/Vars.pm
 scripts/Dpkg/Version.pm
 scripts/Dpkg/Version.pm