Do not reset list of default checks to run if Config.addCheck() is used in config files.

git-svn-id: svn+ssh://rpmlint.zarb.org/home/projects/rpmlint/svn/trunk@1511 9bc8b190-ac0f-0410-8968-dc7d1f502856
This commit is contained in:
Ville Skyttä 2009-01-26 18:37:24 +00:00
parent b9838aafcf
commit e5800a2466
3 changed files with 19 additions and 8 deletions

View File

@ -9,13 +9,11 @@
#############################################################################
class AbstractCheck:
check_names_seen = []
checks = []
known_checks = {}
def __init__(self, name):
if name not in AbstractCheck.check_names_seen:
AbstractCheck.checks.append(self)
AbstractCheck.check_names_seen.append(name)
if not AbstractCheck.known_checks.get(name):
AbstractCheck.known_checks[name] = self
self.name = name
def check(self, pkg):

View File

@ -48,6 +48,7 @@ no_exception = 0
# handle the list of checks to load
_checks = []
_checks.extend(DEFAULT_CHECKS)
def addCheck(check):
global _checks

View File

@ -189,14 +189,19 @@ def runChecks(pkg):
if verbose:
printInfo(pkg, 'checking')
for c in AbstractCheck.AbstractCheck.checks:
c.check(pkg)
for name in Config.allChecks():
check = AbstractCheck.AbstractCheck.known_checks.get(name)
if check:
check.check(pkg)
else:
sys.stderr.write('(none): W: unknown check %s, skipping\n' % name)
pkg.cleanup()
#############################################################################
#
#############################################################################
sys.argv[0] = os.path.basename(sys.argv[0])
# parse options
@ -221,6 +226,7 @@ except getopt.error, e:
# process options
checkdir = '/usr/share/rpmlint'
checks = []
verbose = 0
extract_dir = None
allpkgs = 0
@ -244,7 +250,7 @@ del f
# process command line options
for o in opt:
if o[0] == '-c' or o[0] == '--check':
Config.addCheck(o[1])
checks.append(o[1])
elif o[0] == '-i' or o[0] == '--info':
Config.info = 1
elif o[0] == '-I':
@ -284,6 +290,8 @@ if not extract_dir:
if info_error:
Config.info = 1
for c in checks:
Config.addCheck(c)
for c in Config.allChecks():
loadCheck(c)
for e in info_error.split(','):
@ -297,6 +305,10 @@ if args == [] and not allpkgs:
sys.exit(1)
if __name__ == '__main__':
if checks:
Config.resetChecks()
for check in checks:
Config.addCheck(check)
main()
# rpmlint.py ends here