[fedora-review] Backport fix for #967571

Stanislav Ochotnicky sochotni at fedoraproject.org
Thu May 30 10:09:07 UTC 2013


commit 892c3a86a47028f946a976a2d8f6499cad5c7be2
Author: Stanislav Ochotnicky <sochotnicky at redhat.com>
Date:   Thu May 30 12:08:34 2013 +0200

    Backport fix for #967571

 ...ec.get_section-returned-None-before-using.patch |   69 ++++++++++++++++++++
 fedora-review.spec                                 |    9 ++-
 2 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/0001-Check-if-spec.get_section-returned-None-before-using.patch b/0001-Check-if-spec.get_section-returned-None-before-using.patch
new file mode 100644
index 0000000..09336cb
--- /dev/null
+++ b/0001-Check-if-spec.get_section-returned-None-before-using.patch
@@ -0,0 +1,69 @@
+From e60ae9f56c5309f0424c9d47eb97b5b5cc1eec97 Mon Sep 17 00:00:00 2001
+From: Stanislav Ochotnicky <sochotnicky at redhat.com>
+Date: Tue, 28 May 2013 14:45:38 +0200
+Subject: [PATCH] Check if spec.get_section returned None before using it
+
+Depending on the check in question it either fails when given section is
+missing or possibly even succeeds.
+
+Non-existing %install section is something which should never happen really but
+apparently there are people who manage...So let's not crash
+
+See https://bugzilla.redhat.com/show_bug.cgi?id=967571
+---
+ plugins/generic.py | 9 ++++++++-
+ plugins/java.py    | 4 ++--
+ 2 files changed, 10 insertions(+), 3 deletions(-)
+
+diff --git a/plugins/generic.py b/plugins/generic.py
+index 5f5b867..289b677 100644
+--- a/plugins/generic.py
++++ b/plugins/generic.py
+@@ -232,6 +232,9 @@ class CheckCleanBuildroot(GenericCheckBase):
+         buildroot = buildroot.replace('+', r'\+')
+         regex = regex.replace('@buildroot@', buildroot)
+         install_sec = self.spec.get_section('%install', raw=True)
++        if not install_sec:
++            self.set_passed(self.NA)
++            return
+         self.log.debug('regex: ' + regex)
+         self.log.debug('install_sec: ' + install_sec)
+         has_clean = install_sec and re.search(regex, install_sec)
+@@ -782,7 +785,7 @@ class CheckMakeinstall(GenericCheckBase):
+ 
+     def run_on_applicable(self):
+         install = self.spec.get_section('%install', raw=True)
+-        if '%makeinstall' in install:
++        if install and '%makeinstall' in install:
+             self.set_passed(self.PENDING,
+                             '%makeinstall used in %install section')
+         else:
+@@ -1330,6 +1333,10 @@ class CheckUpdateDesktopDatabase(GenericCheckBase):
+         using = []
+         failed = False
+         install = self.spec.get_section('%install', raw=True)
++        if not install:
++            self.set_passed(self.NA)
++            return
++
+         for pkg in self.spec.packages:
+             if self.rpms.find('*.desktop', pkg):
+                 using.append(pkg)
+diff --git a/plugins/java.py b/plugins/java.py
+index 142bfb5..92f9566 100644
+--- a/plugins/java.py
++++ b/plugins/java.py
+@@ -390,8 +390,8 @@ class CheckTestSkip(JavaCheckBase):
+         xmvn_skip_regex = re.compile(r'mvn-build\s+.*(-f|--force|'
+                                       '--skip-tests).*')
+         build_section = self.spec.get_section('%build', raw=True)
+-        if (skip_regex.search(build_section) or
+-            xmvn_skip_regex.search(build_section)):
++        if build_section and (skip_regex.search(build_section) or
++                              xmvn_skip_regex.search(build_section)):
+             self.set_passed(self.PENDING, """Tests seem to be skipped. Verify
+         there is a commment giving a reason for this""")
+         else:
+-- 
+1.8.1.4
+
diff --git a/fedora-review.spec b/fedora-review.spec
index 9fa53ee..1123aaa 100644
--- a/fedora-review.spec
+++ b/fedora-review.spec
@@ -6,13 +6,16 @@
 
 Name:       fedora-review
 Version:    0.4.1
-Release:    1%{?git_tag}%{?dist}
+Release:    2%{?git_tag}%{?dist}
 Summary:    Review tool for fedora rpm packages
 
 License:    GPLv2+
 URL:        https://fedorahosted.org/FedoraReview/
 Source0:    https://fedorahosted.org/released/FedoraReview/%{name}-%{version}%{?git_tag}.tar.gz
 
+# backport from upstream commit a775357fcf
+Patch1:     0001-Check-if-spec.get_section-returned-None-before-using.patch
+
 BuildArch:  noarch
 
 BuildRequires:  python-BeautifulSoup
@@ -73,6 +76,7 @@ see http://php5.laurent-laville.org/compatinfo/.
 
 %prep
 %setup -q
+%patch1 -p1
 
 %build
 %{__python} setup.py --quiet build
@@ -124,6 +128,9 @@ python -m unittest discover -f
 
 
 %changelog
+* Thu May 30 2013 Stanislav Ochotnicky <sochotnicky at redhat.com> - 0.4.1-2
+- Backport fix for #967571
+
 * Mon Apr 29 2013 Stanislav Ochotnicky <sochotnicky at redhat.com> - 0.4.1-1
 - Update to latest upstream version
 


More information about the scm-commits mailing list