xf86-video-omapfb: pandora: handle cycle/forcer events better
[openembedded.git] / classes / oelint.bbclass
1 addtask lint before do_fetch
2 do_lint[nostamp] = "1"
3 python do_lint() {
4         def testVar(var, explain=None):
5                 try:
6                         s = d[var]
7                         return s["content"]
8                 except KeyError:
9                         bb.error("%s is not set" % var)
10                         if explain: bb.note(explain)
11                         return None
12
13
14         ##############################
15         # Test that DESCRIPTION exists
16         #
17         testVar("DESCRIPTION")
18
19
20         ##############################
21         # Test that HOMEPAGE exists
22         #
23         s = testVar("HOMEPAGE")
24         if s=="unknown":
25                 bb.error("HOMEPAGE is not set")
26         elif not s.startswith("http://"):
27                 bb.error("HOMEPAGE doesn't start with http://")
28
29
30
31         ##############################
32         # Test for valid LICENSE
33         #
34         valid_licenses = {
35                 "GPL-2"         : "GPLv2",
36                 "GPL LGPL FDL"  : True,
37                 "GPL PSF"       : True,
38                 "GPL/QPL"       : True,
39                 "GPL"           : True,
40                 "GPLv2"         : True,
41                 "IBM"           : True,
42                 "LGPL GPL"      : True,
43                 "LGPL"          : True,
44                 "MIT"           : True,
45                 "OSL"           : True,
46                 "Perl"          : True,
47                 "Public Domain" : True,
48                 "QPL"           : "GPL/QPL",
49                 }
50         s = testVar("LICENSE")
51         if s=="unknown":
52                 bb.error("LICENSE is not set")
53         elif s.startswith("Vendor"):
54                 pass
55         else:
56                 try:
57                         newlic = valid_licenses[s]
58                         if newlic == False:
59                                 bb.note("LICENSE '%s' is not recommended" % s)
60                         elif newlic != True:
61                                 bb.note("LICENSE '%s' is not recommended, better use '%s'" % (s, newsect))
62                 except:
63                         bb.note("LICENSE '%s' is not recommended" % s)
64
65
66         ##############################
67         # Test for valid MAINTAINER
68         #
69         s = testVar("MAINTAINER")
70         if s=="OpenEmbedded Team <openembedded-devel@openembedded.org>":
71                 bb.error("explicit MAINTAINER is missing, using default")
72         elif s and s.find("@") == -1:
73                 bb.error("You forgot to put an e-mail address into MAINTAINER")
74
75
76         ##############################
77         # Test for valid SECTION
78         #
79         # if Correct section: True      section name is valid
80         #                     False     section name is invalid, no suggestion
81         #                     string    section name is invalid, better name suggested
82         #
83         valid_sections = {
84                 # Current Section         Correct section
85                 "apps"                  : True,
86                 "audio"                 : True,
87                 "base"                  : True,
88                 "console/games"         : True,
89                 "console/net"           : "console/network",
90                 "console/network"       : True,
91                 "console/utils"         : True,
92                 "devel"                 : True,
93                 "developing"            : "devel",
94                 "devel/python"          : True,
95                 "fonts"                 : True,
96                 "games"                 : True,
97                 "games/libs"            : True,
98                 "gnome/base"            : True,
99                 "gnome/libs"            : True,
100                 "gpe"                   : True,
101                 "gpe/libs"              : True,
102                 "gui"                   : False,
103                 "libc"                  : "libs",
104                 "libs"                  : True,
105                 "libs/net"              : True,
106                 "multimedia"            : True,
107                 "net"                   : "network",
108                 "NET"                   : "network",
109                 "network"               : True,
110                 "opie/applets"          : True,
111                 "opie/applications"     : True,
112                 "opie/base"             : True,
113                 "opie/codecs"           : True,
114                 "opie/decorations"      : True,
115                 "opie/fontfactories"    : True,
116                 "opie/fonts"            : True,
117                 "opie/games"            : True,
118                 "opie/help"             : True,
119                 "opie/inputmethods"     : True,
120                 "opie/libs"             : True,
121                 "opie/multimedia"       : True,
122                 "opie/pim"              : True,
123                 "opie/setting"          : "opie/settings",
124                 "opie/settings"         : True,
125                 "opie/Shell"            : False,
126                 "opie/styles"           : True,
127                 "opie/today"            : True,
128                 "scientific"            : True,
129                 "utils"                 : True,
130                 "x11"                   : True,
131                 "x11/libs"              : True,
132                 "x11/wm"                : True,
133                 }
134         s = testVar("SECTION")
135         if s:
136                 try:
137                         newsect = valid_sections[s]
138                         if newsect == False:
139                                 bb.note("SECTION '%s' is not recommended" % s)
140                         elif newsect != True:
141                                 bb.note("SECTION '%s' is not recommended, better use '%s'" % (s, newsect))
142                 except:
143                         bb.note("SECTION '%s' is not recommended" % s)
144
145                 if not s.islower():
146                         bb.error("SECTION should only use lower case")
147
148
149
150         
151         ##############################
152         # Test for valid PRIORITY
153         #
154         valid_priorities = {
155                 "standard"              : True,
156                 "required"              : True,
157                 "optional"              : True,
158                 "extra"                 : True,
159                 }
160         s = testVar("PRIORITY")
161         if s:
162                 try:
163                         newprio = valid_priorities[s]
164                         if newprio == False:
165                                 bb.note("PRIORITY '%s' is not recommended" % s)
166                         elif newprio != True:
167                                 bb.note("PRIORITY '%s' is not recommended, better use '%s'" % (s, newprio))
168                 except:
169                         bb.note("PRIORITY '%s' is not recommended" % s)
170
171                 if not s.islower():
172                         bb.error("PRIORITY should only use lower case")
173         
174 }