handle %license
[platform/upstream/rpmlint.git] / ConfigCheck.py
1 # -*- coding: utf-8 -*-
2 #############################################################################
3 # File          : ConfigCheck.py
4 # Package       : rpmlint
5 # Author        : Frederic Lepied
6 # Created on    : Sun Oct  3 21:48:20 1999
7 # Version       : $Id: ConfigCheck.py 1774 2010-04-20 20:07:10Z scop $
8 # Purpose       :
9 #############################################################################
10
11 from Filter import addDetails, printError, printWarning
12 import AbstractCheck
13
14
15 class ConfigCheck(AbstractCheck.AbstractCheck):
16
17     def __init__(self):
18         AbstractCheck.AbstractCheck.__init__(self, "ConfigCheck")
19
20     def check(self, pkg):
21         # Check only binary package
22         if pkg.isSource():
23             return
24
25         config_files = pkg.configFiles()
26         noreplace_files = pkg.noreplaceFiles()
27
28         for c in config_files:
29             if c.startswith("/var/lib/games/"):
30                 printError(pkg, "score-file-must-not-be-conffile", c)
31             elif not c.startswith("/etc/") and not c.startswith("/var/"):
32                 printWarning(pkg, "non-etc-or-var-file-marked-as-conffile", c)
33
34             if c not in noreplace_files:
35                 printWarning(pkg, "conffile-without-noreplace-flag", c)
36
37 # Create an object to enable the auto registration of the test
38 check = ConfigCheck()
39
40 # Add information about checks
41 addDetails(
42 'score-file-must-not-be-conffile',
43 """A file in /var/lib/games/ is a configuration file. Store your conf
44 files in /etc instead.""",
45
46 'non-etc-or-var-file-marked-as-conffile',
47 """A file not in /etc or /var is marked as being a configuration file.
48 Please put your conf files in /etc or /var.""",
49
50 'conffile-without-noreplace-flag',
51 """A configuration file is stored in your package without the noreplace flag.
52 A way to resolve this is to put the following in your SPEC file:
53
54 %config(noreplace) /etc/your_config_file_here
55 """,
56
57 )
58
59 # ConfigCheck.py ends here
60
61 # Local variables:
62 # indent-tabs-mode: nil
63 # py-indent-offset: 4
64 # End:
65 # ex: ts=4 sw=4 et