1 # -*- coding: utf-8 -*-
2 #############################################################################
3 # File : DistributionCheck.py
5 # Author : Frederic Lepied
6 # Created on : Tue Sep 28 00:05:33 1999
7 # Version : $Id: DistributionCheck.py 1732 2010-02-21 11:28:42Z scop $
8 # Purpose : check the Distribution specificities in a binary rpm package.
9 #############################################################################
15 from Filter import addDetails, printWarning
20 man_regex = re.compile("/man(?:\d[px]?|n)/")
21 info_regex = re.compile("(/usr/share|/usr)/info/")
22 vendor = Config.getOption("Vendor")
23 distribution = Config.getOption("Distribution")
24 compress_ext = Config.getOption("CompressExtension", "bz2")
26 class DistributionCheck(AbstractCheck.AbstractCheck):
30 AbstractCheck.AbstractCheck.__init__(self, "DistributionCheck")
33 # Check only binary package
37 if vendor and pkg[rpm.RPMTAG_VENDOR] != vendor:
38 printWarning(pkg, "invalid-vendor", pkg[rpm.RPMTAG_VENDOR])
40 if distribution and pkg[rpm.RPMTAG_DISTRIBUTION] != distribution:
41 printWarning(pkg, "invalid-distribution",
42 pkg[rpm.RPMTAG_DISTRIBUTION])
45 for fname in pkg.files():
46 if man_regex.search(fname):
47 if not fname.endswith(compress_ext):
48 printWarning(pkg, 'manpage-not-compressed',
50 elif info_regex.search(fname) and \
51 not fname.endswith("/info/dir"):
52 if not fname.endswith(compress_ext):
53 printWarning(pkg, 'infopage-not-compressed',
57 # Create an object to enable the auto registration of the test
58 check = DistributionCheck()
62 '''In the "%s" distribution, vendor should be "%s".''' % (distribution, vendor),
64 'invalid-distribution',
65 'The distribution value should be "' + distribution + '".',
67 'manpage-not-compressed',
68 '''This manual page is not compressed with the %s compression method
69 (does not have the %s extension). If the compression does not happen
70 automatically when the package is rebuilt, make sure that you have the
71 appropriate rpm helper and/or config packages for your target distribution
72 installed and try rebuilding again; if it still does not happen automatically,
73 you can compress this file in the %%install section of the spec file.''' \
74 % (compress_ext, compress_ext),
76 'infopage-not-compressed',
77 '''This info page is not compressed with the %s compression method
78 (does not have the %s extension). If the compression does not happen
79 automatically when the package is rebuilt, make sure that you have the
80 appropriate rpm helper and/or config packages for your target distribution
81 installed and try rebuilding again; if it still does not happen automatically,
82 you can compress this file in the %%install section of the spec file.''' \
83 % (compress_ext, compress_ext),
86 # DistributionCheck.py ends here
89 # indent-tabs-mode: nil