This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=01244e3c0319245601d60e5782ef8e886922f67c commit 01244e3c0319245601d60e5782ef8e886922f67c Author: Guillem Jover <guil...@debian.org> AuthorDate: Thu Mar 9 04:12:23 2023 +0100 Dpkg::Vars: Fold into Dpkg::Package This module has a very generic and odd name for what it is actually doing. Move the functions inside into Dpkg::Package, although eventually these should be moved as methods for Dpkg::Source::Package. But for now this location is better than before. --- scripts/Dpkg/Package.pm | 30 +++++++++++++++++++++++++- scripts/Dpkg/Vars.pm | 53 ---------------------------------------------- scripts/Makefile.am | 2 -- scripts/dpkg-genchanges.pl | 2 +- scripts/dpkg-gencontrol.pl | 3 +-- scripts/dpkg-source.pl | 2 +- scripts/po/POTFILES.in | 1 - scripts/t/Dpkg_Package.t | 15 ++++++++++++- scripts/t/Dpkg_Vars.t | 38 --------------------------------- 9 files changed, 46 insertions(+), 100 deletions(-) diff --git a/scripts/Dpkg/Package.pm b/scripts/Dpkg/Package.pm index e49c01bd3..276f8ac39 100644 --- a/scripts/Dpkg/Package.pm +++ b/scripts/Dpkg/Package.pm @@ -1,5 +1,6 @@ # Copyright © 2006 Frank Lichtenheld <dj...@debian.org> -# Copyright © 2007,2012 Guillem Jover <guil...@debian.org> +# Copyright © 2007-2009, 2012-2013 Guillem Jover <guil...@debian.org> +# Copyright © 2007 Raphaël Hertzog <hert...@debian.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -22,10 +23,14 @@ use warnings; our $VERSION = '0.01'; our @EXPORT = qw( pkg_name_is_illegal + + get_source_package + set_source_package ); use Exporter qw(import); +use Dpkg::ErrorHandling; use Dpkg::Gettext; sub pkg_name_is_illegal($) { @@ -44,4 +49,27 @@ sub pkg_name_is_illegal($) { return; } +# XXX: Eventually the following functions should be moved as methods for +# Dpkg::Source::Package. + +my $sourcepackage; + +sub get_source_package { + return $sourcepackage; +} + +sub set_source_package { + my $name = shift; + + my $err = pkg_name_is_illegal($name); + error(g_("source package name '%s' is illegal: %s"), $name, $err) if $err; + + if (not defined $sourcepackage) { + $sourcepackage = $name; + } elsif ($name ne $sourcepackage) { + error(g_('source package has two conflicting values - %s and %s'), + $sourcepackage, $name); + } +} + 1; diff --git a/scripts/Dpkg/Vars.pm b/scripts/Dpkg/Vars.pm deleted file mode 100644 index 2253e39be..000000000 --- a/scripts/Dpkg/Vars.pm +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright © 2007-2009,2012-2013 Guillem Jover <guil...@debian.org> -# Copyright © 2007 Raphaël Hertzog <hert...@debian.org> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. - -package Dpkg::Vars; - -use strict; -use warnings; - -our $VERSION = '0.03'; -our @EXPORT = qw( - get_source_package - set_source_package -); - -use Exporter qw(import); - -use Dpkg::ErrorHandling; -use Dpkg::Gettext; -use Dpkg::Package; - -my $sourcepackage; - -sub get_source_package { - return $sourcepackage; -} - -sub set_source_package { - my $v = shift; - my $err = pkg_name_is_illegal($v); - error(g_("source package name '%s' is illegal: %s"), $v, $err) if $err; - - if (not defined($sourcepackage)) { - $sourcepackage = $v; - } elsif ($v ne $sourcepackage) { - error(g_('source package has two conflicting values - %s and %s'), - $sourcepackage, $v); - } -} - -1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index daaaa0ee3..58471b266 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -137,7 +137,6 @@ nobase_dist_perllib_DATA = \ Dpkg/Source/Patch.pm \ Dpkg/Source/Quilt.pm \ Dpkg/Substvars.pm \ - Dpkg/Vars.pm \ Dpkg/Vendor.pm \ Dpkg/Vendor/Debian.pm \ Dpkg/Vendor/Default.pm \ @@ -241,7 +240,6 @@ test_scripts = \ t/Dpkg_Conf.t \ t/Dpkg_Deps.t \ t/Dpkg_Path.t \ - t/Dpkg_Vars.t \ t/Dpkg_Interface_Storable.t \ t/Dpkg_OpenPGP_KeyHandle.t \ t/Dpkg_OpenPGP.t \ diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index c6e2b0582..38055cb2d 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -40,7 +40,7 @@ use Dpkg::Control::Info; use Dpkg::Control::Fields; use Dpkg::Control; use Dpkg::Substvars; -use Dpkg::Vars; +use Dpkg::Package; use Dpkg::Changelog::Parse; use Dpkg::Dist::Files; use Dpkg::Version; diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 87eb6e6a1..694163b44 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -31,14 +31,13 @@ use Dpkg::Gettext; use Dpkg::ErrorHandling; use Dpkg::Lock; use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is debarch_list_parse); -use Dpkg::Package; use Dpkg::BuildProfiles qw(get_build_profiles); use Dpkg::Deps; use Dpkg::Control; use Dpkg::Control::Info; use Dpkg::Control::Fields; use Dpkg::Substvars; -use Dpkg::Vars; +use Dpkg::Package; use Dpkg::Changelog::Parse; use Dpkg::Dist::Files; diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 63caeb231..6906d5a6f 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -45,7 +45,7 @@ use Dpkg::Control::Tests; use Dpkg::Control::Fields; use Dpkg::Substvars; use Dpkg::Version; -use Dpkg::Vars; +use Dpkg::Package; use Dpkg::Changelog::Parse; use Dpkg::Source::Format; use Dpkg::Source::Package qw(get_default_diff_ignore_regex diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in index 6b3e9b8f3..aa9befa76 100644 --- a/scripts/po/POTFILES.in +++ b/scripts/po/POTFILES.in @@ -88,7 +88,6 @@ scripts/Dpkg/Source/Package/V3/Quilt.pm scripts/Dpkg/Source/Patch.pm scripts/Dpkg/Source/Quilt.pm scripts/Dpkg/Substvars.pm -scripts/Dpkg/Vars.pm scripts/Dpkg/Vendor.pm scripts/Dpkg/Vendor/Debian.pm scripts/Dpkg/Vendor/Default.pm diff --git a/scripts/t/Dpkg_Package.t b/scripts/t/Dpkg_Package.t index b0e825357..f7a7cb924 100644 --- a/scripts/t/Dpkg_Package.t +++ b/scripts/t/Dpkg_Package.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 12; use_ok('Dpkg::Package'); @@ -28,4 +28,17 @@ ok(pkg_name_is_illegal('-abc'), 'package name has a dash'); is(pkg_name_is_illegal('pkg+name-1.0'), undef, 'package name is valid'); +eval { set_source_package('foo%bar') }; +ok($@, 'cannot set invalid source package name'); +is(get_source_package(), undef, 'invalid source package name unset'); + +set_source_package('source'); +is(get_source_package(), 'source', 'set/get source package name'); + +set_source_package('source'); +is(get_source_package(), 'source', 'reset/get same source package name'); + +eval { set_source_package('other') }; +ok($@, 'cannot set different source package name'); + 1; diff --git a/scripts/t/Dpkg_Vars.t b/scripts/t/Dpkg_Vars.t deleted file mode 100644 index f7e53d541..000000000 --- a/scripts/t/Dpkg_Vars.t +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/perl -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. - -use strict; -use warnings; - -use Test::More tests => 6; - -BEGIN { - use_ok('Dpkg::Vars'); -} - -eval { set_source_package('foo%bar') }; -ok($@, 'cannot set invalid source package name'); -is(get_source_package(), undef, 'invalid source package name unset'); - -set_source_package('source'); -is(get_source_package(), 'source', 'set/get source package name'); - -set_source_package('source'); -is(get_source_package(), 'source', 'reset/get same source package name'); - -eval { set_source_package('other') }; -ok($@, 'cannot set different source package name'); - -1; -- Dpkg.Org's dpkg