From 353ba77e54bdd3d2af60e31590860b4a1e0b76a6 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 29 Oct 2009 23:39:34 +0000 Subject: package.bbclass: Move variable checks to one place making the code more readable (from Poky) Signed-off-by: Richard Purdie --- classes/package.bbclass | 52 +++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 38 deletions(-) (limited to 'classes/package.bbclass') diff --git a/classes/package.bbclass b/classes/package.bbclass index e7865754eb..f4a881ab57 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -29,9 +29,6 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst import os, os.path, bb dvar = bb.data.getVar('D', d, True) - if not dvar: - bb.error("D not defined") - return packages = bb.data.getVar('PACKAGES', d, True).split() @@ -303,14 +300,7 @@ python package_do_split_locales() { return dvar = bb.data.getVar('D', d, True) - if not dvar: - bb.error("D not defined") - return - pn = bb.data.getVar('PN', d, True) - if not pn: - bb.error("PN not defined") - return if pn + '-locale' in packages: packages.remove(pn + '-locale') @@ -344,32 +334,17 @@ python package_do_split_locales() { } python populate_packages () { - import glob, stat, errno, re + import os, glob, stat, errno, re workdir = bb.data.getVar('WORKDIR', d, True) - if not workdir: - bb.error("WORKDIR not defined, unable to package") - return - - import os # path manipulations outdir = bb.data.getVar('DEPLOY_DIR', d, True) - if not outdir: - bb.error("DEPLOY_DIR not defined, unable to package") - return - bb.mkdirhier(outdir) - dvar = bb.data.getVar('D', d, True) - if not dvar: - bb.error("D not defined, unable to package") - return - bb.mkdirhier(dvar) - packages = bb.data.getVar('PACKAGES', d, True) - pn = bb.data.getVar('PN', d, True) - if not pn: - bb.error("PN not defined") - return + + bb.mkdirhier(outdir) + bb.mkdirhier(dvar) + os.chdir(dvar) @@ -621,9 +596,6 @@ python package_do_shlibs() { packages = bb.data.getVar('PACKAGES', d, True) workdir = bb.data.getVar('WORKDIR', d, True) - if not workdir: - bb.error("WORKDIR not defined") - return ver = bb.data.getVar('PV', d, True) if not ver: @@ -787,12 +759,7 @@ python package_do_pkgconfig () { import re, os packages = bb.data.getVar('PACKAGES', d, True) - workdir = bb.data.getVar('WORKDIR', d, True) - if not workdir: - bb.error("WORKDIR not defined") - return - pkgdest = bb.data.getVar('PKGDEST', d, True) shlibs_dir = bb.data.getVar('SHLIBSDIR', d, True) @@ -1059,6 +1026,15 @@ python package_do_package () { bb.debug(1, "No packages to build, skipping do_package") return + workdir = bb.data.getVar('WORKDIR', d, True) + outdir = bb.data.getVar('DEPLOY_DIR', d, True) + dvar = bb.data.getVar('D', d, True) + pn = bb.data.getVar('PN', d, True) + + if not workdir or not outdir or not dvar or not pn or not packages: + bb.error("WORKDIR, DEPLOY_DIR, D, and PN all must be defined, unable to package") + return + for f in (bb.data.getVar('PACKAGEFUNCS', d, True) or '').split(): bb.build.exec_func(f, d) package_run_hooks(f, d) -- cgit v1.2.3 From c41e3631d31a1932fcbb0098eab0520f90711cc3 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 29 Oct 2009 23:42:11 +0000 Subject: package.bbclass: Remove hardcoded use of PKGDEST variable (from Poky) Signed-off-by: Richard Purdie --- classes/package.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'classes/package.bbclass') diff --git a/classes/package.bbclass b/classes/package.bbclass index f4a881ab57..2c085be797 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -517,6 +517,7 @@ python emit_pkgdata() { return packages = bb.data.getVar('PACKAGES', d, True) + pkgdest = bb.data.getVar('PKGDEST', d, 1) pkgdatadir = bb.data.getVar('PKGDATA_DIR', d, True) pstageactive = bb.data.getVar('PSTAGING_ACTIVE', d, True) @@ -560,7 +561,7 @@ python emit_pkgdata() { allow_empty = bb.data.getVar('ALLOW_EMPTY_%s' % pkg, d, True) if not allow_empty: allow_empty = bb.data.getVar('ALLOW_EMPTY', d, True) - root = "%s/install/%s" % (workdir, pkg) + root = "%s/%s" % (pkgdest, pkg) os.chdir(root) g = glob('*') + glob('.[!.]*') if g or allow_empty == "1": -- cgit v1.2.3 From 29c7d3351f43678c6e93b707b301832009f64b31 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 30 Oct 2009 00:08:19 +0000 Subject: package.bbclass: Change to operate on a copy of the install directory instead of directly. Also take the opportunity to rename the temp directories so their function is clear (from Poky) Signed-off-by: Richard Purdie --- classes/package.bbclass | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'classes/package.bbclass') diff --git a/classes/package.bbclass b/classes/package.bbclass index 2c085be797..03618ba6fc 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -2,7 +2,8 @@ # General packaging help functions # -PKGDEST = "${WORKDIR}/install" +PKGD = "${WORKDIR}/package" +PKGDEST = "${WORKDIR}/packages-split" def legitimize_package_name(s): """ @@ -28,7 +29,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst """ import os, os.path, bb - dvar = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) packages = bb.data.getVar('PACKAGES', d, True).split() @@ -299,7 +300,7 @@ python package_do_split_locales() { bb.note("datadir not defined") return - dvar = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) pn = bb.data.getVar('PN', d, True) if pn + '-locale' in packages: @@ -333,19 +334,29 @@ python package_do_split_locales() { bb.data.setVar('PACKAGES', ' '.join(packages), d) } +python perform_packagecopy () { + import os + + dest = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) + + bb.mkdirhier(dvar) + + # Start by package population by taking a copy of the installed + # files to operate on + os.system('cp -pPR %s/* %s/' % (dest, dvar)) +} + python populate_packages () { import os, glob, stat, errno, re workdir = bb.data.getVar('WORKDIR', d, True) outdir = bb.data.getVar('DEPLOY_DIR', d, True) - dvar = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) packages = bb.data.getVar('PACKAGES', d, True) pn = bb.data.getVar('PN', d, True) bb.mkdirhier(outdir) - bb.mkdirhier(dvar) - - os.chdir(dvar) def isexec(path): @@ -981,7 +992,8 @@ python package_depchains() { } -PACKAGEFUNCS ?= "package_do_split_locales \ +PACKAGEFUNCS ?= "perform_packagecopy \ + package_do_split_locales \ populate_packages \ package_do_shlibs \ package_do_pkgconfig \ @@ -1029,11 +1041,12 @@ python package_do_package () { workdir = bb.data.getVar('WORKDIR', d, True) outdir = bb.data.getVar('DEPLOY_DIR', d, True) - dvar = bb.data.getVar('D', d, True) + dest = bb.data.getVar('D', d, True) + dvar = bb.data.getVar('PKGD', d, True) pn = bb.data.getVar('PN', d, True) - if not workdir or not outdir or not dvar or not pn or not packages: - bb.error("WORKDIR, DEPLOY_DIR, D, and PN all must be defined, unable to package") + if not workdir or not outdir or not dest or not dvar or not pn or not packages: + bb.error("WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package") return for f in (bb.data.getVar('PACKAGEFUNCS', d, True) or '').split(): -- cgit v1.2.3 From 6111d7132a0c7aa0b4827a3bcca05156a7d20d57 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 30 Oct 2009 00:31:21 +0000 Subject: package.bbclass: Add the option to declare package preprocess function hooks (from Poky) Signed-off-by: Richard Purdie --- classes/package.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'classes/package.bbclass') diff --git a/classes/package.bbclass b/classes/package.bbclass index 03618ba6fc..1c14908f1a 100644 --- a/classes/package.bbclass +++ b/classes/package.bbclass @@ -991,8 +991,9 @@ python package_depchains() { pkg_addrrecs(pkg, base, suffix, func, rdeps, d) } - +PACKAGE_PREPROCESS_FUNCS ?= "" PACKAGEFUNCS ?= "perform_packagecopy \ + ${PACKAGE_PREPROCESS_FUNCS} \ package_do_split_locales \ populate_packages \ package_do_shlibs \ -- cgit v1.2.3