summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2012-08-02 09:23:05 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-08-06 14:29:46 (GMT)
commit81485a47d53e121ac3d8f27e225f7fa8fb7c3bf7 (patch)
tree158fc2b98c0b99176f9192e1f5a12c989e2fe0bc
parentc0149ac6c4859a05a7a1f7310a9bd981caea8f2d (diff)
downloadpoky-81485a47d53e121ac3d8f27e225f7fa8fb7c3bf7.tar.gz
classes/buildhistory: record PKG/PKGE/PKGV/PKGR
Save PKG (the actual output package name, which is often different due to debian renaming), and PKGE/PKGV/PKGR (which may be manipulated in certain special cases e.g. gitpkgv.bbclass in meta-oe, the external-sourcery-toolchain recipe, etc.) Note that these are only written when they are different from the normal package name in the case of PKG, or PE/PV/PR for the other variables. Also, use PKGE/PKGV/PKGR instead of PE/PV/PR when comparing package versions since these actually represent the version that the package manager sees. Implements [YOCTO #2787]. (From OE-Core rev: 65d7e9b2d4d8115ac9fd513c04f39a2df9556a5a) 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.bbclass66
-rw-r--r--meta/lib/oe/buildhistory_analysis.py22
2 files changed, 71 insertions, 17 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 200d031..76648c9 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -51,6 +51,11 @@ python buildhistory_emit_pkghistory() {
51 self.pe = "0" 51 self.pe = "0"
52 self.pv = "0" 52 self.pv = "0"
53 self.pr = "r0" 53 self.pr = "r0"
54 # pkg/pkge/pkgv/pkgr should be empty because we want to be able to default them
55 self.pkg = ""
56 self.pkge = ""
57 self.pkgv = ""
58 self.pkgr = ""
54 self.size = 0 59 self.size = 0
55 self.depends = "" 60 self.depends = ""
56 self.rdepends = "" 61 self.rdepends = ""
@@ -72,8 +77,7 @@ python buildhistory_emit_pkghistory() {
72 77
73 def readPackageInfo(pkg, histfile): 78 def readPackageInfo(pkg, histfile):
74 pkginfo = PackageInfo(pkg) 79 pkginfo = PackageInfo(pkg)
75 f = open(histfile, "r") 80 with open(histfile, "r") as f:
76 try:
77 for line in f: 81 for line in f:
78 lns = line.split('=') 82 lns = line.split('=')
79 name = lns[0].strip() 83 name = lns[0].strip()
@@ -84,6 +88,14 @@ python buildhistory_emit_pkghistory() {
84 pkginfo.pv = value 88 pkginfo.pv = value
85 elif name == "PR": 89 elif name == "PR":
86 pkginfo.pr = value 90 pkginfo.pr = value
91 elif name == "PKG":
92 pkginfo.pkg = value
93 elif name == "PKGE":
94 pkginfo.pkge = value
95 elif name == "PKGV":
96 pkginfo.pkgv = value
97 elif name == "PKGR":
98 pkginfo.pkgr = value
87 elif name == "RDEPENDS": 99 elif name == "RDEPENDS":
88 pkginfo.rdepends = value 100 pkginfo.rdepends = value
89 elif name == "RRECOMMENDS": 101 elif name == "RRECOMMENDS":
@@ -94,8 +106,15 @@ python buildhistory_emit_pkghistory() {
94 pkginfo.files = value 106 pkginfo.files = value
95 elif name == "FILELIST": 107 elif name == "FILELIST":
96 pkginfo.filelist = value 108 pkginfo.filelist = value
97 finally: 109 # Apply defaults
98 f.close() 110 if not pkginfo.pkg:
111 pkginfo.pkg = pkginfo.name
112 if not pkginfo.pkge:
113 pkginfo.pkge = pkginfo.pe
114 if not pkginfo.pkgv:
115 pkginfo.pkgv = pkginfo.pv
116 if not pkginfo.pkgr:
117 pkginfo.pkgr = pkginfo.pr
99 return pkginfo 118 return pkginfo
100 119
101 def getlastpkgversion(pkg): 120 def getlastpkgversion(pkg):
@@ -143,29 +162,33 @@ python buildhistory_emit_pkghistory() {
143 rcpinfo.packages = packages 162 rcpinfo.packages = packages
144 write_recipehistory(rcpinfo, d) 163 write_recipehistory(rcpinfo, d)
145 164
146 # Apparently the version can be different on a per-package basis (see Python)
147 pkgdest = d.getVar('PKGDEST', True) 165 pkgdest = d.getVar('PKGDEST', True)
148 for pkg in packagelist: 166 for pkg in packagelist:
149 pe = getpkgvar(pkg, 'PE') or "0" 167 pkge = getpkgvar(pkg, 'PKGE') or "0"
150 pv = getpkgvar(pkg, 'PV') 168 pkgv = getpkgvar(pkg, 'PKGV')
151 pr = getpkgvar(pkg, 'PR') 169 pkgr = getpkgvar(pkg, 'PKGR')
152 # 170 #
153 # Find out what the last version was 171 # Find out what the last version was
154 # Make sure the version did not decrease 172 # Make sure the version did not decrease
155 # 173 #
156 lastversion = getlastpkgversion(pkg) 174 lastversion = getlastpkgversion(pkg)
157 if lastversion: 175 if lastversion:
158 last_pe = lastversion.pe 176 last_pkge = lastversion.pkge
159 last_pv = lastversion.pv 177 last_pkgv = lastversion.pkgv
160 last_pr = lastversion.pr 178 last_pkgr = lastversion.pkgr
161 r = bb.utils.vercmp((pe, pv, pr), (last_pe, last_pv, last_pr)) 179 r = bb.utils.vercmp((pkge, pkgv, pkgr), (last_pkge, last_pkgv, last_pkgr))
162 if r < 0: 180 if r < 0:
163 bb.error("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)) 181 bb.error("Package version for package %s went backwards which would break package feeds from (%s:%s-%s to %s:%s-%s)" % (pkg, last_pkge, last_pkgv, last_pkgr, pkge, pkgv, pkgr))
164 182
165 pkginfo = PackageInfo(pkg) 183 pkginfo = PackageInfo(pkg)
166 pkginfo.pe = pe 184 # Apparently the version can be different on a per-package basis (see Python)
167 pkginfo.pv = pv 185 pkginfo.pe = getpkgvar(pkg, 'PE') or "0"
168 pkginfo.pr = pr 186 pkginfo.pv = getpkgvar(pkg, 'PV')
187 pkginfo.pr = getpkgvar(pkg, 'PR')
188 pkginfo.pkg = getpkgvar(pkg, 'PKG') or pkg
189 pkginfo.pkge = pkge
190 pkginfo.pkgv = pkgv
191 pkginfo.pkgr = pkgr
169 pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) 192 pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
170 pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) 193 pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))
171 pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") 194 pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "")
@@ -219,6 +242,17 @@ def write_pkghistory(pkginfo, d):
219 f.write("PE = %s\n" % pkginfo.pe) 242 f.write("PE = %s\n" % pkginfo.pe)
220 f.write("PV = %s\n" % pkginfo.pv) 243 f.write("PV = %s\n" % pkginfo.pv)
221 f.write("PR = %s\n" % pkginfo.pr) 244 f.write("PR = %s\n" % pkginfo.pr)
245
246 pkgvars = {}
247 pkgvars['PKG'] = pkginfo.pkg if pkginfo.pkg != pkginfo.name else ''
248 pkgvars['PKGE'] = pkginfo.pkge if pkginfo.pkge != pkginfo.pe else ''
249 pkgvars['PKGV'] = pkginfo.pkgv if pkginfo.pkgv != pkginfo.pv else ''
250 pkgvars['PKGR'] = pkginfo.pkgr if pkginfo.pkgr != pkginfo.pr else ''
251 for pkgvar in pkgvars:
252 val = pkgvars[pkgvar]
253 if val:
254 f.write("%s = %s\n" % (pkgvar, val))
255
222 f.write("RDEPENDS = %s\n" % pkginfo.rdepends) 256 f.write("RDEPENDS = %s\n" % pkginfo.rdepends)
223 f.write("RRECOMMENDS = %s\n" % pkginfo.rrecommends) 257 f.write("RRECOMMENDS = %s\n" % pkginfo.rrecommends)
224 f.write("PKGSIZE = %d\n" % pkginfo.size) 258 f.write("PKGSIZE = %d\n" % pkginfo.size)
diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py
index 6c6a085..55bd7b7 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -19,9 +19,10 @@ import bb.utils
19# How to display fields 19# How to display fields
20list_fields = ['DEPENDS', 'RDEPENDS', 'RRECOMMENDS', 'FILES', 'FILELIST', 'USER_CLASSES', 'IMAGE_CLASSES', 'IMAGE_FEATURES', 'IMAGE_LINGUAS', 'IMAGE_INSTALL', 'BAD_RECOMMENDATIONS'] 20list_fields = ['DEPENDS', 'RDEPENDS', 'RRECOMMENDS', 'FILES', 'FILELIST', 'USER_CLASSES', 'IMAGE_CLASSES', 'IMAGE_FEATURES', 'IMAGE_LINGUAS', 'IMAGE_INSTALL', 'BAD_RECOMMENDATIONS']
21list_order_fields = ['PACKAGES'] 21list_order_fields = ['PACKAGES']
22defaultval_fields = ['PKG', 'PKGE', 'PKGV', 'PKGR']
22numeric_fields = ['PKGSIZE', 'IMAGESIZE'] 23numeric_fields = ['PKGSIZE', 'IMAGESIZE']
23# Fields to monitor 24# Fields to monitor
24monitor_fields = ['RDEPENDS', 'RRECOMMENDS', 'PACKAGES', 'FILELIST', 'PKGSIZE', 'IMAGESIZE'] 25monitor_fields = ['RDEPENDS', 'RRECOMMENDS', 'PACKAGES', 'FILELIST', 'PKGSIZE', 'IMAGESIZE', 'PKG', 'PKGE', 'PKGV', 'PKGR']
25# Percentage change to alert for numeric fields 26# Percentage change to alert for numeric fields
26monitor_numeric_threshold = 20 27monitor_numeric_threshold = 20
27# Image files to monitor (note that image-info.txt is handled separately) 28# Image files to monitor (note that image-info.txt is handled separately)
@@ -90,6 +91,10 @@ class ChangeRecord:
90 else: 91 else:
91 percentchg = 100 92 percentchg = 100
92 out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg) 93 out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg)
94 elif self.fieldname in defaultval_fields:
95 out = '%s changed from %s to %s' % (self.fieldname, self.oldvalue, self.newvalue)
96 if self.fieldname == 'PKG' and '[default]' in self.newvalue:
97 out += ' - may indicate debian renaming failure'
93 elif self.fieldname in ['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']: 98 elif self.fieldname in ['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']:
94 if self.oldvalue and self.newvalue: 99 if self.oldvalue and self.newvalue:
95 out = '%s changed:\n ' % self.fieldname 100 out = '%s changed:\n ' % self.fieldname
@@ -299,6 +304,14 @@ def compare_dict_blobs(path, ablob, bblob, report_all):
299 adict = blob_to_dict(ablob) 304 adict = blob_to_dict(ablob)
300 bdict = blob_to_dict(bblob) 305 bdict = blob_to_dict(bblob)
301 306
307 defaultvals = {}
308 defaultvals['PKG'] = os.path.basename(path)
309 defaultvals['PKGE'] = adict.get('PE', '0')
310 defaultvals['PKGV'] = adict.get('PV', '')
311 defaultvals['PKGR'] = adict.get('PR', '')
312 for key in defaultvals:
313 defaultvals[key] = '%s [default]' % defaultvals[key]
314
302 changes = [] 315 changes = []
303 keys = list(set(adict.keys()) | set(bdict.keys())) 316 keys = list(set(adict.keys()) | set(bdict.keys()))
304 for key in keys: 317 for key in keys:
@@ -327,6 +340,13 @@ def compare_dict_blobs(path, ablob, bblob, report_all):
327 blist.sort() 340 blist.sort()
328 if ' '.join(alist) == ' '.join(blist): 341 if ' '.join(alist) == ' '.join(blist):
329 continue 342 continue
343
344 if key in defaultval_fields:
345 if not astr:
346 astr = defaultvals[key]
347 elif not bstr:
348 bstr = defaultvals[key]
349
330 chg = ChangeRecord(path, key, astr, bstr, key in monitor_fields) 350 chg = ChangeRecord(path, key, astr, bstr, key in monitor_fields)
331 changes.append(chg) 351 changes.append(chg)
332 return changes 352 return changes