summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/buildhistory.bbclass350
-rw-r--r--meta/classes/rootfs_ipk.bbclass27
-rw-r--r--meta/classes/rootfs_rpm.bbclass41
3 files changed, 6 insertions, 412 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
deleted file mode 100644
index 89b2cb1462..0000000000
--- a/meta/classes/buildhistory.bbclass
+++ /dev/null
@@ -1,350 +0,0 @@
1#
2# Records history of build output in order to detect regressions
3#
4# Based in part on testlab.bbclass and packagehistory.bbclass
5#
6# Copyright (C) 2011 Intel Corporation
7# Copyright (C) 2007, 2008 Koen Kooi <koen@openembedded.org>
8#
9
10BUILDHISTORY_DIR ?= "${TMPDIR}/buildhistory"
11BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
12BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
13BUILDHISTORY_COMMIT ?= "0"
14BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
15
16# Must inherit package first before changing PACKAGEFUNCS
17inherit package
18PACKAGEFUNCS += "buildhistory_emit_pkghistory"
19
20#
21# Called during do_package to write out metadata about this package
22# for comparision when writing future packages
23#
24python buildhistory_emit_pkghistory() {
25 import re
26
27 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
28
29 class RecipeInfo:
30 def __init__(self, name):
31 self.name = name
32 self.pe = "0"
33 self.pv = "0"
34 self.pr = "r0"
35 self.depends = ""
36 self.packages = ""
37
38 class PackageInfo:
39 def __init__(self, name):
40 self.name = name
41 self.pe = "0"
42 self.pv = "0"
43 self.pr = "r0"
44 self.size = 0
45 self.depends = ""
46 self.rdepends = ""
47 self.rrecommends = ""
48 self.files = ""
49 self.filelist = ""
50
51 # Should check PACKAGES here to see if anything removed
52
53 def getpkgvar(pkg, var):
54 val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
55 if val:
56 return val
57 val = bb.data.getVar('%s' % (var), d, 1)
58
59 return val
60
61 def readRecipeInfo(pn, histfile):
62 rcpinfo = RecipeInfo(pn)
63 f = open(histfile, "r")
64 try:
65 for line in f:
66 lns = line.split('=')
67 name = lns[0].strip()
68 value = lns[1].strip(" \t\r\n").strip('"')
69 if name == "PE":
70 rcpinfo.pe = value
71 elif name == "PV":
72 rcpinfo.pv = value
73 elif name == "PR":
74 rcpinfo.pr = value
75 elif name == "DEPENDS":
76 rcpinfo.depends = value
77 elif name == "PACKAGES":
78 rcpinfo.packages = value
79 finally:
80 f.close()
81 return rcpinfo
82
83 def readPackageInfo(pkg, histfile):
84 pkginfo = PackageInfo(pkg)
85 f = open(histfile, "r")
86 try:
87 for line in f:
88 lns = line.split('=')
89 name = lns[0].strip()
90 value = lns[1].strip(" \t\r\n").strip('"')
91 if name == "PE":
92 pkginfo.pe = value
93 elif name == "PV":
94 pkginfo.pv = value
95 elif name == "PR":
96 pkginfo.pr = value
97 elif name == "RDEPENDS":
98 pkginfo.rdepends = value
99 elif name == "RRECOMMENDS":
100 pkginfo.rrecommends = value
101 elif name == "PKGSIZE":
102 pkginfo.size = long(value)
103 elif name == "FILES":
104 pkginfo.files = value
105 elif name == "FILELIST":
106 pkginfo.filelist = value
107 finally:
108 f.close()
109 return pkginfo
110
111 def getlastrecipeversion(pn):
112 try:
113 histfile = os.path.join(pkghistdir, "latest")
114 return readRecipeInfo(pn, histfile)
115 except EnvironmentError:
116 return None
117
118 def getlastpkgversion(pkg):
119 try:
120 histfile = os.path.join(pkghistdir, pkg, "latest")
121 return readPackageInfo(pkg, histfile)
122 except EnvironmentError:
123 return None
124
125 def squashspaces(string):
126 return re.sub("\s+", " ", string)
127
128 pn = d.getVar('PN', True)
129 pe = d.getVar('PE', True) or "0"
130 pv = d.getVar('PV', True)
131 pr = d.getVar('PR', True)
132 packages = squashspaces(d.getVar('PACKAGES', True))
133
134 rcpinfo = RecipeInfo(pn)
135 rcpinfo.pe = pe
136 rcpinfo.pv = pv
137 rcpinfo.pr = pr
138 rcpinfo.depends = squashspaces(d.getVar('DEPENDS', True) or "")
139 rcpinfo.packages = packages
140 write_recipehistory(rcpinfo, d)
141 write_latestlink(None, pe, pv, pr, d)
142
143 # Apparently the version can be different on a per-package basis (see Python)
144 pkgdest = d.getVar('PKGDEST', True)
145 for pkg in packages.split():
146 pe = getpkgvar(pkg, 'PE') or "0"
147 pv = getpkgvar(pkg, 'PV')
148 pr = getpkgvar(pkg, 'PR')
149 #
150 # Find out what the last version was
151 # Make sure the version did not decrease
152 #
153 lastversion = getlastpkgversion(pkg)
154 if lastversion:
155 last_pe = lastversion.pe
156 last_pv = lastversion.pv
157 last_pr = lastversion.pr
158 r = bb.utils.vercmp((pe, pv, pr), (last_pe, last_pv, last_pr))
159 if r < 0:
160 bb.fatal("Package version for package %s went backwards which would break package feeds from (%s:%s-%s to %s:%s-%s)" % (pkg, last_pe, last_pv, last_pr, pe, pv, pr))
161
162 pkginfo = PackageInfo(pkg)
163 pkginfo.pe = pe
164 pkginfo.pv = pv
165 pkginfo.pr = pr
166 pkginfo.rdepends = squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")
167 pkginfo.rrecommends = squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")
168 pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "")
169
170 # Gather information about packaged files
171 pkgdestpkg = os.path.join(pkgdest, pkg)
172 filelist = []
173 pkginfo.size = 0
174 for root, dirs, files in os.walk(pkgdestpkg):
175 relpth = os.path.relpath(root, pkgdestpkg)
176 for f in files:
177 fstat = os.lstat(os.path.join(root, f))
178 pkginfo.size += fstat.st_size
179 filelist.append(os.sep + os.path.join(relpth, f))
180 pkginfo.filelist = " ".join(filelist)
181
182 write_pkghistory(pkginfo, d)
183
184 if lastversion:
185 check_pkghistory(pkginfo, lastversion)
186
187 write_latestlink(pkg, pe, pv, pr, d)
188}
189
190
191def check_pkghistory(pkginfo, lastversion):
192
193 bb.debug(2, "Checking package history")
194 # RDEPENDS removed?
195 # PKG changed?
196 # Each file list of each package for file removals?
197
198
199def write_recipehistory(rcpinfo, d):
200 bb.debug(2, "Writing recipe history")
201
202 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
203
204 if not os.path.exists(pkghistdir):
205 os.makedirs(pkghistdir)
206
207 verfile = os.path.join(pkghistdir, "%s:%s-%s" % (rcpinfo.pe, rcpinfo.pv, rcpinfo.pr))
208 f = open(verfile, "w")
209 try:
210 if rcpinfo.pe != "0":
211 f.write("PE = %s\n" % rcpinfo.pe)
212 f.write("PV = %s\n" % rcpinfo.pv)
213 f.write("PR = %s\n" % rcpinfo.pr)
214 f.write("DEPENDS = %s\n" % rcpinfo.depends)
215 f.write("PACKAGES = %s\n" % rcpinfo.packages)
216 finally:
217 f.close()
218
219
220def write_pkghistory(pkginfo, d):
221 bb.debug(2, "Writing package history")
222
223 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
224
225 verpath = os.path.join(pkghistdir, pkginfo.name)
226 if not os.path.exists(verpath):
227 os.makedirs(verpath)
228
229 verfile = os.path.join(verpath, "%s:%s-%s" % (pkginfo.pe, pkginfo.pv, pkginfo.pr))
230 f = open(verfile, "w")
231 try:
232 if pkginfo.pe != "0":
233 f.write("PE = %s\n" % pkginfo.pe)
234 f.write("PV = %s\n" % pkginfo.pv)
235 f.write("PR = %s\n" % pkginfo.pr)
236 f.write("RDEPENDS = %s\n" % pkginfo.rdepends)
237 f.write("RRECOMMENDS = %s\n" % pkginfo.rrecommends)
238 f.write("PKGSIZE = %d\n" % pkginfo.size)
239 f.write("FILES = %s\n" % pkginfo.files)
240 f.write("FILELIST = %s\n" % pkginfo.filelist)
241 finally:
242 f.close()
243
244
245def write_latestlink(pkg, pe, pv, pr, d):
246 import shutil
247
248 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
249
250 def rm_link(path):
251 try:
252 os.unlink(path)
253 except OSError:
254 return
255
256 if pkg:
257 filedir = os.path.join(pkghistdir, pkg)
258 else:
259 filedir = pkghistdir
260 rm_link(os.path.join(filedir, "latest"))
261 shutil.copy(os.path.join(filedir, "%s:%s-%s" % (pe, pv, pr)), os.path.join(filedir, "latest"))
262
263
264buildhistory_get_image_installed() {
265 # Anything requiring the use of the packaging system should be done in here
266 # in case the packaging files are going to be removed for this image
267
268 mkdir -p ${BUILDHISTORY_DIR_IMAGE}
269
270 # Get list of installed packages
271 list_installed_packages | sort > ${BUILDHISTORY_DIR_IMAGE}/installed-package-names.txt
272 INSTALLED_PKGS=`cat ${BUILDHISTORY_DIR_IMAGE}/installed-package-names.txt`
273
274 # Produce installed package file and size lists and dependency graph
275 echo -n > ${BUILDHISTORY_DIR_IMAGE}/installed-packages.txt
276 echo -n > ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp
277 echo -e "digraph depends {\n node [shape=plaintext]" > ${BUILDHISTORY_DIR_IMAGE}/depends.dot
278 for pkg in $INSTALLED_PKGS; do
279 pkgfile=`get_package_filename $pkg`
280 echo `basename $pkgfile` >> ${BUILDHISTORY_DIR_IMAGE}/installed-packages.txt
281 if [ -f $pkgfile ] ; then
282 pkgsize=`du -k $pkgfile | head -n1 | awk '{ print $1 }'`
283 echo $pkgsize $pkg >> ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp
284 fi
285
286 deps=`list_package_depends $pkg`
287 for dep in $deps ; do
288 echo "$pkg OPP $dep;" | sed -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' | sed 's:OPP:->:g' >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot
289 done
290
291 recs=`list_package_recommends $pkg`
292 for rec in $recs ; do
293 echo "$pkg OPP $rec [style=dotted];" | sed -e 's:-:_:g' -e 's:\.:_:g' -e 's:+::g' | sed 's:OPP:->:g' >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot
294 done
295 done
296 echo "}" >> ${BUILDHISTORY_DIR_IMAGE}/depends.dot
297
298 cat ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp | sort -n -r | awk '{print $1 "\tKiB " $2}' > ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.txt
299 rm ${BUILDHISTORY_DIR_IMAGE}/installed-package-sizes.tmp
300
301 # Produce some cut-down graphs (for readability)
302 grep -v kernel_image ${BUILDHISTORY_DIR_IMAGE}/depends.dot | grep -v kernel_2 | grep -v kernel_3 > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel.dot
303 grep -v libc6 ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel.dot | grep -v libgcc > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc.dot
304 grep -v update_ ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc.dot > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate.dot
305 grep -v kernel_module ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate.dot > ${BUILDHISTORY_DIR_IMAGE}/depends-nokernel-nolibc-noupdate-nomodules.dot
306
307 # Workaround for broken shell function dependencies
308 if false ; then
309 get_package_filename
310 list_package_depends
311 list_package_recommends
312 fi
313}
314
315buildhistory_get_imageinfo() {
316 # List the files in the image, but exclude date/time etc.
317 # This awk script is somewhat messy, but handles where the size is not printed for device files under pseudo
318 find ${IMAGE_ROOTFS} -ls | awk '{ if ( $7 ~ /[0-9]/ ) printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, $7, $11, $12, $13 ; else printf "%s %10-s %10-s %10s %s %s %s\n", $3, $5, $6, 0, $10, $11, $12 }' > ${BUILDHISTORY_DIR_IMAGE}/files-in-image.txt
319
320 # Add some configuration information
321 echo "${MACHINE}: ${IMAGE_BASENAME} configured for ${DISTRO} ${DISTRO_VERSION}" > ${BUILDHISTORY_DIR_IMAGE}/build-id
322 echo "${@buildhistory_get_layers(d)}" >> ${BUILDHISTORY_DIR_IMAGE}/build-id
323}
324
325# By prepending we get in before the removal of packaging files
326ROOTFS_POSTPROCESS_COMMAND =+ "buildhistory_get_image_installed ; "
327
328IMAGE_POSTPROCESS_COMMAND += " buildhistory_get_imageinfo ; "
329
330def buildhistory_get_layers(d):
331 layertext = "Configured metadata layers:\n%s\n" % '\n'.join(get_layers_branch_rev(d))
332 return layertext
333
334
335buildhistory_commit() {
336 ( cd ${BUILDHISTORY_DIR}/
337 git add ${BUILDHISTORY_DIR}/*
338 git commit ${BUILDHISTORY_DIR}/ -m "Build ${BUILDNAME} for machine ${MACHINE} configured for ${DISTRO} ${DISTRO_VERSION}" --author "${BUILDHISTORY_COMMIT_AUTHOR}" > /dev/null || true)
339}
340
341python buildhistory_eventhandler() {
342 import bb.build
343 import bb.event
344
345 if isinstance(e, bb.event.BuildCompleted):
346 if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1":
347 bb.build.exec_func("buildhistory_commit", e.data)
348}
349
350addhandler buildhistory_eventhandler
diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
index b4b95c5645..4a5a2dd3be 100644
--- a/meta/classes/rootfs_ipk.bbclass
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -143,36 +143,11 @@ remove_packaging_data_files() {
143 mkdir ${IMAGE_ROOTFS}${opkglibdir} 143 mkdir ${IMAGE_ROOTFS}${opkglibdir}
144} 144}
145 145
146list_installed_packages() {
147 grep ^Package: ${IMAGE_ROOTFS}${opkglibdir}/status | sed "s/^Package: //"
148}
149
150get_package_filename() {
151 name=`opkg-cl ${IPKG_ARGS} info $1 | grep -B 7 -A 7 "^Status.* \(\(installed\)\|\(unpacked\)\)" | awk '/^Package/ {printf $2"_"}'`
152 name=$name`opkg-cl ${IPKG_ARGS} info $1 | grep -B 7 -A 7 "^Status.* \(\(installed\)\|\(unpacked\)\)" | awk -F: '/^Version/ {printf $NF"_"}' | sed 's/^\s*//g'`
153 name=$name`opkg-cl ${IPKG_ARGS} info $1 | grep -B 7 -A 7 "^Status.* \(\(installed\)\|\(unpacked\)\)" | awk '/^Archi/ {print $2".ipk"}'`
154
155 fullname=`find ${DEPLOY_DIR_IPK} -name "$name" || true`
156 if [ "$fullname" = "" ] ; then
157 echo $name
158 else
159 echo $fullname
160 fi
161}
162
163list_package_depends() {
164 opkg-cl ${IPKG_ARGS} info $1 | grep ^Depends | sed -e 's/^Depends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
165}
166
167list_package_recommends() {
168 opkg-cl ${IPKG_ARGS} info $1 | grep ^Recommends | sed -e 's/^Recommends: //' -e 's/,//g' -e 's:([=<>]* [0-9a-zA-Z.~\-]*)::g'
169}
170
171install_all_locales() { 146install_all_locales() {
172 147
173 PACKAGES_TO_INSTALL="" 148 PACKAGES_TO_INSTALL=""
174 149
175 INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"` 150 INSTALLED_PACKAGES=`grep ^Package: ${IMAGE_ROOTFS}${opkglibdir}/status |sed "s/^Package: //"|egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"`
176 151
177 for pkg in $INSTALLED_PACKAGES 152 for pkg in $INSTALLED_PACKAGES
178 do 153 do
diff --git a/meta/classes/rootfs_rpm.bbclass b/meta/classes/rootfs_rpm.bbclass
index 5fd45d758c..6973008c59 100644
--- a/meta/classes/rootfs_rpm.bbclass
+++ b/meta/classes/rootfs_rpm.bbclass
@@ -160,47 +160,16 @@ remove_packaging_data_files() {
160 rm -rf ${IMAGE_ROOTFS}${opkglibdir} 160 rm -rf ${IMAGE_ROOTFS}${opkglibdir}
161} 161}
162 162
163RPM_QUERY_CMD = '${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
164 -D "__dbi_txn create nofsync private"'
165
166list_installed_packages() {
167 ${RPM_QUERY_CMD} -qa --qf "[%{NAME}\n]"
168}
169
170get_package_filename() {
171 resolve_package_rpm ${RPMCONF_TARGET_BASE}-base_archs.conf $1
172}
173
174list_package_depends() {
175 pkglist=`list_installed_packages`
176
177 for req in `${RPM_QUERY_CMD} -q --qf "[%{REQUIRES}\n]" $1`; do
178 if echo "$req" | grep -q "^rpmlib" ; then continue ; fi
179
180 realpkg=""
181 for dep in $pkglist; do
182 if [ "$dep" = "$req" ] ; then
183 realpkg="1"
184 echo $req
185 break
186 fi
187 done
188
189 if [ "$realdep" = "" ] ; then
190 ${RPM_QUERY_CMD} -q --whatprovides $req --qf "%{NAME}\n"
191 fi
192 done
193}
194
195list_package_recommends() {
196 :
197}
198 163
199install_all_locales() { 164install_all_locales() {
200 PACKAGES_TO_INSTALL="" 165 PACKAGES_TO_INSTALL=""
201 166
202 # Generate list of installed packages... 167 # Generate list of installed packages...
203 INSTALLED_PACKAGES=`list_installed_packages | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)"` 168 INSTALLED_PACKAGES=$( \
169 ${RPM} --root ${IMAGE_ROOTFS} -D "_dbpath ${rpmlibdir}" \
170 -D "__dbi_txn create nofsync private" \
171 -qa --qf "[%{NAME}\n]" | egrep -v -- "(-locale-|-dev$|-doc$|^kernel|^glibc|^ttf|^task|^perl|^python)" \
172 )
204 173
205 # This would likely be faster if we did it in one transaction 174 # This would likely be faster if we did it in one transaction
206 # but this should be good enough for the few users of this function... 175 # but this should be good enough for the few users of this function...