Fixed version comparisons for x.y.z-style versions such as reportlab (bug #1121433).

Resolves: rhbz#1121433
This commit is contained in:
Tim Waugh 2014-07-21 11:15:43 +01:00
parent d54088ddce
commit bd96d14768
2 changed files with 136 additions and 1 deletions

126
hplip-reportlab.patch Normal file
View File

@ -0,0 +1,126 @@
diff -up hplip-3.14.6/installer/core_install.py.reportlab hplip-3.14.6/installer/core_install.py
--- hplip-3.14.6/installer/core_install.py.reportlab 2014-06-03 07:31:24.000000000 +0100
+++ hplip-3.14.6/installer/core_install.py 2014-07-21 12:08:05.374416889 +0100
@@ -793,19 +793,19 @@ class CoreInstall(object):
log.debug("Trying to import 'reportlab'...")
import reportlab
- ver = reportlab.Version
- try:
- ver_f = float(ver)
- except ValueError:
- log.debug("Can't determine version.")
- return False
+ def xint(x):
+ try:
+ return int(x)
+ except:
+ return 0
+
+ ver = [xint(x) for x in reportlab.Version.split ('.')]
+ log.debug("Version: %s" % ver)
+ if ver >= [2, 0]:
+ log.debug("Success.")
+ return True
else:
- log.debug("Version: %.1f" % ver_f)
- if ver_f >= 2.0:
- log.debug("Success.")
- return True
- else:
- return False
+ return False
except ImportError:
log.debug("Failed.")
diff -up hplip-3.14.6/installer/dcheck.py.reportlab hplip-3.14.6/installer/dcheck.py
--- hplip-3.14.6/installer/dcheck.py.reportlab 2014-06-03 07:31:24.000000000 +0100
+++ hplip-3.14.6/installer/dcheck.py 2014-07-21 12:08:43.349615825 +0100
@@ -212,6 +212,13 @@ def check_lsmod(module):
def check_version(inst_ver_str, min_ver_str='0.0'):
log.debug("Checking: installed ver=%s min ver=%s" % (inst_ver_str, min_ver_str))
+
+ def xint(x):
+ try:
+ return int(x)
+ except ValueError:
+ return 0
+
min_ver = 0
if min_ver_str != '-':
match_obj=ver_pat.search(min_ver_str)
@@ -219,10 +226,8 @@ def check_version(inst_ver_str, min_ver_
ver = match_obj.group(1)
except AttributeError:
ver = ''
- try:
- min_ver = float(ver)
- except ValueError:
- min_ver = 0
+
+ min_ver = [xint(x) for x in ver.split ('.')]
inst_ver = 0
if inst_ver_str != '-':
@@ -231,11 +236,8 @@ def check_version(inst_ver_str, min_ver_
ver = match_obj.group(1)
except AttributeError:
ver = ''
- try:
- inst_ver = float(ver)
- except ValueError:
- inst_ver = 0
+ inst_ver = [xint(x) for x in ver.split ('.')]
if inst_ver < min_ver:
log.debug("Found, but newer version required.")
diff -up hplip-3.14.6/ui4/sendfaxdialog.py.reportlab hplip-3.14.6/ui4/sendfaxdialog.py
--- hplip-3.14.6/ui4/sendfaxdialog.py.reportlab 2014-06-03 07:31:26.000000000 +0100
+++ hplip-3.14.6/ui4/sendfaxdialog.py 2014-07-21 12:08:05.375416895 +0100
@@ -74,13 +74,14 @@ coverpages_enabled = False
if fax_enabled:
try:
import reportlab
- ver = reportlab.Version
- try:
- ver_f = float(ver)
- except ValueError:
- ver_f = 0.0
+ def xint(x):
+ try:
+ return int(x)
+ except:
+ return 0
- if ver_f >= 2.0:
+ ver = [xint(x) for x in reportlab.Version.split('.')]
+ if ver >= [2, 0]:
coverpages_enabled = True
else:
log.warn("Pre-2.0 version of Reportlab installed. Fax coverpages disabled.")
diff -up hplip-3.14.6/ui/scrollfax.py.reportlab hplip-3.14.6/ui/scrollfax.py
--- hplip-3.14.6/ui/scrollfax.py.reportlab 2014-06-03 07:31:28.000000000 +0100
+++ hplip-3.14.6/ui/scrollfax.py 2014-07-21 12:08:05.375416895 +0100
@@ -52,13 +52,14 @@ coverpages_enabled = False
if fax_enabled:
try:
import reportlab
- ver = reportlab.Version
- try:
- ver_f = float(ver)
- except ValueError:
- ver_f = 0.0
+ def xint(x):
+ try:
+ return int(x)
+ except:
+ return 0
- if ver_f >= 2.0:
+ ver = [xint(x) for x in reportlab.Version.split('.')]
+ if ver >= [2, 0]:
coverpages_enabled = True
else:
log.warn("Pre-2.0 version of Reportlab installed. Fax coverpages disabled.")

View File

@ -7,7 +7,7 @@
Summary: HP Linux Imaging and Printing Project
Name: hplip
Version: 3.14.6
Release: 3%{?dist}
Release: 4%{?dist}
License: GPLv2+ and MIT
Url: http://hplip.sourceforge.net/
@ -33,6 +33,7 @@ Patch16: hplip-scan-tmp.patch
Patch17: hplip-codec.patch
Patch18: hplip-log-stderr.patch
Patch19: hplip-avahi-parsing.patch
Patch20: hplip-reportlab.patch
%global hpijs_epoch 1
Requires: hpijs%{?_isa} = %{hpijs_epoch}:%{version}-%{release}
@ -246,6 +247,10 @@ done
# Fix parsing of avahi-daemon output (bug #1096939).
%patch19 -p1 -b .parsing
# Fixed version comparisons for x.y.z-style versions such as
# reportlab (bug #1121433).
%patch20 -p1 -b .reportlab
sed -i.duplex-constraints \
-e 's,\(UIConstraints.* \*Duplex\),//\1,' \
prnt/drv/hpcups.drv.in
@ -482,6 +487,10 @@ rm -f %{buildroot}%{_sysconfdir}/xdg/autostart/hplip-systray.desktop
%postun libs -p /sbin/ldconfig
%changelog
* Mon Jul 21 2014 Tim Waugh <twaugh@redhat.com> - 3.14.6-4
- Fixed version comparisons for x.y.z-style versions such as
reportlab (bug #1121433).
* Wed Jul 9 2014 Tim Waugh <twaugh@redhat.com> - 3.14.6-3
- Another fix for commafy() (bug #984167/bug #1076954 comment #21).