summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-02-12 18:36:36 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-02-12 18:36:36 +0000
commit862c6130a58a6c87c69d2d937e66f434b9b001e0 (patch)
treee551a77d843917dac8d0e13e4c91088f5e6caf3b
parentef7b99ecfed9f4a3f5064bc0c945dda789e1a7d6 (diff)
Fix package name renaming for classes like debian.bbclass:
package.bbclass now tracks any package renaming performed using PKG_*. When a package is built, the runtime variables are translated using this cached information which is stored in staging. From now on, only use package names are valid in runtime variables like RDEPENDS, RRECOMMENDS and RSUGGESTS. eg. fontconfig-dev is correct, libfontconfig-dev would be wrong. As debian.bbclass can't determine package renaming until after a package's contents is known, the class has to set BUILD_ALL_DEPS = "1". This also means OE is no longer forced into one package renaming scheme.
-rw-r--r--classes/debian.bbclass8
-rw-r--r--classes/package.bbclass74
-rw-r--r--classes/package_ipk.bbclass3
3 files changed, 83 insertions, 2 deletions
diff --git a/classes/debian.bbclass b/classes/debian.bbclass
index 63a126ca17..5688dad93b 100644
--- a/classes/debian.bbclass
+++ b/classes/debian.bbclass
@@ -1,3 +1,11 @@
+STAGING_PKGMAPS_DIR = "${STAGING_DIR}/pkgmaps/debian"
+
+# Debain package renaming only occurs when a package is built
+# We therefore have to make sure we build all runtime packages
+# before building the current package to make the packages runtime
+# depends are correct
+BUILD_ALL_DEPS = "1"
+
python debian_package_name_hook () {
import glob, copy, stat, errno, re
diff --git a/classes/package.bbclass b/classes/package.bbclass
index fd8d1b7b09..ab1cea37c0 100644
--- a/classes/package.bbclass
+++ b/classes/package.bbclass
@@ -1,6 +1,73 @@
def legitimize_package_name(s):
return s.lower().replace('_', '-').replace('@', '+').replace(',', '+').replace('/', '-')
+STAGING_PKGMAPS_DIR ?= "${STAGING_DIR}/pkgmaps"
+
+def add_package_mapping (pkg, new_name, d):
+ import bb, os
+
+ def encode(str):
+ import codecs
+ c = codecs.getencoder("string_escape")
+ return c(str)[0]
+
+ pmap_dir = bb.data.getVar('STAGING_PKGMAPS_DIR', d, 1)
+
+ bb.mkdirhier(pmap_dir)
+
+ data_file = os.path.join(pmap_dir, pkg)
+
+ f = open(data_file, 'w')
+ f.write("%s\n" % encode(new_name))
+ f.close()
+
+def get_package_mapping (pkg, d):
+ import bb, os
+
+ def decode(str):
+ import codecs
+ c = codecs.getdecoder("string_escape")
+ return c(str)[0]
+
+ data_file = bb.data.expand("${STAGING_PKGMAPS_DIR}/%s" % pkg, d)
+
+ if os.access(data_file, os.R_OK):
+ f = file(data_file, 'r')
+ lines = f.readlines()
+ f.close()
+ for l in lines:
+ return decode(l).strip()
+ return pkg
+
+def runtime_mapping_rename (varname, d):
+ import bb, os
+
+ #bb.note("%s before: %s" % (varname, bb.data.getVar(varname, d, 1)))
+
+ new_depends = []
+ for depend in explode_deps(bb.data.getVar(varname, d, 1) or ""):
+ # Have to be careful with any version component of the depend
+ split_depend = depend.split(' (')
+ new_depend = get_package_mapping(split_depend[0].strip(), d)
+ if len(split_depend) > 1:
+ new_depends.append("%s (%s" % (new_depend, split_depend[1]))
+ else:
+ new_depends.append(new_depend)
+
+ bb.data.setVar(varname, " ".join(new_depends) or None, d)
+
+ #bb.note("%s after: %s" % (varname, bb.data.getVar(varname, d, 1)))
+
+python package_mapping_rename_hook () {
+ runtime_mapping_rename("RDEPENDS", d)
+ runtime_mapping_rename("RRECOMMENDS", d)
+ runtime_mapping_rename("RSUGGESTS", d)
+ runtime_mapping_rename("RPROVIDES", d)
+ runtime_mapping_rename("RREPLACES", d)
+ runtime_mapping_rename("RCONFLICTS", d)
+}
+
+
def do_split_packages(d, root, file_regex, output_pattern, description, postinst=None, recursive=False, hook=None, extra_depends=None, aux_files_pattern=None, postrm=None, allow_dirs=False, prepend=False, match_path=False):
import os, os.path, bb
@@ -240,8 +307,11 @@ python populate_packages () {
bb.build.exec_func("package_name_hook", d)
for pkg in packages.split():
- if bb.data.getVar('PKG_%s' % pkg, d, 1) is None:
+ pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1)
+ if pkgname is None:
bb.data.setVar('PKG_%s' % pkg, pkg, d)
+ else:
+ add_package_mapping(pkg, pkgname, d)
dangling_links = {}
pkg_files = {}
@@ -641,5 +711,5 @@ python package_do_package () {
do_package[dirs] = "${D}"
populate_packages[dirs] = "${D}"
-EXPORT_FUNCTIONS do_package do_shlibs do_split_locales
+EXPORT_FUNCTIONS do_package do_shlibs do_split_locales mapping_rename_hook
addtask package before do_build after do_populate_staging
diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass
index a70b1e8cdd..9ae526bb3b 100644
--- a/classes/package_ipk.bbclass
+++ b/classes/package_ipk.bbclass
@@ -165,6 +165,9 @@ python do_package_ipk () {
ctrlfile.close()
raise bb.build.FuncFailed("Missing field for ipk generation: %s" % value)
# more fields
+
+ bb.build.exec_func("mapping_rename_hook", localdata)
+
rdepends = explode_deps(bb.data.getVar("RDEPENDS", localdata, 1) or "")
rrecommends = explode_deps(bb.data.getVar("RRECOMMENDS", localdata, 1) or "")
rsuggests = (bb.data.getVar("RSUGGESTS", localdata, 1) or "").split()