summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorChris Larson <kergoth@openedhand.com>2006-09-21 16:29:02 +0000
committerChris Larson <kergoth@openedhand.com>2006-09-21 16:29:02 +0000
commit8d804ea40a349e679850b716012120e54fe5242d (patch)
treed8b1d37ea78880df826f81bb4b791f8f93f1f985 /meta/classes/package.bbclass
parent5cacd3ea7efd69e57979d962616bf87c521c6f8b (diff)
downloadpoky-8d804ea40a349e679850b716012120e54fe5242d.tar.gz
Merge devgen branch to trunk.
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@743 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass122
1 files changed, 87 insertions, 35 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index d39a1afb70..e2e98624ca 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -107,7 +107,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
107 objs.append(relpath) 107 objs.append(relpath)
108 108
109 if extra_depends == None: 109 if extra_depends == None:
110 extra_depends = bb.data.getVar('PKG_' + packages[0], d, 1) or packages[0] 110 extra_depends = packages[0]
111 111
112 for o in objs: 112 for o in objs:
113 import re, stat 113 import re, stat
@@ -287,10 +287,7 @@ python populate_packages () {
287 287
288 bb.data.setVar('ROOT', '', localdata) 288 bb.data.setVar('ROOT', '', localdata)
289 bb.data.setVar('ROOT_%s' % pkg, root, localdata) 289 bb.data.setVar('ROOT_%s' % pkg, root, localdata)
290 pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) 290 bb.data.setVar('PKG', pkg, localdata)
291 if not pkgname:
292 pkgname = pkg
293 bb.data.setVar('PKG', pkgname, localdata)
294 291
295 overrides = bb.data.getVar('OVERRIDES', localdata, 1) 292 overrides = bb.data.getVar('OVERRIDES', localdata, 1)
296 if not overrides: 293 if not overrides:
@@ -381,14 +378,17 @@ python populate_packages () {
381 bb.debug(1, "target found in %s" % p) 378 bb.debug(1, "target found in %s" % p)
382 if p == pkg: 379 if p == pkg:
383 break 380 break
384 dp = bb.data.getVar('PKG_' + p, d, 1) or p 381 if not p in rdepends:
385 if not dp in rdepends: 382 rdepends.append(p)
386 rdepends.append(dp)
387 break 383 break
388 if found == False: 384 if found == False:
389 bb.note("%s contains dangling symlink to %s" % (pkg, l)) 385 bb.note("%s contains dangling symlink to %s" % (pkg, l))
390 bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) 386 bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
391 387
388 bb.build.exec_func('emit_pkgdata', d)
389}
390
391python emit_pkgdata() {
392 def write_if_exists(f, pkg, var): 392 def write_if_exists(f, pkg, var):
393 def encode(str): 393 def encode(str):
394 import codecs 394 import codecs
@@ -399,21 +399,29 @@ python populate_packages () {
399 if val: 399 if val:
400 f.write('%s_%s: %s\n' % (var, pkg, encode(val))) 400 f.write('%s_%s: %s\n' % (var, pkg, encode(val)))
401 401
402 data_file = os.path.join(workdir, "install", pn + ".package") 402 packages = bb.data.getVar('PACKAGES', d, 1)
403 if not packages:
404 return
405
406 data_file = bb.data.expand("${STAGING_DIR}/pkgdata/${PN}", d)
403 f = open(data_file, 'w') 407 f = open(data_file, 'w')
404 f.write("PACKAGES: %s\n" % packages) 408 f.write("PACKAGES: %s\n" % packages)
405 for pkg in packages.split():
406 write_if_exists(f, pkg, 'DESCRIPTION')
407 write_if_exists(f, pkg, 'RDEPENDS')
408 write_if_exists(f, pkg, 'RPROVIDES')
409 write_if_exists(f, pkg, 'PKG')
410 write_if_exists(f, pkg, 'ALLOW_EMPTY')
411 write_if_exists(f, pkg, 'FILES')
412 write_if_exists(f, pkg, 'pkg_postinst')
413 write_if_exists(f, pkg, 'pkg_postrm')
414 write_if_exists(f, pkg, 'pkg_preinst')
415 write_if_exists(f, pkg, 'pkg_prerm')
416 f.close() 409 f.close()
410
411 for pkg in packages.split():
412 subdata_file = bb.data.expand("${STAGING_DIR}/pkgdata/runtime/%s" % pkg, d)
413 sf = open(subdata_file, 'w')
414 write_if_exists(sf, pkg, 'DESCRIPTION')
415 write_if_exists(sf, pkg, 'RDEPENDS')
416 write_if_exists(sf, pkg, 'RPROVIDES')
417 write_if_exists(sf, pkg, 'PKG')
418 write_if_exists(sf, pkg, 'ALLOW_EMPTY')
419 write_if_exists(sf, pkg, 'FILES')
420 write_if_exists(sf, pkg, 'pkg_postinst')
421 write_if_exists(sf, pkg, 'pkg_postrm')
422 write_if_exists(sf, pkg, 'pkg_preinst')
423 write_if_exists(sf, pkg, 'pkg_prerm')
424 sf.close()
417 bb.build.exec_func("read_subpackage_metadata", d) 425 bb.build.exec_func("read_subpackage_metadata", d)
418} 426}
419 427
@@ -423,6 +431,57 @@ if [ x"$D" = "x" ]; then
423fi 431fi
424} 432}
425 433
434python package_depchains() {
435 """
436 For a given set of prefix and postfix modifiers, make those packages
437 RRECOMMENDS on the corresponding packages for its DEPENDS.
438
439 Example: If package A depends upon package B, and A's .bb emits an
440 A-dev package, this would make A-dev Recommends: B-dev.
441 """
442
443 packages = bb.data.getVar('PACKAGES', d, 1)
444 postfixes = (bb.data.getVar('DEPCHAIN_POST', d, 1) or '').split()
445 prefixes = (bb.data.getVar('DEPCHAIN_PRE', d, 1) or '').split()
446
447 def pkg_addrrecs(pkg, base, func, d):
448 rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + base, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "")
449 # bb.note('rdepends for %s is %s' % (base, rdepends))
450 rreclist = []
451
452 for depend in rdepends:
453 split_depend = depend.split(' (')
454 name = split_depend[0].strip()
455 func(rreclist, name)
456
457 bb.data.setVar('RRECOMMENDS_%s' % pkg, ' '.join(rreclist), d)
458
459 def packaged(pkg, d):
460 return os.access(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), os.R_OK)
461
462 for pkg in packages.split():
463 for postfix in postfixes:
464 def func(list, name):
465 pkg = '%s%s' % (name, postfix)
466 if packaged(pkg, d):
467 list.append(pkg)
468
469 base = pkg[:-len(postfix)]
470 if pkg.endswith(postfix):
471 pkg_addrrecs(pkg, base, func, d)
472 continue
473
474 for prefix in prefixes:
475 def func(list, name):
476 pkg = '%s%s' % (prefix, name)
477 if packaged(pkg, d):
478 list.append(pkg)
479
480 base = pkg[len(prefix):]
481 if pkg.startswith(prefix):
482 pkg_addrrecs(pkg, base, func, d)
483}
484
426python package_do_shlibs() { 485python package_do_shlibs() {
427 import os, re, os.path 486 import os, re, os.path
428 487
@@ -468,10 +527,6 @@ python package_do_shlibs() {
468 needs_ldconfig = False 527 needs_ldconfig = False
469 bb.debug(2, "calculating shlib provides for %s" % pkg) 528 bb.debug(2, "calculating shlib provides for %s" % pkg)
470 529
471 pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1)
472 if not pkgname:
473 pkgname = pkg
474
475 needed[pkg] = [] 530 needed[pkg] = []
476 sonames = list() 531 sonames = list()
477 top = os.path.join(workdir, "install", pkg) 532 top = os.path.join(workdir, "install", pkg)
@@ -493,10 +548,10 @@ python package_do_shlibs() {
493 sonames.append(m.group(1)) 548 sonames.append(m.group(1))
494 if m and libdir_re.match(root): 549 if m and libdir_re.match(root):
495 needs_ldconfig = True 550 needs_ldconfig = True
496 shlibs_file = os.path.join(shlibs_dir, pkgname + ".list") 551 shlibs_file = os.path.join(shlibs_dir, pkg + ".list")
497 if os.path.exists(shlibs_file): 552 if os.path.exists(shlibs_file):
498 os.remove(shlibs_file) 553 os.remove(shlibs_file)
499 shver_file = os.path.join(shlibs_dir, pkgname + ".ver") 554 shver_file = os.path.join(shlibs_dir, pkg + ".ver")
500 if os.path.exists(shver_file): 555 if os.path.exists(shver_file):
501 os.remove(shver_file) 556 os.remove(shver_file)
502 if len(sonames): 557 if len(sonames):
@@ -540,14 +595,12 @@ python package_do_shlibs() {
540 for pkg in packages.split(): 595 for pkg in packages.split():
541 bb.debug(2, "calculating shlib requirements for %s" % pkg) 596 bb.debug(2, "calculating shlib requirements for %s" % pkg)
542 597
543 p_pkg = bb.data.getVar("PKG_%s" % pkg, d, 1) or pkg
544
545 deps = list() 598 deps = list()
546 for n in needed[pkg]: 599 for n in needed[pkg]:
547 if n in shlib_provider.keys(): 600 if n in shlib_provider.keys():
548 (dep_pkg, ver_needed) = shlib_provider[n] 601 (dep_pkg, ver_needed) = shlib_provider[n]
549 602
550 if dep_pkg == p_pkg: 603 if dep_pkg == pkg:
551 continue 604 continue
552 605
553 if ver_needed: 606 if ver_needed:
@@ -559,7 +612,6 @@ python package_do_shlibs() {
559 else: 612 else:
560 bb.note("Couldn't find shared library provider for %s" % n) 613 bb.note("Couldn't find shared library provider for %s" % n)
561 614
562
563 deps_file = os.path.join(workdir, "install", pkg + ".shlibdeps") 615 deps_file = os.path.join(workdir, "install", pkg + ".shlibdeps")
564 if os.path.exists(deps_file): 616 if os.path.exists(deps_file):
565 os.remove(deps_file) 617 os.remove(deps_file)
@@ -635,8 +687,7 @@ python package_do_pkgconfig () {
635 pkgconfig_needed[pkg] += exp.replace(',', ' ').split() 687 pkgconfig_needed[pkg] += exp.replace(',', ' ').split()
636 688
637 for pkg in packages.split(): 689 for pkg in packages.split():
638 ppkg = bb.data.getVar("PKG_" + pkg, d, 1) or pkg 690 pkgs_file = os.path.join(shlibs_dir, pkg + ".pclist")
639 pkgs_file = os.path.join(shlibs_dir, ppkg + ".pclist")
640 if os.path.exists(pkgs_file): 691 if os.path.exists(pkgs_file):
641 os.remove(pkgs_file) 692 os.remove(pkgs_file)
642 if pkgconfig_provided[pkg] != []: 693 if pkgconfig_provided[pkg] != []:
@@ -725,7 +776,7 @@ python package_do_split_locales() {
725 pkg = pn + '-locale-' + ln 776 pkg = pn + '-locale-' + ln
726 packages.append(pkg) 777 packages.append(pkg)
727 bb.data.setVar('FILES_' + pkg, os.path.join(datadir, 'locale', l), d) 778 bb.data.setVar('FILES_' + pkg, os.path.join(datadir, 'locale', l), d)
728 bb.data.setVar('RDEPENDS_' + pkg, '${PKG_%s} virtual-locale-%s' % (mainpkg, ln), d) 779 bb.data.setVar('RDEPENDS_' + pkg, '%s virtual-locale-%s' % (mainpkg, ln), d)
729 bb.data.setVar('RPROVIDES_' + pkg, '%s-locale %s-translation' % (pn, ln), d) 780 bb.data.setVar('RPROVIDES_' + pkg, '%s-locale %s-translation' % (pn, ln), d)
730 bb.data.setVar('DESCRIPTION_' + pkg, '%s translation for %s' % (l, pn), d) 781 bb.data.setVar('DESCRIPTION_' + pkg, '%s translation for %s' % (l, pn), d)
731 782
@@ -738,7 +789,8 @@ python package_do_split_locales() {
738 789
739PACKAGEFUNCS = "package_do_split_locales \ 790PACKAGEFUNCS = "package_do_split_locales \
740 populate_packages package_do_shlibs \ 791 populate_packages package_do_shlibs \
741 package_do_pkgconfig read_shlibdeps" 792 package_do_pkgconfig read_shlibdeps \
793 package_depchains"
742python package_do_package () { 794python package_do_package () {
743 for f in (bb.data.getVar('PACKAGEFUNCS', d, 1) or '').split(): 795 for f in (bb.data.getVar('PACKAGEFUNCS', d, 1) or '').split():
744 bb.build.exec_func(f, d) 796 bb.build.exec_func(f, d)
@@ -747,6 +799,6 @@ python package_do_package () {
747do_package[dirs] = "${D}" 799do_package[dirs] = "${D}"
748# shlibs requires any DEPENDS to have already packaged for the *.list files 800# shlibs requires any DEPENDS to have already packaged for the *.list files
749do_package[deptask] = "do_package" 801do_package[deptask] = "do_package"
750populate_packages[dirs] = "${D}" 802populate_packages[dirs] = "${STAGING_DIR}/pkgdata/runtime ${D}"
751EXPORT_FUNCTIONS do_package do_shlibs do_split_locales mapping_rename_hook 803EXPORT_FUNCTIONS do_package do_shlibs do_split_locales mapping_rename_hook
752addtask package before do_build after do_install 804addtask package before do_build after do_install