summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRoss Burton <ross@openedhand.com>2007-01-21 21:28:51 +0000
committerRoss Burton <ross@openedhand.com>2007-01-21 21:28:51 +0000
commit248c3ed47739d7f8b56c377fd89f437c4d4ebfd5 (patch)
treea8d9a0f34b0ff25a4e0f25f5f73cb854c10f8cf7 /meta/classes
parentf682c4261a2584d796414196191a3a0e9d566b8a (diff)
downloadpoky-248c3ed47739d7f8b56c377fd89f437c4d4ebfd5.tar.gz
Add insane, from OE (but with fatal warnings)
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1187 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/insane.bbclass151
1 files changed, 151 insertions, 0 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
new file mode 100644
index 0000000000..5912ae494e
--- /dev/null
+++ b/meta/classes/insane.bbclass
@@ -0,0 +1,151 @@
1# BB Class inspired by ebuild.sh
2#
3# This class will test files after installation for certain
4# security issues and other kind of issues.
5#
6# Checks we do:
7# -Check the ownership and permissions
8# -Check the RUNTIME path for the $TMPDIR
9# -Check if .la files wrongly point to workdir
10# -Check if .pc files wrongly point to workdir
11# -Check if packages contains .debug directories or .so files where they should be in -dev or -dbg
12#
13
14
15#
16# We need to have the scanelf utility as soon as
17# possible and this is contained within the pax-utils-native
18#
19
20
21# We play a special package function
22inherit package
23PACKAGE_DEPENDS += "pax-utils-native"
24PACKAGEFUNCS += " do_package_qa "
25
26def package_qa_check_rpath(file,name,d):
27 """
28 Check for dangerous RPATHs
29 """
30 import bb, os
31 scanelf = os.path.join(bb.data.getVar('STAGING_BINDIR_NATIVE',d,True),'scanelf')
32 bad_dir = bb.data.getVar('TMPDIR', d, True) + "/work"
33 if not os.path.exists(scanelf):
34 bb.note("Can not check RPATH scanelf not found")
35 if not bad_dir in bb.data.getVar('WORKDIR', d, True):
36 bb.fatal("This class assumed that WORKDIR is ${TMPDIR}/work... Not doing any check")
37
38 output = os.popen("%s -Byr %s" % (scanelf,file))
39 txt = output.readline().rsplit()
40 if bad_dir in txt:
41 bb.fatal("QA Issue package %s contains bad RPATH %s in file %s" % (name, txt, file))
42
43 pass
44
45def package_qa_check_devdbg(path, name,d):
46 """
47 Check for debug remains inside the binary or
48 non dev packages containing
49 """
50
51 import bb
52 if not "-dev" in name:
53 if path[-3:] == ".so":
54 bb.fatal("QA Issue: non dev package contains .so: %s" % name)
55
56 if not "-dbg" in name:
57 if '.debug' in path:
58 bb.fatal("QA Issue: non debug package contains .debug directory: %s" % name)
59
60def package_qa_check_perm(path,name,d):
61 """
62 Check the permission of files
63 """
64 pass
65
66def package_qa_check_arch(path,name,d):
67 """
68 Check if archs are compatible
69 """
70 pass
71
72def package_qa_check_pcla(path,name,d):
73 """
74 .pc and .la files should not point
75 """
76
77def package_qa_check_staged(path,d):
78 """
79 Check staged la and pc files for sanity
80 -e.g. installed being false
81 """
82 pass
83
84# Walk over all files in a directory and call func
85def package_qa_walk(path, funcs, package,d):
86 import os
87 for root, dirs, files in os.walk(path):
88 for file in files:
89 path = os.path.join(root,file)
90 for func in funcs:
91 func(path, package,d)
92
93
94def package_qa_check_rdepends(pkg, workdir, d):
95 import bb
96 if not "-dbg" in pkg and not "task-" in pkg and not "-image" in pkg:
97 # Copied from package_ipk.bbclass
98 # boiler plate to update the data
99 localdata = bb.data.createCopy(d)
100 root = "%s/install/%s" % (workdir, pkg)
101
102 bb.data.setVar('ROOT', '', localdata)
103 bb.data.setVar('ROOT_%s' % pkg, root, localdata)
104 pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1)
105 if not pkgname:
106 pkgname = pkg
107 bb.data.setVar('PKG', pkgname, localdata)
108
109 overrides = bb.data.getVar('OVERRIDES', localdata)
110 if not overrides:
111 raise bb.build.FuncFailed('OVERRIDES not defined')
112 overrides = bb.data.expand(overrides, localdata)
113 bb.data.setVar('OVERRIDES', overrides + ':' + pkg, localdata)
114
115 bb.data.update_data(localdata)
116
117 # Now check the RDEPENDS
118 rdepends = explode_deps(bb.data.getVar('RDEPENDS', localdata, True) or "")
119
120
121 # Now do the sanity check!!!
122 for rdepend in rdepends:
123 if "-dbg" in rdepend:
124 bb.fatal("QA issue, koen give us a better msg!!!")
125
126# The PACKAGE FUNC to scan each package
127python do_package_qa () {
128 bb.note("DO PACKAGE QA")
129 workdir = bb.data.getVar('WORKDIR', d, True)
130 packages = bb.data.getVar('PACKAGES',d, True)
131
132 # no packages should be scanned
133 if not packages:
134 return
135
136 for package in packages.split():
137 bb.note("Package: %s" % package)
138 path = "%s/install/%s" % (workdir, package)
139 package_qa_walk(path, [package_qa_check_rpath, package_qa_check_devdbg, package_qa_check_perm, package_qa_check_arch], package, d)
140 package_qa_check_rdepends(package, workdir, d)
141
142}
143
144
145# The Staging Func, to check all staging
146addtask qa_staging after do_populate_staging before do_build
147python do_qa_staging() {
148 bb.note("Staged!")
149
150 package_qa_check_staged(bb.data.getVar('STAGING_DIR',d,True), d)
151}