summaryrefslogtreecommitdiff
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 12:44:48 +0000
commitcd7f7efcd5f297d876823b8f579ecefb9542b089 (patch)
treef05f4acc9e8e252aa37c220c432ba774c9151bde
parenta10189366f180b87f5be20b66834b7e7a9bb8c12 (diff)
downloadopenembedded-core-cd7f7efcd5f297d876823b8f579ecefb9542b089.tar.gz
openembedded-core-cd7f7efcd5f297d876823b8f579ecefb9542b089.tar.bz2
openembedded-core-cd7f7efcd5f297d876823b8f579ecefb9542b089.zip
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] Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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"
BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
BUILDHISTORY_PUSH_REPO ?= ""
-# Must inherit package first before changing PACKAGEFUNCS
-inherit package
-PACKAGEFUNCS += "buildhistory_emit_pkghistory"
-
-# We don't want to force a rerun of do_package for everything
-# if the buildhistory_emit_pkghistory function or any of the
-# variables it refers to changes
-do_package[vardepsexclude] += "buildhistory_emit_pkghistory"
+SSTATEPOSTINSTFUNCS += "buildhistory_emit_pkghistory"
#
-# Called during do_package to write out metadata about this package
-# for comparision when writing future packages
+# Write out metadata about this package for comparision when writing future packages
#
python buildhistory_emit_pkghistory() {
- import re
+ if not d.getVar('BB_CURRENTTASK', True) in ['packagedata', 'packagedata_setscene']:
+ return 0
if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split():
return 0
+ import re
+ import json
+ import errno
+
pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
class RecipeInfo:
@@ -75,14 +72,6 @@ python buildhistory_emit_pkghistory() {
# Should check PACKAGES here to see if anything removed
- def getpkgvar(pkg, var):
- val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
- if val:
- return val
- val = bb.data.getVar('%s' % (var), d, 1)
-
- return val
-
def readPackageInfo(pkg, histfile):
pkginfo = PackageInfo(pkg)
with open(histfile, "r") as f:
@@ -156,7 +145,20 @@ python buildhistory_emit_pkghistory() {
pv = d.getVar('PV', True)
pr = d.getVar('PR', True)
- packages = squashspaces(d.getVar('PACKAGES', True))
+ pkgdata_dir = d.getVar('PKGDATA_DIR', True)
+ packages = ""
+ try:
+ with open(os.path.join(pkgdata_dir, pn)) as f:
+ for line in f.readlines():
+ if line.startswith('PACKAGES: '):
+ packages = squashspaces(line.split(': ', 1)[1])
+ break
+ except IOError as e:
+ if e.errno == errno.ENOENT:
+ # Probably a -cross recipe, just ignore
+ return 0
+ else:
+ raise
packagelist = packages.split()
if not os.path.exists(pkghistdir):
@@ -181,9 +183,15 @@ python buildhistory_emit_pkghistory() {
pkgdest = d.getVar('PKGDEST', True)
for pkg in packagelist:
- pkge = getpkgvar(pkg, 'PKGE') or "0"
- pkgv = getpkgvar(pkg, 'PKGV')
- pkgr = getpkgvar(pkg, 'PKGR')
+ pkgdata = {}
+ with open(os.path.join(pkgdata_dir, 'runtime', pkg)) as f:
+ for line in f.readlines():
+ item = line.rstrip('\n').split(': ', 1)
+ pkgdata[item[0]] = item[1].decode('string_escape')
+
+ pkge = pkgdata.get('PKGE', '0')
+ pkgv = pkgdata['PKGV']
+ pkgr = pkgdata['PKGR']
#
# Find out what the last version was
# Make sure the version did not decrease
@@ -200,35 +208,32 @@ python buildhistory_emit_pkghistory() {
pkginfo = PackageInfo(pkg)
# Apparently the version can be different on a per-package basis (see Python)
- pkginfo.pe = getpkgvar(pkg, 'PE') or "0"
- pkginfo.pv = getpkgvar(pkg, 'PV')
- pkginfo.pr = getpkgvar(pkg, 'PR')
- pkginfo.pkg = getpkgvar(pkg, 'PKG') or pkg
+ pkginfo.pe = pkgdata.get('PE', '0')
+ pkginfo.pv = pkgdata['PV']
+ pkginfo.pr = pkgdata['PR']
+ pkginfo.pkg = pkgdata['PKG_%s' % pkg]
pkginfo.pkge = pkge
pkginfo.pkgv = pkgv
pkginfo.pkgr = pkgr
- pkginfo.rprovides = sortpkglist(squashspaces(getpkgvar(pkg, 'RPROVIDES') or ""))
- pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
- pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))
- pkginfo.rsuggests = sortpkglist(squashspaces(getpkgvar(pkg, 'RSUGGESTS') or ""))
- pkginfo.rreplaces = sortpkglist(squashspaces(getpkgvar(pkg, 'RREPLACES') or ""))
- pkginfo.rconflicts = sortpkglist(squashspaces(getpkgvar(pkg, 'RCONFLICTS') or ""))
- pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "")
+ pkginfo.rprovides = sortpkglist(squashspaces(pkgdata.get('RPROVIDES_%s' % pkg, "")))
+ pkginfo.rdepends = sortpkglist(squashspaces(pkgdata.get('RDEPENDS_%s' % pkg, "")))
+ pkginfo.rrecommends = sortpkglist(squashspaces(pkgdata.get('RRECOMMENDS_%s' % pkg, "")))
+ pkginfo.rsuggests = sortpkglist(squashspaces(pkgdata.get('RSUGGESTS_%s' % pkg, "")))
+ pkginfo.rreplaces = sortpkglist(squashspaces(pkgdata.get('RREPLACES_%s' % pkg, "")))
+ pkginfo.rconflicts = sortpkglist(squashspaces(pkgdata.get('RCONFLICTS_%s' % pkg, "")))
+ pkginfo.files = squashspaces(pkgdata.get('FILES_%s' % pkg, ""))
for filevar in pkginfo.filevars:
- pkginfo.filevars[filevar] = getpkgvar(pkg, filevar)
+ pkginfo.filevars[filevar] = pkgdata.get('%s_%s' % (filevar, pkg), "")
# Gather information about packaged files
- pkgdestpkg = os.path.join(pkgdest, pkg)
- filelist = []
- pkginfo.size = 0
- for f in pkgfiles[pkg]:
- relpth = os.path.relpath(f, pkgdestpkg)
- fstat = os.lstat(f)
- pkginfo.size += fstat.st_size
- filelist.append(os.sep + relpth)
+ val = pkgdata.get('FILES_INFO', '')
+ dictval = json.loads(val)
+ filelist = dictval.keys()
filelist.sort()
pkginfo.filelist = " ".join(filelist)
+ pkginfo.size = int(pkgdata['PKGSIZE_%s' % pkg])
+
write_pkghistory(pkginfo, d)
}