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

Dpkg::Source::Package: Capitalize variant module names

Lowercase module names are reserved by convention for pragmas, and
there's really no need to diverge here from the general dpkg project
naming convention. Also make sure source package format variant names
are always in lowercase, to not allow names that would not work with
previous dpkg-source versions.

Fixes NamingConventions::Capitalization.
Guillem Jover лет назад: 13
Родитель
Сommit
62783ea26c

+ 7 - 1
scripts/Dpkg/Source/Package.pm

@@ -223,9 +223,15 @@ sub upgrade_object_type {
 
     if ($format =~ /^([\d\.]+)(?:\s+\((.*)\))?$/) {
         my ($version, $variant, $major, $minor) = ($1, $2, $1, undef);
+
+        if (defined $variant and $variant ne lc $variant) {
+            error(_g("source package format '%s' is not supported: %s"),
+                  $format, _g('format variant must be in lowercase'));
+        }
+
         $major =~ s/\.[\d\.]+$//;
         my $module = "Dpkg::Source::Package::V$major";
-        $module .= "::$variant" if defined $variant;
+        $module .= '::' . ucfirst $variant if defined $variant;
         eval "require $module; \$minor = \$${module}::CURRENT_MINOR_VERSION;";
         $minor //= 0;
         if ($update_format) {

+ 4 - 4
scripts/Dpkg/Source/Package/V1.pm

@@ -30,7 +30,7 @@ use Dpkg::Source::Archive;
 use Dpkg::Source::Patch;
 use Dpkg::Exit;
 use Dpkg::Source::Functions qw(erasedir);
-use Dpkg::Source::Package::V3::native;
+use Dpkg::Source::Package::V3::Native;
 
 use POSIX qw(:errno_h);
 use Cwd;
@@ -108,11 +108,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::native doesn't handle orig.tar
+        $native = 0; # V3::Native doesn't handle orig.tar
     }
 
     if ($native) {
-        Dpkg::Source::Package::V3::native::do_extract($self, $newdirectory);
+        Dpkg::Source::Package::V3::Native::do_extract($self, $newdirectory);
     } else {
         my $expectprefix = $newdirectory;
         $expectprefix .= '.orig';
@@ -288,7 +288,7 @@ sub do_build {
 
     if ($sourcestyle eq 'n') {
         $self->{options}{ARGV} = []; # ensure we have no error
-        Dpkg::Source::Package::V3::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]/) {

+ 1 - 1
scripts/Dpkg/Source/Package/V3/bzr.pm

@@ -19,7 +19,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-package Dpkg::Source::Package::V3::bzr;
+package Dpkg::Source::Package::V3::Bzr;
 
 use strict;
 use warnings;

+ 1 - 1
scripts/Dpkg/Source/Package/V3/custom.pm

@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-package Dpkg::Source::Package::V3::custom;
+package Dpkg::Source::Package::V3::Custom;
 
 use strict;
 use warnings;

+ 1 - 1
scripts/Dpkg/Source/Package/V3/git.pm

@@ -17,7 +17,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-package Dpkg::Source::Package::V3::git;
+package Dpkg::Source::Package::V3::Git;
 
 use strict;
 use warnings;

+ 1 - 1
scripts/Dpkg/Source/Package/V3/native.pm

@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-package Dpkg::Source::Package::V3::native;
+package Dpkg::Source::Package::V3::Native;
 
 use strict;
 use warnings;

+ 1 - 1
scripts/Dpkg/Source/Package/V3/quilt.pm

@@ -13,7 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-package Dpkg::Source::Package::V3::quilt;
+package Dpkg::Source::Package::V3::Quilt;
 
 use strict;
 use warnings;

+ 5 - 5
scripts/Makefile.am

@@ -94,11 +94,11 @@ nobase_dist_perllib_DATA = \
 	Dpkg/Source/Package.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/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/Quilt.pm \
 	Dpkg/Substvars.pm \

+ 5 - 5
scripts/po/POTFILES.in

@@ -55,11 +55,11 @@ scripts/Dpkg/Source/Patch.pm
 scripts/Dpkg/Source/Package.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/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/Source/Quilt.pm
 scripts/Dpkg/Substvars.pm
 scripts/Dpkg/Vars.pm

+ 1 - 0
test/100_critic.t

@@ -68,6 +68,7 @@ my @policies = qw(
     Modules::RequireEndWithOne
     Modules::RequireExplicitPackage
     Modules::RequireFilenameMatchesPackage
+    NamingConventions::Capitalization
     Objects::ProhibitIndirectSyntax
     RegularExpressions::ProhibitUnusualDelimiters
     RegularExpressions::RequireBracesForMultiline