From 864dc76ed25e63eaa9072df4f5aa82baca16f919 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Fri, 25 Apr 2008 21:35:19 +0200 Subject: [PATCH] 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. --- ChangeLog | 21 +++++++++++++++++++ debian/changelog | 5 +++++ scripts/Dpkg/Source/Package.pm | 18 ++++++++++------ .../Dpkg/Source/Package/{V1_0.pm => V1.pm} | 12 ++++++----- .../Dpkg/Source/Package/{V2_0.pm => V2.pm} | 4 +++- .../Dpkg/Source/Package/{V3_0 => V3}/bzr.pm | 4 +++- .../Source/Package/{V3_0 => V3}/custom.pm | 4 +++- .../Dpkg/Source/Package/{V3_0 => V3}/git.pm | 4 +++- .../Source/Package/{V3_0 => V3}/native.pm | 9 +++----- .../Dpkg/Source/Package/{V3_0 => V3}/quilt.pm | 6 ++++-- scripts/Makefile.am | 14 ++++++------- scripts/po/POTFILES.in | 14 ++++++------- 12 files changed, 78 insertions(+), 37 deletions(-) rename scripts/Dpkg/Source/Package/{V1_0.pm => V1.pm} (97%) rename scripts/Dpkg/Source/Package/{V2_0.pm => V2.pm} (99%) rename scripts/Dpkg/Source/Package/{V3_0 => V3}/bzr.pm (98%) rename scripts/Dpkg/Source/Package/{V3_0 => V3}/custom.pm (95%) rename scripts/Dpkg/Source/Package/{V3_0 => V3}/git.pm (99%) rename scripts/Dpkg/Source/Package/{V3_0 => V3}/native.pm (93%) rename scripts/Dpkg/Source/Package/{V3_0 => V3}/quilt.pm (98%) diff --git a/ChangeLog b/ChangeLog index 7bf5326f..502883ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-04-26 Raphael Hertzog + + * 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 * scripts/Dpkg/Source/Package/V3_0/quilt.pm: Parse correctly diff --git a/debian/changelog b/debian/changelog index 519550d8..ab6f5d41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,6 +27,11 @@ dpkg (1.14.19) UNRELEASED; urgency=low in a single Conflicts: dpkg-dev (<< 1.14.16). * The "3.0 (quilt)" source package format now parses correctly series files 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 ] * Minor fixes and clarifications to man pages. diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index ed87a66d..f086e85b 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -150,19 +150,25 @@ sub initialize { $self->parse_files(); - $self->upgrade_object_type(); + $self->upgrade_object_type(0); } sub upgrade_object_type { - my ($self) = @_; + my ($self, $update_format) = @_; + $update_format = 1 unless defined $update_format; my $format = $self->{'fields'}{'Format'}; 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; - 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 ($@) { error(_g("source package format `%s' is not supported (Perl module %s is required)"), $format, $module); } diff --git a/scripts/Dpkg/Source/Package/V1_0.pm b/scripts/Dpkg/Source/Package/V1.pm similarity index 97% rename from scripts/Dpkg/Source/Package/V1_0.pm rename to scripts/Dpkg/Source/Package/V1.pm index 5ec2c2e1..00fccf6c 100644 --- a/scripts/Dpkg/Source/Package/V1_0.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -14,7 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -package Dpkg::Source::Package::V1_0; +package Dpkg::Source::Package::V1; use strict; use warnings; @@ -30,13 +30,15 @@ use Dpkg::Source::Patch; use Dpkg::Version qw(check_version); use Dpkg::Exit; use Dpkg::Source::Functions qw(erasedir); -use Dpkg::Source::Package::V3_0::native; +use Dpkg::Source::Package::V3::native; use POSIX; use File::Basename; use File::Temp qw(tempfile); use File::Spec; +our $CURRENT_MINOR_VERSION = "0"; + sub init_options { my ($self) = @_; # 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; if ($native and ($tarfile =~ /\.orig\.tar\.gz$/)) { 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) { - Dpkg::Source::Package::V3_0::native::do_extract($self, $newdirectory); + Dpkg::Source::Package::V3::native::do_extract($self, $newdirectory); } else { my $expectprefix = $newdirectory; $expectprefix .= '.orig'; @@ -268,7 +270,7 @@ sub do_build { if ($sourcestyle eq "n") { $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]/) { if (stat($tarname)) { unless ($sourcestyle =~ m/[nUR]/) { diff --git a/scripts/Dpkg/Source/Package/V2_0.pm b/scripts/Dpkg/Source/Package/V2.pm similarity index 99% rename from scripts/Dpkg/Source/Package/V2_0.pm rename to scripts/Dpkg/Source/Package/V2.pm index baf78e0b..f6b99da9 100644 --- a/scripts/Dpkg/Source/Package/V2_0.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -14,7 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -package Dpkg::Source::Package::V2_0; +package Dpkg::Source::Package::V2; use strict; use warnings; @@ -38,6 +38,8 @@ use File::Path; use File::Spec; use File::Find; +our $CURRENT_MINOR_VERSION = "0"; + sub init_options { my ($self) = @_; $self->SUPER::init_options(); diff --git a/scripts/Dpkg/Source/Package/V3_0/bzr.pm b/scripts/Dpkg/Source/Package/V3/bzr.pm similarity index 98% rename from scripts/Dpkg/Source/Package/V3_0/bzr.pm rename to scripts/Dpkg/Source/Package/V3/bzr.pm index 617678ce..47ebe096 100644 --- a/scripts/Dpkg/Source/Package/V3_0/bzr.pm +++ b/scripts/Dpkg/Source/Package/V3/bzr.pm @@ -20,7 +20,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # 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 warnings; @@ -41,6 +41,8 @@ use Dpkg::Source::Archive; use Dpkg::Exit; use Dpkg::Source::Functions qw(erasedir); +our $CURRENT_MINOR_VERSION = "0"; + sub import { foreach my $dir (split(/:/, $ENV{PATH})) { if (-x "$dir/bzr") { diff --git a/scripts/Dpkg/Source/Package/V3_0/custom.pm b/scripts/Dpkg/Source/Package/V3/custom.pm similarity index 95% rename from scripts/Dpkg/Source/Package/V3_0/custom.pm rename to scripts/Dpkg/Source/Package/V3/custom.pm index 74152f6b..8ad92cf2 100644 --- a/scripts/Dpkg/Source/Package/V3_0/custom.pm +++ b/scripts/Dpkg/Source/Package/V3/custom.pm @@ -14,7 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 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 warnings; @@ -25,6 +25,8 @@ use Dpkg; use Dpkg::Gettext; use Dpkg::ErrorHandling qw(error); +our $CURRENT_MINOR_VERSION = "0"; + sub parse_cmdline_option { my ($self, $opt) = @_; if ($opt =~ /^--target-format=(.*)$/) { diff --git a/scripts/Dpkg/Source/Package/V3_0/git.pm b/scripts/Dpkg/Source/Package/V3/git.pm similarity index 99% rename from scripts/Dpkg/Source/Package/V3_0/git.pm rename to scripts/Dpkg/Source/Package/V3/git.pm index 8b134fc2..b6098499 100644 --- a/scripts/Dpkg/Source/Package/V3_0/git.pm +++ b/scripts/Dpkg/Source/Package/V3/git.pm @@ -18,7 +18,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # 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 warnings; @@ -39,6 +39,8 @@ use Dpkg::Source::Archive; use Dpkg::Exit; use Dpkg::Source::Functions qw(erasedir); +our $CURRENT_MINOR_VERSION = "0"; + # Remove variables from the environment that might cause git to do # something unexpected. delete $ENV{GIT_DIR}; diff --git a/scripts/Dpkg/Source/Package/V3_0/native.pm b/scripts/Dpkg/Source/Package/V3/native.pm similarity index 93% rename from scripts/Dpkg/Source/Package/V3_0/native.pm rename to scripts/Dpkg/Source/Package/V3/native.pm index 16c8a827..b4353752 100644 --- a/scripts/Dpkg/Source/Package/V3_0/native.pm +++ b/scripts/Dpkg/Source/Package/V3/native.pm @@ -14,7 +14,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 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 warnings; @@ -32,6 +32,8 @@ use POSIX; use File::Basename; use File::Temp qw(tempfile); +our $CURRENT_MINOR_VERSION = "0"; + sub do_extract { my ($self, $newdirectory) = @_; my $sourcestyle = $self->{'options'}{'sourcestyle'}; @@ -96,11 +98,6 @@ sub do_build { syserr(_g("unable to change permission of `%s'"), $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 diff --git a/scripts/Dpkg/Source/Package/V3_0/quilt.pm b/scripts/Dpkg/Source/Package/V3/quilt.pm similarity index 98% rename from scripts/Dpkg/Source/Package/V3_0/quilt.pm rename to scripts/Dpkg/Source/Package/V3/quilt.pm index 270fe7de..e995e665 100644 --- a/scripts/Dpkg/Source/Package/V3_0/quilt.pm +++ b/scripts/Dpkg/Source/Package/V3/quilt.pm @@ -14,13 +14,13 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 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 warnings; # Based on wig&pen implementation -use base 'Dpkg::Source::Package::V2_0'; +use base 'Dpkg::Source::Package::V2'; use Dpkg; use Dpkg::Gettext; @@ -32,6 +32,8 @@ use POSIX; use File::Basename; use File::Spec; +our $CURRENT_MINOR_VERSION = "0"; + sub init_options { my ($self) = @_; $self->SUPER::init_options(); diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 75c101f8..a9e149e4 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -112,13 +112,13 @@ nobase_dist_perllib_DATA = \ Dpkg/Source/Compressor.pm \ Dpkg/Source/Functions.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.pm diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in index 332b74cb..1c0c66b1 100644 --- a/scripts/po/POTFILES.in +++ b/scripts/po/POTFILES.in @@ -33,13 +33,13 @@ scripts/Dpkg/Source/Compressor.pm scripts/Dpkg/Source/Functions.pm scripts/Dpkg/Source/Patch.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/Vars.pm scripts/Dpkg/Version.pm -- 2.39.5