diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2012-08-02 10:23:05 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-08-06 15:29:46 +0100 |
commit | 81485a47d53e121ac3d8f27e225f7fa8fb7c3bf7 (patch) | |
tree | 158fc2b98c0b99176f9192e1f5a12c989e2fe0bc /meta/classes/buildhistory.bbclass | |
parent | c0149ac6c4859a05a7a1f7310a9bd981caea8f2d (diff) | |
download | poky-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>
Diffstat (limited to 'meta/classes/buildhistory.bbclass')
-rw-r--r-- | meta/classes/buildhistory.bbclass | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 200d03192e..76648c9499 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) |