summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2013-12-02 18:50:49 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-03 17:45:50 +0000
commitcdfef971d3596778b9f88e784379ee2fd56acbfa (patch)
tree11ee4932b13b65cceeb560a249d5bb6c23cf7e0d /meta
parent0cb38ee34adda69b7e8c171464040a5e7d143edd (diff)
downloadpoky-cdfef971d3596778b9f88e784379ee2fd56acbfa.tar.gz
classes/buildhistory: improve collection of package info
Use a function added to SSTATEPOSTINSTFUNCS and read the necessary information out of pkgdata, instead of using a function executed during do_package that reads the data directly. This has two benefits: * The package info collection will now work when the package content is restored from shared state * Adding/removing the inherit of buildhistory will no longer change the do_package signatures and force re-execution of that function for every recipe. Fixes [YOCTO #5358] (From OE-Core rev: cd7f7efcd5f297d876823b8f579ecefb9542b089) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/buildhistory.bbclass91
1 files changed, 48 insertions, 43 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 68c81f6019..b11e9bab5c 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -17,25 +17,22 @@ BUILDHISTORY_COMMIT ?= "0"
17BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" 17BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
18BUILDHISTORY_PUSH_REPO ?= "" 18BUILDHISTORY_PUSH_REPO ?= ""
19 19
20# Must inherit package first before changing PACKAGEFUNCS 20SSTATEPOSTINSTFUNCS += "buildhistory_emit_pkghistory"
21inherit package
22PACKAGEFUNCS += "buildhistory_emit_pkghistory"
23
24# We don't want to force a rerun of do_package for everything
25# if the buildhistory_emit_pkghistory function or any of the
26# variables it refers to changes
27do_package[vardepsexclude] += "buildhistory_emit_pkghistory"
28 21
29# 22#
30# Called during do_package to write out metadata about this package 23# Write out metadata about this package for comparision when writing future packages
31# for comparision when writing future packages
32# 24#
33python buildhistory_emit_pkghistory() { 25python buildhistory_emit_pkghistory() {
34 import re 26 if not d.getVar('BB_CURRENTTASK', True) in ['packagedata', 'packagedata_setscene']:
27 return 0
35 28
36 if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split(): 29 if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split():
37 return 0 30 return 0
38 31
32 import re
33 import json
34 import errno
35
39 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) 36 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
40 37
41 class RecipeInfo: 38 class RecipeInfo:
@@ -75,14 +72,6 @@ python buildhistory_emit_pkghistory() {
75 72
76 # Should check PACKAGES here to see if anything removed 73 # Should check PACKAGES here to see if anything removed
77 74
78 def getpkgvar(pkg, var):
79 val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
80 if val:
81 return val
82 val = bb.data.getVar('%s' % (var), d, 1)
83
84 return val
85
86 def readPackageInfo(pkg, histfile): 75 def readPackageInfo(pkg, histfile):
87 pkginfo = PackageInfo(pkg) 76 pkginfo = PackageInfo(pkg)
88 with open(histfile, "r") as f: 77 with open(histfile, "r") as f:
@@ -156,7 +145,20 @@ python buildhistory_emit_pkghistory() {
156 pv = d.getVar('PV', True) 145 pv = d.getVar('PV', True)
157 pr = d.getVar('PR', True) 146 pr = d.getVar('PR', True)
158 147
159 packages = squashspaces(d.getVar('PACKAGES', True)) 148 pkgdata_dir = d.getVar('PKGDATA_DIR', True)
149 packages = ""
150 try:
151 with open(os.path.join(pkgdata_dir, pn)) as f:
152 for line in f.readlines():
153 if line.startswith('PACKAGES: '):
154 packages = squashspaces(line.split(': ', 1)[1])
155 break
156 except IOError as e:
157 if e.errno == errno.ENOENT:
158 # Probably a -cross recipe, just ignore
159 return 0
160 else:
161 raise
160 162
161 packagelist = packages.split() 163 packagelist = packages.split()
162 if not os.path.exists(pkghistdir): 164 if not os.path.exists(pkghistdir):
@@ -181,9 +183,15 @@ python buildhistory_emit_pkghistory() {
181 183
182 pkgdest = d.getVar('PKGDEST', True) 184 pkgdest = d.getVar('PKGDEST', True)
183 for pkg in packagelist: 185 for pkg in packagelist:
184 pkge = getpkgvar(pkg, 'PKGE') or "0" 186 pkgdata = {}
185 pkgv = getpkgvar(pkg, 'PKGV') 187 with open(os.path.join(pkgdata_dir, 'runtime', pkg)) as f:
186 pkgr = getpkgvar(pkg, 'PKGR') 188 for line in f.readlines():
189 item = line.rstrip('\n').split(': ', 1)
190 pkgdata[item[0]] = item[1].decode('string_escape')
191
192 pkge = pkgdata.get('PKGE', '0')
193 pkgv = pkgdata['PKGV']
194 pkgr = pkgdata['PKGR']
187 # 195 #
188 # Find out what the last version was 196 # Find out what the last version was
189 # Make sure the version did not decrease 197 # Make sure the version did not decrease
@@ -200,35 +208,32 @@ python buildhistory_emit_pkghistory() {
200 208
201 pkginfo = PackageInfo(pkg) 209 pkginfo = PackageInfo(pkg)
202 # Apparently the version can be different on a per-package basis (see Python) 210 # Apparently the version can be different on a per-package basis (see Python)
203 pkginfo.pe = getpkgvar(pkg, 'PE') or "0" 211 pkginfo.pe = pkgdata.get('PE', '0')
204 pkginfo.pv = getpkgvar(pkg, 'PV') 212 pkginfo.pv = pkgdata['PV']
205 pkginfo.pr = getpkgvar(pkg, 'PR') 213 pkginfo.pr = pkgdata['PR']
206 pkginfo.pkg = getpkgvar(pkg, 'PKG') or pkg 214 pkginfo.pkg = pkgdata['PKG_%s' % pkg]
207 pkginfo.pkge = pkge 215 pkginfo.pkge = pkge
208 pkginfo.pkgv = pkgv 216 pkginfo.pkgv = pkgv
209 pkginfo.pkgr = pkgr 217 pkginfo.pkgr = pkgr
210 pkginfo.rprovides = sortpkglist(squashspaces(getpkgvar(pkg, 'RPROVIDES') or "")) 218 pkginfo.rprovides = sortpkglist(squashspaces(pkgdata.get('RPROVIDES_%s' % pkg, "")))
211 pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) 219 pkginfo.rdepends = sortpkglist(squashspaces(pkgdata.get('RDEPENDS_%s' % pkg, "")))
212 pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) 220 pkginfo.rrecommends = sortpkglist(squashspaces(pkgdata.get('RRECOMMENDS_%s' % pkg, "")))
213 pkginfo.rsuggests = sortpkglist(squashspaces(getpkgvar(pkg, 'RSUGGESTS') or "")) 221 pkginfo.rsuggests = sortpkglist(squashspaces(pkgdata.get('RSUGGESTS_%s' % pkg, "")))
214 pkginfo.rreplaces = sortpkglist(squashspaces(getpkgvar(pkg, 'RREPLACES') or "")) 222 pkginfo.rreplaces = sortpkglist(squashspaces(pkgdata.get('RREPLACES_%s' % pkg, "")))
215 pkginfo.rconflicts = sortpkglist(squashspaces(getpkgvar(pkg, 'RCONFLICTS') or "")) 223 pkginfo.rconflicts = sortpkglist(squashspaces(pkgdata.get('RCONFLICTS_%s' % pkg, "")))
216 pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") 224 pkginfo.files = squashspaces(pkgdata.get('FILES_%s' % pkg, ""))
217 for filevar in pkginfo.filevars: 225 for filevar in pkginfo.filevars:
218 pkginfo.filevars[filevar] = getpkgvar(pkg, filevar) 226 pkginfo.filevars[filevar] = pkgdata.get('%s_%s' % (filevar, pkg), "")
219 227
220 # Gather information about packaged files 228 # Gather information about packaged files
221 pkgdestpkg = os.path.join(pkgdest, pkg) 229 val = pkgdata.get('FILES_INFO', '')
222 filelist = [] 230 dictval = json.loads(val)
223 pkginfo.size = 0 231 filelist = dictval.keys()
224 for f in pkgfiles[pkg]:
225 relpth = os.path.relpath(f, pkgdestpkg)
226 fstat = os.lstat(f)
227 pkginfo.size += fstat.st_size
228 filelist.append(os.sep + relpth)
229 filelist.sort() 232 filelist.sort()
230 pkginfo.filelist = " ".join(filelist) 233 pkginfo.filelist = " ".join(filelist)
231 234
235 pkginfo.size = int(pkgdata['PKGSIZE_%s' % pkg])
236
232 write_pkghistory(pkginfo, d) 237 write_pkghistory(pkginfo, d)
233} 238}
234 239