| |
@@ -23,7 +23,7 @@
|
| |
import os.path
|
| |
import re
|
| |
from glob import glob
|
| |
- from io import BytesIO
|
| |
+ from six import BytesIO
|
| |
from subprocess import Popen, PIPE, CalledProcessError
|
| |
|
| |
import rpm
|
| |
@@ -144,7 +144,7 @@
|
| |
|
| |
def run(self):
|
| |
archs = self.checks.spec.expand_tag('BuildArchs')
|
| |
- if len(archs) == 1 and archs[0].lower() == 'noarch':
|
| |
+ if len(archs) == 1 and archs[0].lower() == b'noarch':
|
| |
self.set_passed(self.NA)
|
| |
return
|
| |
self.set_passed(self.PENDING)
|
| |
@@ -253,7 +253,7 @@
|
| |
try:
|
| |
cmd = 'find %s -perm -4000' % rpms_dir
|
| |
with open('/dev/null', 'w') as f:
|
| |
- suids = check_output(cmd.split(), stderr=f).strip().split()
|
| |
+ suids = check_output(cmd.split(), stderr=f, universal_newlines=True).strip().split()
|
| |
except CalledProcessError:
|
| |
self.log.info('Cannot run find command: %s', cmd)
|
| |
suids = []
|
| |
@@ -321,9 +321,9 @@
|
| |
def run(self):
|
| |
bad_tags = []
|
| |
for pkg_name in self.spec.packages:
|
| |
- if '%' in self.spec.expand_tag('Summary', pkg_name):
|
| |
+ 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):
|
| |
+ 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,
|
| |
@@ -597,7 +597,7 @@
|
| |
def _write_license(files_by_license, filename):
|
| |
''' Dump files_by_license to filename. '''
|
| |
with open(filename, 'w') as f:
|
| |
- for license_ in sorted(files_by_license.iterkeys()):
|
| |
+ for license_ in sorted(files_by_license.keys()):
|
| |
f.write('\n' + license_ + '\n')
|
| |
f.write('-' * len(license_) + '\n')
|
| |
for path in sorted(files_by_license[license_]):
|
| |
@@ -642,7 +642,7 @@
|
| |
license_ = license_.strip()
|
| |
if not license_is_valid(license_):
|
| |
license_ = self.unknown_license
|
| |
- if license_ not in files_by_license.iterkeys():
|
| |
+ if license_ not in files_by_license.keys():
|
| |
files_by_license[license_] = []
|
| |
files_by_license[license_].append(file_)
|
| |
return files_by_license
|
| |
@@ -654,7 +654,7 @@
|
| |
if os.path.exists(source_dir):
|
| |
cmd = 'licensecheck -r ' + source_dir
|
| |
try:
|
| |
- out = check_output(cmd, shell=True)
|
| |
+ out = check_output(cmd, shell=True, universal_newlines=True)
|
| |
except (OSError, CalledProcessError) as err:
|
| |
self.set_passed(self.PENDING,
|
| |
"Cannot run licensecheck: " + str(err))
|
| |
@@ -672,7 +672,7 @@
|
| |
msg += ' Please check the source files for licenses manually.'
|
| |
else:
|
| |
msg += ' Licenses found: "' \
|
| |
- + '", "'.join(files_by_license.iterkeys()) + '".'
|
| |
+ + '", "'.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])
|
| |
@@ -720,9 +720,8 @@
|
| |
'COPYRIGHT', 'copyright']:
|
| |
pattern = '*' + potentialfile + '*'
|
| |
licenses.extend(self.rpms.find_all(pattern))
|
| |
- licenses = filter(lambda l: not self.rpms.find(l + '/*'),
|
| |
- licenses)
|
| |
- licenses = map(lambda f: f.split('/')[-1], licenses)
|
| |
+ licenses = [l.split('/')[-1] for l in licenses
|
| |
+ if not self.rpms.find(l + '/*')]
|
| |
if licenses == []:
|
| |
self.set_passed(self.PENDING)
|
| |
return
|
| |
@@ -732,19 +731,19 @@
|
| |
for pkg in self.spec.packages:
|
| |
nvr = self.spec.get_package_nvr(pkg)
|
| |
rpm_path = Mock.get_package_rpm_path(nvr)
|
| |
- cmd = 'rpm -qp%s %s' % (self._license_flag, rpm_path)
|
| |
- doclist = check_output(cmd.split())
|
| |
+ 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 = map(lambda f: f.split('/')[-1], flagged_files)
|
| |
+ flagged_files = [f.split('/')[-1] for f in flagged_files]
|
| |
|
| |
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
|
| |
- qpL_list = check_output(cmd.split())
|
| |
+ qpL_list = check_output(cmd.split(), universal_newlines=True)
|
| |
qpL_files.extend(qpL_list.split('\n'))
|
| |
- qpL_files = map(lambda f: f.split('/')[-1], qpL_files)
|
| |
+ 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:
|
| |
@@ -871,7 +870,7 @@
|
| |
self.type = 'MUST'
|
| |
|
| |
def is_applicable(self):
|
| |
- license_ = self.spec.expand_tag('License').lower().split()
|
| |
+ license_ = self.spec.expand_tag('License').decode('utf-8').lower().split()
|
| |
return 'and' in license_ or 'or' in license_
|
| |
|
| |
|
| |
@@ -902,7 +901,7 @@
|
| |
if passed:
|
| |
self.set_passed(passed)
|
| |
else:
|
| |
- self.set_passed(passed, '%s\n%s' % (self.spec.name, output))
|
| |
+ self.set_passed(passed, '{}\n{}'.format(self.spec.name, output))
|
| |
|
| |
|
| |
class CheckNaming(GenericCheckBase):
|
| |
@@ -1112,7 +1111,7 @@
|
| |
items = []
|
| |
for d in owners_by_dir:
|
| |
owners = ', '.join(owners_by_dir[d])
|
| |
- items.append("{0}({1})".format(d, owners))
|
| |
+ items.append("{}({})".format(d, owners))
|
| |
return "Dirs in package are owned also by: " + \
|
| |
', '.join(items)
|
| |
|
| |
@@ -1211,10 +1210,10 @@
|
| |
self.log.warn(
|
| |
"Cannot extract local source: %s", s.filename)
|
| |
return(False, None)
|
| |
- cmd = '/usr/bin/diff -U2 -r %s %s' % (upstream, local)
|
| |
+ 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)
|
| |
+ 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)
|
| |
@@ -1238,9 +1237,9 @@
|
| |
local = self.srpm.check_source_checksum(source.filename)
|
| |
upstream = source.check_source_checksum()
|
| |
text += source.url + ' :\n'
|
| |
- text += ' CHECKSUM({0}) this package : {1}\n'.\
|
| |
+ text += ' CHECKSUM({}) this package : {}\n'.\
|
| |
format(Settings.checksum.upper(), local)
|
| |
- text += ' CHECKSUM({0}) upstream package : {1}\n'.\
|
| |
+ text += ' CHECKSUM({}) upstream package : {}\n'.\
|
| |
format(Settings.checksum.upper(), upstream)
|
| |
if local != upstream:
|
| |
all_sources_passed = False
|
| |
@@ -1871,8 +1870,8 @@
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- systemd_post_re = re.compile(re.escape(rpm.expandMacro('%systemd_post .*.service')).replace('\.\*', '.*')[2:-4], re.M)
|
| |
- systemd_preun_re = re.compile(re.escape(rpm.expandMacro('%systemd_preun .*.service')).replace('\.\*', '.*')[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):
|
| |
using.append(pkg)
|
| |
@@ -1904,8 +1903,8 @@
|
| |
def run(self):
|
| |
using = []
|
| |
failed = False
|
| |
- systemd_user_post_re = re.compile(re.escape(rpm.expandMacro('%systemd_user_post .*.service')).replace('\.\*', '.*')[2:], re.M)
|
| |
- systemd_user_preun_re = re.compile(re.escape(rpm.expandMacro('%systemd_user_preun .*.service')).replace('\.\*', '.*')[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):
|
| |
using.append(pkg)
|
| |