summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-19 11:32:20 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-19 12:33:20 +0100
commit2665be9dd5730c3f1135b92d7d91de479c397a29 (patch)
tree60fdfaec4eb8a542e852f71908ffbdf9ca4c85d7
parent09d11c2794f445a4311f6cba3fdd79bfc216abc5 (diff)
downloadpoky-2665be9dd5730c3f1135b92d7d91de479c397a29.tar.gz
buildhistory.bbclass: Fix python whitespace
(From OE-Core rev: 51d402fa0ec9e4adf10c3dac2a69a385ee720fa1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/buildhistory.bbclass494
1 files changed, 247 insertions, 247 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 916aae6bad..f0bf849860 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -29,249 +29,249 @@ do_package[vardepsexclude] += "buildhistory_emit_pkghistory"
29# for comparision when writing future packages 29# for comparision when writing future packages
30# 30#
31python buildhistory_emit_pkghistory() { 31python buildhistory_emit_pkghistory() {
32 import re 32 import re
33 33
34 if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split(): 34 if not "package" in (d.getVar('BUILDHISTORY_FEATURES', True) or "").split():
35 return 0 35 return 0
36 36
37 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) 37 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
38 38
39 class RecipeInfo: 39 class RecipeInfo:
40 def __init__(self, name): 40 def __init__(self, name):
41 self.name = name 41 self.name = name
42 self.pe = "0" 42 self.pe = "0"
43 self.pv = "0" 43 self.pv = "0"
44 self.pr = "r0" 44 self.pr = "r0"
45 self.depends = "" 45 self.depends = ""
46 self.packages = "" 46 self.packages = ""
47 47
48 class PackageInfo: 48 class PackageInfo:
49 def __init__(self, name): 49 def __init__(self, name):
50 self.name = name 50 self.name = name
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 self.size = 0 54 self.size = 0
55 self.depends = "" 55 self.depends = ""
56 self.rdepends = "" 56 self.rdepends = ""
57 self.rrecommends = "" 57 self.rrecommends = ""
58 self.files = "" 58 self.files = ""
59 self.filelist = "" 59 self.filelist = ""
60 60
61 # Should check PACKAGES here to see if anything removed 61 # Should check PACKAGES here to see if anything removed
62 62
63 def getpkgvar(pkg, var): 63 def getpkgvar(pkg, var):
64 val = bb.data.getVar('%s_%s' % (var, pkg), d, 1) 64 val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
65 if val: 65 if val:
66 return val 66 return val
67 val = bb.data.getVar('%s' % (var), d, 1) 67 val = bb.data.getVar('%s' % (var), d, 1)
68 68
69 return val 69 return val
70 70
71 def readRecipeInfo(pn, histfile): 71 def readRecipeInfo(pn, histfile):
72 rcpinfo = RecipeInfo(pn) 72 rcpinfo = RecipeInfo(pn)
73 f = open(histfile, "r") 73 f = open(histfile, "r")
74 try: 74 try:
75 for line in f: 75 for line in f:
76 lns = line.split('=') 76 lns = line.split('=')
77 name = lns[0].strip() 77 name = lns[0].strip()
78 value = lns[1].strip(" \t\r\n").strip('"') 78 value = lns[1].strip(" \t\r\n").strip('"')
79 if name == "PE": 79 if name == "PE":
80 rcpinfo.pe = value 80 rcpinfo.pe = value
81 elif name == "PV": 81 elif name == "PV":
82 rcpinfo.pv = value 82 rcpinfo.pv = value
83 elif name == "PR": 83 elif name == "PR":
84 rcpinfo.pr = value 84 rcpinfo.pr = value
85 elif name == "DEPENDS": 85 elif name == "DEPENDS":
86 rcpinfo.depends = value 86 rcpinfo.depends = value
87 elif name == "PACKAGES": 87 elif name == "PACKAGES":
88 rcpinfo.packages = value 88 rcpinfo.packages = value
89 finally: 89 finally:
90 f.close() 90 f.close()
91 return rcpinfo 91 return rcpinfo
92 92
93 def readPackageInfo(pkg, histfile): 93 def readPackageInfo(pkg, histfile):
94 pkginfo = PackageInfo(pkg) 94 pkginfo = PackageInfo(pkg)
95 f = open(histfile, "r") 95 f = open(histfile, "r")
96 try: 96 try:
97 for line in f: 97 for line in f:
98 lns = line.split('=') 98 lns = line.split('=')
99 name = lns[0].strip() 99 name = lns[0].strip()
100 value = lns[1].strip(" \t\r\n").strip('"') 100 value = lns[1].strip(" \t\r\n").strip('"')
101 if name == "PE": 101 if name == "PE":
102 pkginfo.pe = value 102 pkginfo.pe = value
103 elif name == "PV": 103 elif name == "PV":
104 pkginfo.pv = value 104 pkginfo.pv = value
105 elif name == "PR": 105 elif name == "PR":
106 pkginfo.pr = value 106 pkginfo.pr = value
107 elif name == "RDEPENDS": 107 elif name == "RDEPENDS":
108 pkginfo.rdepends = value 108 pkginfo.rdepends = value
109 elif name == "RRECOMMENDS": 109 elif name == "RRECOMMENDS":
110 pkginfo.rrecommends = value 110 pkginfo.rrecommends = value
111 elif name == "PKGSIZE": 111 elif name == "PKGSIZE":
112 pkginfo.size = long(value) 112 pkginfo.size = long(value)
113 elif name == "FILES": 113 elif name == "FILES":
114 pkginfo.files = value 114 pkginfo.files = value
115 elif name == "FILELIST": 115 elif name == "FILELIST":
116 pkginfo.filelist = value 116 pkginfo.filelist = value
117 finally: 117 finally:
118 f.close() 118 f.close()
119 return pkginfo 119 return pkginfo
120 120
121 def getlastrecipeversion(pn): 121 def getlastrecipeversion(pn):
122 try: 122 try:
123 histfile = os.path.join(pkghistdir, "latest") 123 histfile = os.path.join(pkghistdir, "latest")
124 return readRecipeInfo(pn, histfile) 124 return readRecipeInfo(pn, histfile)
125 except EnvironmentError: 125 except EnvironmentError:
126 return None 126 return None
127 127
128 def getlastpkgversion(pkg): 128 def getlastpkgversion(pkg):
129 try: 129 try:
130 histfile = os.path.join(pkghistdir, pkg, "latest") 130 histfile = os.path.join(pkghistdir, pkg, "latest")
131 return readPackageInfo(pkg, histfile) 131 return readPackageInfo(pkg, histfile)
132 except EnvironmentError: 132 except EnvironmentError:
133 return None 133 return None
134 134
135 def sortpkglist(string): 135 def sortpkglist(string):
136 pkgiter = re.finditer(r'[a-zA-Z0-9.+-]+( \([><=]+ [^ )]+\))?', string, 0) 136 pkgiter = re.finditer(r'[a-zA-Z0-9.+-]+( \([><=]+ [^ )]+\))?', string, 0)
137 pkglist = [p.group(0) for p in pkgiter] 137 pkglist = [p.group(0) for p in pkgiter]
138 pkglist.sort() 138 pkglist.sort()
139 return ' '.join(pkglist) 139 return ' '.join(pkglist)
140 140
141 def sortlist(string): 141 def sortlist(string):
142 items = string.split(' ') 142 items = string.split(' ')
143 items.sort() 143 items.sort()
144 return ' '.join(items) 144 return ' '.join(items)
145 145
146 pn = d.getVar('PN', True) 146 pn = d.getVar('PN', True)
147 pe = d.getVar('PE', True) or "0" 147 pe = d.getVar('PE', True) or "0"
148 pv = d.getVar('PV', True) 148 pv = d.getVar('PV', True)
149 pr = d.getVar('PR', True) 149 pr = d.getVar('PR', True)
150 packages = squashspaces(d.getVar('PACKAGES', True)) 150 packages = squashspaces(d.getVar('PACKAGES', True))
151 151
152 rcpinfo = RecipeInfo(pn) 152 rcpinfo = RecipeInfo(pn)
153 rcpinfo.pe = pe 153 rcpinfo.pe = pe
154 rcpinfo.pv = pv 154 rcpinfo.pv = pv
155 rcpinfo.pr = pr 155 rcpinfo.pr = pr
156 rcpinfo.depends = sortlist(squashspaces(d.getVar('DEPENDS', True) or "")) 156 rcpinfo.depends = sortlist(squashspaces(d.getVar('DEPENDS', True) or ""))
157 rcpinfo.packages = packages 157 rcpinfo.packages = packages
158 write_recipehistory(rcpinfo, d) 158 write_recipehistory(rcpinfo, d)
159 write_latestlink(None, pe, pv, pr, d) 159 write_latestlink(None, pe, pv, pr, d)
160 160
161 # Apparently the version can be different on a per-package basis (see Python) 161 # Apparently the version can be different on a per-package basis (see Python)
162 pkgdest = d.getVar('PKGDEST', True) 162 pkgdest = d.getVar('PKGDEST', True)
163 for pkg in packages.split(): 163 for pkg in packages.split():
164 pe = getpkgvar(pkg, 'PE') or "0" 164 pe = getpkgvar(pkg, 'PE') or "0"
165 pv = getpkgvar(pkg, 'PV') 165 pv = getpkgvar(pkg, 'PV')
166 pr = getpkgvar(pkg, 'PR') 166 pr = getpkgvar(pkg, 'PR')
167 # 167 #
168 # Find out what the last version was 168 # Find out what the last version was
169 # Make sure the version did not decrease 169 # Make sure the version did not decrease
170 # 170 #
171 lastversion = getlastpkgversion(pkg) 171 lastversion = getlastpkgversion(pkg)
172 if lastversion: 172 if lastversion:
173 last_pe = lastversion.pe 173 last_pe = lastversion.pe
174 last_pv = lastversion.pv 174 last_pv = lastversion.pv
175 last_pr = lastversion.pr 175 last_pr = lastversion.pr
176 r = bb.utils.vercmp((pe, pv, pr), (last_pe, last_pv, last_pr)) 176 r = bb.utils.vercmp((pe, pv, pr), (last_pe, last_pv, last_pr))
177 if r < 0: 177 if r < 0:
178 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)) 178 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))
179 179
180 pkginfo = PackageInfo(pkg) 180 pkginfo = PackageInfo(pkg)
181 pkginfo.pe = pe 181 pkginfo.pe = pe
182 pkginfo.pv = pv 182 pkginfo.pv = pv
183 pkginfo.pr = pr 183 pkginfo.pr = pr
184 pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) 184 pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or ""))
185 pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) 185 pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or ""))
186 pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") 186 pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "")
187 187
188 # Gather information about packaged files 188 # Gather information about packaged files
189 pkgdestpkg = os.path.join(pkgdest, pkg) 189 pkgdestpkg = os.path.join(pkgdest, pkg)
190 filelist = [] 190 filelist = []
191 pkginfo.size = 0 191 pkginfo.size = 0
192 for root, dirs, files in os.walk(pkgdestpkg): 192 for root, dirs, files in os.walk(pkgdestpkg):
193 relpth = os.path.relpath(root, pkgdestpkg) 193 relpth = os.path.relpath(root, pkgdestpkg)
194 for f in files: 194 for f in files:
195 fstat = os.lstat(os.path.join(root, f)) 195 fstat = os.lstat(os.path.join(root, f))
196 pkginfo.size += fstat.st_size 196 pkginfo.size += fstat.st_size
197 filelist.append(os.sep + os.path.join(relpth, f)) 197 filelist.append(os.sep + os.path.join(relpth, f))
198 filelist.sort() 198 filelist.sort()
199 pkginfo.filelist = " ".join(filelist) 199 pkginfo.filelist = " ".join(filelist)
200 200
201 write_pkghistory(pkginfo, d) 201 write_pkghistory(pkginfo, d)
202 202
203 write_latestlink(pkg, pe, pv, pr, d) 203 write_latestlink(pkg, pe, pv, pr, d)
204} 204}
205 205
206 206
207def write_recipehistory(rcpinfo, d): 207def write_recipehistory(rcpinfo, d):
208 bb.debug(2, "Writing recipe history") 208 bb.debug(2, "Writing recipe history")
209 209
210 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) 210 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
211 211
212 if not os.path.exists(pkghistdir): 212 if not os.path.exists(pkghistdir):
213 os.makedirs(pkghistdir) 213 os.makedirs(pkghistdir)
214 214
215 verfile = os.path.join(pkghistdir, "%s:%s-%s" % (rcpinfo.pe, rcpinfo.pv, rcpinfo.pr)) 215 verfile = os.path.join(pkghistdir, "%s:%s-%s" % (rcpinfo.pe, rcpinfo.pv, rcpinfo.pr))
216 f = open(verfile, "w") 216 f = open(verfile, "w")
217 try: 217 try:
218 if rcpinfo.pe != "0": 218 if rcpinfo.pe != "0":
219 f.write("PE = %s\n" % rcpinfo.pe) 219 f.write("PE = %s\n" % rcpinfo.pe)
220 f.write("PV = %s\n" % rcpinfo.pv) 220 f.write("PV = %s\n" % rcpinfo.pv)
221 f.write("PR = %s\n" % rcpinfo.pr) 221 f.write("PR = %s\n" % rcpinfo.pr)
222 f.write("DEPENDS = %s\n" % rcpinfo.depends) 222 f.write("DEPENDS = %s\n" % rcpinfo.depends)
223 f.write("PACKAGES = %s\n" % rcpinfo.packages) 223 f.write("PACKAGES = %s\n" % rcpinfo.packages)
224 finally: 224 finally:
225 f.close() 225 f.close()
226 226
227 227
228def write_pkghistory(pkginfo, d): 228def write_pkghistory(pkginfo, d):
229 bb.debug(2, "Writing package history") 229 bb.debug(2, "Writing package history")
230 230
231 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) 231 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
232 232
233 verpath = os.path.join(pkghistdir, pkginfo.name) 233 verpath = os.path.join(pkghistdir, pkginfo.name)
234 if not os.path.exists(verpath): 234 if not os.path.exists(verpath):
235 os.makedirs(verpath) 235 os.makedirs(verpath)
236 236
237 verfile = os.path.join(verpath, "%s:%s-%s" % (pkginfo.pe, pkginfo.pv, pkginfo.pr)) 237 verfile = os.path.join(verpath, "%s:%s-%s" % (pkginfo.pe, pkginfo.pv, pkginfo.pr))
238 f = open(verfile, "w") 238 f = open(verfile, "w")
239 try: 239 try:
240 if pkginfo.pe != "0": 240 if pkginfo.pe != "0":
241 f.write("PE = %s\n" % pkginfo.pe) 241 f.write("PE = %s\n" % pkginfo.pe)
242 f.write("PV = %s\n" % pkginfo.pv) 242 f.write("PV = %s\n" % pkginfo.pv)
243 f.write("PR = %s\n" % pkginfo.pr) 243 f.write("PR = %s\n" % pkginfo.pr)
244 f.write("RDEPENDS = %s\n" % pkginfo.rdepends) 244 f.write("RDEPENDS = %s\n" % pkginfo.rdepends)
245 f.write("RRECOMMENDS = %s\n" % pkginfo.rrecommends) 245 f.write("RRECOMMENDS = %s\n" % pkginfo.rrecommends)
246 f.write("PKGSIZE = %d\n" % pkginfo.size) 246 f.write("PKGSIZE = %d\n" % pkginfo.size)
247 f.write("FILES = %s\n" % pkginfo.files) 247 f.write("FILES = %s\n" % pkginfo.files)
248 f.write("FILELIST = %s\n" % pkginfo.filelist) 248 f.write("FILELIST = %s\n" % pkginfo.filelist)
249 finally: 249 finally:
250 f.close() 250 f.close()
251 251
252 252
253def write_latestlink(pkg, pe, pv, pr, d): 253def write_latestlink(pkg, pe, pv, pr, d):
254 import shutil 254 import shutil
255 255
256 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) 256 pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True)
257 257
258 def rm_link(path): 258 def rm_link(path):
259 try: 259 try:
260 os.unlink(path) 260 os.unlink(path)
261 except OSError: 261 except OSError:
262 return 262 return
263 263
264 if pkg: 264 if pkg:
265 filedir = os.path.join(pkghistdir, pkg) 265 filedir = os.path.join(pkghistdir, pkg)
266 else: 266 else:
267 filedir = pkghistdir 267 filedir = pkghistdir
268 latest_file = os.path.join(filedir, "latest") 268 latest_file = os.path.join(filedir, "latest")
269 ver_file = os.path.join(filedir, "%s:%s-%s" % (pe, pv, pr)) 269 ver_file = os.path.join(filedir, "%s:%s-%s" % (pe, pv, pr))
270 rm_link(latest_file) 270 rm_link(latest_file)
271 if d.getVar('BUILDHISTORY_KEEP_VERSIONS', True) == '1': 271 if d.getVar('BUILDHISTORY_KEEP_VERSIONS', True) == '1':
272 shutil.copy(ver_file, latest_file) 272 shutil.copy(ver_file, latest_file)
273 else: 273 else:
274 shutil.move(ver_file, latest_file) 274 shutil.move(ver_file, latest_file)
275 275
276 276
277buildhistory_get_image_installed() { 277buildhistory_get_image_installed() {
@@ -360,29 +360,29 @@ ROOTFS_POSTPROCESS_COMMAND =+ "buildhistory_get_image_installed ; "
360IMAGE_POSTPROCESS_COMMAND += " buildhistory_get_imageinfo ; " 360IMAGE_POSTPROCESS_COMMAND += " buildhistory_get_imageinfo ; "
361 361
362def buildhistory_get_layers(d): 362def buildhistory_get_layers(d):
363 layertext = "Configured metadata layers:\n%s\n" % '\n'.join(get_layers_branch_rev(d)) 363 layertext = "Configured metadata layers:\n%s\n" % '\n'.join(get_layers_branch_rev(d))
364 return layertext 364 return layertext
365 365
366 366
367def squashspaces(string): 367def squashspaces(string):
368 import re 368 import re
369 return re.sub("\s+", " ", string).strip() 369 return re.sub("\s+", " ", string).strip()
370 370
371 371
372def buildhistory_get_imagevars(d): 372def buildhistory_get_imagevars(d):
373 imagevars = "DISTRO DISTRO_VERSION USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS ROOTFS_POSTPROCESS_COMMAND IMAGE_POSTPROCESS_COMMAND" 373 imagevars = "DISTRO DISTRO_VERSION USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS ROOTFS_POSTPROCESS_COMMAND IMAGE_POSTPROCESS_COMMAND"
374 listvars = "USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS" 374 listvars = "USER_CLASSES IMAGE_CLASSES IMAGE_FEATURES IMAGE_LINGUAS IMAGE_INSTALL BAD_RECOMMENDATIONS"
375 375
376 imagevars = imagevars.split() 376 imagevars = imagevars.split()
377 listvars = listvars.split() 377 listvars = listvars.split()
378 ret = "" 378 ret = ""
379 for var in imagevars: 379 for var in imagevars:
380 value = d.getVar(var, True) or "" 380 value = d.getVar(var, True) or ""
381 if var in listvars: 381 if var in listvars:
382 # Squash out spaces 382 # Squash out spaces
383 value = squashspaces(value) 383 value = squashspaces(value)
384 ret += "%s = %s\n" % (var, value) 384 ret += "%s = %s\n" % (var, value)
385 return ret.rstrip('\n') 385 return ret.rstrip('\n')
386 386
387 387
388buildhistory_commit() { 388buildhistory_commit() {
@@ -414,10 +414,10 @@ buildhistory_commit() {
414} 414}
415 415
416python buildhistory_eventhandler() { 416python buildhistory_eventhandler() {
417 if isinstance(e, bb.event.BuildCompleted): 417 if isinstance(e, bb.event.BuildCompleted):
418 if e.data.getVar('BUILDHISTORY_FEATURES', True).strip(): 418 if e.data.getVar('BUILDHISTORY_FEATURES', True).strip():
419 if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1": 419 if e.data.getVar("BUILDHISTORY_COMMIT", True) == "1":
420 bb.build.exec_func("buildhistory_commit", e.data) 420 bb.build.exec_func("buildhistory_commit", e.data)
421} 421}
422 422
423addhandler buildhistory_eventhandler 423addhandler buildhistory_eventhandler