#303 Check if packages contain contain %{pythonX_site(lib|arch)}/* in files
Merged 5 years ago by ngompa. Opened 5 years ago by eclipseo.
Unknown source add_CheckPythonX_Site  into  devel

file modified
+43
@@ -2,6 +2,7 @@

  ''' Python package tests '''

  

  import re

+ import rpm

  

  from FedoraReview import CheckBase, RegistryBase

  
@@ -67,3 +68,45 @@

                                         'found.')

              return

          self.set_passed(self.PASS)

+ 

+ 

+ class CheckPythonX_Site(PythonCheckBase):

+     '''

+     MUST: One must not use any of the following in the %files section:

+ 

+     %{python3_sitelib}/*

+     %{python3_sitearch}/*

+     %{python2_sitelib}/*

+     %{python2_sitearch}/*

+     %{python_sitelib}/*

+     %{python_sitearch}/*

+     

+     https://pagure.io/packaging-committee/issue/782

+ 

+     '''

+     def __init__(self, base):

+         PythonCheckBase.__init__(self, base)

+         self.url = 'https://pagure.io/packaging-committee/issue/782'

+         self.text = 'Python packages must not contain %{pythonX_site(lib|arch)}/* in %files'

+         self.automatic = True

+         self.type = 'MUST'

+ 

+     def run_on_applicable(self):

+         has_python_site = False

+         python_sitelib = re.compile(rpm.expandMacro(r'^%{python_sitelib}\/\*$') + '|' + \

+             rpm.expandMacro(r'^%{python_sitearch}\/\*$') + '|' + \

+             rpm.expandMacro(r'^%{python2_sitelib}\/\*$') + '|' + \

+             rpm.expandMacro(r'^%{python2_sitearch}\/\*$') + '|' + \

+             rpm.expandMacro(r'^%{python3_sitelib}\/\*$')  + '|' + \

+             rpm.expandMacro(r'^%{python3_sitearch}\/\*$'))

+         

+         for pkg in self.spec.packages:

+             for line in self.spec.get_files(pkg):

+                 if python_sitelib.match(line):

+                     has_python_site = True

+                     break

+         if has_python_site:

+             self.set_passed(self.FAIL, 'Package contains %{pythonX_site(lib|arch)}/* in %files')

+         else:

+             self.set_passed(self.PASS)

+ 

rebased onto 71563939ea06481ccf5ab7ba29a370992724a8a6

5 years ago

If I read it correctly, you miss the check for unversioned one.

rebased onto 40529c6097313dc686f79ec6554e3372475685a9

5 years ago

conflicts. Could you please rebase?

rebased onto 034975d5d388628a055937f3c4444f7a0bdde7d5

5 years ago

I've rebased it, hopefully it is correct now.

Looks good to me. @churchyard, second opinion?

If we are not reporting which one it was, can we join this to one regex?

rebased onto 5a3997398a9f36ba6171c3e8cc1a3a8062fa6d86

5 years ago

PR now uses one regex.

@eclipseo Is this still relevant? If so, could you please rebase this PR?

rebased onto 8063ebc1f935c5f7e6f0dcdb577f64da8405db6a

5 years ago

rebased onto aa93f80

5 years ago

Pull-Request has been merged by ngompa

5 years ago
Metadata