2000-02-10 19:58:43 +08:00
|
|
|
#############################################################################
|
|
|
|
# File : DistributionCheck.py
|
|
|
|
# Package : rpmlint
|
|
|
|
# Author : Frederic Lepied
|
|
|
|
# Created on : Tue Sep 28 00:05:33 1999
|
|
|
|
# Version : $Id$
|
|
|
|
# Purpose : check the Distribution specificities in a binary rpm package.
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
from Filter import *
|
|
|
|
import AbstractCheck
|
|
|
|
import rpm
|
|
|
|
import re
|
|
|
|
import Config
|
|
|
|
|
2001-07-16 01:01:17 +08:00
|
|
|
man_regex=re.compile("/man./")
|
2001-10-03 01:55:51 +08:00
|
|
|
info_regex=re.compile("(/usr/share|/usr)/info/")
|
2001-07-16 01:01:17 +08:00
|
|
|
info_dir_regex=re.compile("/info/dir$")
|
|
|
|
bz2_regex=re.compile(".bz2$")
|
|
|
|
gz_regex=re.compile(".gz$")
|
|
|
|
vendor=Config.getOption("Vendor", "MandrakeSoft")
|
|
|
|
distribution=Config.getOption("Distribution", "Mandrake Linux")
|
|
|
|
use_bzip2=Config.getOption("UseBzip2", 1)
|
|
|
|
|
2000-02-10 19:58:43 +08:00
|
|
|
class DistributionCheck(AbstractCheck.AbstractCheck):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
AbstractCheck.AbstractCheck.__init__(self, "DistributionCheck")
|
|
|
|
|
2001-11-15 00:34:02 +08:00
|
|
|
def check(self, pkg):
|
2000-02-10 19:58:43 +08:00
|
|
|
# Check only binary package
|
|
|
|
if pkg.isSource():
|
|
|
|
return
|
|
|
|
|
2001-07-16 01:01:17 +08:00
|
|
|
if pkg[rpm.RPMTAG_VENDOR] != vendor:
|
2000-02-10 19:58:43 +08:00
|
|
|
printWarning(pkg, "invalid-vendor", pkg[rpm.RPMTAG_VENDOR])
|
|
|
|
|
2001-07-16 01:01:17 +08:00
|
|
|
if pkg[rpm.RPMTAG_DISTRIBUTION] != distribution:
|
2000-02-10 19:58:43 +08:00
|
|
|
printWarning(pkg, "invalid-distribution", pkg[rpm.RPMTAG_DISTRIBUTION])
|
|
|
|
|
|
|
|
# Check the listing of files
|
|
|
|
list=pkg[rpm.RPMTAG_FILENAMES]
|
|
|
|
|
|
|
|
if list:
|
|
|
|
for f in list:
|
2001-07-16 01:01:17 +08:00
|
|
|
if man_regex.search(f):
|
|
|
|
if use_bzip2:
|
|
|
|
if not bz2_regex.search(f):
|
2000-02-10 19:58:43 +08:00
|
|
|
printWarning(pkg, "manpage-not-bzipped", f)
|
2001-07-16 01:01:17 +08:00
|
|
|
elif not gz_regex.search(f):
|
2000-02-10 19:58:43 +08:00
|
|
|
printWarning(pkg, "manpage-not-gzipped", f)
|
2001-07-16 01:01:17 +08:00
|
|
|
if info_regex.search(f) and not info_dir_regex.search(f):
|
|
|
|
if use_bzip2:
|
|
|
|
if not bz2_regex.search(f):
|
2000-02-10 19:58:43 +08:00
|
|
|
printWarning(pkg, "infopage-not-bzipped", f)
|
2001-07-16 01:01:17 +08:00
|
|
|
elif not gz_regex.search(f):
|
2000-02-10 19:58:43 +08:00
|
|
|
printWarning(pkg, "infopage-not-gzipped", f)
|
|
|
|
|
|
|
|
# Create an object to enable the auto registration of the test
|
|
|
|
check=DistributionCheck()
|
|
|
|
|
2001-06-19 06:43:23 +08:00
|
|
|
if Config.info:
|
|
|
|
addDetails(
|
|
|
|
'invalid-vendor',
|
2001-07-16 01:01:17 +08:00
|
|
|
'In the ' + distribution + ' distribution, the vendor should be "' + 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 + '".',
|
2001-06-19 06:43:23 +08:00
|
|
|
|
|
|
|
'manpage-not-bzipped',
|
2001-07-16 01:01:17 +08:00
|
|
|
'''Manual Pages are not under the .bz2 extension/format. Please
|
|
|
|
run bzip2 <man page file> to bzip it in the %install section and
|
|
|
|
after, build the package. You can also use the spec-helper package
|
|
|
|
that automatizes this task.''',
|
2001-06-19 06:43:23 +08:00
|
|
|
|
|
|
|
'manpage-not-gzipped',
|
2001-07-16 01:01:17 +08:00
|
|
|
'''Manual Pages are not under the .gz extension/format. Please
|
|
|
|
run gzip <man page file> to gzip it and after, build the package.''',
|
2001-06-19 06:43:23 +08:00
|
|
|
|
|
|
|
'infopage-not-bzipped',
|
2001-07-16 01:01:17 +08:00
|
|
|
'''An info page is not under the .bz2 extension/format. Please
|
|
|
|
run bzip2 <info page file> to bzip it and after, build the package.
|
|
|
|
You can also use the spec-helper package that automatizes this task.''',
|
2001-06-19 06:43:23 +08:00
|
|
|
|
|
|
|
'infopage-not-gzipped',
|
2001-07-16 01:01:17 +08:00
|
|
|
'''An info page is not under the .gz extension/format. Please
|
|
|
|
run gzip <info page file> to gzip it and after, build the package.''',
|
2001-06-19 06:43:23 +08:00
|
|
|
|
|
|
|
)
|
2000-02-10 19:58:43 +08:00
|
|
|
# DistributionCheck.py ends here
|