summaryrefslogtreecommitdiffstats
path: root/meta/classes/sanity.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
committerRichard Purdie <richard@openedhand.com>2006-07-21 10:10:31 +0000
commitb2f192faabe412adce79534e22efe9fb69ee40e2 (patch)
tree7076c49d4286f8a1733650bd8fbc7161af200d57 /meta/classes/sanity.bbclass
parent2cf0eadf9f730027833af802d7e6c90b44248f80 (diff)
downloadpoky-b2f192faabe412adce79534e22efe9fb69ee40e2.tar.gz
Rename /openembedded/ -> /meta/
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@530 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/sanity.bbclass')
-rw-r--r--meta/classes/sanity.bbclass112
1 files changed, 112 insertions, 0 deletions
diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
new file mode 100644
index 0000000000..a626162ffb
--- /dev/null
+++ b/meta/classes/sanity.bbclass
@@ -0,0 +1,112 @@
1#
2# Sanity check the users setup for common misconfigurations
3#
4
5def raise_sanity_error(msg):
6 import bb
7 bb.fatal(""" Openembedded's config sanity checker detected a potential misconfiguration.
8 Either fix the cause of this error or at your own risk disable the checker (see sanity.conf).
9 Following is the list of potential problems / advisories:
10
11 %s""" % msg)
12
13def check_conf_exists(fn, data):
14 import bb, os
15
16 bbpath = []
17 fn = bb.data.expand(fn, data)
18 vbbpath = bb.data.getVar("BBPATH", data)
19 if vbbpath:
20 bbpath += vbbpath.split(":")
21 for p in bbpath:
22 currname = os.path.join(bb.data.expand(p, data), fn)
23 if os.access(currname, os.R_OK):
24 return True
25 return False
26
27def check_app_exists(app, d):
28 from bb import which, data
29
30 app = data.expand(app, d)
31 path = data.getVar('PATH', d)
32 return len(which(path, app)) != 0
33
34
35def check_sanity(e):
36 from bb import note, error, data, __version__
37 from bb.event import Handled, NotHandled, getName
38 try:
39 from distutils.version import LooseVersion
40 except ImportError:
41 def LooseVersion(v): print "WARNING: sanity.bbclass can't compare versions without python-distutils"; return 1
42 import os
43
44 # Check the bitbake version meets minimum requirements
45 minversion = data.getVar('BB_MIN_VERSION', e.data , True)
46 if not minversion:
47 # Hack: BB_MIN_VERSION hasn't been parsed yet so return
48 # and wait for the next call
49 print "Foo %s" % minversion
50 return
51
52 if (LooseVersion(__version__) < LooseVersion(minversion)):
53 raise_sanity_error('Bitbake version %s is required and version %s was found' % (minversion, __version__))
54
55 # Check TARGET_ARCH is set
56 if data.getVar('TARGET_ARCH', e.data, True) == 'INVALID':
57 raise_sanity_error('Please set TARGET_ARCH directly, or choose a MACHINE or DISTRO that does so.')
58
59 # Check TARGET_OS is set
60 if data.getVar('TARGET_OS', e.data, True) == 'INVALID':
61 raise_sanity_error('Please set TARGET_OS directly, or choose a MACHINE or DISTRO that does so.')
62
63 # Check user doesn't have ASSUME_PROVIDED = instead of += in local.conf
64 if "diffstat-native" not in data.getVar('ASSUME_PROVIDED', e.data, True).split():
65 raise_sanity_error('Please use ASSUME_PROVIDED +=, not ASSUME_PROVIDED = in your local.conf')
66
67 # Check the MACHINE is valid
68 if not check_conf_exists("conf/machine/${MACHINE}.conf", e.data):
69 raise_sanity_error('Please set a valid MACHINE in your local.conf')
70
71 # Check the distro is valid
72 if not check_conf_exists("conf/distro/${DISTRO}.conf", e.data):
73 raise_sanity_error('Please set a valid DISTRO in your local.conf')
74
75 if not check_app_exists("${MAKE}", e.data):
76 raise_sanity_error('GNU make missing. Please install GNU make')
77
78 if not check_app_exists('${BUILD_PREFIX}gcc', e.data):
79 raise_sanity_error('C Host-Compiler is missing, please install one' )
80
81 if not check_app_exists('${BUILD_PREFIX}g++', e.data):
82 raise_sanity_error('C++ Host-Compiler is missing, please install one' )
83
84 if not check_app_exists('patch', e.data):
85 raise_sanity_error('Please install the patch utility, preferable GNU patch.')
86
87 if not check_app_exists('diffstat', e.data):
88 raise_sanity_error('Please install the diffstat utility')
89
90 if not check_app_exists('texi2html', e.data):
91 raise_sanity_error('Please install the texi2html binary')
92
93 if not check_app_exists('cvs', e.data):
94 raise_sanity_error('Please install the cvs utility')
95
96 if not check_app_exists('svn', e.data):
97 raise_sanity_error('Please install the svn utility')
98
99 oes_bb_conf = data.getVar( 'OES_BITBAKE_CONF', e.data, True )
100 if not oes_bb_conf:
101 raise_sanity_error('You do not include OpenEmbeddeds version of conf/bitbake.conf')
102
103addhandler check_sanity_eventhandler
104python check_sanity_eventhandler() {
105 from bb import note, error, data, __version__
106 from bb.event import getName
107
108 if getName(e) == "BuildStarted":
109 check_sanity(e)
110
111 return NotHandled
112}