2009-01-24 05:18:08 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2000-02-10 19:58:43 +08:00
|
|
|
#############################################################################
|
2005-11-28 05:49:15 +08:00
|
|
|
# File : DistributionCheck.py
|
|
|
|
# Package : rpmlint
|
|
|
|
# Author : Frederic Lepied
|
|
|
|
# Created on : Tue Sep 28 00:05:33 1999
|
|
|
|
# Purpose : check the Distribution specificities in a binary rpm package.
|
2000-02-10 19:58:43 +08:00
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
import re
|
2009-01-27 06:54:05 +08:00
|
|
|
|
|
|
|
import rpm
|
|
|
|
|
2009-01-28 06:44:45 +08:00
|
|
|
from Filter import addDetails, printWarning
|
2009-01-27 06:54:05 +08:00
|
|
|
import AbstractCheck
|
2000-02-10 19:58:43 +08:00
|
|
|
import Config
|
|
|
|
|
2009-01-27 06:54:05 +08:00
|
|
|
|
2008-10-30 07:01:44 +08:00
|
|
|
man_regex = re.compile("/man(?:\d[px]?|n)/")
|
|
|
|
info_regex = re.compile("(/usr/share|/usr)/info/")
|
|
|
|
vendor = Config.getOption("Vendor")
|
|
|
|
distribution = Config.getOption("Distribution")
|
2010-01-21 04:10:01 +08:00
|
|
|
compress_ext = Config.getOption("CompressExtension", "bz2")
|
2001-07-16 01:01:17 +08:00
|
|
|
|
2000-02-10 19:58:43 +08:00
|
|
|
|
2014-05-30 02:50:58 +08:00
|
|
|
class DistributionCheck(AbstractCheck.AbstractCheck):
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2000-02-10 19:58:43 +08:00
|
|
|
def __init__(self):
|
2005-11-28 05:49:15 +08:00
|
|
|
AbstractCheck.AbstractCheck.__init__(self, "DistributionCheck")
|
2000-02-10 19:58:43 +08:00
|
|
|
|
2014-02-14 20:01:06 +08:00
|
|
|
def check_binary(self, pkg):
|
2006-04-01 00:48:34 +08:00
|
|
|
if vendor and pkg[rpm.RPMTAG_VENDOR] != vendor:
|
2005-11-28 05:49:15 +08:00
|
|
|
printWarning(pkg, "invalid-vendor", pkg[rpm.RPMTAG_VENDOR])
|
|
|
|
|
2006-04-01 00:48:34 +08:00
|
|
|
if distribution and pkg[rpm.RPMTAG_DISTRIBUTION] != distribution:
|
2010-02-21 19:28:42 +08:00
|
|
|
printWarning(pkg, "invalid-distribution",
|
|
|
|
pkg[rpm.RPMTAG_DISTRIBUTION])
|
2000-02-10 19:58:43 +08:00
|
|
|
|
2010-01-21 04:10:01 +08:00
|
|
|
if compress_ext:
|
|
|
|
for fname in pkg.files():
|
|
|
|
if man_regex.search(fname):
|
|
|
|
if not fname.endswith(compress_ext):
|
|
|
|
printWarning(pkg, 'manpage-not-compressed',
|
|
|
|
compress_ext, fname)
|
|
|
|
elif info_regex.search(fname) and \
|
|
|
|
not fname.endswith("/info/dir"):
|
|
|
|
if not fname.endswith(compress_ext):
|
|
|
|
printWarning(pkg, 'infopage-not-compressed',
|
|
|
|
compress_ext, fname)
|
|
|
|
|
2000-02-10 19:58:43 +08:00
|
|
|
|
|
|
|
# Create an object to enable the auto registration of the test
|
2008-10-30 07:01:44 +08:00
|
|
|
check = DistributionCheck()
|
2000-02-10 19:58:43 +08:00
|
|
|
|
2009-01-31 06:01:50 +08:00
|
|
|
addDetails(
|
2001-06-19 06:43:23 +08:00
|
|
|
'invalid-vendor',
|
2010-02-21 19:28:42 +08:00
|
|
|
'''In the "%s" distribution, vendor should be "%s".''' % (distribution, vendor),
|
2001-06-19 06:43:23 +08:00
|
|
|
|
|
|
|
'invalid-distribution',
|
2001-07-16 01:01:17 +08:00
|
|
|
'The distribution value should be "' + distribution + '".',
|
2006-04-01 16:09:17 +08:00
|
|
|
|
2010-01-21 04:10:01 +08:00
|
|
|
'manpage-not-compressed',
|
|
|
|
'''This manual page is not compressed with the %s compression method
|
|
|
|
(does not have the %s extension). If the compression does not happen
|
|
|
|
automatically when the package is rebuilt, make sure that you have the
|
2009-06-18 05:05:22 +08:00
|
|
|
appropriate rpm helper and/or config packages for your target distribution
|
|
|
|
installed and try rebuilding again; if it still does not happen automatically,
|
2014-05-30 02:50:58 +08:00
|
|
|
you can compress this file in the %%install section of the spec file.'''
|
2010-01-21 04:10:01 +08:00
|
|
|
% (compress_ext, compress_ext),
|
|
|
|
|
|
|
|
'infopage-not-compressed',
|
|
|
|
'''This info page is not compressed with the %s compression method
|
|
|
|
(does not have the %s extension). If the compression does not happen
|
2009-06-18 05:05:22 +08:00
|
|
|
automatically when the package is rebuilt, make sure that you have the
|
|
|
|
appropriate rpm helper and/or config packages for your target distribution
|
|
|
|
installed and try rebuilding again; if it still does not happen automatically,
|
2014-05-30 02:50:58 +08:00
|
|
|
you can compress this file in the %%install section of the spec file.'''
|
2010-01-21 04:10:01 +08:00
|
|
|
% (compress_ext, compress_ext),
|
|
|
|
)
|
2009-06-18 05:05:22 +08:00
|
|
|
|
2000-02-10 19:58:43 +08:00
|
|
|
# DistributionCheck.py ends here
|
2006-04-01 16:09:17 +08:00
|
|
|
|
|
|
|
# Local variables:
|
|
|
|
# indent-tabs-mode: nil
|
|
|
|
# py-indent-offset: 4
|
|
|
|
# End:
|
|
|
|
# ex: ts=4 sw=4 et
|