2009-01-24 05:18:08 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-05-30 02:50:58 +08:00
|
|
|
#############################################################################
|
2005-04-16 04:01:46 +08:00
|
|
|
# Project : Mandriva Linux
|
2001-02-02 14:44:07 +08:00
|
|
|
# Module : rpmlint
|
|
|
|
# File : LSBCheck.py
|
|
|
|
# Author : Frederic Lepied
|
|
|
|
# Created On : Tue Jan 30 14:44:37 2001
|
|
|
|
# Purpose : LSB non compliance checks
|
2014-05-30 02:50:58 +08:00
|
|
|
#############################################################################
|
2001-02-02 14:44:07 +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, printError
|
2009-01-27 06:54:05 +08:00
|
|
|
import AbstractCheck
|
|
|
|
|
|
|
|
|
2008-10-30 07:01:44 +08:00
|
|
|
version_regex = re.compile('^[a-zA-Z0-9.+]+$')
|
|
|
|
name_regex = re.compile('^[a-z0-9.+-]+$')
|
2001-02-02 14:44:07 +08:00
|
|
|
|
2014-05-30 02:50:58 +08:00
|
|
|
|
2001-02-02 14:44:07 +08:00
|
|
|
class LSBCheck(AbstractCheck.AbstractCheck):
|
2005-11-28 05:49:15 +08:00
|
|
|
|
2001-02-02 14:44:07 +08:00
|
|
|
def __init__(self):
|
2005-11-28 05:49:15 +08:00
|
|
|
AbstractCheck.AbstractCheck.__init__(self, "LSBCheck")
|
2001-02-02 14:44:07 +08:00
|
|
|
|
2001-11-15 00:34:02 +08:00
|
|
|
def check(self, pkg):
|
2001-02-02 14:44:07 +08:00
|
|
|
|
2008-10-30 07:01:44 +08:00
|
|
|
name = pkg.name
|
2005-11-28 05:49:15 +08:00
|
|
|
if name and not name_regex.search(name):
|
|
|
|
printError(pkg, 'non-lsb-compliant-package-name', name)
|
2001-02-02 14:44:07 +08:00
|
|
|
|
2008-10-30 07:01:44 +08:00
|
|
|
version = pkg[rpm.RPMTAG_VERSION]
|
2014-02-28 04:08:30 +08:00
|
|
|
if version and not version_regex.search(version):
|
2014-02-09 04:34:50 +08:00
|
|
|
printError(pkg, 'non-lsb-compliant-version', version)
|
2001-02-02 14:44:07 +08:00
|
|
|
|
2008-10-30 07:01:44 +08:00
|
|
|
release = pkg[rpm.RPMTAG_RELEASE]
|
2014-02-28 04:08:30 +08:00
|
|
|
if release and not version_regex.search(release):
|
2014-02-09 04:34:50 +08:00
|
|
|
printError(pkg, 'non-lsb-compliant-release', release)
|
2001-02-02 14:44:07 +08:00
|
|
|
|
|
|
|
# Create an object to enable the auto registration of the test
|
2008-10-30 07:01:44 +08:00
|
|
|
check = LSBCheck()
|
2001-02-02 14:44:07 +08:00
|
|
|
|
2009-01-31 06:01:50 +08:00
|
|
|
addDetails(
|
2001-06-19 08:16:19 +08:00
|
|
|
'non-lsb-compliant-package-name',
|
2003-12-22 19:23:54 +08:00
|
|
|
"""Your package name contains an illegal character. Use only
|
|
|
|
alphanumeric symbols in your package name.""",
|
2001-06-19 08:16:19 +08:00
|
|
|
|
|
|
|
'non-lsb-compliant-version',
|
2003-12-22 19:23:54 +08:00
|
|
|
"""Your version number contains an illegal character. Use only
|
|
|
|
lowercase letters and/or numbers.""",
|
2001-06-19 08:16:19 +08:00
|
|
|
|
|
|
|
'non-lsb-compliant-release',
|
2003-12-22 19:23:54 +08:00
|
|
|
"""Your version number contains an illegal character. Use only
|
|
|
|
lowercase letters and/or numbers.""",
|
2001-06-19 08:16:19 +08:00
|
|
|
|
|
|
|
)
|
2006-04-01 16:09:17 +08:00
|
|
|
|
2001-02-02 14:44:07 +08:00
|
|
|
# LSBCheck.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
|