diff options
Diffstat (limited to 'classes/packaged-staging.bbclass')
| -rw-r--r-- | classes/packaged-staging.bbclass | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/classes/packaged-staging.bbclass b/classes/packaged-staging.bbclass index 0dd6900d77..1c5c4cd531 100644 --- a/classes/packaged-staging.bbclass +++ b/classes/packaged-staging.bbclass @@ -13,14 +13,11 @@ # PSTAGE_PKGVERSION = "${PV}-${PR}" PSTAGE_PKGARCH = "${BUILD_SYS}" -PSTAGE_EXTRAPATH ?= "" +PSTAGE_EXTRAPATH ?= "/${OELAYOUT_ABI}/${DISTRO_PR}/" PSTAGE_PKGPATH = "${DISTRO}${PSTAGE_EXTRAPATH}" PSTAGE_PKGPN = "${@bb.data.expand('staging-${PN}-${MULTIMACH_ARCH}${TARGET_VENDOR}-${TARGET_OS}', d).replace('_', '-')}" PSTAGE_PKGNAME = "${PSTAGE_PKGPN}_${PSTAGE_PKGVERSION}_${PSTAGE_PKGARCH}.ipk" -PSTAGE_PKG = "${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGPATH}/${PSTAGE_PKGNAME}" - -# multimachine.bbclass will override this but add a default in case we're not using it -MULTIMACH_ARCH ?= "${PACKAGE_ARCH}" +PSTAGE_PKG ?= "${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGPATH}/${PSTAGE_PKGNAME}" PSTAGE_NATIVEDEPENDS = "\ shasum-native \ @@ -30,7 +27,6 @@ PSTAGE_NATIVEDEPENDS = "\ BB_STAMP_WHITELIST = "${PSTAGE_NATIVEDEPENDS}" python () { - import bb pstage_allowed = True # These classes encode staging paths into the binary data so can only be @@ -52,6 +48,9 @@ python () { if bb.data.inherits_class('image', d): pstage_allowed = False + if bb.data.getVar('PSTAGING_DISABLED', d, True) == "1": + pstage_allowed = False + # Add task dependencies if we're active, otherwise mark packaged staging # as inactive. if pstage_allowed: @@ -70,7 +69,7 @@ python () { bb.data.setVar("PSTAGING_ACTIVE", "0", d) } -DEPLOY_DIR_PSTAGE = "${DEPLOY_DIR}/pstage" +DEPLOY_DIR_PSTAGE ?= "${DEPLOY_DIR}/pstage" PSTAGE_MACHCONFIG = "${DEPLOY_DIR_PSTAGE}/opkg.conf" PSTAGE_PKGMANAGER = "stage-manager-ipkg" @@ -84,8 +83,6 @@ PSTAGE_LIST_CMD = "${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -o ${TMP PSTAGE_TMPDIR_STAGE = "${WORKDIR}/staging-pkg" def pstage_manualclean(srcname, destvarname, d): - import os, bb - src = os.path.join(bb.data.getVar('PSTAGE_TMPDIR_STAGE', d, True), srcname) dest = bb.data.getVar(destvarname, d, True) @@ -96,7 +93,6 @@ def pstage_manualclean(srcname, destvarname, d): os.system("rm %s" % filepath) def pstage_set_pkgmanager(d): - import bb path = bb.data.getVar("PATH", d, 1) pkgmanager = bb.which(path, 'opkg-cl') if pkgmanager == "": @@ -106,23 +102,21 @@ def pstage_set_pkgmanager(d): def pstage_cleanpackage(pkgname, d): - import os, bb - path = bb.data.getVar("PATH", d, 1) pstage_set_pkgmanager(d) list_cmd = bb.data.getVar("PSTAGE_LIST_CMD", d, True) - bb.note("Checking if staging package installed") - lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) + bb.debug(2, "Checking if staging package installed") + lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d)) ret = os.system("PATH=\"%s\" %s | grep %s" % (path, list_cmd, pkgname)) if ret == 0: - bb.note("Yes. Uninstalling package from staging...") + bb.debug(1, "Uninstalling package from staging...") removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, pkgname)) if ret != 0: bb.note("Failure removing staging package") else: - bb.note("No. Manually removing any installed files") + bb.debug(1, "Manually removing any installed files from staging...") pstage_manualclean("staging", "STAGING_DIR", d) pstage_manualclean("cross", "CROSS_DIR", d) pstage_manualclean("deploy", "DEPLOY_DIR", d) @@ -138,7 +132,7 @@ do_clean_prepend() { pstage_cleanpackage(removepkg, d) stagepkg = bb.data.expand("${PSTAGE_PKG}", d) - bb.note("Removing staging package %s" % stagepkg) + bb.note("Removing staging package %s" % base_path_out(stagepkg, d)) os.system('rm -rf ' + stagepkg) } @@ -155,12 +149,11 @@ staging_helper () { done echo "dest root /" >> $conffile fi - if [ ! -e ${TMPDIR}${layout_libdir}/opkg/info/ ]; then - mkdir -p ${TMPDIR}${layout_libdir}/opkg/info/ + if [ ! -e ${TMPDIR}${libdir_native}/opkg/info/ ]; then + mkdir -p ${TMPDIR}${libdir_native}/opkg/info/ fi - if [ ! -e ${TMPDIR}${layout_libdir}/ipkg/ ]; then - cd ${TMPDIR}${layout_libdir}/ - ln -s opkg/ ipkg + if [ ! -e ${TMPDIR}${libdir_native}/ipkg/ ]; then + ln -sf opkg/ ${TMPDIR}${libdir_native}/ipkg || true fi } @@ -169,14 +162,13 @@ PSTAGE_TASKS_COVERED = "fetch unpack munge patch configure qa_configure rig_loca SCENEFUNCS += "packagestage_scenefunc" python packagestage_scenefunc () { - import os - if bb.data.getVar("PSTAGING_ACTIVE", d, 1) == "0": return bb.build.exec_func("staging_helper", d) removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) + pstage_cleanpackage(removepkg, d) stagepkg = bb.data.expand("${PSTAGE_PKG}", d) @@ -190,7 +182,8 @@ python packagestage_scenefunc () { # # Install the staging package somewhere temporarily so we can extract the stamp files # - cmd = bb.data.expand("${PSTAGE_PKGMANAGER} -force-depends -f ${PSTAGE_MACHCONFIG} -o ${WORKDIR}/tstage install", d) + bb.mkdirhier(bb.data.expand("${WORKDIR}/tstage/${libdir_native}/opkg/info/ ", d)) + cmd = bb.data.expand("${PSTAGE_PKGMANAGER} -f ${PSTAGE_MACHCONFIG} -force-depends -o ${WORKDIR}/tstage install", d) ret = os.system("PATH=\"%s\" %s %s" % (path, cmd, stagepkg)) if ret != 0: bb.fatal("Couldn't install the staging package to a temp directory") @@ -230,7 +223,7 @@ python packagestage_scenefunc () { if stageok: bb.note("Staging package found, using it for %s." % file) installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1) - lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) + lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d)) ret = os.system("PATH=\"%s\" %s %s" % (path, installcmd, stagepkg)) bb.utils.unlockfile(lf) if ret != 0: @@ -246,10 +239,7 @@ packagestage_scenefunc[dirs] = "${STAGING_DIR}" addhandler packagedstage_stampfixing_eventhandler python packagedstage_stampfixing_eventhandler() { - from bb.event import getName - import os - - if getName(e) == "StampUpdate": + if bb.event.getName(e) == "StampUpdate": taskscovered = bb.data.getVar("PSTAGE_TASKS_COVERED", e.data, 1).split() for (fn, task) in e.targets: # strip off 'do_' @@ -286,7 +276,7 @@ populate_staging_postamble () { if [ "$exitcode" != "5" -a "$exitcode" != "0" ]; then exit $exitcode fi - stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-cross -u -d ${PSTAGE_TMPDIR_STAGE}/cross + stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-cross -u -d ${PSTAGE_TMPDIR_STAGE}/cross/${BASE_PACKAGE_ARCH} if [ "$exitcode" != "5" -a "$exitcode" != "0" ]; then exit $exitcode fi @@ -294,13 +284,21 @@ populate_staging_postamble () { fi } -do_populate_staging[lockfiles] = "${STAGING_DIR}/staging.lock" +packagedstaging_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() { +python populate_staging_prehook() { bb.build.exec_func("populate_staging_preamble", d) } -python do_populate_staging_append() { +python populate_staging_posthook() { bb.build.exec_func("populate_staging_postamble", d) } @@ -331,20 +329,20 @@ staging_packager () { staging_package_installer () { #${PSTAGE_INSTALL_CMD} ${PSTAGE_PKG} - STATUSFILE=${TMPDIR}${layout_libdir}/opkg/status + STATUSFILE=${TMPDIR}${libdir_native}/opkg/status echo "Package: ${PSTAGE_PKGPN}" >> $STATUSFILE echo "Version: ${PSTAGE_PKGVERSION}" >> $STATUSFILE echo "Status: install user installed" >> $STATUSFILE echo "Architecture: ${PSTAGE_PKGARCH}" >> $STATUSFILE echo "" >> $STATUSFILE - CTRLFILE=${TMPDIR}${layout_libdir}/opkg/info/${PSTAGE_PKGPN}.control + CTRLFILE=${TMPDIR}${libdir_native}/opkg/info/${PSTAGE_PKGPN}.control echo "Package: ${PSTAGE_PKGPN}" > $CTRLFILE echo "Version: ${PSTAGE_PKGVERSION}" >> $CTRLFILE echo "Architecture: ${PSTAGE_PKGARCH}" >> $CTRLFILE cd ${PSTAGE_TMPDIR_STAGE} - find -type f | grep -v ./CONTROL | sed -e 's/^\.//' > ${TMPDIR}${layout_libdir}/opkg/info/${PSTAGE_PKGPN}.list + find -type f | grep -v ./CONTROL | sed -e 's/^\.//' > ${TMPDIR}${libdir_native}/opkg/info/${PSTAGE_PKGPN}.list } python do_package_stage () { @@ -363,6 +361,8 @@ python do_package_stage () { ipkpath = bb.data.getVar('DEPLOY_DIR_IPK', d, True).replace(tmpdir, stagepath) if bb.data.inherits_class('package_deb', d): debpath = bb.data.getVar('DEPLOY_DIR_DEB', d, True).replace(tmpdir, stagepath) + if bb.data.inherits_class('package_rpm', d): + rpmpath = bb.data.getVar('DEPLOY_DIR_RPM', d, True).replace(tmpdir, stagepath) for pkg in packages: pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1) @@ -395,6 +395,18 @@ python do_package_stage () { bb.mkdirhier(destpath) bb.copyfile(srcfile, destpath + srcname) + if bb.data.inherits_class('package_rpm', d): + version = bb.data.getVar('PV', d, 1) + version = version.replace('-', '+') + bb.data.setVar('RPMPV', version, d) + srcname = bb.data.expand(pkgname + "-${RPMPV}-" + pr + ".${TARGET_ARCH}.rpm", d) + srcfile = bb.data.expand("${DEPLOY_DIR_RPM}/" + arch + "/" + srcname, d) + if os.path.exists(srcfile): + destpath = rpmpath + "/" + arch + "/" + bb.mkdirhier(destpath) + bb.copyfile(srcfile, destpath + srcname) + + # # Handle stamps/ files # @@ -408,7 +420,7 @@ python do_package_stage () { pstage_set_pkgmanager(d) bb.build.exec_func("staging_helper", d) bb.build.exec_func("staging_packager", d) - lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) + lf = bb.utils.lockfile(bb.data.expand("${SYSROOT_LOCK}", d)) bb.build.exec_func("staging_package_installer", d) bb.utils.unlockfile(lf) } |
