1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

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>
This commit is contained in:
Paul Eggleton
2013-12-02 18:50:49 +00:00
committed by Richard Purdie
parent 0cb38ee34a
commit cdfef971d3
+48 -43
View File
@@ -17,25 +17,22 @@ BUILDHISTORY_COMMIT ?= "0"
BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>" BUILDHISTORY_COMMIT_AUTHOR ?= "buildhistory <buildhistory@${DISTRO}>"
BUILDHISTORY_PUSH_REPO ?= "" BUILDHISTORY_PUSH_REPO ?= ""
# Must inherit package first before changing PACKAGEFUNCS SSTATEPOSTINSTFUNCS += "buildhistory_emit_pkghistory"
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"
# #
# Called during do_package to write out metadata about this package # Write out metadata about this package for comparision when writing future packages
# for comparision when writing future packages
# #
python buildhistory_emit_pkghistory() { 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(): if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split():
return 0 return 0
import re
import json
import errno
pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
class RecipeInfo: class RecipeInfo:
@@ -75,14 +72,6 @@ python buildhistory_emit_pkghistory() {
# Should check PACKAGES here to see if anything removed # 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): def readPackageInfo(pkg, histfile):
pkginfo = PackageInfo(pkg) pkginfo = PackageInfo(pkg)
with open(histfile, "r") as f: with open(histfile, "r") as f:
@@ -156,7 +145,20 @@ python buildhistory_emit_pkghistory() {
pv = d.getVar('PV', True) pv = d.getVar('PV', True)
pr = d.getVar('PR', 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() packagelist = packages.split()
if not os.path.exists(pkghistdir): if not os.path.exists(pkghistdir):
@@ -181,9 +183,15 @@ python buildhistory_emit_pkghistory() {
pkgdest = d.getVar('PKGDEST', True) pkgdest = d.getVar('PKGDEST', True)
for pkg in packagelist: for pkg in packagelist:
pkge = getpkgvar(pkg, 'PKGE') or "0" pkgdata = {}
pkgv = getpkgvar(pkg, 'PKGV') with open(os.path.join(pkgdata_dir, 'runtime', pkg)) as f:
pkgr = getpkgvar(pkg, 'PKGR') 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 # Find out what the last version was
# Make sure the version did not decrease # Make sure the version did not decrease
@@ -200,35 +208,32 @@ python buildhistory_emit_pkghistory() {
pkginfo = PackageInfo(pkg) pkginfo = PackageInfo(pkg)
# Apparently the version can be different on a per-package basis (see Python) # Apparently the version can be different on a per-package basis (see Python)
pkginfo.pe = getpkgvar(pkg, 'PE') or "0" pkginfo.pe = pkgdata.get('PE', '0')
pkginfo.pv = getpkgvar(pkg, 'PV') pkginfo.pv = pkgdata['PV']
pkginfo.pr = getpkgvar(pkg, 'PR') pkginfo.pr = pkgdata['PR']
pkginfo.pkg = getpkgvar(pkg, 'PKG') or pkg pkginfo.pkg = pkgdata['PKG_%s' % pkg]
pkginfo.pkge = pkge pkginfo.pkge = pkge
pkginfo.pkgv = pkgv pkginfo.pkgv = pkgv
pkginfo.pkgr = pkgr pkginfo.pkgr = pkgr
pkginfo.rprovides = sortpkglist(squashspaces(getpkgvar(pkg, 'RPROVIDES') or "")) pkginfo.rprovides = sortpkglist(squashspaces(pkgdata.get('RPROVIDES_%s' % pkg, "")))
pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) pkginfo.rdepends = sortpkglist(squashspaces(pkgdata.get('RDEPENDS_%s' % pkg, "")))
pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) pkginfo.rrecommends = sortpkglist(squashspaces(pkgdata.get('RRECOMMENDS_%s' % pkg, "")))
pkginfo.rsuggests = sortpkglist(squashspaces(getpkgvar(pkg, 'RSUGGESTS') or "")) pkginfo.rsuggests = sortpkglist(squashspaces(pkgdata.get('RSUGGESTS_%s' % pkg, "")))
pkginfo.rreplaces = sortpkglist(squashspaces(getpkgvar(pkg, 'RREPLACES') or "")) pkginfo.rreplaces = sortpkglist(squashspaces(pkgdata.get('RREPLACES_%s' % pkg, "")))
pkginfo.rconflicts = sortpkglist(squashspaces(getpkgvar(pkg, 'RCONFLICTS') or "")) pkginfo.rconflicts = sortpkglist(squashspaces(pkgdata.get('RCONFLICTS_%s' % pkg, "")))
pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") pkginfo.files = squashspaces(pkgdata.get('FILES_%s' % pkg, ""))
for filevar in pkginfo.filevars: 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 # Gather information about packaged files
pkgdestpkg = os.path.join(pkgdest, pkg) val = pkgdata.get('FILES_INFO', '')
filelist = [] dictval = json.loads(val)
pkginfo.size = 0 filelist = dictval.keys()
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)
filelist.sort() filelist.sort()
pkginfo.filelist = " ".join(filelist) pkginfo.filelist = " ".join(filelist)
pkginfo.size = int(pkgdata['PKGSIZE_%s' % pkg])
write_pkghistory(pkginfo, d) write_pkghistory(pkginfo, d)
} }