From 8d804ea40a349e679850b716012120e54fe5242d Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 21 Sep 2006 16:29:02 +0000 Subject: Merge devgen branch to trunk. git-svn-id: https://svn.o-hand.com/repos/poky/trunk@743 311d38ba-8fff-0310-9ca6-ca027cbcb966 --- meta/classes/package.bbclass | 122 ++++++++++++++++++++++++++++++------------- 1 file changed, 87 insertions(+), 35 deletions(-) (limited to 'meta/classes/package.bbclass') diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index d39a1afb7..e2e98624c 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 objs.append(relpath) if extra_depends == None: - extra_depends = bb.data.getVar('PKG_' + packages[0], d, 1) or packages[0] + extra_depends = packages[0] for o in objs: import re, stat @@ -287,10 +287,7 @@ python populate_packages () { bb.data.setVar('ROOT', '', localdata) bb.data.setVar('ROOT_%s' % pkg, root, localdata) - pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) - if not pkgname: - pkgname = pkg - bb.data.setVar('PKG', pkgname, localdata) + bb.data.setVar('PKG', pkg, localdata) overrides = bb.data.getVar('OVERRIDES', localdata, 1) if not overrides: @@ -381,14 +378,17 @@ python populate_packages () { bb.debug(1, "target found in %s" % p) if p == pkg: break - dp = bb.data.getVar('PKG_' + p, d, 1) or p - if not dp in rdepends: - rdepends.append(dp) + if not p in rdepends: + rdepends.append(p) break if found == False: bb.note("%s contains dangling symlink to %s" % (pkg, l)) bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) + bb.build.exec_func('emit_pkgdata', d) +} + +python emit_pkgdata() { def write_if_exists(f, pkg, var): def encode(str): import codecs @@ -399,21 +399,29 @@ python populate_packages () { if val: f.write('%s_%s: %s\n' % (var, pkg, encode(val))) - data_file = os.path.join(workdir, "install", pn + ".package") + packages = bb.data.getVar('PACKAGES', d, 1) + if not packages: + return + + data_file = bb.data.expand("${STAGING_DIR}/pkgdata/${PN}", d) f = open(data_file, 'w') f.write("PACKAGES: %s\n" % packages) - for pkg in packages.split(): - write_if_exists(f, pkg, 'DESCRIPTION') - write_if_exists(f, pkg, 'RDEPENDS') - write_if_exists(f, pkg, 'RPROVIDES') - write_if_exists(f, pkg, 'PKG') - write_if_exists(f, pkg, 'ALLOW_EMPTY') - write_if_exists(f, pkg, 'FILES') - write_if_exists(f, pkg, 'pkg_postinst') - write_if_exists(f, pkg, 'pkg_postrm') - write_if_exists(f, pkg, 'pkg_preinst') - write_if_exists(f, pkg, 'pkg_prerm') f.close() + + for pkg in packages.split(): + subdata_file = bb.data.expand("${STAGING_DIR}/pkgdata/runtime/%s" % pkg, d) + sf = open(subdata_file, 'w') + write_if_exists(sf, pkg, 'DESCRIPTION') + write_if_exists(sf, pkg, 'RDEPENDS') + write_if_exists(sf, pkg, 'RPROVIDES') + write_if_exists(sf, pkg, 'PKG') + write_if_exists(sf, pkg, 'ALLOW_EMPTY') + write_if_exists(sf, pkg, 'FILES') + write_if_exists(sf, pkg, 'pkg_postinst') + write_if_exists(sf, pkg, 'pkg_postrm') + write_if_exists(sf, pkg, 'pkg_preinst') + write_if_exists(sf, pkg, 'pkg_prerm') + sf.close() bb.build.exec_func("read_subpackage_metadata", d) } @@ -423,6 +431,57 @@ if [ x"$D" = "x" ]; then fi } +python package_depchains() { + """ + For a given set of prefix and postfix modifiers, make those packages + RRECOMMENDS on the corresponding packages for its DEPENDS. + + Example: If package A depends upon package B, and A's .bb emits an + A-dev package, this would make A-dev Recommends: B-dev. + """ + + packages = bb.data.getVar('PACKAGES', d, 1) + postfixes = (bb.data.getVar('DEPCHAIN_POST', d, 1) or '').split() + prefixes = (bb.data.getVar('DEPCHAIN_PRE', d, 1) or '').split() + + def pkg_addrrecs(pkg, base, func, d): + rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + base, d, 1) or bb.data.getVar('RDEPENDS', d, 1) or "") + # bb.note('rdepends for %s is %s' % (base, rdepends)) + rreclist = [] + + for depend in rdepends: + split_depend = depend.split(' (') + name = split_depend[0].strip() + func(rreclist, name) + + bb.data.setVar('RRECOMMENDS_%s' % pkg, ' '.join(rreclist), d) + + def packaged(pkg, d): + return os.access(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), os.R_OK) + + for pkg in packages.split(): + for postfix in postfixes: + def func(list, name): + pkg = '%s%s' % (name, postfix) + if packaged(pkg, d): + list.append(pkg) + + base = pkg[:-len(postfix)] + if pkg.endswith(postfix): + pkg_addrrecs(pkg, base, func, d) + continue + + for prefix in prefixes: + def func(list, name): + pkg = '%s%s' % (prefix, name) + if packaged(pkg, d): + list.append(pkg) + + base = pkg[len(prefix):] + if pkg.startswith(prefix): + pkg_addrrecs(pkg, base, func, d) +} + python package_do_shlibs() { import os, re, os.path @@ -468,10 +527,6 @@ python package_do_shlibs() { needs_ldconfig = False bb.debug(2, "calculating shlib provides for %s" % pkg) - pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1) - if not pkgname: - pkgname = pkg - needed[pkg] = [] sonames = list() top = os.path.join(workdir, "install", pkg) @@ -493,10 +548,10 @@ python package_do_shlibs() { sonames.append(m.group(1)) if m and libdir_re.match(root): needs_ldconfig = True - shlibs_file = os.path.join(shlibs_dir, pkgname + ".list") + shlibs_file = os.path.join(shlibs_dir, pkg + ".list") if os.path.exists(shlibs_file): os.remove(shlibs_file) - shver_file = os.path.join(shlibs_dir, pkgname + ".ver") + shver_file = os.path.join(shlibs_dir, pkg + ".ver") if os.path.exists(shver_file): os.remove(shver_file) if len(sonames): @@ -540,14 +595,12 @@ python package_do_shlibs() { for pkg in packages.split(): bb.debug(2, "calculating shlib requirements for %s" % pkg) - p_pkg = bb.data.getVar("PKG_%s" % pkg, d, 1) or pkg - deps = list() for n in needed[pkg]: if n in shlib_provider.keys(): (dep_pkg, ver_needed) = shlib_provider[n] - if dep_pkg == p_pkg: + if dep_pkg == pkg: continue if ver_needed: @@ -559,7 +612,6 @@ python package_do_shlibs() { else: bb.note("Couldn't find shared library provider for %s" % n) - deps_file = os.path.join(workdir, "install", pkg + ".shlibdeps") if os.path.exists(deps_file): os.remove(deps_file) @@ -635,8 +687,7 @@ python package_do_pkgconfig () { pkgconfig_needed[pkg] += exp.replace(',', ' ').split() for pkg in packages.split(): - ppkg = bb.data.getVar("PKG_" + pkg, d, 1) or pkg - pkgs_file = os.path.join(shlibs_dir, ppkg + ".pclist") + pkgs_file = os.path.join(shlibs_dir, pkg + ".pclist") if os.path.exists(pkgs_file): os.remove(pkgs_file) if pkgconfig_provided[pkg] != []: @@ -725,7 +776,7 @@ python package_do_split_locales() { pkg = pn + '-locale-' + ln packages.append(pkg) bb.data.setVar('FILES_' + pkg, os.path.join(datadir, 'locale', l), d) - bb.data.setVar('RDEPENDS_' + pkg, '${PKG_%s} virtual-locale-%s' % (mainpkg, ln), d) + bb.data.setVar('RDEPENDS_' + pkg, '%s virtual-locale-%s' % (mainpkg, ln), d) bb.data.setVar('RPROVIDES_' + pkg, '%s-locale %s-translation' % (pn, ln), d) bb.data.setVar('DESCRIPTION_' + pkg, '%s translation for %s' % (l, pn), d) @@ -738,7 +789,8 @@ python package_do_split_locales() { PACKAGEFUNCS = "package_do_split_locales \ populate_packages package_do_shlibs \ - package_do_pkgconfig read_shlibdeps" + package_do_pkgconfig read_shlibdeps \ + package_depchains" python package_do_package () { for f in (bb.data.getVar('PACKAGEFUNCS', d, 1) or '').split(): bb.build.exec_func(f, d) @@ -747,6 +799,6 @@ python package_do_package () { do_package[dirs] = "${D}" # shlibs requires any DEPENDS to have already packaged for the *.list files do_package[deptask] = "do_package" -populate_packages[dirs] = "${D}" +populate_packages[dirs] = "${STAGING_DIR}/pkgdata/runtime ${D}" EXPORT_FUNCTIONS do_package do_shlibs do_split_locales mapping_rename_hook addtask package before do_build after do_install -- cgit v1.2.3