本文整理汇总了Python中Filter.addDetails方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.addDetails方法的具体用法?Python Filter.addDetails怎么用?Python Filter.addDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter.addDetails方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ErlangCheck
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
class ErlangCheck(AbstractCheck.AbstractFilesCheck):
def __init__(self):
AbstractCheck.AbstractFilesCheck.__init__(
self, "ErlangCheck", r'.*?\.beam$')
build_dir = rpm.expandMacro("%_builddir")
self.source_re = re.compile(build_dir)
def check_file(self, pkg, filename):
beam = BeamFile(pkg.files()[filename].path)
if 'debug_info' not in beam.compileinfo['options']:
Filter.printWarning(
pkg, "beam-compiled-without-debug_info", filename)
if not self.source_re.match(Pkg.b2s(beam.compileinfo['source'].value)):
Filter.printWarning(
pkg, "beam-was-not-recompiled", filename,
beam.compileinfo['source'].value)
check = ErlangCheck()
Filter.addDetails(
'beam-compiled-without-debug_info',
""""Your beam file indicates that it doesn't contain debug_info.
Please, make sure that you compile with +debug_info.""",
'beam-was-not-recompiled',
"""It seems that your beam file was not compiled by you, but was
just copied in binary form to destination. Please, make sure
that you really compile it from the sources.""",
)
示例2: lang_ignore_pkg
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
not lang_ignore_pkg(pkg.name):
Filter.printWarning(pkg, "package-with-huge-translation",
("%3d%%" % (lang_size * 100 / complete_size)))
for f in pkg.docFiles():
mode = files[f].mode
if not stat.S_ISREG(mode) or not mode & 0o111:
continue
for ext in ['txt', 'gif', 'jpg', 'html',
'pdf', 'ps', 'pdf.gz', 'ps.gz']:
if f.endswith("." + ext):
Filter.printError(pkg, 'executable-docs', f)
for name in ['README', 'NEWS', 'COPYING', 'AUTHORS']:
if f.endswith("/" + name):
Filter.printError(pkg, 'executable-docs', f)
check = ExecDocsCheck()
Filter.addDetails(
'executable-docs',
"Documentation should not be executable.",
'package-with-huge-docs',
"""More than half the size of your package is documentation.
Consider splitting it into a -doc subpackage.""",
'package-with-huge-translation',
"""More than half the size of your package is language-specific.
Consider splitting it into a -lang subpackage."""
)
示例3: CommonFilesCheck
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
if f[:-3] in files:
Filter.printError(pkg, "makefile-junk", f[:-3])
check = CommonFilesCheck()
if Config.info:
Filter.addDetails(
'generic-build-instructions',
"""Your package contains a file that contains the FSF generic
configure/make/make install instructions. Those are useless
for a binary package. Consider removing it to save 3kb of rpm size.""",
'duplicated-file-gpl-v3',
"""Your package contains a file that contains the FSF GPLv3
license. If you really have to ship it, consider symlinking it
from the licenses package.""",
'duplicated-file-gpl-v2',
"""Your package contains a file that contains the FSF GPLv2
license. If you really have to ship it, consider symlinking it
from the licenses package.""",
'non-linux-readme',
"""Your package contains a file that contains instructions
for non-linux platforms. They're most likely unneccessary bloat,
consider removing them from your package.""",
'makefile-junk',
"""Your package contains makefiles that only make sense in a
source package. Did you package a complete directory from the
tarball by using %doc? Consider removing Makefile* from this
directory at the end of your %install section to reduce bloat."""
)
示例4: check_file
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
def check_file(self, pkg, filename):
if filename.startswith('/usr/lib/debug') or pkg.isSource():
return
if not stat.S_ISREG(pkg.files()[filename].mode):
return
grep_date = pkg.grep(self.istoday, filename)
if len(grep_date):
grep_time = pkg.grep(self.looksliketime, filename)
if len(grep_time):
Filter.printError(pkg, "file-contains-date-and-time", filename)
else:
Filter.printWarning(pkg, "file-contains-current-date",
filename)
check = BuildDateCheck()
if Config.info:
Filter.addDetails(
'file-contains-current-date',
"""Your file contains the current date, this may cause the package
to rebuild in excess.""",
'file-contains-date-and-time',
"""Your file uses __DATE and __TIME__ this causes the package to
rebuild when not needed"""
)
示例5: file
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
if pkg.grep(self.suspicious_dir, filename):
Filter.printError(pkg, "invalid-pkgconfig-file", filename)
pc_file = file(pkg.dirName() + "/" + filename, "r")
for l in pc_file:
if l.startswith('Libs:') and self.wronglib_dir.search(l):
Filter.printError(pkg, 'pkgconfig-invalid-libs-dir',
filename, l)
check = PkgConfigCheck()
if Config.info:
Filter.addDetails(
'invalid-pkgconfig-file',
'''Your .pc file appears to be invalid. Possible causes are:
- it contains traces of $RPM_BUILD_ROOT or $RPM_BUILD_DIR.
- it contains unreplaced macros (@[email protected])
- it references invalid paths (e.g. /home or /tmp)
Please double-check and report false positives.
''',
'pkgconfig-invalid-libs-dir',
''' Your .pc file contains -L/usr/lib or -L/lib and is
built on a lib64 target, or contains references to -L/usr/lib64 or
-L/lib64 and is built for a lib target.
Please remove the wrong library paths from the pc file.'''
)
示例6: BuildRootCheck
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
import re
import rpm
import stat
class BuildRootCheck(AbstractCheck.AbstractFilesCheck):
def __init__(self):
AbstractCheck.AbstractFilesCheck.__init__(self, "CheckBuildRoot", ".*")
t = rpm.expandMacro('%buildroot')
for m in ('name', 'version', 'release', 'NAME', 'VERSION', 'RELEASE'):
t = t.replace("%%{%s}" % (m), r'[\w\!-\.]{1,20}')
self.build_root_re = re.compile(t)
def check_file(self, pkg, filename):
if filename.startswith('/usr/lib/debug') or pkg.isSource():
return
if not stat.S_ISREG(pkg.files()[filename].mode):
return
if len(pkg.grep(self.build_root_re, filename)):
Filter.printError(pkg, "file-contains-buildroot", filename)
check = BuildRootCheck()
if Config.info:
Filter.addDetails(
'file-contains-buildroot',
"Your file contains traces of $RPM_BUILD_ROOT."
)
示例7: get_filestart
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
if ext in magic and magic[ext] != get_filestart(file):
return 1
return 0
class CompressionCheck(AbstractCheck.AbstractCheck):
def __init__(self):
self.map = []
AbstractCheck.AbstractCheck.__init__(self, "CompressionCheck")
def check(self, pkg):
ghosts = pkg.ghostFiles()
for filename in pkg.files():
if filename in ghosts:
continue
if not stat.S_ISREG(pkg.files()[filename].mode):
continue
if wrong_compression(os.path.join(pkg.dirname, filename)):
Filter.printError(pkg, 'files-wrong-compression', filename)
check = CompressionCheck()
if Config.info:
Filter.addDetails(
'files-wrong-compression',
"""Your package has compressed files that are not using the compression indicated by their extension.
You should rename them."""
)
示例8: get_prefix
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import addDetails [as 别名]
for dupe in duplicates:
if partition != get_prefix(dupe):
diff = diff - 1
sum += sizes[f] * diff
if sizes[f] and diff > 0:
Filter.printWarning(pkg, 'files-duplicate', one,
":".join(duplicates))
if sum > 100000:
Filter.printError(pkg, 'files-duplicated-waste', sum)
check = DuplicatesCheck()
if Config.info:
Filter.addDetails(
'files-duplicated-waste',
"""Your package contains duplicated files that are not hard- or symlinks.
You should use the %fdupes macro to link the files to one.""",
'hardlink-across-partition',
"""Your package contains two files that are apparently hardlinked and
that are likely on different partitions. Installation of such an RPM will fail
due to RPM being unable to unpack the hardlink. do not hardlink across
the first two levels of a path, e.g. between /srv/ftp and /srv/www or
/etc and /usr. """,
'hardlink-across-config-files',
"""Your package contains two config files that are apparently hardlinked.
Hardlinking a config file is probably not what you want. Please double
check and report false positives."""
)