diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2008-02-19 12:08:38 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@rpsys.net> | 2008-02-19 12:08:38 +0000 |
commit | 695ca19882ed557a40fd39c9d5252af105190eac (patch) | |
tree | 8946d47aac549f5ece16ea21b3fce6ba6a5665e4 /classes | |
parent | d56c0688ea805c88d94afad341cf074060b61c16 (diff) |
packaged-staging.bbclass: Remove older version and replace with improved version
Diffstat (limited to 'classes')
-rw-r--r-- | classes/packaged-staging.bbclass | 389 | ||||
-rw-r--r-- | classes/packaged-staging2.bbclass | 229 |
2 files changed, 195 insertions, 423 deletions
diff --git a/classes/packaged-staging.bbclass b/classes/packaged-staging.bbclass index 4b4ebb58bf..29ce72d65c 100644 --- a/classes/packaged-staging.bbclass +++ b/classes/packaged-staging.bbclass @@ -1,228 +1,229 @@ # -# Populated ${STAGING} using packages +# Populate builds using prebuilt packages where possible to speed up builds +# and allow staging to be reconstructed. # # To use it add that line to conf/local.conf: # -# INHERIT += "packaged-staging" -# -# You also need ipkg-cl and ipkg-make-index installed on your host -# put ipkg-build from org.openembedded.packaged-staging/contrib/ in your $PATH - -# BUGS: -# * does not distinguish between -native, -cross and other packages - -# TODO: -# * also build a feed for native and cross packages -# * make package detection a bit smarter (search for compatible archs) -# * make do_clean clean staging as well - -# Summary: -# This class will have two modes of operation: -# PSTAGE_MODE = 'repopulate': repopulated staging from scratch for each packages -# PSTAGE_MODE = 'append': append each package to staging (current behaviour) - -inherit package +# INHERIT = "packaged-staging" + +python () { + import bb + if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('image', d) and not bb.data.inherits_class('cross', d) and not bb.data.inherits_class('sdk', d): + deps = bb.data.getVarFlag('do_populate_staging', 'depends', d) or "" + deps += " stagemanager-native:do_populate_staging" + bb.data.setVarFlag('do_populate_staging', 'depends', deps, d) + + deps = bb.data.getVarFlag('do_prepackaged_stage', 'depends', d) or "" + deps += " ipkg-native:do_populate_staging ipkg-utils-native:do_populate_staging" + bb.data.setVarFlag('do_prepackaged_stage', 'depends', deps, d) + else: + bb.data.setVar("PSTAGING_DISABLED", "1", d) +} -DEPENDS = "stagemanager-native" +export PSTAGING_DISABLED = "0" DEPLOY_DIR_PSTAGE = "${DEPLOY_DIR}/pstage" PSTAGE_BUILD_CMD = "${IPKGBUILDCMD}" -PSTAGE_INSTALL_CMD = "ipkg-cl install -force-depends -f ${DEPLOY_DIR_PSTAGE}/ipkg.conf -o " -PSTAGE_UPDATE_CMD = "ipkg-cl update -f ${DEPLOY_DIR_PSTAGE}/ipkg.conf -o " -PSTAGE_LIST_CMD = "ipkg-cl list_installed -f ${DEPLOY_DIR_PSTAGE}/ipkg.conf -o " -PSTAGE_PKGNAME = "staging-${PN}_${PV}-${PR}_${PACKAGE_ARCH}.ipk" -PCROSS_PKGNAME = "cross-${PN}_${PV}-${PR}_${BUILD_ARCH}.ipk" - -SPAWNFILE = "${STAGING_DIR}/pkgmaps/${P}-${PR}.spawn" -SPAWNIPK = "${spawn}" - -PSTAGE_TMPDIR_STAGE = "${TMPDIR}/tmp-staging" -PSTAGE_TMPDIR_CROSS = "${TMPDIR}/tmp-cross" - -STAGING_BASEDIR = "${STAGING_LIBDIR}/.." - -PACKAGEFUNCS += "do_write_ipk_list" - -python do_write_ipk_list () { - import os, sys - ipkdir = bb.data.getVar('DEPLOY_DIR_IPK', d, 1) - stagingdir = bb.data.getVar('STAGING_DIR', d, 1) - tmpdir = bb.data.getVar('TMPDIR', d, 1) - p = bb.data.getVar('P', d, 1) - pr = bb.data.getVar('PR', d, 1) - - packages = bb.data.getVar('PACKAGES', d, 1) - if not packages: - bb.debug(1, "PACKAGES not defined, nothing to package") - return - - if packages == []: - bb.debug(1, "No packages; nothing to do") - return - - # Generate ipk.conf if it or the stamp doesnt exist - listfile = os.path.join(stagingdir,"pkgmaps","%s-%s.spawn" % ( p , pr )) - os.system('mkdir -p ' + stagingdir + '/pkgmaps') - if not os.access(listfile, os.R_OK): - os.system('rm -f ' + listfile) - f = open(listfile,"w") - for spawn in packages.split(): - #check if the packagename has changed due to debian shlib renaming - localdata = bb.data.createCopy(d) - pkgname = bb.data.getVar('PKG_%s' % spawn, localdata, 1) - if not pkgname: - pkgname = spawn - f.write("%s\n" % pkgname) - f.close() -} +PSTAGE_INSTALL_CMD = "ipkg-cl install -force-depends -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" +PSTAGE_UPDATE_CMD = "ipkg-cl update -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" +PSTAGE_REMOVE_CMD = "ipkg-cl remove -force-depends -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" +PSTAGE_LIST_CMD = "ipkg-cl list_installed -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" +PSTAGE_PKGNAME = "staging-${PN}_${PV}-${PR}_${MULTIMACH_ARCH}.ipk" +PSTAGE_TMPDIR_STAGE = "${WORKDIR}/staging-pkg" do_clean_append() { - """clear the build and temp directories""" + """ + Clear the build and temp directories + """ + bb.note("Uninstalling package from staging...") + path = bb.data.getVar("PATH", d, 1) + removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) + removepkg = bb.data.expand("staging-${PN}", d) + ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) + if ret != 0: + bb.note("Failure removing staging package") + stagepkg = bb.data.expand("${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME}", d) - if stagepkg == '//': raise bb.build.FuncFailed("wrong DATADIR") - bb.note("removing " + stagepkg) - os.system('rm -rf ' + stagepkg) + bb.note("Removing staging package %s" % stagepkg) + #os.system('rm -rf ' + stagepkg) } - -do_stage_prepend() { - - stage-manager -p ${STAGING_DIR} -c ${DEPLOY_DIR_PSTAGE}/staging-stamp-cache -u - - stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/cross-stamp-cache -u - - if [ ! -e ${STAGING_BASEDIR} ]; then - mkdir -p ${STAGING_BASEDIR} - fi - - if [ ! -e ${DEPLOY_DIR_PSTAGE} ]; then - mkdir -p ${DEPLOY_DIR_PSTAGE} - fi - - if [ -e ${STAGING_BASEDIR}/usr ]; then - oenote "${STAGING_BASEDIR}/usr already present, leaving it alone" - else - oenote "${STAGING_BASEDIR}/usr not present, symlinking it" - ln -s ${STAGING_BASEDIR}/ ${STAGING_BASEDIR}/usr - fi - +staging_helper () { #assemble appropriate ipkg.conf - if [ -e ${DEPLOY_DIR_PSTAGE}/ipkg.conf ]; then - rm ${DEPLOY_DIR_PSTAGE}/ipkg.conf + conffile=${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf + mkdir -p ${DEPLOY_DIR_PSTAGE}/pstaging_lists + if [ ! -e $conffile ]; then + ipkgarchs="${BUILD_ARCH} all any noarch ${TARGET_ARCH} ${PACKAGE_ARCHS} ${PACKAGE_EXTRA_ARCHS} ${MACHINE}" + priority=1 + for arch in $ipkgarchs; do + echo "arch $arch $priority" >> $conffile + priority=$(expr $priority + 5) + done + echo "src oe-staging file:${DEPLOY_DIR_PSTAGE}" >> $conffile + + OLD_PWD=`pwd` + cd ${DEPLOY_DIR_PSTAGE} + ipkg-make-index -p Packages . + cd ${OLD_PWD} + + ${PSTAGE_UPDATE_CMD} fi +} - ipkgarchs="${BUILD_ARCH} all any noarch ${TARGET_ARCH} ${PACKAGE_ARCHS} ${PACKAGE_EXTRA_ARCHS} ${MACHINE}" - priority=1 - for arch in $ipkgarchs; do - echo "arch $arch $priority" >> ${DEPLOY_DIR_PSTAGE}/ipkg.conf - priority=$(expr $priority + 5) - done - echo "src oe file:${DEPLOY_DIR_IPK}" >> ${DEPLOY_DIR_PSTAGE}/ipkg.conf - export OLD_PWD=`pwd` - cd ${DEPLOY_DIR_IPK} && rm *${BUILD_ARCH}.ipk -f ; ipkg-make-index -p Packages . ; cd ${OLD_PWD} - ${PSTAGE_UPDATE_CMD} ${STAGING_BASEDIR} - - #check for generated packages - if [ -e ${SPAWNFILE} ]; then - oenote "List of spawned packages found: ${P}.spawn" - for spawn in `cat ${SPAWNFILE} | grep -v locale | grep -v dbg | grep -v gconv | grep -v charmap` ; do \ - if [ -e ${DEPLOY_DIR_IPK}/${spawn}_* ]; then - ${PSTAGE_INSTALL_CMD} ${STAGING_BASEDIR} ${spawn} - # clean up .la files to avoid having references to the builddirs in the binaries - for lafile in ${STAGING_LIBDIR}/*.la ; do \ - sed -i s:installed=yes:installed=no:g ${lafile} || true - done - - #fix up linker script to poin to staging - if [ -e ${STAGING_LIBDIR}/libc.so ]; then - sed -i s:\ /lib:\ ${STAGING_LIBDIR}:g ${STAGING_LIBDIR}/libc.so - sed -i s:\ /usr/lib:\ ${STAGING_LIBDIR}:g ${STAGING_LIBDIR}/libc.so - fi - else - oenote "${spawn} not found, probably empty package" - fi - done - exit 0 - else - oenote "Spawn file not found!" - fi +python do_prepackaged_stage () { + import os + + if bb.data.getVar("PSTAGING_DISABLED", d, 1) == "1": + bb.build.make_stamp("do_prepackaged_stage", d) + return + + bb.note("Uninstalling any existing package from staging...") + path = bb.data.getVar("PATH", d, 1) + removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) + removepkg = bb.data.expand("staging-${PN}", d) + lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) + ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) + bb.utils.unlockfile(lf) + if ret != 0: + bb.note("Failure attempting to remove staging package") + + stagepkg = bb.data.expand("${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME}", d) + + if os.path.exists(stagepkg): + bb.note("Following speedup\n") + path = bb.data.getVar("PATH", d, 1) + installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1) + + bb.build.exec_func("staging_helper", d) + + bb.debug(1, "Staging stuff already packaged, using that instead") + lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) + ret = os.system("PATH=\"%s\" %s %s" % (path, installcmd, stagepkg)) + bb.utils.unlockfile(lf) + if ret != 0: + bb.note("Failure installing prestage package") + + bb.build.make_stamp("do_prepackaged_stage", d) + bb.build.make_stamp("do_fetch", d) + bb.build.make_stamp("do_unpack", d) + bb.build.make_stamp("do_munge", d) + bb.build.make_stamp("do_patch", d) + bb.build.make_stamp("do_configure", d) + bb.build.make_stamp("do_qa_configure", d) + bb.build.make_stamp("do_rig_locales", d) + bb.build.make_stamp("do_compile", d) + bb.build.make_stamp("do_install", d) + bb.build.make_stamp("do_deploy", d) + bb.build.make_stamp("do_package", d) + bb.build.make_stamp("do_populate_staging", d) + bb.build.make_stamp("do_package_write_deb", d) + bb.build.make_stamp("do_package_write_ipk", d) + bb.build.make_stamp("do_package_write", d) + bb.build.make_stamp("do_package_stage", d) + bb.build.make_stamp("do_qa_staging", d) + + else: + bb.build.make_stamp("do_prepackaged_stage", d) +} +do_prepackaged_stage[cleandirs] = "${PSTAGE_TMPDIR_STAGE}" +do_prepackaged_stage[selfstamp] = "1" +addtask prepackaged_stage before do_fetch - if [ -e ${DEPLOY_DIR_PSTAGE}/${PCROSS_PKGNAME} ]; then - oenote "Cross stuff already packaged, using that instead" - ${PSTAGE_INSTALL_CMD} ${CROSS_DIR} ${DEPLOY_DIR_PSTAGE}/${PCROSS_PKGNAME} - fi +populate_staging_preamble () { + if [ "$PSTAGING_DISABLED" != "1" ]; then + #mkdir -p ${DEPLOY_DIR_PSTAGE} - if [ -e ${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME} ]; then - oenote "Staging stuff already packaged, using that instead" - ${PSTAGE_INSTALL_CMD} ${STAGING_DIR} ${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME} - exit 0 + stage-manager -p ${STAGING_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-staging -u + stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-cross -u fi - - - mkdir -p ${STAGING_BINDIR} - mkdir -p ${STAGING_LIBDIR} - mkdir -p ${STAGING_INCDIR} - mkdir -p ${STAGING_DATADIR}/aclocal } -do_stage_append() { +populate_staging_postamble () { + if [ "$PSTAGING_DISABLED" != "1" ]; then + # list the packages currently installed in staging + ${PSTAGE_LIST_CMD} | awk '{print $1}' > ${DEPLOY_DIR_PSTAGE}/installed-list - mkdir -p ${DEPLOY_DIR_PSTAGE} + set +e + stage-manager -p ${STAGING_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-staging -u -d ${PSTAGE_TMPDIR_STAGE}/staging + stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-cross -u -d ${PSTAGE_TMPDIR_STAGE}/cross + set -e + fi +} - # list the packages currently installed in staging - ${PSTAGE_LIST_CMD} ${STAGING_DIR} | awk '{print $1}' > ${DEPLOY_DIR_PSTAGE}/installed-staging_list - ${PSTAGE_LIST_CMD} ${CROSS_DIR} | awk '{print $1}' > ${DEPLOY_DIR_PSTAGE}/installed-cross_list +do_populate_staging[lockfiles] = "${STAGING_DIR}/staging.lock" +do_populate_staging[dirs] =+ "${DEPLOY_DIR_PSTAGE}" +python do_populate_staging_prepend() { + bb.build.exec_func("populate_staging_preamble", d) +} - set +e - rm -rf ${PSTAGE_TMPDIR_STAGE} - stage-manager -p ${STAGING_DIR} -c ${DEPLOY_DIR_PSTAGE}/staging-stamp-cache -u -d ${PSTAGE_TMPDIR_STAGE} - rc=$? - set -e +python do_populate_staging_append() { + bb.build.exec_func("populate_staging_postamble", d) +} - if [ $rc == 5 ]; then - #make a package for staging - mkdir -p ${PSTAGE_TMPDIR_STAGE}/CONTROL +staging_packager () { - echo "Package: staging-${PN}" > ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Version: ${PV}-${PR}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Description: ${DESCRIPTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Section: ${SECTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Priority: Optional" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Maintainer: ${MAINTAINER}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Architecture: ${PACKAGE_ARCH}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Source: ${SRC_URI}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + mkdir -p ${PSTAGE_TMPDIR_STAGE}/CONTROL - ${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_STAGE} ${DEPLOY_DIR_PSTAGE} + echo "Package: staging-${PN}" > ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Version: ${PV}-${PR}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Description: ${DESCRIPTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Section: ${SECTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Priority: Optional" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Maintainer: ${MAINTAINER}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Architecture: ${MULTIMACH_ARCH}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control + echo "Source: ${SRC_URI}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - ${PSTAGE_INSTALL_CMD} ${STAGING_DIR} ${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME} - fi + ${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_STAGE} ${DEPLOY_DIR_PSTAGE} + ${PSTAGE_INSTALL_CMD} ${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME} +} - set +e - rm -rf ${PSTAGE_TMPDIR_CROSS} - stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/cross-stamp-cache -u -d ${PSTAGE_TMPDIR_CROSS} - rc=$? - set -e - - if [ $rc == 5 ]; then - - #make a package for cross - mkdir -p ${PSTAGE_TMPDIR_CROSS}/CONTROL - - echo "Package: cross-${PN}" > ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Version: ${PV}-${PR}" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Description: ${DESCRIPTION}" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Section: ${SECTION}" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Priority: Optional" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Maintainer: ${MAINTAINER}" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Architecture: ${BUILD_ARCH}" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - echo "Source: ${SRC_URI}" >> ${PSTAGE_TMPDIR_CROSS}/CONTROL/control - - ${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_CROSS} ${DEPLOY_DIR_PSTAGE} - - ${PSTAGE_INSTALL_CMD} ${CROSS_DIR} ${DEPLOY_DIR_PSTAGE}/${PCROSS_PKGNAME} - fi +python do_package_stage () { + if bb.data.getVar("PSTAGING_DISABLED", d, 1) == "1": + return + + bb.build.exec_func("read_subpackage_metadata", d) + packages = (bb.data.getVar('PACKAGES', d, 1) or "").split() + if len(packages) > 0: + stagepath = bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1) + if bb.data.inherits_class('package_ipk', d): + ipkpath = os.path.join(stagepath, "deploy", "ipk") + bb.mkdirhier(ipkpath) + if bb.data.inherits_class('package_deb', d): + debpath = os.path.join(stagepath, "deploy", "deb") + bb.mkdirhier(debpath) + + for pkg in packages: + pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1) + if not pkgname: + pkgname = pkg + arch = bb.data.getVar('PACKAGE_ARCH_%s' % pkg, d, 1) + if not arch: + arch = bb.data.getVar('PACKAGE_ARCH', d, 1) + if not packaged(pkg, d): + continue + if bb.data.inherits_class('package_ipk', d): + srcname = bb.data.expand(pkgname + "_${PV}-${PR}_" + arch + ".ipk", d) + srcfile = bb.data.expand("${DEPLOY_DIR_IPK}/" + arch + "/" + srcname, d) + if not os.path.exists(srcfile): + bb.fatal("Package %s does not exist yet it should" % srcfile) + bb.copyfile(srcfile, ipkpath + "/" + srcname) + if bb.data.inherits_class('package_deb', d): + if arch == 'all': + srcname = bb.data.expand(pkgname + "_${PV}-${PR}_all.deb", d) + else: + srcname = bb.data.expand(pkgname + "_${PV}-${PR}_${DPKG_ARCH}.deb", d) + srcfile = bb.data.expand("${DEPLOY_DIR_DEB}/" + arch + "/" + srcname, d) + if not os.path.exists(srcfile): + bb.fatal("Package %s does not exist yet it should" % srcfile) + bb.copyfile(srcfile, debpath + "/" + srcname) + bb.build.exec_func("staging_helper", d) + lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) + bb.build.exec_func("staging_packager", d) + bb.utils.unlockfile(lf) } +addtask package_stage after do_package_write_ipk do_package_write_deb do_package_write do_populate_staging before do_build + diff --git a/classes/packaged-staging2.bbclass b/classes/packaged-staging2.bbclass deleted file mode 100644 index 29ce72d65c..0000000000 --- a/classes/packaged-staging2.bbclass +++ /dev/null @@ -1,229 +0,0 @@ -# -# Populate builds using prebuilt packages where possible to speed up builds -# and allow staging to be reconstructed. -# -# To use it add that line to conf/local.conf: -# -# INHERIT = "packaged-staging" - -python () { - import bb - if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('image', d) and not bb.data.inherits_class('cross', d) and not bb.data.inherits_class('sdk', d): - deps = bb.data.getVarFlag('do_populate_staging', 'depends', d) or "" - deps += " stagemanager-native:do_populate_staging" - bb.data.setVarFlag('do_populate_staging', 'depends', deps, d) - - deps = bb.data.getVarFlag('do_prepackaged_stage', 'depends', d) or "" - deps += " ipkg-native:do_populate_staging ipkg-utils-native:do_populate_staging" - bb.data.setVarFlag('do_prepackaged_stage', 'depends', deps, d) - else: - bb.data.setVar("PSTAGING_DISABLED", "1", d) -} - -export PSTAGING_DISABLED = "0" - -DEPLOY_DIR_PSTAGE = "${DEPLOY_DIR}/pstage" - -PSTAGE_BUILD_CMD = "${IPKGBUILDCMD}" -PSTAGE_INSTALL_CMD = "ipkg-cl install -force-depends -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" -PSTAGE_UPDATE_CMD = "ipkg-cl update -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" -PSTAGE_REMOVE_CMD = "ipkg-cl remove -force-depends -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" -PSTAGE_LIST_CMD = "ipkg-cl list_installed -f ${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf -o ${TMPDIR}" -PSTAGE_PKGNAME = "staging-${PN}_${PV}-${PR}_${MULTIMACH_ARCH}.ipk" - -PSTAGE_TMPDIR_STAGE = "${WORKDIR}/staging-pkg" - -do_clean_append() { - """ - Clear the build and temp directories - """ - bb.note("Uninstalling package from staging...") - path = bb.data.getVar("PATH", d, 1) - removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) - removepkg = bb.data.expand("staging-${PN}", d) - ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) - if ret != 0: - bb.note("Failure removing staging package") - - stagepkg = bb.data.expand("${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME}", d) - bb.note("Removing staging package %s" % stagepkg) - #os.system('rm -rf ' + stagepkg) -} - -staging_helper () { - #assemble appropriate ipkg.conf - conffile=${DEPLOY_DIR_PSTAGE}/ipkg-${MACHINE}.conf - mkdir -p ${DEPLOY_DIR_PSTAGE}/pstaging_lists - if [ ! -e $conffile ]; then - ipkgarchs="${BUILD_ARCH} all any noarch ${TARGET_ARCH} ${PACKAGE_ARCHS} ${PACKAGE_EXTRA_ARCHS} ${MACHINE}" - priority=1 - for arch in $ipkgarchs; do - echo "arch $arch $priority" >> $conffile - priority=$(expr $priority + 5) - done - echo "src oe-staging file:${DEPLOY_DIR_PSTAGE}" >> $conffile - - OLD_PWD=`pwd` - cd ${DEPLOY_DIR_PSTAGE} - ipkg-make-index -p Packages . - cd ${OLD_PWD} - - ${PSTAGE_UPDATE_CMD} - fi -} - -python do_prepackaged_stage () { - import os - - if bb.data.getVar("PSTAGING_DISABLED", d, 1) == "1": - bb.build.make_stamp("do_prepackaged_stage", d) - return - - bb.note("Uninstalling any existing package from staging...") - path = bb.data.getVar("PATH", d, 1) - removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) - removepkg = bb.data.expand("staging-${PN}", d) - lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) - ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) - bb.utils.unlockfile(lf) - if ret != 0: - bb.note("Failure attempting to remove staging package") - - stagepkg = bb.data.expand("${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME}", d) - - if os.path.exists(stagepkg): - bb.note("Following speedup\n") - path = bb.data.getVar("PATH", d, 1) - installcmd = bb.data.getVar("PSTAGE_INSTALL_CMD", d, 1) - - bb.build.exec_func("staging_helper", d) - - bb.debug(1, "Staging stuff already packaged, using that instead") - lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) - ret = os.system("PATH=\"%s\" %s %s" % (path, installcmd, stagepkg)) - bb.utils.unlockfile(lf) - if ret != 0: - bb.note("Failure installing prestage package") - - bb.build.make_stamp("do_prepackaged_stage", d) - bb.build.make_stamp("do_fetch", d) - bb.build.make_stamp("do_unpack", d) - bb.build.make_stamp("do_munge", d) - bb.build.make_stamp("do_patch", d) - bb.build.make_stamp("do_configure", d) - bb.build.make_stamp("do_qa_configure", d) - bb.build.make_stamp("do_rig_locales", d) - bb.build.make_stamp("do_compile", d) - bb.build.make_stamp("do_install", d) - bb.build.make_stamp("do_deploy", d) - bb.build.make_stamp("do_package", d) - bb.build.make_stamp("do_populate_staging", d) - bb.build.make_stamp("do_package_write_deb", d) - bb.build.make_stamp("do_package_write_ipk", d) - bb.build.make_stamp("do_package_write", d) - bb.build.make_stamp("do_package_stage", d) - bb.build.make_stamp("do_qa_staging", d) - - else: - bb.build.make_stamp("do_prepackaged_stage", d) -} -do_prepackaged_stage[cleandirs] = "${PSTAGE_TMPDIR_STAGE}" -do_prepackaged_stage[selfstamp] = "1" -addtask prepackaged_stage before do_fetch - -populate_staging_preamble () { - if [ "$PSTAGING_DISABLED" != "1" ]; then - #mkdir -p ${DEPLOY_DIR_PSTAGE} - - stage-manager -p ${STAGING_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-staging -u - stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-cross -u - fi -} - -populate_staging_postamble () { - if [ "$PSTAGING_DISABLED" != "1" ]; then - # list the packages currently installed in staging - ${PSTAGE_LIST_CMD} | awk '{print $1}' > ${DEPLOY_DIR_PSTAGE}/installed-list - - set +e - stage-manager -p ${STAGING_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-staging -u -d ${PSTAGE_TMPDIR_STAGE}/staging - stage-manager -p ${CROSS_DIR} -c ${DEPLOY_DIR_PSTAGE}/stamp-cache-cross -u -d ${PSTAGE_TMPDIR_STAGE}/cross - set -e - fi -} - -do_populate_staging[lockfiles] = "${STAGING_DIR}/staging.lock" -do_populate_staging[dirs] =+ "${DEPLOY_DIR_PSTAGE}" -python do_populate_staging_prepend() { - bb.build.exec_func("populate_staging_preamble", d) -} - -python do_populate_staging_append() { - bb.build.exec_func("populate_staging_postamble", d) -} - - -staging_packager () { - - mkdir -p ${PSTAGE_TMPDIR_STAGE}/CONTROL - - echo "Package: staging-${PN}" > ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Version: ${PV}-${PR}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Description: ${DESCRIPTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Section: ${SECTION}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Priority: Optional" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Maintainer: ${MAINTAINER}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Architecture: ${MULTIMACH_ARCH}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - echo "Source: ${SRC_URI}" >> ${PSTAGE_TMPDIR_STAGE}/CONTROL/control - - ${PSTAGE_BUILD_CMD} ${PSTAGE_TMPDIR_STAGE} ${DEPLOY_DIR_PSTAGE} - ${PSTAGE_INSTALL_CMD} ${DEPLOY_DIR_PSTAGE}/${PSTAGE_PKGNAME} -} - -python do_package_stage () { - if bb.data.getVar("PSTAGING_DISABLED", d, 1) == "1": - return - - bb.build.exec_func("read_subpackage_metadata", d) - packages = (bb.data.getVar('PACKAGES', d, 1) or "").split() - if len(packages) > 0: - stagepath = bb.data.getVar("PSTAGE_TMPDIR_STAGE", d, 1) - if bb.data.inherits_class('package_ipk', d): - ipkpath = os.path.join(stagepath, "deploy", "ipk") - bb.mkdirhier(ipkpath) - if bb.data.inherits_class('package_deb', d): - debpath = os.path.join(stagepath, "deploy", "deb") - bb.mkdirhier(debpath) - - for pkg in packages: - pkgname = bb.data.getVar('PKG_%s' % pkg, d, 1) - if not pkgname: - pkgname = pkg - arch = bb.data.getVar('PACKAGE_ARCH_%s' % pkg, d, 1) - if not arch: - arch = bb.data.getVar('PACKAGE_ARCH', d, 1) - if not packaged(pkg, d): - continue - if bb.data.inherits_class('package_ipk', d): - srcname = bb.data.expand(pkgname + "_${PV}-${PR}_" + arch + ".ipk", d) - srcfile = bb.data.expand("${DEPLOY_DIR_IPK}/" + arch + "/" + srcname, d) - if not os.path.exists(srcfile): - bb.fatal("Package %s does not exist yet it should" % srcfile) - bb.copyfile(srcfile, ipkpath + "/" + srcname) - if bb.data.inherits_class('package_deb', d): - if arch == 'all': - srcname = bb.data.expand(pkgname + "_${PV}-${PR}_all.deb", d) - else: - srcname = bb.data.expand(pkgname + "_${PV}-${PR}_${DPKG_ARCH}.deb", d) - srcfile = bb.data.expand("${DEPLOY_DIR_DEB}/" + arch + "/" + srcname, d) - if not os.path.exists(srcfile): - bb.fatal("Package %s does not exist yet it should" % srcfile) - bb.copyfile(srcfile, debpath + "/" + srcname) - bb.build.exec_func("staging_helper", d) - lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) - bb.build.exec_func("staging_packager", d) - bb.utils.unlockfile(lf) -} - -addtask package_stage after do_package_write_ipk do_package_write_deb do_package_write do_populate_staging before do_build - |