[bugzilla/f19] - Fix the comparison of module versions (#1044854) - Really honor the PROJECT environment va

Emmanuel Seyman eseyman at fedoraproject.org
Sun Jan 19 15:33:02 UTC 2014


commit c8f4da994f963f8c7e42182b39226161d07ee24f
Author: Emmanuel Seyman <emmanuel at seyman.fr>
Date:   Sun Jan 19 16:33:05 2014 +0100

        - Fix the comparison of module versions (#1044854)
        - Really honor the PROJECT environment variable (#911943)

 bugzilla-invalid-version.patch |   22 ++++++++++++++
 bugzilla-rw-paths.patch        |    2 +-
 bugzilla-vers-cmp.patch        |   64 ++++++++++++++++++++++++++++++++++++++++
 bugzilla.spec                  |   12 +++++++-
 4 files changed, 98 insertions(+), 2 deletions(-)
---
diff --git a/bugzilla-invalid-version.patch b/bugzilla-invalid-version.patch
new file mode 100644
index 0000000..21360a8
--- /dev/null
+++ b/bugzilla-invalid-version.patch
@@ -0,0 +1,22 @@
+=== modified file 'Bugzilla/Install/Requirements.pm'
+--- ./Bugzilla/Install/Requirements.pm	2013-03-26 11:07:25 +0000
++++ ./Bugzilla/Install/Requirements.pm	2013-12-02 16:00:20 +0000
+@@ -659,8 +659,15 @@
+     Bugzilla::Install::Util::set_output_encoding();
+ 
+     # VERSION is provided by UNIVERSAL::, and can be called even if
+-    # the module isn't loaded.
+-    my $vnum = $module->VERSION || -1;
++    # the module isn't loaded. We eval'uate ->VERSION because it can die
++    # when the version is not valid (yes, this happens from time to time).
++    # In that case, we use an uglier method to get the version.
++    my $vnum = eval { $module->VERSION };
++    if ($@) {
++        no strict 'refs';
++        $vnum = ${"${module}::VERSION"};
++    }
++    $vnum ||= -1;
+ 
+     # CGI's versioning scheme went 2.75, 2.751, 2.752, 2.753, 2.76
+     # That breaks the standard version tests, so we need to manually correct
+
diff --git a/bugzilla-rw-paths.patch b/bugzilla-rw-paths.patch
index f2f342b..1bad35c 100644
--- a/bugzilla-rw-paths.patch
+++ b/bugzilla-rw-paths.patch
@@ -11,7 +11,7 @@ diff -up ./Bugzilla/Constants.pm.orig ./Bugzilla/Constants.pm
 -        'localconfig' => "$libpath/$localconfig",
 -        'datadir'     => $datadir,
 -        'attachdir'   => "$datadir/attachments",
-+        'localconfig' => "/etc/bugzilla/localconfig",
++        'localconfig' => "/etc/bugzilla/$localconfig",
 +        'datadir'     => "/var/lib/bugzilla/$datadir",
 +        'attachdir'   => "/var/lib/bugzilla/$datadir/attachments",
          'skinsdir'    => "$libpath/skins",
diff --git a/bugzilla-vers-cmp.patch b/bugzilla-vers-cmp.patch
new file mode 100644
index 0000000..33f4d5e
--- /dev/null
+++ b/bugzilla-vers-cmp.patch
@@ -0,0 +1,64 @@
+=== modified file 'Bugzilla/Install/Requirements.pm'
+--- ./Bugzilla/Install/Requirements.pm	2013-12-02 16:00:20 +0000
++++ ./Bugzilla/Install/Requirements.pm	2013-12-02 16:07:30 +0000
+@@ -24,6 +24,7 @@
+ # MUST NOT "use."
+ 
+ use strict;
++use version;
+ 
+ use Bugzilla::Constants;
+ use Bugzilla::Install::Util qw(vers_cmp install_string bin_loc 
+@@ -206,7 +207,9 @@
+         package => 'Chart',
+         module  => 'Chart::Lines',
+         # Versions below 2.1 cannot be detected accurately.
+-        version => '2.1',
++        # There is no 2.1.0 release (it was 2.1), but .0 is required to fix
++        # https://rt.cpan.org/Public/Bug/Display.html?id=28218.
++        version => '2.1.0',
+         feature => [qw(new_charts old_charts)],
+     },
+     {
+@@ -640,8 +643,8 @@
+     return $return;
+ }
+ 
+-# This was originally clipped from the libnet Makefile.PL, adapted here to
+-# use the below vers_cmp routine for accurate version checking.
++# This was originally clipped from the libnet Makefile.PL, adapted here for
++# accurate version checking.
+ sub have_vers {
+     my ($params, $output) = @_;
+     my $module  = $params->{module};
+@@ -666,21 +669,17 @@
+     if ($@) {
+         no strict 'refs';
+         $vnum = ${"${module}::VERSION"};
++
++        # If we come here, then the version is not a valid one.
++        # We try to sanitize it.
++        if ($vnum =~ /^((\d+)(\.\d+)*)/) {
++            $vnum = $1;
++        }
+     }
+     $vnum ||= -1;
+ 
+-    # CGI's versioning scheme went 2.75, 2.751, 2.752, 2.753, 2.76
+-    # That breaks the standard version tests, so we need to manually correct
+-    # the version
+-    if ($module eq 'CGI' && $vnum =~ /(2\.7\d)(\d+)/) {
+-        $vnum = $1 . "." . $2;
+-    }
+-    # CPAN did a similar thing, where it has versions like 1.9304.
+-    if ($module eq 'CPAN' and $vnum =~ /^(\d\.\d{2})\d{2}$/) {
+-        $vnum = $1;
+-    }
+-
+-    my $vok = (vers_cmp($vnum,$wanted) > -1);
++    # Must do a string comparison as $vnum may be of the form 5.10.1.
++    my $vok = ($vnum ne '-1' && version->new($vnum) >= version->new($wanted)) ? 1 : 0;
+     my $blacklisted;
+     if ($vok && $params->{blacklist}) {
+         $blacklisted = grep($vnum =~ /$_/, @{$params->{blacklist}});
+
diff --git a/bugzilla.spec b/bugzilla.spec
index 150ea64..58f5749 100644
--- a/bugzilla.spec
+++ b/bugzilla.spec
@@ -6,7 +6,7 @@ URL: http://www.bugzilla.org/
 Name: bugzilla
 Version: 4.2.7
 Group: Applications/Publishing
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: MPLv1.1
 Source0: http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-%{version}.tar.gz
 Source1: bugzilla-httpd-conf
@@ -15,6 +15,10 @@ Source3: bugzilla.cron-daily
 Patch0: bugzilla-rw-paths.patch
 Patch1: bugzilla-yum.patch
 Patch2: bugzilla-project-mod_perl.patch
+# Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=938300
+Patch3: bugzilla-invalid-version.patch
+# Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=781672
+Patch4: bugzilla-vers-cmp.patch
 
 BuildArch: noarch
 Requires: webserver, patchutils, perl(SOAP::Lite), which
@@ -106,6 +110,8 @@ Contributed scripts and functions for Bugzilla
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
+%patch4 -p1
 rm -f Bugzilla/Constants.pm.orig
 rm -f Bugzilla/Install/Requirements.pm.orig
 # Remove bundled libs
@@ -218,6 +224,10 @@ popd > /dev/null)
 %{bzinstallprefix}/bugzilla/contrib/syncLDAP.pl
 
 %changelog
+* Sun Jan 19 2014 Emmanuel Seyman <emmanuel at seyman.fr> - 4.2.7-3
+- Fix the comparison of module versions (#1044854)
+- Really honor the PROJECT environment variable (#911943)
+
 * Fri Nov 15 2013 Emmanuel Seyman <emmanuel at seyman.fr> - 4.2.7-2
 - Add patch to cache bz_locations() (bmo #843457)
 - Fix constants patch to honor the PROJECT environment variable (#911943)


More information about the scm-commits mailing list