summaryrefslogtreecommitdiffstats
path: root/meta/classes/package_ipk.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-19 11:23:23 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-07-19 12:24:50 +0100
commit09d11c2794f445a4311f6cba3fdd79bfc216abc5 (patch)
treed49afd62fb6dcd9da963ad6f7604452add45be18 /meta/classes/package_ipk.bbclass
parent73cf0335c463758379765fa5f26a4484afaca8a0 (diff)
downloadpoky-09d11c2794f445a4311f6cba3fdd79bfc216abc5.tar.gz
package_ipk.bbclass: Fix python whitespace
(From OE-Core rev: 8a6c2278377edd63af54a469f0fb2b23f90e056b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_ipk.bbclass')
-rw-r--r--meta/classes/package_ipk.bbclass438
1 files changed, 219 insertions, 219 deletions
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index e682e6a611..a297a1f9d4 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -11,59 +11,59 @@ PKGWRITEDIRIPK = "${WORKDIR}/deploy-ipks"
11OPKGBUILDCMD ??= "opkg-build" 11OPKGBUILDCMD ??= "opkg-build"
12 12
13python package_ipk_fn () { 13python package_ipk_fn () {
14 d.setVar('PKGFN', d.getVar('PKG')) 14 d.setVar('PKGFN', d.getVar('PKG'))
15} 15}
16 16
17python package_ipk_install () { 17python package_ipk_install () {
18 import subprocess 18 import subprocess
19 19
20 pkg = d.getVar('PKG', True) 20 pkg = d.getVar('PKG', True)
21 pkgfn = d.getVar('PKGFN', True) 21 pkgfn = d.getVar('PKGFN', True)
22 rootfs = d.getVar('IMAGE_ROOTFS', True) 22 rootfs = d.getVar('IMAGE_ROOTFS', True)
23 ipkdir = d.getVar('DEPLOY_DIR_IPK', True) 23 ipkdir = d.getVar('DEPLOY_DIR_IPK', True)
24 stagingdir = d.getVar('STAGING_DIR', True) 24 stagingdir = d.getVar('STAGING_DIR', True)
25 tmpdir = d.getVar('TMPDIR', True) 25 tmpdir = d.getVar('TMPDIR', True)
26 26
27 if None in (pkg,pkgfn,rootfs): 27 if None in (pkg,pkgfn,rootfs):
28 raise bb.build.FuncFailed("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)") 28 raise bb.build.FuncFailed("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)")
29 try: 29 try:
30 bb.mkdirhier(rootfs) 30 bb.mkdirhier(rootfs)
31 os.chdir(rootfs) 31 os.chdir(rootfs)
32 except OSError: 32 except OSError:
33 import sys 33 import sys
34 (type, value, traceback) = sys.exc_info() 34 (type, value, traceback) = sys.exc_info()
35 print value 35 print value
36 raise bb.build.FuncFailed 36 raise bb.build.FuncFailed
37 37
38 # Generate ipk.conf if it or the stamp doesnt exist 38 # Generate ipk.conf if it or the stamp doesnt exist
39 conffile = os.path.join(stagingdir,"ipkg.conf") 39 conffile = os.path.join(stagingdir,"ipkg.conf")
40 if not os.access(conffile, os.R_OK): 40 if not os.access(conffile, os.R_OK):
41 ipkg_archs = d.getVar('PACKAGE_ARCHS') 41 ipkg_archs = d.getVar('PACKAGE_ARCHS')
42 if ipkg_archs is None: 42 if ipkg_archs is None:
43 bb.error("PACKAGE_ARCHS missing") 43 bb.error("PACKAGE_ARCHS missing")
44 raise FuncFailed 44 raise FuncFailed
45 ipkg_archs = ipkg_archs.split() 45 ipkg_archs = ipkg_archs.split()
46 arch_priority = 1 46 arch_priority = 1
47 47
48 f = open(conffile,"w") 48 f = open(conffile,"w")
49 for arch in ipkg_archs: 49 for arch in ipkg_archs:
50 f.write("arch %s %s\n" % ( arch, arch_priority )) 50 f.write("arch %s %s\n" % ( arch, arch_priority ))
51 arch_priority += 1 51 arch_priority += 1
52 f.write("src local file:%s" % ipkdir) 52 f.write("src local file:%s" % ipkdir)
53 f.close() 53 f.close()
54 54
55 55
56 if not os.access(os.path.join(ipkdir,"Packages"), os.R_OK) or not os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"),os.R_OK): 56 if not os.access(os.path.join(ipkdir,"Packages"), os.R_OK) or not os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"),os.R_OK):
57 ret = subprocess.call('opkg-make-index -p %s %s ' % (os.path.join(ipkdir, "Packages"), ipkdir), shell=True) 57 ret = subprocess.call('opkg-make-index -p %s %s ' % (os.path.join(ipkdir, "Packages"), ipkdir), shell=True)
58 if (ret != 0 ): 58 if (ret != 0 ):
59 raise bb.build.FuncFailed 59 raise bb.build.FuncFailed
60 f = open(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"),"w") 60 f = open(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"),"w")
61 f.close() 61 f.close()
62 62
63 ret = subprocess.call('opkg-cl -o %s -f %s update' % (rootfs, conffile), shell=True) 63 ret = subprocess.call('opkg-cl -o %s -f %s update' % (rootfs, conffile), shell=True)
64 ret = subprocess.call('opkg-cl -o %s -f %s install %s' % (rootfs, conffile, pkgfn), shell=True) 64 ret = subprocess.call('opkg-cl -o %s -f %s install %s' % (rootfs, conffile, pkgfn), shell=True)
65 if (ret != 0 ): 65 if (ret != 0 ):
66 raise bb.build.FuncFailed 66 raise bb.build.FuncFailed
67} 67}
68 68
69package_tryout_install_multilib_ipk() { 69package_tryout_install_multilib_ipk() {
@@ -262,174 +262,174 @@ package_generate_archlist () {
262} 262}
263 263
264python do_package_ipk () { 264python do_package_ipk () {
265 import re, copy 265 import re, copy
266 import textwrap 266 import textwrap
267 import subprocess 267 import subprocess
268 268
269 workdir = d.getVar('WORKDIR', True) 269 workdir = d.getVar('WORKDIR', True)
270 outdir = d.getVar('PKGWRITEDIRIPK', True) 270 outdir = d.getVar('PKGWRITEDIRIPK', True)
271 tmpdir = d.getVar('TMPDIR', True) 271 tmpdir = d.getVar('TMPDIR', True)
272 pkgdest = d.getVar('PKGDEST', True) 272 pkgdest = d.getVar('PKGDEST', True)
273 if not workdir or not outdir or not tmpdir: 273 if not workdir or not outdir or not tmpdir:
274 bb.error("Variables incorrectly set, unable to package") 274 bb.error("Variables incorrectly set, unable to package")
275 return 275 return
276 276
277 packages = d.getVar('PACKAGES', True) 277 packages = d.getVar('PACKAGES', True)
278 if not packages or packages == '': 278 if not packages or packages == '':
279 bb.debug(1, "No packages; nothing to do") 279 bb.debug(1, "No packages; nothing to do")
280 return 280 return
281 281
282 # We're about to add new packages so the index needs to be checked 282 # We're about to add new packages so the index needs to be checked
283 # so remove the appropriate stamp file. 283 # so remove the appropriate stamp file.
284 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): 284 if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
285 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) 285 os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
286 286
287 for pkg in packages.split(): 287 for pkg in packages.split():
288 localdata = bb.data.createCopy(d) 288 localdata = bb.data.createCopy(d)
289 root = "%s/%s" % (pkgdest, pkg) 289 root = "%s/%s" % (pkgdest, pkg)
290 290
291 lf = bb.utils.lockfile(root + ".lock") 291 lf = bb.utils.lockfile(root + ".lock")
292 292
293 localdata.setVar('ROOT', '') 293 localdata.setVar('ROOT', '')
294 localdata.setVar('ROOT_%s' % pkg, root) 294 localdata.setVar('ROOT_%s' % pkg, root)
295 pkgname = localdata.getVar('PKG_%s' % pkg, True) 295 pkgname = localdata.getVar('PKG_%s' % pkg, True)
296 if not pkgname: 296 if not pkgname:
297 pkgname = pkg 297 pkgname = pkg
298 localdata.setVar('PKG', pkgname) 298 localdata.setVar('PKG', pkgname)
299 299
300 localdata.setVar('OVERRIDES', pkg) 300 localdata.setVar('OVERRIDES', pkg)
301 301
302 bb.data.update_data(localdata) 302 bb.data.update_data(localdata)
303 basedir = os.path.join(os.path.dirname(root)) 303 basedir = os.path.join(os.path.dirname(root))
304 arch = localdata.getVar('PACKAGE_ARCH', True) 304 arch = localdata.getVar('PACKAGE_ARCH', True)
305 pkgoutdir = "%s/%s" % (outdir, arch) 305 pkgoutdir = "%s/%s" % (outdir, arch)
306 bb.mkdirhier(pkgoutdir) 306 bb.mkdirhier(pkgoutdir)
307 os.chdir(root) 307 os.chdir(root)
308 from glob import glob 308 from glob import glob
309 g = glob('*') 309 g = glob('*')
310 try: 310 try:
311 del g[g.index('CONTROL')] 311 del g[g.index('CONTROL')]
312 del g[g.index('./CONTROL')] 312 del g[g.index('./CONTROL')]
313 except ValueError: 313 except ValueError:
314 pass 314 pass
315 if not g and localdata.getVar('ALLOW_EMPTY') != "1": 315 if not g and localdata.getVar('ALLOW_EMPTY') != "1":
316 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True))) 316 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True)))
317 bb.utils.unlockfile(lf) 317 bb.utils.unlockfile(lf)
318 continue 318 continue
319 319
320 controldir = os.path.join(root, 'CONTROL') 320 controldir = os.path.join(root, 'CONTROL')
321 bb.mkdirhier(controldir) 321 bb.mkdirhier(controldir)
322 try: 322 try:
323 ctrlfile = file(os.path.join(controldir, 'control'), 'w') 323 ctrlfile = file(os.path.join(controldir, 'control'), 'w')
324 except OSError: 324 except OSError:
325 bb.utils.unlockfile(lf) 325 bb.utils.unlockfile(lf)
326 raise bb.build.FuncFailed("unable to open control file for writing.") 326 raise bb.build.FuncFailed("unable to open control file for writing.")
327 327
328 fields = [] 328 fields = []
329 pe = d.getVar('PKGE', True) 329 pe = d.getVar('PKGE', True)
330 if pe and int(pe) > 0: 330 if pe and int(pe) > 0:
331 fields.append(["Version: %s:%s-%s\n", ['PKGE', 'PKGV', 'PKGR']]) 331 fields.append(["Version: %s:%s-%s\n", ['PKGE', 'PKGV', 'PKGR']])
332 else: 332 else:
333 fields.append(["Version: %s-%s\n", ['PKGV', 'PKGR']]) 333 fields.append(["Version: %s-%s\n", ['PKGV', 'PKGR']])
334 fields.append(["Description: %s\n", ['DESCRIPTION']]) 334 fields.append(["Description: %s\n", ['DESCRIPTION']])
335 fields.append(["Section: %s\n", ['SECTION']]) 335 fields.append(["Section: %s\n", ['SECTION']])
336 fields.append(["Priority: %s\n", ['PRIORITY']]) 336 fields.append(["Priority: %s\n", ['PRIORITY']])
337 fields.append(["Maintainer: %s\n", ['MAINTAINER']]) 337 fields.append(["Maintainer: %s\n", ['MAINTAINER']])
338 fields.append(["License: %s\n", ['LICENSE']]) 338 fields.append(["License: %s\n", ['LICENSE']])
339 fields.append(["Architecture: %s\n", ['PACKAGE_ARCH']]) 339 fields.append(["Architecture: %s\n", ['PACKAGE_ARCH']])
340 fields.append(["OE: %s\n", ['PN']]) 340 fields.append(["OE: %s\n", ['PN']])
341 fields.append(["Homepage: %s\n", ['HOMEPAGE']]) 341 fields.append(["Homepage: %s\n", ['HOMEPAGE']])
342 342
343 def pullData(l, d): 343 def pullData(l, d):
344 l2 = [] 344 l2 = []
345 for i in l: 345 for i in l:
346 l2.append(d.getVar(i, True)) 346 l2.append(d.getVar(i, True))
347 return l2 347 return l2
348 348
349 ctrlfile.write("Package: %s\n" % pkgname) 349 ctrlfile.write("Package: %s\n" % pkgname)
350 # check for required fields 350 # check for required fields
351 try: 351 try:
352 for (c, fs) in fields: 352 for (c, fs) in fields:
353 for f in fs: 353 for f in fs:
354 if localdata.getVar(f) is None: 354 if localdata.getVar(f) is None:
355 raise KeyError(f) 355 raise KeyError(f)
356 # Special behavior for description... 356 # Special behavior for description...
357 if 'DESCRIPTION' in fs: 357 if 'DESCRIPTION' in fs:
358 summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "." 358 summary = localdata.getVar('SUMMARY', True) or localdata.getVar('DESCRIPTION', True) or "."
359 description = localdata.getVar('DESCRIPTION', True) or "." 359 description = localdata.getVar('DESCRIPTION', True) or "."
360 description = textwrap.dedent(description).strip() 360 description = textwrap.dedent(description).strip()
361 ctrlfile.write('Description: %s\n' % summary) 361 ctrlfile.write('Description: %s\n' % summary)
362 ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' ')) 362 ctrlfile.write('%s\n' % textwrap.fill(description, width=74, initial_indent=' ', subsequent_indent=' '))
363 else: 363 else:
364 ctrlfile.write(c % tuple(pullData(fs, localdata))) 364 ctrlfile.write(c % tuple(pullData(fs, localdata)))
365 except KeyError: 365 except KeyError:
366 import sys 366 import sys
367 (type, value, traceback) = sys.exc_info() 367 (type, value, traceback) = sys.exc_info()
368 ctrlfile.close() 368 ctrlfile.close()
369 bb.utils.unlockfile(lf) 369 bb.utils.unlockfile(lf)
370 raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value) 370 raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value)
371 # more fields 371 # more fields
372 372
373 mapping_rename_hook(localdata) 373 mapping_rename_hook(localdata)
374 374
375 rdepends = bb.utils.explode_dep_versions(localdata.getVar("RDEPENDS", True) or "") 375 rdepends = bb.utils.explode_dep_versions(localdata.getVar("RDEPENDS", True) or "")
376 rrecommends = bb.utils.explode_dep_versions(localdata.getVar("RRECOMMENDS", True) or "") 376 rrecommends = bb.utils.explode_dep_versions(localdata.getVar("RRECOMMENDS", True) or "")
377 rsuggests = bb.utils.explode_dep_versions(localdata.getVar("RSUGGESTS", True) or "") 377 rsuggests = bb.utils.explode_dep_versions(localdata.getVar("RSUGGESTS", True) or "")
378 rprovides = bb.utils.explode_dep_versions(localdata.getVar("RPROVIDES", True) or "") 378 rprovides = bb.utils.explode_dep_versions(localdata.getVar("RPROVIDES", True) or "")
379 rreplaces = bb.utils.explode_dep_versions(localdata.getVar("RREPLACES", True) or "") 379 rreplaces = bb.utils.explode_dep_versions(localdata.getVar("RREPLACES", True) or "")
380 rconflicts = bb.utils.explode_dep_versions(localdata.getVar("RCONFLICTS", True) or "") 380 rconflicts = bb.utils.explode_dep_versions(localdata.getVar("RCONFLICTS", True) or "")
381 381
382 if rdepends: 382 if rdepends:
383 ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends)) 383 ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends))
384 if rsuggests: 384 if rsuggests:
385 ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests)) 385 ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests))
386 if rrecommends: 386 if rrecommends:
387 ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends)) 387 ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends))
388 if rprovides: 388 if rprovides:
389 ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides)) 389 ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides))
390 if rreplaces: 390 if rreplaces:
391 ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces)) 391 ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces))
392 if rconflicts: 392 if rconflicts:
393 ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts)) 393 ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts))
394 src_uri = localdata.getVar("SRC_URI", True) or "None" 394 src_uri = localdata.getVar("SRC_URI", True) or "None"
395 if src_uri: 395 if src_uri:
396 src_uri = re.sub("\s+", " ", src_uri) 396 src_uri = re.sub("\s+", " ", src_uri)
397 ctrlfile.write("Source: %s\n" % " ".join(src_uri.split())) 397 ctrlfile.write("Source: %s\n" % " ".join(src_uri.split()))
398 ctrlfile.close() 398 ctrlfile.close()
399 399
400 for script in ["preinst", "postinst", "prerm", "postrm"]: 400 for script in ["preinst", "postinst", "prerm", "postrm"]:
401 scriptvar = localdata.getVar('pkg_%s' % script, True) 401 scriptvar = localdata.getVar('pkg_%s' % script, True)
402 if not scriptvar: 402 if not scriptvar:
403 continue 403 continue
404 try: 404 try:
405 scriptfile = file(os.path.join(controldir, script), 'w') 405 scriptfile = file(os.path.join(controldir, script), 'w')
406 except OSError: 406 except OSError:
407 bb.utils.unlockfile(lf) 407 bb.utils.unlockfile(lf)
408 raise bb.build.FuncFailed("unable to open %s script file for writing." % script) 408 raise bb.build.FuncFailed("unable to open %s script file for writing." % script)
409 scriptfile.write(scriptvar) 409 scriptfile.write(scriptvar)
410 scriptfile.close() 410 scriptfile.close()
411 os.chmod(os.path.join(controldir, script), 0755) 411 os.chmod(os.path.join(controldir, script), 0755)
412 412
413 conffiles_str = localdata.getVar("CONFFILES", True) 413 conffiles_str = localdata.getVar("CONFFILES", True)
414 if conffiles_str: 414 if conffiles_str:
415 try: 415 try:
416 conffiles = file(os.path.join(controldir, 'conffiles'), 'w') 416 conffiles = file(os.path.join(controldir, 'conffiles'), 'w')
417 except OSError: 417 except OSError:
418 bb.utils.unlockfile(lf) 418 bb.utils.unlockfile(lf)
419 raise bb.build.FuncFailed("unable to open conffiles for writing.") 419 raise bb.build.FuncFailed("unable to open conffiles for writing.")
420 for f in conffiles_str.split(): 420 for f in conffiles_str.split():
421 conffiles.write('%s\n' % f) 421 conffiles.write('%s\n' % f)
422 conffiles.close() 422 conffiles.close()
423 423
424 os.chdir(basedir) 424 os.chdir(basedir)
425 ret = subprocess.call("PATH=\"%s\" %s %s %s" % (localdata.getVar("PATH", True), 425 ret = subprocess.call("PATH=\"%s\" %s %s %s" % (localdata.getVar("PATH", True),
426 d.getVar("OPKGBUILDCMD",1), pkg, pkgoutdir), shell=True) 426 d.getVar("OPKGBUILDCMD",1), pkg, pkgoutdir), shell=True)
427 if ret != 0: 427 if ret != 0:
428 bb.utils.unlockfile(lf) 428 bb.utils.unlockfile(lf)
429 raise bb.build.FuncFailed("opkg-build execution failed") 429 raise bb.build.FuncFailed("opkg-build execution failed")
430 430
431 bb.utils.prunedir(controldir) 431 bb.utils.prunedir(controldir)
432 bb.utils.unlockfile(lf) 432 bb.utils.unlockfile(lf)
433 433
434} 434}
435 435
@@ -439,7 +439,7 @@ do_package_write_ipk[sstate-inputdirs] = "${PKGWRITEDIRIPK}"
439do_package_write_ipk[sstate-outputdirs] = "${DEPLOY_DIR_IPK}" 439do_package_write_ipk[sstate-outputdirs] = "${DEPLOY_DIR_IPK}"
440 440
441python do_package_write_ipk_setscene () { 441python do_package_write_ipk_setscene () {
442 sstate_setscene(d) 442 sstate_setscene(d)
443} 443}
444addtask do_package_write_ipk_setscene 444addtask do_package_write_ipk_setscene
445 445
@@ -452,8 +452,8 @@ python () {
452} 452}
453 453
454python do_package_write_ipk () { 454python do_package_write_ipk () {
455 bb.build.exec_func("read_subpackage_metadata", d) 455 bb.build.exec_func("read_subpackage_metadata", d)
456 bb.build.exec_func("do_package_ipk", d) 456 bb.build.exec_func("do_package_ipk", d)
457} 457}
458do_package_write_ipk[dirs] = "${PKGWRITEDIRIPK}" 458do_package_write_ipk[dirs] = "${PKGWRITEDIRIPK}"
459do_package_write_ipk[umask] = "022" 459do_package_write_ipk[umask] = "022"