summaryrefslogtreecommitdiff
path: root/meta/classes
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/base.bbclass48
-rw-r--r--meta/classes/package.bbclass122
-rw-r--r--meta/classes/package_ipk.bbclass2
3 files changed, 131 insertions, 41 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index a36829006..0d5f5ea16 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -624,24 +624,60 @@ python read_shlibdeps () {
bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d)
}
-python read_subpackage_metadata () {
- import re
+def read_pkgdatafile(fn):
+ pkgdata = {}
def decode(str):
import codecs
c = codecs.getdecoder("string_escape")
return c(str)[0]
- data_file = bb.data.expand("${WORKDIR}/install/${PN}.package", d)
- if os.access(data_file, os.R_OK):
- f = file(data_file, 'r')
+ import os
+ if os.access(fn, os.R_OK):
+ import re
+ f = file(fn, 'r')
lines = f.readlines()
f.close()
r = re.compile("([^:]+):\s*(.*)")
for l in lines:
m = r.match(l)
if m:
- bb.data.setVar(m.group(1), decode(m.group(2)), d)
+ pkgdata[m.group(1)] = decode(m.group(2))
+
+ return pkgdata
+
+def has_subpkgdata(pkg, d):
+ import bb, os
+ fn = bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s' % pkg, d)
+ return os.access(fn, os.R_OK)
+
+def read_subpkgdata(pkg, d):
+ import bb, os
+ fn = bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s' % pkg, d)
+ return read_pkgdatafile(fn)
+
+
+def has_pkgdata(pn, d):
+ import bb, os
+ fn = bb.data.expand('${STAGING_DIR}/pkgdata/%s' % pn, d)
+ return os.access(fn, os.R_OK)
+
+def read_pkgdata(pn, d):
+ import bb, os
+ fn = bb.data.expand('${STAGING_DIR}/pkgdata/%s' % pn, d)
+ return read_pkgdatafile(fn)
+
+python read_subpackage_metadata () {
+ import bb
+ data = read_pkgdata(bb.data.getVar('PN', d, 1), d)
+
+ for key in data.keys():
+ bb.data.setVar(key, data[key], d)
+
+ for pkg in bb.data.getVar('PACKAGES', d, 1).split():
+ sdata = read_subpkgdata(pkg, d)
+ for key in sdata.keys():
+ bb.data.setVar(key, sdata[key], d)
}
python __anonymous () {
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
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index 2847cee6e..cb4448485 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -222,6 +222,8 @@ python do_package_ipk () {
if ret != 0:
raise bb.build.FuncFailed("ipkg-build execution failed")
+ file(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), 'w').close()
+
for script in ["preinst", "postinst", "prerm", "postrm", "control" ]:
scriptfile = os.path.join(controldir, script)
try: