| |
@@ -17,7 +17,7 @@
|
| |
# (C) 2011 - Tim Lauridsen <timlau@fedoraproject.org>
|
| |
|
| |
|
| |
- ''' Generic MUST checks, default Generic group. '''
|
| |
+ """ Generic MUST checks, default Generic group. """
|
| |
|
| |
import os
|
| |
import os.path
|
| |
@@ -29,18 +29,18 @@
|
| |
import rpm
|
| |
from FedoraReview.el_compat import check_output
|
| |
from FedoraReview import CheckBase, Mock, ReviewDirs
|
| |
- from FedoraReview import ReviewError # pylint: disable=W0611
|
| |
+ from FedoraReview import ReviewError # pylint: disable=W0611
|
| |
from FedoraReview import RegistryBase, Settings
|
| |
|
| |
import FedoraReview.deps as deps
|
| |
|
| |
- _DIR_SORT_KEY = '30'
|
| |
- _LICENSE_SORT_KEY = '20'
|
| |
- _GL_SORT_KEY = '90'
|
| |
+ _DIR_SORT_KEY = "30"
|
| |
+ _LICENSE_SORT_KEY = "20"
|
| |
+ _GL_SORT_KEY = "90"
|
| |
|
| |
|
| |
def in_list(what, list_):
|
| |
- ''' test if 'what' is in each item in list_. '''
|
| |
+ """ test if 'what' is in each item in list_. """
|
| |
for item in list_:
|
| |
if not item:
|
| |
return False
|
| |
@@ -50,18 +50,17 @@
|
| |
|
| |
|
| |
class Registry(RegistryBase):
|
| |
- ''' Module registration, register all checks. '''
|
| |
- group = 'Generic'
|
| |
+ """ Module registration, register all checks. """
|
| |
+
|
| |
+ group = "Generic"
|
| |
|
| |
def register_flags(self):
|
| |
- epel6 = self.Flag('EPEL6', 'Review package for EPEL6', __file__)
|
| |
- epel7 = self.Flag('EPEL7', 'Review package for EPEL7', __file__)
|
| |
- disttag = self.Flag('DISTTAG',
|
| |
- 'Default disttag e. g., "fc21".',
|
| |
- __file__)
|
| |
- batch = self.Flag('BATCH',
|
| |
- 'Disable all build, install, rpmlint etc. tasks',
|
| |
- __file__)
|
| |
+ epel6 = self.Flag("EPEL6", "Review package for EPEL6", __file__)
|
| |
+ epel7 = self.Flag("EPEL7", "Review package for EPEL7", __file__)
|
| |
+ disttag = self.Flag("DISTTAG", 'Default disttag e. g., "fc21".', __file__)
|
| |
+ batch = self.Flag(
|
| |
+ "BATCH", "Disable all build, install, rpmlint etc. tasks", __file__
|
| |
+ )
|
| |
self.checks.flags.add(epel6)
|
| |
self.checks.flags.add(epel7)
|
| |
self.checks.flags.add(disttag)
|
| |
@@ -72,48 +71,55 @@
|
| |
|
| |
|
| |
class GenericCheckBase(CheckBase):
|
| |
- ''' Base class for all generic tests. '''
|
| |
+ """ Base class for all generic tests. """
|
| |
|
| |
def __init__(self, checks):
|
| |
CheckBase.__init__(self, checks, __file__)
|
| |
|
| |
|
| |
class CheckApprovedLicense(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: The package must be licensed with a Fedora approved license and
|
| |
meet the Licensing Guidelines .
|
| |
- '''
|
| |
+ """
|
| |
|
| |
sort_key = _LICENSE_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/LicensingGuidelines/'
|
| |
- self.text = 'Package is licensed with an open-source' \
|
| |
- ' compatible license and meets other legal' \
|
| |
- ' requirements as defined in the legal section' \
|
| |
- ' of Packaging Guidelines.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/LicensingGuidelines/"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Package is licensed with an open-source"
|
| |
+ " compatible license and meets other legal"
|
| |
+ " requirements as defined in the legal section"
|
| |
+ " of Packaging Guidelines."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckBundledLibs(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Packages must NOT bundle copies of system libraries.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#bundling'
|
| |
- self.text = 'Package contains no bundled libraries without' \
|
| |
- ' FPC exception.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/#bundling"
|
| |
+ )
|
| |
+ self.text = "Package contains no bundled libraries without" " FPC exception."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- pattern = '(.*?/)(3rdparty|thirdparty|libraries|libs|ext|external' \
|
| |
- '|include|3rd_party|third_party)/.*'
|
| |
+ pattern = (
|
| |
+ "(.*?/)(3rdparty|thirdparty|libraries|libs|ext|external"
|
| |
+ "|include|3rd_party|third_party)/.*"
|
| |
+ )
|
| |
regex = re.compile(pattern, re.IGNORECASE)
|
| |
check_dirs = set()
|
| |
for i in self.sources.get_filelist():
|
| |
@@ -123,70 +129,75 @@
|
| |
if check_dirs:
|
| |
self.set_passed(
|
| |
self.PENDING,
|
| |
- 'Especially check following dirs for bundled code: ' +
|
| |
- ', '.join(check_dirs))
|
| |
+ "Especially check following dirs for bundled code: "
|
| |
+ + ", ".join(check_dirs),
|
| |
+ )
|
| |
else:
|
| |
self.set_passed(self.PENDING)
|
| |
|
| |
|
| |
class CheckBuildCompilerFlags(GenericCheckBase):
|
| |
- '''Thou shall use %{optflags}. '''
|
| |
+ """Thou shall use %{optflags}. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_compiler_flags'
|
| |
- self.text = '%build honors applicable compiler flags or ' \
|
| |
- 'justifies otherwise.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_compiler_flags"
|
| |
+ )
|
| |
+ self.text = "%build honors applicable compiler flags or " "justifies otherwise."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
- self.needs.append('generic-large-data') # Ensure unpacked rpms
|
| |
+ self.type = "MUST"
|
| |
+ self.needs.append("generic-large-data") # Ensure unpacked rpms
|
| |
|
| |
def run(self):
|
| |
- archs = self.checks.spec.expand_tag('BuildArchs')
|
| |
- if len(archs) == 1 and archs[0].lower() == b'noarch':
|
| |
+ archs = self.checks.spec.expand_tag("BuildArchs")
|
| |
+ if len(archs) == 1 and archs[0].lower() == b"noarch":
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
self.set_passed(self.PENDING)
|
| |
|
| |
|
| |
class CheckChangelogFormat(GenericCheckBase):
|
| |
- ''' Changelog in correct format. '''
|
| |
+ """ Changelog in correct format. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#changelogs'
|
| |
- self.text = 'Changelog in prescribed format.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/#changelogs"
|
| |
+ )
|
| |
+ self.text = "Changelog in prescribed format."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckCodeAndContent(GenericCheckBase):
|
| |
- ''' MUST: The package must contain code, or permissable content. '''
|
| |
+ """ MUST: The package must contain code, or permissable content. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/what-can-be-packaged' \
|
| |
- '/#_impermissible_content'
|
| |
- self.text = 'Sources contain only permissible' \
|
| |
- ' code or content.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/what-can-be-packaged"
|
| |
+ "/#_impermissible_content"
|
| |
+ )
|
| |
+ self.text = "Sources contain only permissible" " code or content."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckConfigNoReplace(GenericCheckBase):
|
| |
- ''' '%config files are marked noreplace or reason justified. '''
|
| |
+ """ '%config files are marked noreplace or reason justified. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_configuration_files'
|
| |
- self.text = '%config files are marked noreplace or the reason' \
|
| |
- ' is justified.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_configuration_files"
|
| |
+ )
|
| |
+ self.text = "%config files are marked noreplace or the reason" " is justified."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
rc = self.NA
|
| |
@@ -194,283 +205,311 @@
|
| |
extra = None
|
| |
for pkg in self.spec.packages:
|
| |
for line in self.spec.get_files(pkg):
|
| |
- if line.startswith('%config'):
|
| |
- if not line.startswith('%config(noreplace)'):
|
| |
+ if line.startswith("%config"):
|
| |
+ if not line.startswith("%config(noreplace)"):
|
| |
bad_lines.append(line)
|
| |
else:
|
| |
rc = self.PASS
|
| |
if bad_lines:
|
| |
- extra = "No (noreplace) in " + ' '.join(bad_lines)
|
| |
+ extra = "No (noreplace) in " + " ".join(bad_lines)
|
| |
rc = self.PENDING
|
| |
self.set_passed(rc, extra)
|
| |
|
| |
|
| |
class CheckCleanBuildroot(GenericCheckBase):
|
| |
- ''' Check that buildroot is cleaned as appropriate. '''
|
| |
+ """ Check that buildroot is cleaned as appropriate. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.text = 'Package does not run rm -rf %{buildroot}' \
|
| |
- ' (or $RPM_BUILD_ROOT) at the beginning of %install.'
|
| |
+ self.text = (
|
| |
+ "Package does not run rm -rf %{buildroot}"
|
| |
+ " (or $RPM_BUILD_ROOT) at the beginning of %install."
|
| |
+ )
|
| |
self.automatic = True
|
| |
|
| |
def run(self):
|
| |
has_clean = False
|
| |
- regex = r'rm\s+\-[rf][rf]\s+(@buildroot@|$RPM_BUILD_ROOT)[^/]'
|
| |
- buildroot = rpm.expandMacro('%{buildroot}')
|
| |
+ regex = r"rm\s+\-[rf][rf]\s+(@buildroot@|$RPM_BUILD_ROOT)[^/]"
|
| |
+ buildroot = rpm.expandMacro("%{buildroot}")
|
| |
# BZ 908830: handle '+' in package name.
|
| |
- buildroot = buildroot.replace('+', r'\+')
|
| |
- regex = regex.replace('@buildroot@', buildroot)
|
| |
- install_sec = self.spec.get_section('%install', raw=True)
|
| |
+ 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: %s', regex)
|
| |
- self.log.debug('install_sec: %s', install_sec)
|
| |
+ self.log.debug("regex: %s", regex)
|
| |
+ self.log.debug("install_sec: %s", install_sec)
|
| |
has_clean = install_sec and re.search(regex, install_sec)
|
| |
if has_clean:
|
| |
- self.set_passed(self.PENDING,
|
| |
- 'rm -rf %{buildroot} present but not required')
|
| |
+ self.set_passed(
|
| |
+ self.PENDING, "rm -rf %{buildroot} present but not required"
|
| |
+ )
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckDaemonCompileFlags(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Sensitive code should use hardened build flags.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_compiler_flags'
|
| |
- self.text = 'Package uses hardened build flags if required to.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_compiler_flags"
|
| |
+ )
|
| |
+ self.text = "Package uses hardened build flags if required to."
|
| |
self.automatic = True
|
| |
- self.needs.append('generic-large-data') # Ensure unpacked rpms
|
| |
+ self.needs.append("generic-large-data") # Ensure unpacked rpms
|
| |
|
| |
def run(self):
|
| |
- extra = ''
|
| |
- rpms_dir = os.path.join(ReviewDirs.root, 'rpms-unpacked')
|
| |
+ extra = ""
|
| |
+ rpms_dir = os.path.join(ReviewDirs.root, "rpms-unpacked")
|
| |
try:
|
| |
- cmd = 'find %s -perm -4000' % rpms_dir
|
| |
- with open('/dev/null', 'w') as f:
|
| |
- suids = check_output(cmd.split(), stderr=f, universal_newlines=True).strip().split()
|
| |
+ cmd = "find %s -perm -4000" % rpms_dir
|
| |
+ with open("/dev/null", "w") as f:
|
| |
+ suids = (
|
| |
+ check_output(cmd.split(), stderr=f, universal_newlines=True)
|
| |
+ .strip()
|
| |
+ .split()
|
| |
+ )
|
| |
except CalledProcessError:
|
| |
- self.log.info('Cannot run find command: %s', cmd)
|
| |
+ self.log.info("Cannot run find command: %s", cmd)
|
| |
suids = []
|
| |
else:
|
| |
suids = [os.path.basename(s) for s in suids]
|
| |
if suids:
|
| |
- extra += 'suid files: ' + ', '.join(suids)
|
| |
+ extra += "suid files: " + ", ".join(suids)
|
| |
|
| |
- systemd_files = self.rpms.find_all('/lib/systemd/system/*')
|
| |
+ systemd_files = self.rpms.find_all("/lib/systemd/system/*")
|
| |
if systemd_files:
|
| |
files = [os.path.basename(f) for f in systemd_files]
|
| |
- extra += 'Systemd files (daemon?): ' + ', '.join(files)
|
| |
+ extra += "Systemd files (daemon?): " + ", ".join(files)
|
| |
|
| |
if not extra:
|
| |
self.set_passed(self.NA)
|
| |
- elif self.spec.find_re(r'[^# ]*%global\s+_hardened_build\s+1'):
|
| |
+ elif self.spec.find_re(r"[^# ]*%global\s+_hardened_build\s+1"):
|
| |
self.set_passed(self.PASS, extra)
|
| |
else:
|
| |
- extra += ' and not %global _hardened_build'
|
| |
+ extra += " and not %global _hardened_build"
|
| |
self.set_passed(self.FAIL, extra)
|
| |
|
| |
|
| |
class CheckDefattr(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Permissions on files must be set properly. Executables
|
| |
should be set with executable permissions, for example. Every
|
| |
%files section must include a %defattr(...) line.
|
| |
Update: 29-04-2011 This is only for pre rpm 4.4 that this is needed
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_file_permissions'
|
| |
- self.text = 'Each %files section contains %defattr if rpm < 4.4'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_file_permissions"
|
| |
+ )
|
| |
+ self.text = "Each %files section contains %defattr if rpm < 4.4"
|
| |
self.automatic = True
|
| |
|
| |
def run(self):
|
| |
has_defattr = False
|
| |
for pkg in self.spec.packages:
|
| |
- if pkg.endswith(('-debuginfo', '-debugsource')):
|
| |
+ if pkg.endswith(("-debuginfo", "-debugsource")):
|
| |
# auto-generated %defattr, ignore
|
| |
continue
|
| |
for line in self.spec.get_files(pkg):
|
| |
- if line.startswith('%defattr('):
|
| |
+ if line.startswith("%defattr("):
|
| |
has_defattr = True
|
| |
break
|
| |
if has_defattr:
|
| |
- self.set_passed(self.PENDING, '%defattr present but not needed')
|
| |
+ self.set_passed(self.PENDING, "%defattr present but not needed")
|
| |
else:
|
| |
self.set_passed(self.NA)
|
| |
|
| |
|
| |
class CheckDescMacros(GenericCheckBase):
|
| |
- ''' Macros in description etc. should be expandable. '''
|
| |
+ """ Macros in description etc. should be expandable. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_source_rpm_buildtime_macros'
|
| |
- self.text = 'Macros in Summary, %description expandable at' \
|
| |
- ' SRPM build time.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_source_rpm_buildtime_macros"
|
| |
+ )
|
| |
+ self.text = "Macros in Summary, %description expandable at" " SRPM build time."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
bad_tags = []
|
| |
for pkg_name in self.spec.packages:
|
| |
- if '%' in self.spec.expand_tag('Summary', pkg_name).decode('utf-8'):
|
| |
- bad_tags.append(pkg_name + ' (summary)')
|
| |
- if '%' in self.spec.expand_tag('Description', pkg_name).decode('utf-8'):
|
| |
- bad_tags.append(pkg_name + ' (description)')
|
| |
+ if "%" in self.spec.expand_tag("Summary", pkg_name).decode("utf-8"):
|
| |
+ bad_tags.append(pkg_name + " (summary)")
|
| |
+ if "%" in self.spec.expand_tag("Description", pkg_name).decode("utf-8"):
|
| |
+ bad_tags.append(pkg_name + " (description)")
|
| |
if bad_tags:
|
| |
- self.set_passed(self.PENDING,
|
| |
- 'Macros in: ' + ', '.join(bad_tags))
|
| |
+ self.set_passed(self.PENDING, "Macros in: " + ", ".join(bad_tags))
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckDesktopFile(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Packages containing GUI applications must include a
|
| |
%{name}.desktop file. If you feel that your packaged GUI
|
| |
application does not need a .desktop file, you must put a
|
| |
comment in the spec file with your explanation.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_desktop_files'
|
| |
- self.text = 'Package contains desktop file if it is a GUI' \
|
| |
- ' application.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_desktop_files"
|
| |
+ )
|
| |
+ self.text = "Package contains desktop file if it is a GUI" " application."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- have_desktop = self.rpms.find('*.desktop')
|
| |
+ have_desktop = self.rpms.find("*.desktop")
|
| |
self.set_passed(True if have_desktop else self.PENDING)
|
| |
|
| |
|
| |
class CheckDesktopFileInstall(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Packages containing GUI applications must include a
|
| |
%{name}.desktop file, and that file must be properly installed
|
| |
with desktop-file-install in the %install section.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_desktop_files'
|
| |
- self.text = 'Package installs a %{name}.desktop using' \
|
| |
- ' desktop-file-install or desktop-file-validate' \
|
| |
- ' if there is such a file.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_desktop_files"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Package installs a %{name}.desktop using"
|
| |
+ " desktop-file-install or desktop-file-validate"
|
| |
+ " if there is such a file."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- if not self.rpms.find('*.desktop'):
|
| |
+ if not self.rpms.find("*.desktop"):
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- pattern = r'(desktop-file-install|desktop-file-validate)' \
|
| |
- r'.*(desktop|SOURCE|\$\w+)'
|
| |
+ pattern = (
|
| |
+ r"(desktop-file-install|desktop-file-validate)" r".*(desktop|SOURCE|\$\w+)"
|
| |
+ )
|
| |
found = self.spec.find_re(re.compile(pattern))
|
| |
self.set_passed(self.PASS if found else self.FAIL)
|
| |
|
| |
|
| |
class CheckDevelFilesInDevel(GenericCheckBase):
|
| |
- ''' MUST: Development files must be in a -devel package '''
|
| |
+ """ MUST: Development files must be in a -devel package """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_devel_packages'
|
| |
- self.text = 'Development files must be in a -devel package'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_devel_packages"
|
| |
+ )
|
| |
+ self.text = "Development files must be in a -devel package"
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckDistTag(GenericCheckBase):
|
| |
- ''' Disttag %{?dist} is present in Release: '''
|
| |
+ """ Disttag %{?dist} is present in Release: """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/DistTag/'
|
| |
- self.text = 'Dist tag is present.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/DistTag/"
|
| |
+ )
|
| |
+ self.text = "Dist tag is present."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- rel_tags = self.spec.find_all_re(r'^Release\s*:')
|
| |
- found = in_list('%{?dist}', rel_tags)
|
| |
+ rel_tags = self.spec.find_all_re(r"^Release\s*:")
|
| |
+ found = in_list("%{?dist}", rel_tags)
|
| |
if len(rel_tags) > 1:
|
| |
- self.set_passed(found, 'Multiple Release: tags found')
|
| |
+ self.set_passed(found, "Multiple Release: tags found")
|
| |
elif not rel_tags:
|
| |
- self.set_passed(found, 'No Release: tags found')
|
| |
+ self.set_passed(found, "No Release: tags found")
|
| |
else:
|
| |
self.set_passed(found)
|
| |
|
| |
|
| |
class CheckDirectoryRequire(GenericCheckBase):
|
| |
- ''' Package should require directories it uses. '''
|
| |
+ """ Package should require directories it uses. """
|
| |
|
| |
sort_key = _DIR_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_file_and_directory_ownership'
|
| |
- self.text = 'Package requires other packages for directories it uses.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_file_and_directory_ownership"
|
| |
+ )
|
| |
+ self.text = "Package requires other packages for directories it uses."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
- '''
|
| |
+ """
|
| |
Build raw list of directory paths in pkg, package owning the
|
| |
leaf.
|
| |
Split list into /part1 /part1/part2 /part1/part2/part3...
|
| |
Remove all paths part of filesystem.
|
| |
Remove all paths part of package.
|
| |
Remaining dirs must have a owner, test one by one (painful).
|
| |
- '''
|
| |
+ """
|
| |
dirs = []
|
| |
for path in self.rpms.get_filelist():
|
| |
- path = path.rsplit('/', 1)[0] # We own the leaf.
|
| |
+ path = path.rsplit("/", 1)[0] # We own the leaf.
|
| |
while path:
|
| |
dirs.append(path)
|
| |
- path = path.rsplit('/', 1)[0]
|
| |
+ path = path.rsplit("/", 1)[0]
|
| |
dirs = set(dirs)
|
| |
- filesys_dirs = set(deps.list_paths('filesystem'))
|
| |
+ filesys_dirs = set(deps.list_paths("filesystem"))
|
| |
dirs -= filesys_dirs
|
| |
rpm_paths = set(self.rpms.get_filelist())
|
| |
dirs -= rpm_paths
|
| |
bad_dirs = [d for d in dirs if not deps.list_owners(d)]
|
| |
if bad_dirs:
|
| |
- self.set_passed(self.PENDING,
|
| |
- "No known owner of " + ", ".join(bad_dirs))
|
| |
+ self.set_passed(self.PENDING, "No known owner of " + ", ".join(bad_dirs))
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckDocRuntime(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: If a package includes something as %doc, it must not affect
|
| |
the runtime of the application. To summarize: If it is in %doc,
|
| |
the program must run properly if it is not present.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_documentation'
|
| |
- self.text = 'Package uses nothing in %doc for runtime.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_documentation"
|
| |
+ )
|
| |
+ self.text = "Package uses nothing in %doc for runtime."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckExcludeArch(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: If the package does not successfully compile, build or work
|
| |
on an architecture, then those architectures should be listed in
|
| |
the spec in ExcludeArch. Each architecture listed in ExcludeArch
|
| |
@@ -478,32 +517,38 @@
|
| |
package does not compile/build/work on that architecture. The bug
|
| |
number MUST be placed in a comment, next to the corresponding
|
| |
ExcludeArch line.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_architecture_build_failures'
|
| |
- self.text = 'Package is not known to require ExcludeArch.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_architecture_build_failures"
|
| |
+ )
|
| |
+ self.text = "Package is not known to require ExcludeArch."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckFileDuplicates(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: A Fedora package must not list a file more than once in the
|
| |
spec file's %files listings. (Notable exception: license texts in
|
| |
specific situations)
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_duplicate_files'
|
| |
- self.text = 'Package does not contain duplicates in %files.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_duplicate_files"
|
| |
+ )
|
| |
+ self.text = "Package does not contain duplicates in %files."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- filename = os.path.join(Mock.resultdir, 'build.log')
|
| |
+ filename = os.path.join(Mock.resultdir, "build.log")
|
| |
try:
|
| |
stream = open(filename)
|
| |
except IOError:
|
| |
@@ -511,131 +556,142 @@
|
| |
return
|
| |
content = stream.read()
|
| |
stream.close()
|
| |
- for line in content.split('\n'):
|
| |
- if 'File listed twice' in line:
|
| |
+ for line in content.split("\n"):
|
| |
+ if "File listed twice" in line:
|
| |
self.set_passed(self.FAIL, line)
|
| |
return
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckFilePermissions(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Permissions on files must be set properly. Executables
|
| |
should be set with executable permissions, for example. Every
|
| |
%files section must include a %defattr(...) line
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_file_permissions'
|
| |
- self.text = 'Permissions on files are set properly.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_file_permissions"
|
| |
+ )
|
| |
+ self.text = "Permissions on files are set properly."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
- self.needs.append('CheckRpmlint')
|
| |
+ self.type = "MUST"
|
| |
+ self.needs.append("CheckRpmlint")
|
| |
|
| |
def run(self):
|
| |
- if self.checks.checkdict['CheckRpmlint'].is_disabled:
|
| |
- self.set_passed(self.PENDING, 'Rpmlint run disabled')
|
| |
+ if self.checks.checkdict["CheckRpmlint"].is_disabled:
|
| |
+ self.set_passed(self.PENDING, "Rpmlint run disabled")
|
| |
return
|
| |
for line in Mock.rpmlint_output:
|
| |
- if 'non-standard-executable-perm' in line:
|
| |
- self.set_passed(self.FAIL, 'See rpmlint output')
|
| |
+ if "non-standard-executable-perm" in line:
|
| |
+ self.set_passed(self.FAIL, "See rpmlint output")
|
| |
return
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckGuidelines(GenericCheckBase):
|
| |
- ''' MUST: The package complies to the Packaging Guidelines. '''
|
| |
+ """ MUST: The package complies to the Packaging Guidelines. """
|
| |
|
| |
sort_key = _GL_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US/packaging-guidelines/'
|
| |
- self.text = 'Package complies to the Packaging Guidelines'
|
| |
+ self.url = "https://docs.fedoraproject.org/en-US/packaging-guidelines/"
|
| |
+ self.text = "Package complies to the Packaging Guidelines"
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckLargeDocs(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Large documentation files must go in a -doc subpackage.
|
| |
(The definition of large is left up to the packager's best
|
| |
judgement, but is not restricted to size. Large can refer to
|
| |
either size or quantity).
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_documentation'
|
| |
- self.text = 'Large documentation files are in a -doc' \
|
| |
- ' subpackage, if required.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_documentation"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Large documentation files are in a -doc" " subpackage, if required."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckLicenseField(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: The License field in the package spec file must match the
|
| |
actual license.
|
| |
- '''
|
| |
+ """
|
| |
|
| |
sort_key = _LICENSE_SORT_KEY
|
| |
- unknown_license = 'Unknown or generated'
|
| |
+ unknown_license = "Unknown or generated"
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/LicensingGuidelines/' \
|
| |
- '#_valid_license_short_names'
|
| |
- self.text = 'License field in the package spec file' \
|
| |
- ' matches the actual license.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/LicensingGuidelines/"
|
| |
+ "#_valid_license_short_names"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "License field in the package spec file" " matches the actual license."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
@staticmethod
|
| |
def _write_license(files_by_license, filename):
|
| |
- ''' Dump files_by_license to filename. '''
|
| |
- with open(filename, 'w') as f:
|
| |
+ """ Dump files_by_license to filename. """
|
| |
+ with open(filename, "w") as f:
|
| |
for license_ in sorted(files_by_license.keys()):
|
| |
- f.write('\n' + license_ + '\n')
|
| |
- f.write('-' * len(license_) + '\n')
|
| |
+ f.write("\n" + license_ + "\n")
|
| |
+ f.write("-" * len(license_) + "\n")
|
| |
for path in sorted(files_by_license[license_]):
|
| |
- relpath = re.sub('.*BUILD/', '', path)
|
| |
- f.write(relpath + '\n')
|
| |
+ relpath = re.sub(".*BUILD/", "", path)
|
| |
+ f.write(relpath + "\n")
|
| |
|
| |
@staticmethod
|
| |
def _get_source_dir():
|
| |
- ''' Decide which directory to run licensecheck on. This can be
|
| |
+ """ Decide which directory to run licensecheck on. This can be
|
| |
either patched sources, or we use vanilla unpacked upstream
|
| |
- tarballs if first option fails '''
|
| |
- s = Mock.get_builddir('BUILD') + '/*'
|
| |
+ tarballs if first option fails """
|
| |
+ s = Mock.get_builddir("BUILD") + "/*"
|
| |
globs = glob(s)
|
| |
if globs:
|
| |
- msg = 'Checking patched sources after %prep for licenses.'
|
| |
+ msg = "Checking patched sources after %prep for licenses."
|
| |
source_dir = globs[0]
|
| |
else:
|
| |
- msg = 'There is no build directory. Running licensecheck ' \
|
| |
- 'on vanilla upstream sources.'
|
| |
+ msg = (
|
| |
+ "There is no build directory. Running licensecheck "
|
| |
+ "on vanilla upstream sources."
|
| |
+ )
|
| |
source_dir = ReviewDirs.upstream_unpacked
|
| |
return (source_dir, msg)
|
| |
|
| |
def _parse_licenses(self, raw_text):
|
| |
- ''' Convert licensecheck output to files_by_license dict. '''
|
| |
+ """ Convert licensecheck output to files_by_license dict. """
|
| |
|
| |
def license_is_valid(_license):
|
| |
- ''' Test that license from licencecheck is parsed OK. '''
|
| |
- return 'UNKNOWN' not in _license and \
|
| |
- 'GENERATED' not in _license
|
| |
+ """ Test that license from licencecheck is parsed OK. """
|
| |
+ return "UNKNOWN" not in _license and "GENERATED" not in _license
|
| |
|
| |
files_by_license = {}
|
| |
- raw_file = BytesIO(raw_text.encode('utf-8'))
|
| |
+ raw_file = BytesIO(raw_text.encode("utf-8"))
|
| |
while True:
|
| |
- line = raw_file.readline().decode('utf-8')
|
| |
+ line = raw_file.readline().decode("utf-8")
|
| |
if not line:
|
| |
break
|
| |
try:
|
| |
- file_, license_ = line.split(':')
|
| |
+ file_, license_ = line.split(":")
|
| |
except ValueError:
|
| |
continue
|
| |
file_ = file_.strip()
|
| |
@@ -652,61 +708,65 @@
|
| |
source_dir, msg = self._get_source_dir()
|
| |
self.log.debug("Scanning sources in %s", source_dir)
|
| |
if os.path.exists(source_dir):
|
| |
- cmd = 'licensecheck -r ' + source_dir
|
| |
+ cmd = "licensecheck -r " + source_dir
|
| |
try:
|
| |
out = check_output(cmd, shell=True, universal_newlines=True)
|
| |
except (OSError, CalledProcessError) as err:
|
| |
- self.set_passed(self.PENDING,
|
| |
- "Cannot run licensecheck: " + str(err))
|
| |
+ self.set_passed(
|
| |
+ self.PENDING, "Cannot run licensecheck: " + str(err)
|
| |
+ )
|
| |
return
|
| |
self.log.debug("Got license reply, length: %d", len(out))
|
| |
files_by_license = self._parse_licenses(out)
|
| |
- filename = os.path.join(ReviewDirs.root,
|
| |
- 'licensecheck.txt')
|
| |
+ filename = os.path.join(ReviewDirs.root, "licensecheck.txt")
|
| |
self._write_license(files_by_license, filename)
|
| |
else:
|
| |
- self.log.error('Source directory %s does not exist!',
|
| |
- source_dir)
|
| |
+ self.log.error("Source directory %s does not exist!", source_dir)
|
| |
if not files_by_license:
|
| |
- msg += ' No licenses found.'
|
| |
- msg += ' Please check the source files for licenses manually.'
|
| |
+ msg += " No licenses found."
|
| |
+ msg += " Please check the source files for licenses manually."
|
| |
else:
|
| |
- msg += ' Licenses found: "' \
|
| |
- + '", "'.join(files_by_license.keys()) + '".'
|
| |
+ msg += (
|
| |
+ ' Licenses found: "' + '", "'.join(files_by_license.keys()) + '".'
|
| |
+ )
|
| |
if self.unknown_license in files_by_license:
|
| |
- msg += ' %d files have unknown license.' % \
|
| |
- len(files_by_license[self.unknown_license])
|
| |
- msg += ' Detailed output of licensecheck in ' + filename
|
| |
+ msg += " %d files have unknown license." % len(
|
| |
+ files_by_license[self.unknown_license]
|
| |
+ )
|
| |
+ msg += " Detailed output of licensecheck in " + filename
|
| |
self.set_passed(self.PENDING, msg)
|
| |
except OSError as e:
|
| |
- self.log.error('OSError: %s', str(e))
|
| |
- msg = ' Programmer error: ' + e.strerror
|
| |
+ self.log.error("OSError: %s", str(e))
|
| |
+ msg = " Programmer error: " + e.strerror
|
| |
self.set_passed(self.PENDING, msg)
|
| |
|
| |
|
| |
class CheckLicensInDoc(GenericCheckBase):
|
| |
- ''' Package includes license text files. '''
|
| |
+ """ Package includes license text files. """
|
| |
|
| |
sort_key = _LICENSE_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/LicensingGuidelines/#_license_text'
|
| |
- if not self.flags['EPEL6']:
|
| |
- self._license_flag = 'L'
|
| |
- self._license_macro = '%license'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/LicensingGuidelines/#_license_text"
|
| |
+ )
|
| |
+ if not self.flags["EPEL6"]:
|
| |
+ self._license_flag = "L"
|
| |
+ self._license_macro = "%license"
|
| |
else:
|
| |
- self._license_flag = 'd'
|
| |
- self._license_macro = '%doc'
|
| |
-
|
| |
- self.text = 'If (and only if) the source package includes' \
|
| |
- ' the text of the license(s) in its own file,' \
|
| |
- ' then that file, containing the text of the' \
|
| |
- ' license(s) for the package is included in %s.' % \
|
| |
- self._license_macro
|
| |
+ self._license_flag = "d"
|
| |
+ self._license_macro = "%doc"
|
| |
+
|
| |
+ self.text = (
|
| |
+ "If (and only if) the source package includes"
|
| |
+ " the text of the license(s) in its own file,"
|
| |
+ " then that file, containing the text of the"
|
| |
+ " license(s) for the package is included in %s." % self._license_macro
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
""" Check if there is a license file and if it is present in the
|
| |
@@ -715,13 +775,17 @@
|
| |
# pylint: disable=invalid-name
|
| |
|
| |
licenses = []
|
| |
- for potentialfile in ['COPYING', 'copying',
|
| |
- 'LICEN', 'licen',
|
| |
- 'COPYRIGHT', 'copyright']:
|
| |
- pattern = '*' + potentialfile + '*'
|
| |
+ for potentialfile in [
|
| |
+ "COPYING",
|
| |
+ "copying",
|
| |
+ "LICEN",
|
| |
+ "licen",
|
| |
+ "COPYRIGHT",
|
| |
+ "copyright",
|
| |
+ ]:
|
| |
+ pattern = "*" + potentialfile + "*"
|
| |
licenses.extend(self.rpms.find_all(pattern))
|
| |
- licenses = [l.split('/')[-1] for l in licenses
|
| |
- if not self.rpms.find(l + '/*')]
|
| |
+ licenses = [l.split("/")[-1] for l in licenses if not self.rpms.find(l + "/*")]
|
| |
if licenses == []:
|
| |
self.set_passed(self.PENDING)
|
| |
return
|
| |
@@ -731,221 +795,242 @@
|
| |
for pkg in self.spec.packages:
|
| |
nvr = self.spec.get_package_nvr(pkg)
|
| |
rpm_path = Mock.get_package_rpm_path(nvr)
|
| |
- cmd = 'rpm -qp{} {}'.format(self._license_flag, rpm_path)
|
| |
+ cmd = "rpm -qp{} {}".format(self._license_flag, rpm_path)
|
| |
doclist = check_output(cmd.split(), universal_newlines=True)
|
| |
- flagged_files.extend(doclist.split('\n'))
|
| |
- flagged_files = [f.split('/')[-1] for f in flagged_files]
|
| |
+ flagged_files.extend(doclist.split("\n"))
|
| |
+ flagged_files = [f.split("/")[-1] for f in flagged_files]
|
| |
|
| |
- if self._license_flag == 'L':
|
| |
+ if self._license_flag == "L":
|
| |
for pkg in self.spec.packages:
|
| |
nvr = self.spec.get_package_nvr(pkg)
|
| |
rpm_path = Mock.get_package_rpm_path(nvr)
|
| |
- cmd = 'rpm -qpL %s' % rpm_path
|
| |
+ cmd = "rpm -qpL %s" % rpm_path
|
| |
qpL_list = check_output(cmd.split(), universal_newlines=True)
|
| |
- qpL_files.extend(qpL_list.split('\n'))
|
| |
- qpL_files = [f.split('/')[-1] for f in qpL_files]
|
| |
+ qpL_files.extend(qpL_list.split("\n"))
|
| |
+ qpL_files = [f.split("/")[-1] for f in qpL_files]
|
| |
|
| |
for _license in licenses:
|
| |
- if self._license_flag == 'L' and _license not in qpL_files:
|
| |
+ if self._license_flag == "L" and _license not in qpL_files:
|
| |
self.log.debug("Found %s not marked as %%license", _license)
|
| |
self.set_passed(
|
| |
- self.FAIL,
|
| |
- "License file %s is not marked as %%license" % _license)
|
| |
+ self.FAIL, "License file %s is not marked as %%license" % _license
|
| |
+ )
|
| |
return
|
| |
if _license not in flagged_files:
|
| |
self.log.debug("Cannot find %s in doclist", _license)
|
| |
- self.set_passed(self.FAIL,
|
| |
- "Cannot find %s in rpm(s)", _license)
|
| |
+ self.set_passed(self.FAIL, "Cannot find %s in rpm(s)", _license)
|
| |
return
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckLicenseInSubpackages(GenericCheckBase):
|
| |
- ''' License should always be installed when subpackages.'''
|
| |
+ """ License should always be installed when subpackages."""
|
| |
|
| |
sort_key = _LICENSE_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/LicensingGuidelines' \
|
| |
- '/#subpackage-licensing'
|
| |
- self.text = 'License file installed when any subpackage' \
|
| |
- ' combination is installed.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/LicensingGuidelines"
|
| |
+ "/#subpackage-licensing"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "License file installed when any subpackage" " combination is installed."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def is_applicable(self):
|
| |
- '''Check if subpackages exists'''
|
| |
+ """Check if subpackages exists"""
|
| |
return len(self.spec.packages) > 1
|
| |
|
| |
|
| |
class CheckLocale(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: The spec file MUST handle locales properly. This is done by
|
| |
using the %find_lang macro. Using %{_datadir}/locale/* is strictly
|
| |
forbidden.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_handling_locale_files'
|
| |
- self.text = 'The spec file handles locales properly.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_handling_locale_files"
|
| |
+ )
|
| |
+ self.text = "The spec file handles locales properly."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def is_applicable(self):
|
| |
- return self.rpms.find('/usr/share/locale/*/LC_MESSAGES/*.mo')
|
| |
+ return self.rpms.find("/usr/share/locale/*/LC_MESSAGES/*.mo")
|
| |
|
| |
|
| |
class CheckMacros(GenericCheckBase):
|
| |
- ''' Each package must consistently use macros. '''
|
| |
+ """ Each package must consistently use macros. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_macros'
|
| |
- self.text = 'Package consistently uses macros' \
|
| |
- ' (instead of hard-coded directory names).'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/#_macros"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Package consistently uses macros"
|
| |
+ " (instead of hard-coded directory names)."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckBuildrootMacros(GenericCheckBase):
|
| |
- '''Package must use either %{buildroot} or $RPM_BUILD_ROOT. '''
|
| |
+ """Package must use either %{buildroot} or $RPM_BUILD_ROOT. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_macros'
|
| |
- self.text = 'Package uses either %{buildroot} or $RPM_BUILD_ROOT'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/#_macros"
|
| |
+ )
|
| |
+ self.text = "Package uses either %{buildroot} or $RPM_BUILD_ROOT"
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- br_tag1 = self.spec.find_all_re('.*%{buildroot}.*', True)
|
| |
- br_tag2 = self.spec.find_all_re(r'.*\$RPM_BUILD_ROOT.*', True)
|
| |
+ br_tag1 = self.spec.find_all_re(".*%{buildroot}.*", True)
|
| |
+ br_tag2 = self.spec.find_all_re(r".*\$RPM_BUILD_ROOT.*", True)
|
| |
if br_tag1 and br_tag2:
|
| |
- self.set_passed(self.FAIL,
|
| |
- 'Using both %{buildroot} and $RPM_BUILD_ROOT')
|
| |
+ self.set_passed(self.FAIL, "Using both %{buildroot} and $RPM_BUILD_ROOT")
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckMakeinstall(GenericCheckBase):
|
| |
- ''' Thou shall not use %makeinstall. '''
|
| |
+ """ Thou shall not use %makeinstall. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/' \
|
| |
- '#_why_the_makeinstall_macro_should_not_be_used'
|
| |
- self.text = "Package use %makeinstall only when make install" \
|
| |
- " DESTDIR=... doesn't work."
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/"
|
| |
+ "#_why_the_makeinstall_macro_should_not_be_used"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Package use %makeinstall only when make install"
|
| |
+ " DESTDIR=... doesn't work."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
- install = self.spec.get_section('%install', raw=True)
|
| |
- if install and '%makeinstall' in install:
|
| |
- self.set_passed(self.PENDING,
|
| |
- '%makeinstall used in %install section')
|
| |
+ install = self.spec.get_section("%install", raw=True)
|
| |
+ if install and "%makeinstall" in install:
|
| |
+ self.set_passed(self.PENDING, "%makeinstall used in %install section")
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckMultipleLicenses(GenericCheckBase):
|
| |
- ''' If multiple licenses, we should provide a break-down. '''
|
| |
+ """ If multiple licenses, we should provide a break-down. """
|
| |
|
| |
sort_key = _LICENSE_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/LicensingGuidelines' \
|
| |
- '/#_multiple_licensing_scenarios'
|
| |
- self.text = 'If the package is under multiple licenses, the licensing'\
|
| |
- ' breakdown must be documented in the spec.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/LicensingGuidelines"
|
| |
+ "/#_multiple_licensing_scenarios"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "If the package is under multiple licenses, the licensing"
|
| |
+ " breakdown must be documented in the spec."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def is_applicable(self):
|
| |
- license_ = self.spec.expand_tag('License').decode('utf-8').lower().split()
|
| |
- return 'and' in license_ or 'or' in license_
|
| |
+ license_ = self.spec.expand_tag("License").decode("utf-8").lower().split()
|
| |
+ return "and" in license_ or "or" in license_
|
| |
|
| |
|
| |
class CheckNameCharset(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST:all Fedora packages must be named using only the following
|
| |
ASCII characters...
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/Naming/'
|
| |
- self.text = 'Package is named using only allowed ASCII characters.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/Naming/"
|
| |
+ )
|
| |
+ self.text = "Package is named using only allowed ASCII characters."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
- allowed_chars = 'abcdefghijklmnopqrstuvwxyz' \
|
| |
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._+'
|
| |
- output = ''
|
| |
+ allowed_chars = (
|
| |
+ "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._+"
|
| |
+ )
|
| |
+ output = ""
|
| |
passed = True
|
| |
for char in self.spec.name:
|
| |
if char not in allowed_chars:
|
| |
- output += '^'
|
| |
+ output += "^"
|
| |
passed = False
|
| |
else:
|
| |
- output += ' '
|
| |
+ output += " "
|
| |
if passed:
|
| |
self.set_passed(passed)
|
| |
else:
|
| |
- self.set_passed(passed, '{}\n{}'.format(self.spec.name, output))
|
| |
+ self.set_passed(passed, "{}\n{}".format(self.spec.name, output))
|
| |
|
| |
|
| |
class CheckNaming(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: The package must be named according to the Package Naming
|
| |
Guidelines.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/Naming/'
|
| |
- self.text = 'Package is named according to the Package Naming' \
|
| |
- ' Guidelines.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/Naming/"
|
| |
+ )
|
| |
+ self.text = "Package is named according to the Package Naming" " Guidelines."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckNoConfigInUsr(GenericCheckBase):
|
| |
- ''' No config file under /usr. '''
|
| |
+ """ No config file under /usr. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_configuration_files'
|
| |
- self.text = 'No %config files under /usr.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_configuration_files"
|
| |
+ )
|
| |
+ self.text = "No %config files under /usr."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def is_applicable(self):
|
| |
for pkg in self.spec.packages:
|
| |
for line in self.spec.get_files(pkg):
|
| |
- if line.startswith('%config'):
|
| |
+ if line.startswith("%config"):
|
| |
return True
|
| |
return False
|
| |
|
| |
def run_on_applicable(self):
|
| |
passed = True
|
| |
- extra = ''
|
| |
+ extra = ""
|
| |
for pkg in self.spec.packages:
|
| |
for line in self.spec.get_files(pkg):
|
| |
- if line.startswith('%config'):
|
| |
+ if line.startswith("%config"):
|
| |
l = line.replace("%config", "")
|
| |
l = l.replace("(noreplace)", "").strip()
|
| |
- if l.startswith('/usr'):
|
| |
+ if l.startswith("/usr"):
|
| |
passed = False
|
| |
extra += line
|
| |
|
| |
@@ -953,87 +1038,96 @@
|
| |
|
| |
|
| |
class CheckNoConflicts(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
Whenever possible, Fedora packages should avoid conflicting
|
| |
with each other
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_conflicts'
|
| |
- self.text = 'Package does not generate any conflict.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/#_conflicts"
|
| |
+ )
|
| |
+ self.text = "Package does not generate any conflict."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
text = None
|
| |
- if self.spec.expand_tag('Conflicts'):
|
| |
- text = 'Package contains Conflicts: tag(s)' \
|
| |
- ' needing fix or justification.'
|
| |
+ if self.spec.expand_tag("Conflicts"):
|
| |
+ text = "Package contains Conflicts: tag(s)" " needing fix or justification."
|
| |
self.set_passed(self.PENDING, text)
|
| |
|
| |
|
| |
class CheckObeysFHS(GenericCheckBase):
|
| |
- ''' Package obeys FHS (besides /usr/libexec and /usr/target). '''
|
| |
+ """ Package obeys FHS (besides /usr/libexec and /usr/target). """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_filesystem_layout'
|
| |
- self.text = 'Package obeys FHS, except libexecdir and /usr/target.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_filesystem_layout"
|
| |
+ )
|
| |
+ self.text = "Package obeys FHS, except libexecdir and /usr/target."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckObsoletesForRename(GenericCheckBase):
|
| |
- ''' If package is a rename, we should provide Obsoletes: etc. '''
|
| |
+ """ If package is a rename, we should provide Obsoletes: etc. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines' \
|
| |
- '/#renaming-or-replacing-existing-packages'
|
| |
- self.text = 'If the package is a rename of another package, proper' \
|
| |
- ' Obsoletes and Provides are present.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines"
|
| |
+ "/#renaming-or-replacing-existing-packages"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "If the package is a rename of another package, proper"
|
| |
+ " Obsoletes and Provides are present."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckOwnDirs(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: A package must own all directories that it creates. If it
|
| |
does not create a directory that it uses, then it should require a
|
| |
package which does create that directory.
|
| |
- '''
|
| |
+ """
|
| |
|
| |
sort_key = _DIR_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_file_and_directory_ownership'
|
| |
- self.text = 'Package must own all directories that it creates.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_file_and_directory_ownership"
|
| |
+ )
|
| |
+ self.text = "Package must own all directories that it creates."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
- ''' Test if all directories created by us are owned by us or
|
| |
+ """ Test if all directories created by us are owned by us or
|
| |
of a dependency. Dependency resolution recurses one level, but
|
| |
no more. This is partly to limit the result set, partly a
|
| |
a best practise not to trust deep dependency chains for
|
| |
package directory ownership.
|
| |
- '''
|
| |
+ """
|
| |
|
| |
# pylint: disable=R0912
|
| |
def resolve(requires_arg):
|
| |
- '''
|
| |
+ """
|
| |
Resolve list of symbols to packages in srpm or by repoquery,
|
| |
skipping any version requirements.
|
| |
- '''
|
| |
+ """
|
| |
pkgs = []
|
| |
requires_to_process = list(requires_arg)
|
| |
for r in requires_arg:
|
| |
- if r.startswith('rpmlib'):
|
| |
+ if r.startswith("rpmlib"):
|
| |
requires_to_process.remove(r)
|
| |
continue
|
| |
for pkg in self.spec.packages:
|
| |
@@ -1047,7 +1141,7 @@
|
| |
return list(set(pkgs))
|
| |
|
| |
def get_deps_paths(pkg_deps):
|
| |
- ''' Return aggregated list of files in all pkg_deps. '''
|
| |
+ """ Return aggregated list of files in all pkg_deps. """
|
| |
if not pkg_deps:
|
| |
return []
|
| |
paths = deps.list_paths(pkg_deps)
|
| |
@@ -1059,29 +1153,29 @@
|
| |
bad_dirs = []
|
| |
for pkg in self.spec.packages:
|
| |
pkg_deps = resolve(self.rpms.get(pkg).requires)
|
| |
- pkg_deps.append('filesystem')
|
| |
+ pkg_deps.append("filesystem")
|
| |
pkg_deps_paths = get_deps_paths(pkg_deps)
|
| |
rpm_paths = self.rpms.get_filelist(pkg)
|
| |
for p in rpm_paths:
|
| |
- path = p.rsplit('/', 1)[0] # We own leaf, for sure.
|
| |
+ path = p.rsplit("/", 1)[0] # We own leaf, for sure.
|
| |
while path:
|
| |
if path not in rpm_paths:
|
| |
if path in pkg_deps_paths:
|
| |
break
|
| |
else:
|
| |
bad_dirs.append(path)
|
| |
- path = path.rsplit('/', 1)[0]
|
| |
+ path = path.rsplit("/", 1)[0]
|
| |
if bad_dirs:
|
| |
bad_dirs = list(set(bad_dirs))
|
| |
- self.set_passed(self.PENDING,
|
| |
- "Directories without known owners: " +
|
| |
- ', '.join(bad_dirs))
|
| |
+ self.set_passed(
|
| |
+ self.PENDING, "Directories without known owners: " + ", ".join(bad_dirs)
|
| |
+ )
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckOwnOther(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Packages must not own files or directories already owned by
|
| |
other packages. The rule of thumb here is that the first package
|
| |
to be installed should own the files or directories that other
|
| |
@@ -1091,46 +1185,47 @@
|
| |
that you have a good reason to own a file or directory that
|
| |
another package owns, then please present that at package review
|
| |
time.
|
| |
- '''
|
| |
+ """
|
| |
|
| |
sort_key = _DIR_SORT_KEY
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_file_and_directory_ownership'
|
| |
- self.text = 'Package does not own files or directories' \
|
| |
- ' owned by other packages.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_file_and_directory_ownership"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Package does not own files or directories" " owned by other packages."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
-
|
| |
def format_msg(owners_by_dir):
|
| |
- ''' Message string for PENDING message. '''
|
| |
+ """ Message string for PENDING message. """
|
| |
items = []
|
| |
for d in owners_by_dir:
|
| |
- owners = ', '.join(owners_by_dir[d])
|
| |
+ owners = ", ".join(owners_by_dir[d])
|
| |
items.append("{}({})".format(d, owners))
|
| |
- return "Dirs in package are owned also by: " + \
|
| |
- ', '.join(items)
|
| |
+ return "Dirs in package are owned also by: " + ", ".join(items)
|
| |
|
| |
def skip_rpm(path):
|
| |
- ' Return True if this rpm should not be checked. '
|
| |
- if path.endswith('.src.rpm'):
|
| |
+ " Return True if this rpm should not be checked. "
|
| |
+ if path.endswith(".src.rpm"):
|
| |
return True
|
| |
- pkg = path.rsplit('-', 2)[0]
|
| |
- return pkg.endswith(('-debuginfo', '-debugsource'))
|
| |
+ pkg = path.rsplit("-", 2)[0]
|
| |
+ return pkg.endswith(("-debuginfo", "-debugsource"))
|
| |
|
| |
bad_owners_by_dir = {}
|
| |
- rpm_files = glob(os.path.join(Mock.resultdir, '*.rpm'))
|
| |
+ rpm_files = glob(os.path.join(Mock.resultdir, "*.rpm"))
|
| |
rpm_files = [r for r in rpm_files if not skip_rpm(r)]
|
| |
for rpm_file in rpm_files:
|
| |
rpm_dirs = sorted(deps.list_dirs(rpm_file))
|
| |
my_dirs = []
|
| |
allowed = set(self.spec.packages)
|
| |
for rpm_dir in rpm_dirs:
|
| |
- if '/usr/lib/.build-id' in rpm_dir:
|
| |
+ if "/usr/lib/.build-id" in rpm_dir:
|
| |
continue
|
| |
if rpm_dir.startswith(tuple(my_dirs)):
|
| |
continue
|
| |
@@ -1146,54 +1241,64 @@
|
| |
|
| |
|
| |
class CheckRelocatable(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: If the package is designed to be relocatable,
|
| |
the packager must state this fact in the request for review,
|
| |
along with the rationalization for relocation of that specific package.
|
| |
Without this, use of Prefix: /usr is considered a blocker.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_relocatable_packages'
|
| |
- self.text = 'Package is not relocatable.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_relocatable_packages"
|
| |
+ )
|
| |
+ self.text = "Package is not relocatable."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
- if self.spec.find_re('^Prefix:'):
|
| |
+ if self.spec.find_re("^Prefix:"):
|
| |
self.set_passed(self.FAIL, 'Package has a "Prefix:" tag')
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckRequires(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
https://docs.fedoraproject.org/en-US/packaging-guidelines/#_explicit_requires
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_explicit_requires'
|
| |
- self.text = 'Requires correct, justified where necessary.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_explicit_requires"
|
| |
+ )
|
| |
+ self.text = "Requires correct, justified where necessary."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckSourceMD5(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: The sources used to build the package must match the
|
| |
upstream source, as provided in the spec URL. Reviewers should use
|
| |
md5sum for this task. If no upstream URL can be specified for
|
| |
this package, please see the Source URL Guidelines for how to deal
|
| |
with this.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/SourceURL/'
|
| |
- self.text = 'Sources used to build the package match the' \
|
| |
- ' upstream source, as provided in the spec URL.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US" "/packaging-guidelines/SourceURL/"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Sources used to build the package match the"
|
| |
+ " upstream source, as provided in the spec URL."
|
| |
+ )
|
| |
self.automatic = True
|
| |
|
| |
def make_diff(self, sources):
|
| |
@@ -1207,13 +1312,14 @@
|
| |
upstream = s.extract_dir
|
| |
local = self.srpm.extract(s.filename)
|
| |
if not local:
|
| |
- self.log.warn(
|
| |
- "Cannot extract local source: %s", s.filename)
|
| |
- return(False, None)
|
| |
- cmd = '/usr/bin/diff -U2 -r {} {}'.format(upstream, local)
|
| |
- self.log.debug(' Diff cmd: %s', cmd)
|
| |
+ self.log.warn("Cannot extract local source: %s", s.filename)
|
| |
+ return (False, None)
|
| |
+ cmd = "/usr/bin/diff -U2 -r {} {}".format(upstream, local)
|
| |
+ self.log.debug(" Diff cmd: %s", cmd)
|
| |
try:
|
| |
- p = Popen(cmd.split(), stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
| |
+ p = Popen(
|
| |
+ cmd.split(), stdout=PIPE, stderr=PIPE, universal_newlines=True
|
| |
+ )
|
| |
output = p.communicate()[0]
|
| |
except OSError:
|
| |
self.log.error("Cannot run diff", exc_info=True)
|
| |
@@ -1223,24 +1329,24 @@
|
| |
return (True, None)
|
| |
|
| |
def check_checksums(self, sources):
|
| |
- ''' For all sources, compare checksum with upstream. '''
|
| |
- text = ''
|
| |
+ """ For all sources, compare checksum with upstream. """
|
| |
+ text = ""
|
| |
all_sources_passed = True
|
| |
for source in sources:
|
| |
if source.local:
|
| |
- self.log.debug('Skipping md5-test for %s',
|
| |
- source.filename)
|
| |
+ self.log.debug("Skipping md5-test for %s", source.filename)
|
| |
continue
|
| |
if source.local_src:
|
| |
- text += "Using local file " + source.local_src + \
|
| |
- " as upstream\n"
|
| |
+ text += "Using local file " + source.local_src + " as upstream\n"
|
| |
local = self.srpm.check_source_checksum(source.filename)
|
| |
upstream = source.check_source_checksum()
|
| |
- text += source.url + ' :\n'
|
| |
- text += ' CHECKSUM({}) this package : {}\n'.\
|
| |
- format(Settings.checksum.upper(), local)
|
| |
- text += ' CHECKSUM({}) upstream package : {}\n'.\
|
| |
- format(Settings.checksum.upper(), upstream)
|
| |
+ text += source.url + " :\n"
|
| |
+ text += " CHECKSUM({}) this package : {}\n".format(
|
| |
+ Settings.checksum.upper(), local
|
| |
+ )
|
| |
+ text += " CHECKSUM({}) upstream package : {}\n".format(
|
| |
+ Settings.checksum.upper(), upstream
|
| |
+ )
|
| |
if local != upstream:
|
| |
all_sources_passed = False
|
| |
return (all_sources_passed, text)
|
| |
@@ -1248,196 +1354,218 @@
|
| |
def run(self):
|
| |
sources = self.sources.get_all()
|
| |
if sources == []:
|
| |
- self.log.debug('No testable sources')
|
| |
- self.set_passed(self.PENDING, 'Package has no sources or they'
|
| |
- ' are generated by developer')
|
| |
+ self.log.debug("No testable sources")
|
| |
+ self.set_passed(
|
| |
+ self.PENDING,
|
| |
+ "Package has no sources or they" " are generated by developer",
|
| |
+ )
|
| |
return
|
| |
- msg = 'Check did not complete'
|
| |
+ msg = "Check did not complete"
|
| |
passed = True
|
| |
- text = ''
|
| |
+ text = ""
|
| |
try:
|
| |
sources = [self.sources.get(s) for s in self.sources.get_all()]
|
| |
passed, text = self.check_checksums(sources)
|
| |
if not passed:
|
| |
passed, diff = self.make_diff(sources)
|
| |
if passed:
|
| |
- text += 'However, diff -r shows no differences\n'
|
| |
- msg = 'checksum differs but diff -r is OK'
|
| |
+ text += "However, diff -r shows no differences\n"
|
| |
+ msg = "checksum differs but diff -r is OK"
|
| |
elif not diff:
|
| |
- msg += 'checksum differs and there are problems '\
|
| |
- 'running diff. Please verify manually.\n'
|
| |
+ msg += (
|
| |
+ "checksum differs and there are problems "
|
| |
+ "running diff. Please verify manually.\n"
|
| |
+ )
|
| |
else:
|
| |
- p = os.path.join(ReviewDirs.root, 'diff.txt')
|
| |
- with open(p, 'w') as f:
|
| |
+ p = os.path.join(ReviewDirs.root, "diff.txt")
|
| |
+ with open(p, "w") as f:
|
| |
f.write(diff)
|
| |
- text += 'diff -r also reports differences\n'
|
| |
- msg = 'Upstream MD5sum check error, diff is in ' + p
|
| |
+ text += "diff -r also reports differences\n"
|
| |
+ msg = "Upstream MD5sum check error, diff is in " + p
|
| |
except AttributeError as e:
|
| |
- self.log.debug("CheckSourceMD5(): Attribute error %s", str(e),
|
| |
- exc_info=True)
|
| |
- msg = 'Internal Error!'
|
| |
+ self.log.debug(
|
| |
+ "CheckSourceMD5(): Attribute error %s", str(e), exc_info=True
|
| |
+ )
|
| |
+ msg = "Internal Error!"
|
| |
passed = False
|
| |
finally:
|
| |
if passed:
|
| |
msg = None
|
| |
if text:
|
| |
- attachments = [self.Attachment('Source checksums', text)]
|
| |
+ attachments = [self.Attachment("Source checksums", text)]
|
| |
else:
|
| |
attachments = []
|
| |
self.set_passed(passed, msg, attachments)
|
| |
|
| |
|
| |
class CheckSpecLegibility(GenericCheckBase):
|
| |
- ''' Spec file legible and written in American English. '''
|
| |
+ """ Spec file legible and written in American English. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_spec_legibility'
|
| |
- self.text = 'Spec file is legible and written in American English.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_spec_legibility"
|
| |
+ )
|
| |
+ self.text = "Spec file is legible and written in American English."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
|
| |
class CheckSpecName(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: The spec file name must match the base package %{name},
|
| |
in the format %{name}.spec unless your package has an exemption.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_spec_file_naming'
|
| |
- self.text = 'Spec file name must match the spec package' \
|
| |
- ' %{name}, in the format %{name}.spec.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_spec_file_naming"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Spec file name must match the spec package"
|
| |
+ " %{name}, in the format %{name}.spec."
|
| |
+ )
|
| |
self.automatic = True
|
| |
|
| |
def run(self):
|
| |
- spec_name = '%s.spec' % self.spec.name
|
| |
+ spec_name = "%s.spec" % self.spec.name
|
| |
if os.path.basename(self.spec.filename) == spec_name:
|
| |
self.set_passed(self.PASS)
|
| |
else:
|
| |
- self.set_passed(self.FAIL, '%s should be %s ' %
|
| |
- (os.path.basename(self.spec.filename), spec_name))
|
| |
+ self.set_passed(
|
| |
+ self.FAIL,
|
| |
+ "%s should be %s " % (os.path.basename(self.spec.filename), spec_name),
|
| |
+ )
|
| |
|
| |
|
| |
class CheckStaticLibs(GenericCheckBase):
|
| |
- ''' MUST: Static libraries must be in a -static or -devel package. '''
|
| |
+ """ MUST: Static libraries must be in a -static or -devel package. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#packaging-static-libraries'
|
| |
- self.text = 'Static libraries in -static or -devel subpackage, ' \
|
| |
- 'providing -devel if present.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#packaging-static-libraries"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Static libraries in -static or -devel subpackage, "
|
| |
+ "providing -devel if present."
|
| |
+ )
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def is_applicable(self):
|
| |
- ''' check if this test is applicable '''
|
| |
- return self.rpms.find('*.a')
|
| |
+ """ check if this test is applicable """
|
| |
+ return self.rpms.find("*.a")
|
| |
|
| |
def run_on_applicable(self):
|
| |
- ''' Run the test, called if is_applicable() is True. '''
|
| |
- extra = ''
|
| |
+ """ Run the test, called if is_applicable() is True. """
|
| |
+ extra = ""
|
| |
names = []
|
| |
bad_names = []
|
| |
no_provides = []
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('*.a', pkg):
|
| |
+ if self.rpms.find("*.a", pkg):
|
| |
names.append(pkg)
|
| |
- if not pkg.endswith(('-static', '-devel')):
|
| |
+ if not pkg.endswith(("-static", "-devel")):
|
| |
bad_names.append(pkg)
|
| |
rpm_pkg = self.rpms.get(pkg)
|
| |
- ok = [r for r in rpm_pkg.provides if r.endswith('-static')]
|
| |
+ ok = [r for r in rpm_pkg.provides if r.endswith("-static")]
|
| |
if not ok:
|
| |
no_provides.append(pkg)
|
| |
if names:
|
| |
- extra = 'Package has .a files: ' + ', '.join(names) + '. '
|
| |
+ extra = "Package has .a files: " + ", ".join(names) + ". "
|
| |
if bad_names:
|
| |
- extra += 'Illegal package name: ' + ', '.join(bad_names) + '. '
|
| |
+ extra += "Illegal package name: " + ", ".join(bad_names) + ". "
|
| |
if no_provides:
|
| |
- extra += \
|
| |
- 'Does not provide -static: ' + ', '.join(no_provides) + '.'
|
| |
+ extra += "Does not provide -static: " + ", ".join(no_provides) + "."
|
| |
failed = bool(bad_names) or bool(no_provides)
|
| |
self.set_passed(self.FAIL if failed else self.PASS, extra)
|
| |
|
| |
|
| |
class CheckSystemdScripts(GenericCheckBase):
|
| |
- ''' systemd files if applicable. '''
|
| |
+ """ systemd files if applicable. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US/packaging-guidelines/'
|
| |
- self.text = 'Package contains systemd file(s) if in need.'
|
| |
+ self.url = "https://docs.fedoraproject.org/en-US/packaging-guidelines/"
|
| |
+ self.text = "Package contains systemd file(s) if in need."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
- self.needs.append('CheckDaemonCompileFlags')
|
| |
+ self.type = "MUST"
|
| |
+ self.needs.append("CheckDaemonCompileFlags")
|
| |
|
| |
def run_on_applicable(self):
|
| |
- if self.checks.checkdict['CheckDaemonCompileFlags'].is_na:
|
| |
+ if self.checks.checkdict["CheckDaemonCompileFlags"].is_na:
|
| |
self.set_passed(self.PENDING)
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckUTF8Filenames(GenericCheckBase):
|
| |
- ''' All filenames in rpm packages must be valid UTF-8. '''
|
| |
+ """ All filenames in rpm packages must be valid UTF-8. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_non_ascii_filenames'
|
| |
- self.text = 'File names are valid UTF-8.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_non_ascii_filenames"
|
| |
+ )
|
| |
+ self.text = "File names are valid UTF-8."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
- self.needs.append('CheckRpmlint')
|
| |
+ self.type = "MUST"
|
| |
+ self.needs.append("CheckRpmlint")
|
| |
|
| |
def run(self):
|
| |
- if self.checks.checkdict['CheckRpmlint'].is_disabled:
|
| |
- self.set_passed(self.PENDING, 'Rpmlint run disabled')
|
| |
+ if self.checks.checkdict["CheckRpmlint"].is_disabled:
|
| |
+ self.set_passed(self.PENDING, "Rpmlint run disabled")
|
| |
return
|
| |
for line in Mock.rpmlint_output:
|
| |
- if 'wrong-file-end-of-line-encoding' in line or \
|
| |
- 'file-not-utf8' in line:
|
| |
+ if "wrong-file-end-of-line-encoding" in line or "file-not-utf8" in line:
|
| |
self.set_passed(self.FAIL)
|
| |
self.set_passed(self.PASS)
|
| |
|
| |
|
| |
class CheckUsefulDebuginfo(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
Packages should produce useful -debuginfo packages, or explicitly
|
| |
disable them when it is not possible to generate a useful one but
|
| |
rpmbuild would do it anyway. Whenever a -debuginfo package is
|
| |
explicitly disabled, an explanation why it was done is required in
|
| |
the specfile.
|
| |
- '''
|
| |
+ """
|
| |
+
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_debuginfo_packages'
|
| |
- self.text = 'Useful -debuginfo package or justification' \
|
| |
- ' otherwise.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_debuginfo_packages"
|
| |
+ )
|
| |
+ self.text = "Useful -debuginfo package or justification" " otherwise."
|
| |
self.automatic = False
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def is_applicable(self):
|
| |
for path in Mock.get_package_rpm_paths(self.spec):
|
| |
- if not path.endswith('noarch.rpm'):
|
| |
+ if not path.endswith("noarch.rpm"):
|
| |
return True
|
| |
return False
|
| |
|
| |
|
| |
class CheckNoNameConflict(GenericCheckBase):
|
| |
- ''' Check that there isn't already a package with this name. '''
|
| |
+ """ Check that there isn't already a package with this name. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = "https://docs.fedoraproject.org/en-US" \
|
| |
- "/packaging-guidelines/Naming/#_conflicting_package_names"
|
| |
- self.text = 'Package does not use a name that already exists.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/Naming/#_conflicting_package_names"
|
| |
+ )
|
| |
+ self.text = "Package does not use a name that already exists."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
import json
|
| |
@@ -1447,15 +1575,14 @@
|
| |
name = self.spec.name
|
| |
|
| |
def already_exist(name):
|
| |
- ''' Check if a package name is already in Fedora '''
|
| |
+ """ Check if a package name is already in Fedora """
|
| |
buf = BytesIO()
|
| |
- params = {'pattern': name, 'short': '1', 'fork': '0'}
|
| |
- url = 'https://src.fedoraproject.org/api/0/projects'
|
| |
- headers = ['Content-Type: application/json',
|
| |
- 'Accept: application/json']
|
| |
+ params = {"pattern": name, "short": "1", "fork": "0"}
|
| |
+ url = "https://src.fedoraproject.org/api/0/projects"
|
| |
+ headers = ["Content-Type: application/json", "Accept: application/json"]
|
| |
|
| |
curl = pycurl.Curl()
|
| |
- curl.setopt(pycurl.URL, url + '?' + urlencode(params))
|
| |
+ curl.setopt(pycurl.URL, url + "?" + urlencode(params))
|
| |
curl.setopt(pycurl.HTTPHEADER, headers)
|
| |
curl.setopt(pycurl.WRITEFUNCTION, buf.write)
|
| |
try:
|
| |
@@ -1465,10 +1592,10 @@
|
| |
|
| |
try:
|
| |
j = json.loads(buf.getvalue())
|
| |
- if j['total_projects'] <= 0:
|
| |
+ if j["total_projects"] <= 0:
|
| |
return None
|
| |
|
| |
- return [str(x['fullname']) for x in j['projects']]
|
| |
+ return [str(x["fullname"]) for x in j["projects"]]
|
| |
except (ValueError, KeyError):
|
| |
return None
|
| |
|
| |
@@ -1477,104 +1604,113 @@
|
| |
if fullnames is None:
|
| |
fullnames = already_exist(name)
|
| |
if fullnames is not None:
|
| |
- urls = ['https://src.fedoraproject.org/' + x
|
| |
- for x in fullnames]
|
| |
+ urls = ["https://src.fedoraproject.org/" + x for x in fullnames]
|
| |
self.set_passed(
|
| |
self.FAIL,
|
| |
- 'A package with this name already exists. Please check ' +
|
| |
- ', '.join(urls))
|
| |
+ "A package with this name already exists. Please check "
|
| |
+ + ", ".join(urls),
|
| |
+ )
|
| |
else:
|
| |
self.set_passed(self.PASS)
|
| |
except pycurl.error:
|
| |
- self.set_passed(self.PENDING,
|
| |
- "Couldn't connect to Pagure, check manually")
|
| |
+ self.set_passed(self.PENDING, "Couldn't connect to Pagure, check manually")
|
| |
|
| |
|
| |
class CheckSourcedirMacroUse(GenericCheckBase):
|
| |
- ''' Check for usage of %_sourcedir macro. '''
|
| |
+ """ Check for usage of %_sourcedir macro. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/#_improper_use_of_sourcedir'
|
| |
- self.text = 'Only use %_sourcedir in very specific situations.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/#_improper_use_of_sourcedir"
|
| |
+ )
|
| |
+ self.text = "Only use %_sourcedir in very specific situations."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
- text = ''.join(self.spec.lines)
|
| |
- if '%_sourcedir' in text or '$RPM_SOURCE_DIR' in text or \
|
| |
- '%{_sourcedir}' in text:
|
| |
- self.set_passed(self.PENDING,
|
| |
- '%_sourcedir/$RPM_SOURCE_DIR is used.')
|
| |
+ text = "".join(self.spec.lines)
|
| |
+ if (
|
| |
+ "%_sourcedir" in text
|
| |
+ or "$RPM_SOURCE_DIR" in text
|
| |
+ or "%{_sourcedir}" in text
|
| |
+ ):
|
| |
+ self.set_passed(self.PENDING, "%_sourcedir/$RPM_SOURCE_DIR is used.")
|
| |
else:
|
| |
self.set_passed(self.NA)
|
| |
|
| |
|
| |
class CheckUpdateIconCache(GenericCheckBase):
|
| |
- ''' Check that gtk-update-icon-cache is run if required. '''
|
| |
+ """ Check that gtk-update-icon-cache is run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://fedoraproject.org/wiki/EPEL' \
|
| |
- ':Packaging#Icon_Cache'
|
| |
- self.text = 'gtk-update-icon-cache is invoked in %postun' \
|
| |
- ' and %posttrans if package contains icons.'
|
| |
+ self.url = "https://fedoraproject.org/wiki/EPEL" ":Packaging#Icon_Cache"
|
| |
+ self.text = (
|
| |
+ "gtk-update-icon-cache is invoked in %postun"
|
| |
+ " and %posttrans if package contains icons."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('/usr/share/icons/*', pkg):
|
| |
+ if self.rpms.find("/usr/share/icons/*", pkg):
|
| |
using.append(pkg)
|
| |
rpm_pkg = self.rpms.get(pkg)
|
| |
- if self.flags['EPEL6'] \
|
| |
- or self.flags['EPEL7']:
|
| |
- if not in_list('gtk-update-icon-cache',
|
| |
- [rpm_pkg.postun, rpm_pkg.posttrans]):
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
+ if not in_list(
|
| |
+ "gtk-update-icon-cache", [rpm_pkg.postun, rpm_pkg.posttrans]
|
| |
+ ):
|
| |
failed = True
|
| |
else:
|
| |
- if in_list('gtk-update-icon-cache',
|
| |
- [rpm_pkg.postun, rpm_pkg.posttrans]):
|
| |
+ if in_list(
|
| |
+ "gtk-update-icon-cache", [rpm_pkg.postun, rpm_pkg.posttrans]
|
| |
+ ):
|
| |
failed = True
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "icons in " + ', '.join(using)
|
| |
- if self.flags['EPEL6'] or self.flags['EPEL7']:
|
| |
+ text = "icons in " + ", ".join(using)
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
else:
|
| |
- self.url = ''
|
| |
- self.text = 'gtk-update-icon-cache must not be invoked' \
|
| |
- ' in %post and %posttrans for Fedora 26 and later.'
|
| |
+ self.url = ""
|
| |
+ self.text = (
|
| |
+ "gtk-update-icon-cache must not be invoked"
|
| |
+ " in %post and %posttrans for Fedora 26 and later."
|
| |
+ )
|
| |
self.set_passed(self.FAIL if failed else self.NA, text)
|
| |
|
| |
|
| |
class CheckUpdateDesktopDatabase(GenericCheckBase):
|
| |
- ''' Check that update-desktop-database is run if required. '''
|
| |
+ """ Check that update-desktop-database is run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://fedoraproject.org/wiki/EPEL' \
|
| |
- ':Packaging#desktop-database'
|
| |
- self.text = 'update-desktop-database is invoked in %post and' \
|
| |
- ' %postun if package contains desktop file(s)' \
|
| |
- ' with a MimeType: entry.'
|
| |
+ self.url = "https://fedoraproject.org/wiki/EPEL" ":Packaging#desktop-database"
|
| |
+ self.text = (
|
| |
+ "update-desktop-database is invoked in %post and"
|
| |
+ " %postun if package contains desktop file(s)"
|
| |
+ " with a MimeType: entry."
|
| |
+ )
|
| |
|
| |
self.automatic = True
|
| |
- self.needs.append('generic-large-docs') # Needed to unpack rpms
|
| |
- self.type = 'MUST'
|
| |
+ self.needs.append("generic-large-docs") # Needed to unpack rpms
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
-
|
| |
def has_mimetype(pkg, fname):
|
| |
- ''' Return True if the file fname contains a MimeType entry. '''
|
| |
+ """ Return True if the file fname contains a MimeType entry. """
|
| |
nvr = self.spec.get_package_nvr(pkg)
|
| |
- rpm_dirs = glob(os.path.join(ReviewDirs.root,
|
| |
- 'rpms-unpacked',
|
| |
- pkg + '-' + nvr.version + '*'))
|
| |
+ rpm_dirs = glob(
|
| |
+ os.path.join(
|
| |
+ ReviewDirs.root, "rpms-unpacked", pkg + "-" + nvr.version + "*"
|
| |
+ )
|
| |
+ )
|
| |
path = os.path.join(rpm_dirs[0], fname[1:])
|
| |
if os.path.isdir(path):
|
| |
return False
|
| |
@@ -1583,367 +1719,426 @@
|
| |
return False
|
| |
with open(path) as f:
|
| |
for line in f.readlines():
|
| |
- if line.strip().lower().startswith('mimetype'):
|
| |
+ if line.strip().lower().startswith("mimetype"):
|
| |
return True
|
| |
return False
|
| |
|
| |
using = []
|
| |
failed = False
|
| |
for pkg in self.spec.packages:
|
| |
- dt_files = self.rpms.find_all('*.desktop', pkg)
|
| |
+ dt_files = self.rpms.find_all("*.desktop", pkg)
|
| |
dt_files = [f for f in dt_files if has_mimetype(pkg, f)]
|
| |
if dt_files:
|
| |
using.append(pkg)
|
| |
rpm_pkg = self.rpms.get(pkg)
|
| |
- if self.flags['EPEL6'] \
|
| |
- or self.flags['EPEL7']:
|
| |
- if not in_list('update-desktop-database',
|
| |
- [rpm_pkg.post, rpm_pkg.postun]):
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
+ if not in_list(
|
| |
+ "update-desktop-database", [rpm_pkg.post, rpm_pkg.postun]
|
| |
+ ):
|
| |
failed = True
|
| |
else:
|
| |
- if in_list('update-desktop-database',
|
| |
- [rpm_pkg.post, rpm_pkg.postun]):
|
| |
+ if in_list(
|
| |
+ "update-desktop-database", [rpm_pkg.post, rpm_pkg.postun]
|
| |
+ ):
|
| |
failed = True
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "desktop file(s) with MimeType entry in " + ', '.join(using)
|
| |
- if self.flags['EPEL6'] or self.flags['EPEL7']:
|
| |
+ text = "desktop file(s) with MimeType entry in " + ", ".join(using)
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
else:
|
| |
- self.url = 'https://fedoraproject.org/w/index.php?title=' \
|
| |
- 'Packaging:Scriptlets&oldid=494555#desktop-database'
|
| |
- self.text = 'update-desktop-database must not be invoked' \
|
| |
- ' in %post and %postun for Fedora 24 and later.'
|
| |
+ self.url = (
|
| |
+ "https://fedoraproject.org/w/index.php?title="
|
| |
+ "Packaging:Scriptlets&oldid=494555#desktop-database"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "update-desktop-database must not be invoked"
|
| |
+ " in %post and %postun for Fedora 24 and later."
|
| |
+ )
|
| |
self.set_passed(self.FAIL if failed else self.NA, text)
|
| |
|
| |
|
| |
class CheckGioQueryModules(GenericCheckBase):
|
| |
- ''' Check that gio-querymodules is run if required. '''
|
| |
+ """ Check that gio-querymodules is run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://fedoraproject.org/wiki/EPEL:Packaging#GIO_modules'
|
| |
- self.text = 'gio-querymodules is invoked in %postun and %post' \
|
| |
- ' if package has /lib/gio/modules/* files'
|
| |
+ self.url = "https://fedoraproject.org/wiki/EPEL:Packaging#GIO_modules"
|
| |
+ self.text = (
|
| |
+ "gio-querymodules is invoked in %postun and %post"
|
| |
+ " if package has /lib/gio/modules/* files"
|
| |
+ )
|
| |
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- libdir = Mock.get_macro('%_libdir', self.spec, self.flags)
|
| |
- gio_pattern = os.path.join(libdir, 'gio/modules/', '*')
|
| |
+ libdir = Mock.get_macro("%_libdir", self.spec, self.flags)
|
| |
+ gio_pattern = os.path.join(libdir, "gio/modules/", "*")
|
| |
for pkg in self.spec.packages:
|
| |
if self.rpms.find(gio_pattern, pkg):
|
| |
using.append(pkg)
|
| |
rpmpkg = self.rpms.get(pkg)
|
| |
- if self.flags['EPEL6'] \
|
| |
- or self.flags['EPEL7']:
|
| |
- if not in_list('gio-querymodules',
|
| |
- [rpmpkg.post, rpmpkg.postun]):
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
+ if not in_list("gio-querymodules", [rpmpkg.post, rpmpkg.postun]):
|
| |
failed = True
|
| |
else:
|
| |
- if in_list('gio-querymodules',
|
| |
- [rpmpkg.post, rpmpkg.postun]):
|
| |
+ if in_list("gio-querymodules", [rpmpkg.post, rpmpkg.postun]):
|
| |
failed = True
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "gio module file(s) in " + ', '.join(using)
|
| |
- if self.flags['EPEL6'] or self.flags['EPEL7']:
|
| |
+ text = "gio module file(s) in " + ", ".join(using)
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
else:
|
| |
- self.url = 'https://fedoraproject.org/w/index.php?title=' \
|
| |
- 'Packaging:Scriptlets&oldid=494555#GIO_modules'
|
| |
- self.text = 'gio-querymodules must not be invoked in %postun' \
|
| |
- ' and %post ifor Fedora 24 and later.'
|
| |
+ self.url = (
|
| |
+ "https://fedoraproject.org/w/index.php?title="
|
| |
+ "Packaging:Scriptlets&oldid=494555#GIO_modules"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "gio-querymodules must not be invoked in %postun"
|
| |
+ " and %post ifor Fedora 24 and later."
|
| |
+ )
|
| |
self.set_passed(self.FAIL if failed else self.NA, text)
|
| |
|
| |
|
| |
class CheckGtkQueryModules(GenericCheckBase):
|
| |
- ''' Check that gtk-query-immodules is run if required. '''
|
| |
+ """ Check that gtk-query-immodules is run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://fedoraproject.org/wiki/EPEL' \
|
| |
- ':Packaging#GTK.2B_modules'
|
| |
- self.text = 'gtk-query-immodules is invoked when required'
|
| |
+ self.url = "https://fedoraproject.org/wiki/EPEL" ":Packaging#GTK.2B_modules"
|
| |
+ self.text = "gtk-query-immodules is invoked when required"
|
| |
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- libdir = Mock.get_macro('%_libdir', self.spec, self.flags)
|
| |
- pattern = os.path.join(libdir, 'gtk-3.0/', '*')
|
| |
+ libdir = Mock.get_macro("%_libdir", self.spec, self.flags)
|
| |
+ pattern = os.path.join(libdir, "gtk-3.0/", "*")
|
| |
for pkg in self.spec.packages:
|
| |
if self.rpms.find(pattern, pkg):
|
| |
using.append(pkg)
|
| |
rpmpkg = self.rpms.get(pkg)
|
| |
- if self.flags['EPEL6'] \
|
| |
- or self.flags['EPEL7']:
|
| |
- if not in_list('gtk-query-immodules',
|
| |
- [rpmpkg.postun, rpmpkg.posttrans]):
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
+ if not in_list(
|
| |
+ "gtk-query-immodules", [rpmpkg.postun, rpmpkg.posttrans]
|
| |
+ ):
|
| |
failed = True
|
| |
else:
|
| |
- if in_list('gtk-query-immodules',
|
| |
- [rpmpkg.postun, rpmpkg.posttrans]):
|
| |
+ if in_list(
|
| |
+ "gtk-query-immodules", [rpmpkg.postun, rpmpkg.posttrans]
|
| |
+ ):
|
| |
failed = True
|
| |
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "Gtk module file(s) in " + ', '.join(using)
|
| |
- if self.flags['EPEL6'] or self.flags['EPEL7']:
|
| |
+ text = "Gtk module file(s) in " + ", ".join(using)
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
else:
|
| |
- self.url = 'https://fedoraproject.org/w/index.php?title=' \
|
| |
- 'Packaging:Scriptlets&oldid=494555#GTK.2B_modules'
|
| |
- self.text = 'gtk-query-immodules must not be invoked for' \
|
| |
- ' Fedora 24 and later.'
|
| |
+ self.url = (
|
| |
+ "https://fedoraproject.org/w/index.php?title="
|
| |
+ "Packaging:Scriptlets&oldid=494555#GTK.2B_modules"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "gtk-query-immodules must not be invoked for" " Fedora 24 and later."
|
| |
+ )
|
| |
self.set_passed(self.FAIL if failed else self.NA, text)
|
| |
|
| |
|
| |
class CheckGlibCompileSchemas(GenericCheckBase):
|
| |
- ''' Check that glib-compile-schemas is run if required. '''
|
| |
+ """ Check that glib-compile-schemas is run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://fedoraproject.org/wiki/EPEL' \
|
| |
- ':Packaging#GSettings_Schema'
|
| |
- self.text = 'glib-compile-schemas is run in %postun and' \
|
| |
- ' %posttrans if package has *.gschema.xml files. '
|
| |
+ self.url = "https://fedoraproject.org/wiki/EPEL" ":Packaging#GSettings_Schema"
|
| |
+ self.text = (
|
| |
+ "glib-compile-schemas is run in %postun and"
|
| |
+ " %posttrans if package has *.gschema.xml files. "
|
| |
+ )
|
| |
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('*.gschema.xml', pkg):
|
| |
+ if self.rpms.find("*.gschema.xml", pkg):
|
| |
using.append(pkg)
|
| |
rpm_pkg = self.rpms.get(pkg)
|
| |
- if self.flags['EPEL6'] \
|
| |
- or self.flags['EPEL7']:
|
| |
- if not in_list('glib-compile-schemas',
|
| |
- [rpm_pkg.postun, rpm_pkg.posttrans]):
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
+ if not in_list(
|
| |
+ "glib-compile-schemas", [rpm_pkg.postun, rpm_pkg.posttrans]
|
| |
+ ):
|
| |
failed = True
|
| |
else:
|
| |
- if in_list('glib-compile-schemas',
|
| |
- [rpm_pkg.postun, rpm_pkg.posttrans]):
|
| |
+ if in_list(
|
| |
+ "glib-compile-schemas", [rpm_pkg.postun, rpm_pkg.posttrans]
|
| |
+ ):
|
| |
failed = True
|
| |
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = 'gschema file(s) in ' + ', '.join(using)
|
| |
- if self.flags['EPEL6'] or self.flags['EPEL7']:
|
| |
+ text = "gschema file(s) in " + ", ".join(using)
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
else:
|
| |
- self.url = 'https://fedoraproject.org/w/index.php?title=' \
|
| |
- 'Packaging:Scriptlets&oldid=494555#GSettings_Schema'
|
| |
- self.text = 'glib-compile-schemas must not be run in %postun and' \
|
| |
- ' %posttrans for Fedora 24 and later.'
|
| |
+ self.url = (
|
| |
+ "https://fedoraproject.org/w/index.php?title="
|
| |
+ "Packaging:Scriptlets&oldid=494555#GSettings_Schema"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "glib-compile-schemas must not be run in %postun and"
|
| |
+ " %posttrans for Fedora 24 and later."
|
| |
+ )
|
| |
self.set_passed(self.FAIL if failed else self.NA, text)
|
| |
|
| |
|
| |
class CheckGconfSchemaInstall(GenericCheckBase):
|
| |
- ''' Check that gconf schemas are properly installed. '''
|
| |
+ """ Check that gconf schemas are properly installed. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/Scriptlets/#_gconf'
|
| |
- self.text = 'GConf schemas are properly installed'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/Scriptlets/#_gconf"
|
| |
+ )
|
| |
+ self.text = "GConf schemas are properly installed"
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('/etc/gconf/schemas/*.schemas', pkg):
|
| |
+ if self.rpms.find("/etc/gconf/schemas/*.schemas", pkg):
|
| |
using.append(pkg)
|
| |
rpm_pkg = self.rpms.get(pkg)
|
| |
- if not in_list('%gconf_schema',
|
| |
- [rpm_pkg.post, rpm_pkg.pre]):
|
| |
+ if not in_list("%gconf_schema", [rpm_pkg.post, rpm_pkg.pre]):
|
| |
failed = True
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = 'gconf file(s) in ' + ', '.join(using)
|
| |
+ text = "gconf file(s) in " + ", ".join(using)
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
|
| |
|
| |
class CheckInfoInstall(GenericCheckBase):
|
| |
- ''' Check that info files are properly installed. '''
|
| |
+ """ Check that info files are properly installed. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/Scriptlets/#_texinfo'
|
| |
- self.text = 'Texinfo files are installed using install-info' \
|
| |
- ' in %post and %preun if package has .info files.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/Scriptlets/#_texinfo"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "Texinfo files are installed using install-info"
|
| |
+ " in %post and %preun if package has .info files."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('/usr/share/info/*', pkg):
|
| |
+ if self.rpms.find("/usr/share/info/*", pkg):
|
| |
using.append(pkg)
|
| |
rpm_pkg = self.rpms.get(pkg)
|
| |
- if not in_list('install-info',
|
| |
- [rpm_pkg.post, rpm_pkg.preun]):
|
| |
+ if not in_list("install-info", [rpm_pkg.post, rpm_pkg.preun]):
|
| |
failed = True
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = 'Texinfo .info file(s) in ' + ', '.join(using)
|
| |
+ text = "Texinfo .info file(s) in " + ", ".join(using)
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
|
| |
|
| |
class CheckGdkPixbufLoaders(GenericCheckBase):
|
| |
- ''' Check that gdk-pixbuf-query-loaders is run if required. '''
|
| |
+ """ Check that gdk-pixbuf-query-loaders is run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://fedoraproject.org/wiki/EPEL' \
|
| |
- ':Packaging#gdk-pixbuf_loaders'
|
| |
- self.text = 'gdk-pixbuf-query-loaders is invoked in %post and' \
|
| |
- ' %postun to update gdk-pixbuf'
|
| |
+ self.url = "https://fedoraproject.org/wiki/EPEL" ":Packaging#gdk-pixbuf_loaders"
|
| |
+ self.text = (
|
| |
+ "gdk-pixbuf-query-loaders is invoked in %post and"
|
| |
+ " %postun to update gdk-pixbuf"
|
| |
+ )
|
| |
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- libdir = Mock.get_macro('%_libdir', self.spec, self.flags)
|
| |
- pattern = os.path.join(libdir, 'gdk-pixbuf-2.0/2.10.0/loaders/', '*')
|
| |
+ libdir = Mock.get_macro("%_libdir", self.spec, self.flags)
|
| |
+ pattern = os.path.join(libdir, "gdk-pixbuf-2.0/2.10.0/loaders/", "*")
|
| |
for pkg in self.spec.packages:
|
| |
if self.rpms.find(pattern, pkg):
|
| |
using.append(pkg)
|
| |
rpmpkg = self.rpms.get(pkg)
|
| |
- if self.flags['EPEL6'] \
|
| |
- or self.flags['EPEL7']:
|
| |
- if not in_list('gdk-pixbuf-query-loaders',
|
| |
- [rpmpkg.postun, rpmpkg.post]):
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
+ if not in_list(
|
| |
+ "gdk-pixbuf-query-loaders", [rpmpkg.postun, rpmpkg.post]
|
| |
+ ):
|
| |
failed = True
|
| |
else:
|
| |
- if in_list('gdk-pixbuf-query-loaders',
|
| |
- [rpmpkg.postun, rpmpkg.post]):
|
| |
+ if in_list(
|
| |
+ "gdk-pixbuf-query-loaders", [rpmpkg.postun, rpmpkg.post]
|
| |
+ ):
|
| |
failed = True
|
| |
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "gdk-pixbux module file(s) in " + ', '.join(using)
|
| |
- if self.flags['EPEL6'] or self.flags['EPEL7']:
|
| |
+ text = "gdk-pixbux module file(s) in " + ", ".join(using)
|
| |
+ if self.flags["EPEL6"] or self.flags["EPEL7"]:
|
| |
self.set_passed(self.FAIL if failed else self.PENDING, text)
|
| |
else:
|
| |
- self.url = 'https://fedoraproject.org/w/index.php?title=' \
|
| |
- 'Packaging:Scriptlets&oldid=494555#gdk-pixbuf_loaders'
|
| |
- self.text = 'gdk-pixbuf-query-loaders must not be invoked for' \
|
| |
- ' Fedora 24 and later.'
|
| |
+ self.url = (
|
| |
+ "https://fedoraproject.org/w/index.php?title="
|
| |
+ "Packaging:Scriptlets&oldid=494555#gdk-pixbuf_loaders"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "gdk-pixbuf-query-loaders must not be invoked for"
|
| |
+ " Fedora 24 and later."
|
| |
+ )
|
| |
self.set_passed(self.FAIL if failed else self.NA, text)
|
| |
|
| |
|
| |
class CheckSystemdUnitdirScriplets(GenericCheckBase):
|
| |
- ''' Check that Systemd unitdir scriplets are run if required. '''
|
| |
+ """ Check that Systemd unitdir scriplets are run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/Scriptlets/#_scriptlets'
|
| |
- self.text = 'systemd_post is invoked in %post, systemd_preun in' \
|
| |
- ' %preun, and systemd_postun in %postun for Systemd' \
|
| |
- ' service files.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/Scriptlets/#_scriptlets"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "systemd_post is invoked in %post, systemd_preun in"
|
| |
+ " %preun, and systemd_postun in %postun for Systemd"
|
| |
+ " service files."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- systemd_post_re = re.compile(re.escape(rpm.expandMacro('%systemd_post .*.service')).replace(r'\.\*', '.*')[2:-4], re.M)
|
| |
- systemd_preun_re = re.compile(re.escape(rpm.expandMacro('%systemd_preun .*.service')).replace(r'\.\*', '.*')[2:-4], re.M)
|
| |
+ systemd_post_re = re.compile(
|
| |
+ re.escape(rpm.expandMacro("%systemd_post .*.service")).replace(
|
| |
+ r"\.\*", ".*"
|
| |
+ )[2:-4],
|
| |
+ re.M,
|
| |
+ )
|
| |
+ systemd_preun_re = re.compile(
|
| |
+ re.escape(rpm.expandMacro("%systemd_preun .*.service")).replace(
|
| |
+ r"\.\*", ".*"
|
| |
+ )[2:-4],
|
| |
+ re.M,
|
| |
+ )
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('/usr/lib/systemd/system/*', pkg):
|
| |
+ if self.rpms.find("/usr/lib/systemd/system/*", pkg):
|
| |
using.append(pkg)
|
| |
rpmpkg = self.rpms.get(pkg)
|
| |
- if not systemd_post_re.search(str(rpmpkg.post)) \
|
| |
- or not systemd_preun_re.search(str(rpmpkg.preun)):
|
| |
+ if not systemd_post_re.search(
|
| |
+ str(rpmpkg.post)
|
| |
+ ) or not systemd_preun_re.search(str(rpmpkg.preun)):
|
| |
failed = True
|
| |
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "Systemd service file(s) in " + ', '.join(using)
|
| |
+ text = "Systemd service file(s) in " + ", ".join(using)
|
| |
self.set_passed(self.FAIL if failed else self.PASS, text)
|
| |
|
| |
|
| |
class CheckSystemdUserunitdirScriplets(GenericCheckBase):
|
| |
- ''' Check that Systemd userunitdir scriplets are run if required. '''
|
| |
+ """ Check that Systemd userunitdir scriplets are run if required. """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/Scriptlets/#_user_units'
|
| |
- self.text = 'systemd_user_post is invoked in %post and' \
|
| |
- ' systemd_user_preun in %preun for Systemd' \
|
| |
- ' user units service files.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/Scriptlets/#_user_units"
|
| |
+ )
|
| |
+ self.text = (
|
| |
+ "systemd_user_post is invoked in %post and"
|
| |
+ " systemd_user_preun in %preun for Systemd"
|
| |
+ " user units service files."
|
| |
+ )
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- systemd_user_post_re = re.compile(re.escape(rpm.expandMacro('%systemd_user_post .*.service')).replace(r'\.\*', '.*')[2:], re.M)
|
| |
- systemd_user_preun_re = re.compile(re.escape(rpm.expandMacro('%systemd_user_preun .*.service')).replace(r'\.\*', '.*')[2:], re.M)
|
| |
+ systemd_user_post_re = re.compile(
|
| |
+ re.escape(rpm.expandMacro("%systemd_user_post .*.service")).replace(
|
| |
+ r"\.\*", ".*"
|
| |
+ )[2:],
|
| |
+ re.M,
|
| |
+ )
|
| |
+ systemd_user_preun_re = re.compile(
|
| |
+ re.escape(rpm.expandMacro("%systemd_user_preun .*.service")).replace(
|
| |
+ r"\.\*", ".*"
|
| |
+ )[2:],
|
| |
+ re.M,
|
| |
+ )
|
| |
for pkg in self.spec.packages:
|
| |
- if self.rpms.find('/usr/lib/systemd/user/*', pkg):
|
| |
+ if self.rpms.find("/usr/lib/systemd/user/*", pkg):
|
| |
using.append(pkg)
|
| |
rpmpkg = self.rpms.get(pkg)
|
| |
- if not systemd_user_post_re.search(str(rpmpkg.post)) \
|
| |
- or not systemd_user_preun_re.search(str(rpmpkg.preun)):
|
| |
+ if not systemd_user_post_re.search(
|
| |
+ str(rpmpkg.post)
|
| |
+ ) or not systemd_user_preun_re.search(str(rpmpkg.preun)):
|
| |
failed = True
|
| |
|
| |
if not using:
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
- text = "Systemd user unit service file(s) in " + ', '.join(using)
|
| |
+ text = "Systemd user unit service file(s) in " + ", ".join(using)
|
| |
self.set_passed(self.FAIL if failed else self.PASS, text)
|
| |
|
| |
|
| |
class CheckIfDepsDeprecated(GenericCheckBase):
|
| |
- '''
|
| |
+ """
|
| |
MUST: Check if package does not depend on deprecated() packages
|
| |
- '''
|
| |
+ """
|
| |
|
| |
def __init__(self, base):
|
| |
GenericCheckBase.__init__(self, base)
|
| |
- self.url = 'https://docs.fedoraproject.org/en-US' \
|
| |
- '/packaging-guidelines/deprecating-packages/'
|
| |
- self.text = 'Package must not depend on deprecated() packages.'
|
| |
+ self.url = (
|
| |
+ "https://docs.fedoraproject.org/en-US"
|
| |
+ "/packaging-guidelines/deprecating-packages/"
|
| |
+ )
|
| |
+ self.text = "Package must not depend on deprecated() packages."
|
| |
self.automatic = True
|
| |
- self.type = 'MUST'
|
| |
+ self.type = "MUST"
|
| |
|
| |
def run_on_applicable(self):
|
| |
|
| |
# pylint: disable=R0912
|
| |
def resolve(requires_arg):
|
| |
- '''
|
| |
+ """
|
| |
Resolve list of symbols to packages in srpm or by repoquery
|
| |
- '''
|
| |
+ """
|
| |
pkgs = []
|
| |
requires_to_process = list(requires_arg)
|
| |
for r in requires_arg:
|
| |
- if r.startswith('rpmlib'):
|
| |
+ if r.startswith("rpmlib"):
|
| |
requires_to_process.remove(r)
|
| |
continue
|
| |
if "python(abi)" in r:
|
| |
@@ -1967,9 +2162,10 @@
|
| |
|
| |
for pkg in pkg_deps:
|
| |
provides = deps.list_provides(pkg)
|
| |
- if any('deprecated()' in p for p in provides):
|
| |
- self.set_passed(self.FAIL, pkg + ' is deprecated, you must '
|
| |
- 'not depend on it.')
|
| |
+ if any("deprecated()" in p for p in provides):
|
| |
+ self.set_passed(
|
| |
+ self.FAIL, pkg + " is deprecated, you must " "not depend on it."
|
| |
+ )
|
| |
return
|
| |
|
| |
self.set_passed(self.PASS)
|
| |
This is just 3 simple commits, I will not change anything manually until this is in. This has a large potential to diverge, so please merge soon before doing other changes.