From d7399bd56c8fc7c58af79ef91dc67382cc23eb47 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 2 Nov 2009 20:43:22 +0000 Subject: base.bbclass: Rework staging function to use a DESTDIR style configuration based on the data from the do_install step. This falls back to any standard do_stage function if defined, see the mailing list for more info. Signed-off-by: Richard Purdie --- meta/classes/base.bbclass | 68 ++++++++++++++++++++++++++++++----- meta/classes/packaged-staging.bbclass | 53 ++++++--------------------- 2 files changed, 70 insertions(+), 51 deletions(-) (limited to 'meta') diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index b536f92e4..086a6d05d 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass @@ -976,15 +976,22 @@ sysroot_stage_dirs() { sysroot_stage_dir $from${datadir} $to${STAGING_DATADIR} } - sysroot_stage_all() { sysroot_stage_dirs ${D} ${SYSROOT_DESTDIR} } - -base_do_stage () { - : -} +def is_legacy_staging(d): + stagefunc = bb.data.getVar('do_stage', d, True) + legacy = True + if stagefunc is None: + legacy = False + elif stagefunc.strip() == "autotools_stage_all": + legacy = False + elif stagefunc.strip() == "do_stage_native" and bb.data.getVar('AUTOTOOLS_NATIVE_STAGE_INSTALL', d, 1) == "1": + legacy = False + if bb.data.getVar('PSTAGE_BROKEN_DESTDIR', d, 1) == "1": + legacy = True + return legacy do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${bindir} ${STAGING_DIR_TARGET}/${libdir} \ ${STAGING_DIR_TARGET}/${includedir} \ @@ -996,19 +1003,60 @@ do_populate_staging[dirs] = "${STAGING_DIR_TARGET}/${bindir} ${STAGING_DIR_TARGE # Could be compile but populate_staging and do_install shouldn't run at the same time addtask populate_staging after do_install +PSTAGING_ACTIVE = "0" SYSROOT_PREPROCESS_FUNCS ?= "" SYSROOT_DESTDIR = "${WORKDIR}/sysroot-destdir/" SYSROOT_LOCK = "${STAGING_DIR}/staging.lock" +python populate_staging_prehook () { + return +} + +python populate_staging_posthook () { + return +} + +packagedstageing_fastpath () { + : +} + python do_populate_staging () { # - # Only run do_stage if its not the empty default above + # if do_stage exists, we're legacy. In that case run the do_stage, + # modify the SYSROOT_DESTDIR variable and then run the staging preprocess + # functions against staging directly. # - stagefunc = bb.data.getVar('do_stage', d, 1).strip() - if stagefunc != "base_do_stage": + # Otherwise setup a destdir, copy the results from do_install + # and run the staging preprocess against that + # + pstageactive = (bb.data.getVar("PSTAGING_ACTIVE", d, True) == "1") + lockfile = bb.data.getVar("SYSROOT_LOCK", d, True) + stagefunc = bb.data.getVar('do_stage', d, True) + legacy = is_legacy_staging(d) + if legacy: + bb.data.setVar("SYSROOT_DESTDIR", "", d) + bb.note("Legacy staging mode for %s" % bb.data.getVar("FILE", d, True)) + lock = bb.utils.lockfile(lockfile) bb.build.exec_func('do_stage', d) + bb.build.exec_func('populate_staging_prehook', d) + for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split(): + bb.build.exec_func(f, d) + bb.build.exec_func('populate_staging_posthook', d) + bb.utils.unlockfile(lock) + else: + dest = bb.data.getVar('D', d, True) + sysrootdest = bb.data.expand('${SYSROOT_DESTDIR}${STAGING_DIR_TARGET}', d) + bb.mkdirhier(sysrootdest) + + bb.build.exec_func("sysroot_stage_all", d) + #os.system('cp -pPR %s/* %s/' % (dest, sysrootdest)) for f in (bb.data.getVar('SYSROOT_PREPROCESS_FUNCS', d, True) or '').split(): bb.build.exec_func(f, d) + bb.build.exec_func("packagedstageing_fastpath", d) + + lock = bb.utils.lockfile(lockfile) + os.system('cp -pPR %s/* /' % (sysrootdest)) + bb.utils.unlockfile(lock) } addtask install after do_compile @@ -1149,6 +1197,8 @@ def base_after_parse(d): python () { base_after_parse(d) + if is_legacy_staging(d): + bb.debug(1, "Legacy staging mode for %s" % bb.data.getVar("FILE", d, True)) } def check_app_exists(app, d): @@ -1175,7 +1225,7 @@ inherit patch # Move to autotools.bbclass? inherit siteinfo -EXPORT_FUNCTIONS do_setscene do_clean do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_stage do_rebuild do_fetchall +EXPORT_FUNCTIONS do_setscene do_clean do_fetch do_unpack do_configure do_compile do_install do_package do_populate_pkgs do_rebuild do_fetchall MIRRORS[func] = "0" MIRRORS () { diff --git a/meta/classes/packaged-staging.bbclass b/meta/classes/packaged-staging.bbclass index 6df13876c..44f657a2c 100644 --- a/meta/classes/packaged-staging.bbclass +++ b/meta/classes/packaged-staging.bbclass @@ -63,29 +63,6 @@ python () { bb.data.setVarFlag('do_setscene', 'recrdeptask', deps, d) bb.data.setVar("PSTAGING_ACTIVE", "1", d) - - # - # Here we notice if the staging function is one of our standard staging - # routines. If it is, we can remvoe the need to lock staging and take - # timestamps which gives a nice speedup - # - fastpath = False - stagefunc = bb.data.getVar('do_stage', d, 1).strip() - if stagefunc == "autotools_stage_all": - fastpath = True - elif stagefunc == "base_do_stage": - fastpath = True - elif stagefunc == "do_stage_native" and bb.data.getVar('AUTOTOOLS_NATIVE_STAGE_INSTALL', d, 1) == "1": - fastpath = True - if bb.data.getVar('PSTAGE_BROKEN_DESTDIR', d, 1) == "1": - fastpath = False - if fastpath: - #bb.note("Optimised for staging: " + bb.data.getVar('FILE', d, 1)) - bb.data.setVar("PSTAGING_NEEDSTAMP", "0", d) - bb.data.setVar("STAGE_TEMP_PREFIX", "${WORKDIR}/temp-staging-pstage", d) - else: - #bb.note("Can optimise staging better: " + bb.data.getVar('FILE', d, 1)) - bb.data.setVar("PSTAGING_NEEDSTAMP", "1", d) else: bb.data.setVar("PSTAGING_ACTIVE", "0", d) } @@ -320,30 +297,22 @@ populate_staging_postamble () { fi } -autotools_staging_pstage () { - mkdir -p ${PSTAGE_TMPDIR_STAGE}/staging/ - cp -fpPR ${WORKDIR}/temp-staging-pstage/${STAGING_DIR}/* ${PSTAGE_TMPDIR_STAGE}/staging/ || /bin/true - cp -fpPR ${WORKDIR}/temp-staging-pstage/${STAGING_DIR}/* ${STAGING_DIR}/ || /bin/true +packagedstageing_fastpath () { + if [ "$PSTAGING_ACTIVE" = "1" ]; then + mkdir -p ${PSTAGE_TMPDIR_STAGE}/staging/ + mkdir -p ${PSTAGE_TMPDIR_STAGE}/cross/ + cp -fpPR ${SYSROOT_DESTDIR}/${STAGING_DIR}/* ${PSTAGE_TMPDIR_STAGE}/staging/ || /bin/true + cp -fpPR ${SYSROOT_DESTDIR}/${CROSS_DIR}/* ${PSTAGE_TMPDIR_STAGE}/cross/ || /bin/true + fi } do_populate_staging[dirs] =+ "${DEPLOY_DIR_PSTAGE}" -python do_populate_staging_prepend() { - needstamp = bb.data.getVar("PSTAGING_NEEDSTAMP", d, 1) - pstageactive = bb.data.getVar("PSTAGING_ACTIVE", d, True) - lock = bb.data.expand("${SYSROOT_LOCK}", d) - if needstamp == "1": - stamplock = bb.utils.lockfile(lock) - bb.build.exec_func("populate_staging_preamble", d) +python populate_staging_prehook() { + bb.build.exec_func("populate_staging_preamble", d) } -python do_populate_staging_append() { - if needstamp == "1": - bb.build.exec_func("populate_staging_postamble", d) - bb.utils.unlockfile(stamplock) - elif pstageactive == "1": - stamplock = bb.utils.lockfile(lock) - bb.build.exec_func("autotools_staging_pstage", d) - bb.utils.unlockfile(stamplock) +python populate_staging_posthook() { + bb.build.exec_func("populate_staging_postamble", d) } -- cgit v1.2.3