diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-10-09 22:22:44 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-10-09 22:38:03 -0700 |
commit | a3fa60656f2d411e1d726eae095fe65bbd0bcda4 (patch) | |
tree | cbabf8e61366d53f8fd54c71346daff9abaf38bb | |
parent | 77734527095b04989c7773f6bc5a941faae532eb (diff) | |
download | openembedded-a3fa60656f2d411e1d726eae095fe65bbd0bcda4.tar.gz |
Implement 'dbg', 'dev', and 'doc' package groups
These allow one to include debugging, development, and documentation files for
all packages installed in the image, via IMAGE_FEATURES.
Signed-off-by: Chris Larson <chris_larson@mentor.com>
-rw-r--r-- | classes/image.bbclass | 53 | ||||
-rw-r--r-- | lib/oe/packagedata.py | 118 | ||||
-rw-r--r-- | lib/oe/packagegroup.py | 23 |
3 files changed, 139 insertions, 55 deletions
diff --git a/classes/image.bbclass b/classes/image.bbclass index 60f2d89b69..8f1afef1d6 100644 --- a/classes/image.bbclass +++ b/classes/image.bbclass @@ -25,9 +25,9 @@ IMAGE_KEEPROOTFS ?= "" IMAGE_KEEPROOTFS[doc] = "Set to non-empty to keep ${IMAGE_ROOTFS} around after image creation." IMAGE_BOOT ?= "${IMAGE_INITSCRIPTS} \ -${IMAGE_DEV_MANAGER} \ -${IMAGE_INIT_MANAGER} \ -${IMAGE_LOGIN_MANAGER} " + ${IMAGE_DEV_MANAGER} \ + ${IMAGE_INIT_MANAGER} \ + ${IMAGE_LOGIN_MANAGER}" # some default locales IMAGE_LINGUAS ?= "de-de fr-fr en-gb" @@ -37,8 +37,8 @@ LINGUAS_INSTALL_linux = "glibc-localedata-i18n" LINGUAS_INSTALL_linux += "${@' '.join(map(lambda s: 'locale-base-%s' % s, '${IMAGE_LINGUAS}'.split()))}" LINGUAS_INSTALL_linux-gnueabi = "${LINGUAS_INSTALL_linux}" -PACKAGE_INSTALL = "${@oe.packagegroup.required_packages('${IMAGE_FEATURES}'.split(), d)}" -PACKAGE_INSTALL_ATTEMPTONLY = "${@oe.packagegroup.optional_packages('${IMAGE_FEATURES}'.split(), d)}" +PACKAGE_INSTALL = "${@' '.join(oe.packagegroup.required_packages('${IMAGE_FEATURES}'.split(), d))}" +PACKAGE_INSTALL_ATTEMPTONLY = "${@' '.join(oe.packagegroup.optional_packages('${IMAGE_FEATURES}'.split(), d))}" IMAGE_FEATURES ?= "" IMAGE_FEATURES_prepend = "image_base " @@ -46,6 +46,33 @@ IMAGE_FEATURES_prepend = "image_base " # Define our always included package group PACKAGE_GROUP_image_base = "${IMAGE_INSTALL} ${IMAGE_BOOT} ${LINGUAS_INSTALL}" +# The following package groups allow one to add debugging, development, and +# documentation files for all packages installed in the image. + +def string_set(iterable): + return ' '.join(set(iterable)) + +def image_features_noextras(d): + for f in d.getVar("IMAGE_FEATURES", True).split(): + if not f in ('dbg', 'dev', 'doc'): + yield f + +def dbg_packages(d): + from itertools import chain + + features = image_features_noextras(d) + return string_set("%s-dbg" % pkg + for pkg in chain(oe.packagegroup.active_packages(features, d), + oe.packagegroup.active_recipes(features, d))) + +PACKAGE_GROUP_dbg = "${@dbg_packages(d)}" +PACKAGE_GROUP_dbg[optional] = "1" +PACKAGE_GROUP_dev = "${@string_set('%s-dev' % pn for pn in oe.packagegroup.active_recipes(image_features_noextras(d), d))}" +PACKAGE_GROUP_dev[optional] = "1" +PACKAGE_GROUP_doc = "${@string_set('%s-doc' % pn for pn in oe.packagegroup.active_recipes(image_features_noextras(d), d))}" +PACKAGE_GROUP_doc[optional] = "1" + + RDEPENDS += "${PACKAGE_INSTALL}" # "export IMAGE_BASENAME" not supported at this time @@ -151,7 +178,7 @@ fakeroot do_rootfs () { ${@get_imagecmds(d)} ${IMAGE_POSTPROCESS_COMMAND} - + ${MACHINE_POSTPROCESS_COMMAND} ${@['rm -rf ${IMAGE_ROOTFS}', ''][bool(d.getVar("IMAGE_KEEPROOTFS", 1))]} } @@ -165,7 +192,7 @@ do_deploy_to () { } insert_feed_uris () { - + echo "Building feeds for [${DISTRO}].." for line in ${FEED_URIS} @@ -174,9 +201,9 @@ insert_feed_uris () { line_clean="`echo "$line"|sed 's/^[ \t]*//;s/[ \t]*$//'`" feed_name="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\1/p'`" feed_uri="`echo "$line_clean" | sed -n 's/\(.*\)##\(.*\)/\2/p'`" - + echo "Added $feed_name feed with URL $feed_uri" - + # insert new feed-sources echo "src/gz $feed_name $feed_uri" >> ${IMAGE_ROOTFS}/etc/opkg/${feed_name}-feed.conf done @@ -198,9 +225,9 @@ log_check() { for target in $* do lf_path="${WORKDIR}/temp/log.do_$target.${PID}" - + echo "log_check: Using $lf_path as logfile" - + if test -e "$lf_path" then rootfs_${IMAGE_PKGTYPE}_log_check $target $lf_path @@ -219,7 +246,7 @@ log_check() { zap_root_password () { sed 's%^root:[^:]*:%root::%' < ${IMAGE_ROOTFS}/etc/passwd >${IMAGE_ROOTFS}/etc/passwd.new mv ${IMAGE_ROOTFS}/etc/passwd.new ${IMAGE_ROOTFS}/etc/passwd -} +} create_etc_timestamp() { date +%2m%2d%2H%2M%Y >${IMAGE_ROOTFS}/etc/timestamp @@ -246,7 +273,7 @@ set_image_autologin () { sed -i 's%^AUTOLOGIN=\"false"%AUTOLOGIN="true"%g' ${IMAGE_ROOTFS}/etc/sysconfig/gpelogin } -# Can be use to create /etc/timestamp during image construction to give a reasonably +# Can be use to create /etc/timestamp during image construction to give a reasonably # sane default time setting rootfs_update_timestamp () { date "+%m%d%H%M%Y" >${IMAGE_ROOTFS}/etc/timestamp diff --git a/lib/oe/packagedata.py b/lib/oe/packagedata.py index d93cafb892..7f0a89d282 100644 --- a/lib/oe/packagedata.py +++ b/lib/oe/packagedata.py @@ -3,60 +3,104 @@ import bb.data import codecs def packaged(pkg, d): - return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK) + return os.access(get_subpkgedata_fn(pkg, d) + '.packaged', os.R_OK) def read_pkgdatafile(fn): - pkgdata = {} + pkgdata = {} - def decode(str): - c = codecs.getdecoder("string_escape") - return c(str)[0] + def decode(str): + c = codecs.getdecoder("string_escape") + return c(str)[0] - 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: - pkgdata[m.group(1)] = decode(m.group(2)) + 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: + pkgdata[m.group(1)] = decode(m.group(2)) - return pkgdata + return pkgdata def get_subpkgedata_fn(pkg, d): - archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ") - archs.reverse() - pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d) - targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d) - for arch in archs: - fn = pkgdata + arch + targetdir + pkg - if os.path.exists(fn): - return fn - return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d) + archs = bb.data.expand("${PACKAGE_ARCHS}", d).split(" ") + archs.reverse() + pkgdata = bb.data.expand('${TMPDIR}/pkgdata/', d) + targetdir = bb.data.expand('${TARGET_VENDOR}-${TARGET_OS}/runtime/', d) + for arch in archs: + fn = pkgdata + arch + targetdir + pkg + if os.path.exists(fn): + return fn + return bb.data.expand('${PKGDATA_DIR}/runtime/%s' % pkg, d) def has_subpkgdata(pkg, d): - return os.access(get_subpkgedata_fn(pkg, d), os.R_OK) + return os.access(get_subpkgedata_fn(pkg, d), os.R_OK) def read_subpkgdata(pkg, d): - return read_pkgdatafile(get_subpkgedata_fn(pkg, d)) + return read_pkgdatafile(get_subpkgedata_fn(pkg, d)) def has_pkgdata(pn, d): - fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) - return os.access(fn, os.R_OK) + fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) + return os.access(fn, os.R_OK) def read_pkgdata(pn, d): - fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) - return read_pkgdatafile(fn) + fn = bb.data.expand('${PKGDATA_DIR}/%s' % pn, d) + return read_pkgdatafile(fn) # # Collapse FOO_pkg variables into FOO # def read_subpkgdata_dict(pkg, d): - ret = {} - subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d)) - for var in subd: - newvar = var.replace("_" + pkg, "") - ret[newvar] = subd[var] - return ret + ret = {} + subd = read_pkgdatafile(get_subpkgedata_fn(pkg, d)) + for var in subd: + newvar = var.replace("_" + pkg, "") + ret[newvar] = subd[var] + return ret + +def _pkgmap(d): + """Return a dictionary mapping package to recipe name.""" + + target_os = d.getVar("TARGET_OS", True) + target_vendor = d.getVar("TARGET_VENDOR", True) + basedir = os.path.dirname(d.getVar("PKGDATA_DIR", True)) + + dirs = ("%s%s-%s" % (arch, target_vendor, target_os) + for arch in d.getVar("PACKAGE_ARCHS", True).split()) + + pkgmap = {} + for pkgdatadir in (os.path.join(basedir, sys) for sys in dirs): + try: + files = os.listdir(pkgdatadir) + except OSError: + continue + + for pn in filter(lambda f: not os.path.isdir(os.path.join(pkgdatadir, f)), files): + try: + pkgdata = read_pkgdatafile(os.path.join(pkgdatadir, pn)) + except OSError: + continue + + for pkg in pkgdata["PACKAGES"].split(): + pkgmap[pkg] = pn + + return pkgmap + +def pkgmap(d): + """Return a dictionary mapping package to recipe name. + Cache the mapping in the metadata""" + + pkgmap_data = d.getVar("__pkgmap_data", False) + if pkgmap_data is None: + pkgmap_data = _pkgmap(d) + d.setVar("__pkgmap_data", pkgmap_data) + + return pkgmap_data + +def recipename(pkg, d): + """Return the recipe name for the given binary package name.""" + + return pkgmap(d).get(pkg) diff --git a/lib/oe/packagegroup.py b/lib/oe/packagegroup.py index 6dc9cd7e28..7371fa72ce 100644 --- a/lib/oe/packagegroup.py +++ b/lib/oe/packagegroup.py @@ -1,15 +1,28 @@ +import itertools + def is_optional(group, d): return bool(d.getVarFlag("PACKAGE_GROUP_%s" % group, "optional")) def packages(groups, d): - from itertools import chain - return chain.from_iterable(d.getVar("PACKAGE_GROUP_%s" % group, True).split() - for group in groups) + return itertools.chain.from_iterable(d.getVar("PACKAGE_GROUP_%s" % group, True).split() + for group in groups) def required_packages(groups, d): req = filter(lambda group: not is_optional(group, d), groups) - return " ".join(packages(req, d)) + return packages(req, d) def optional_packages(groups, d): opt = filter(lambda group: is_optional(group, d), groups) - return " ".join(packages(opt, d)) + return packages(opt, d) + +def active_packages(features, d): + return itertools.chain(required_packages(features, d), + optional_packages(features, d)) + +def active_recipes(features, d): + import oe.packagedata + + for pkg in active_packages(features, d): + recipe = oe.packagedata.recipename(pkg, d) + if recipe: + yield recipe |