From a932aef56158bdb5922df3d4c3cfd8564759a920 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 1 Sep 2007 23:01:27 +0000 Subject: package_ipk.bbclass: Sync with poky for locking, code to add package_write_ipk task (not activated yet), change OE: field to use PN (not P), cleanups and conf and index generation functions --- classes/package_ipk.bbclass | 84 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 6 deletions(-) (limited to 'classes') diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass index b7d378b20c..8f963b4dd5 100644 --- a/classes/package_ipk.bbclass +++ b/classes/package_ipk.bbclass @@ -6,6 +6,9 @@ BOOTSTRAP_EXTRA_RDEPENDS += "ipkg-collateral ipkg" PACKAGE_WRITE_FUNCS += "do_package_ipk" IMAGE_PKGTYPE ?= "ipk" +IPKGCONF_TARGET = "${STAGING_ETCDIR_NATIVE}/ipkg.conf" +IPKGCONF_SDK = "${STAGING_ETCDIR_NATIVE}/ipkg-sdk.conf" + python package_ipk_fn () { from bb import data bb.data.setVar('PKGFN', bb.data.getVar('PKG',d), d) @@ -53,7 +56,7 @@ python package_ipk_install () { ret = os.system('ipkg-make-index -p %s %s ' % (os.path.join(ipkdir, "Packages"), ipkdir)) if (ret != 0 ): raise bb.build.FuncFailed - f=open(os.path.join(tmpdir, "stamps" ,"do_packages"),"w") + f=open(os.path.join(tmpdir, "stamps", "do_packages"),"w") f.close() ret = os.system('ipkg-cl -o %s -f %s update' % (rootfs, conffile)) @@ -62,10 +65,53 @@ python package_ipk_install () { raise bb.build.FuncFailed } +# +# Update the Packages index files in ${DEPLOY_DIR_IPK} +# +package_update_index_ipk () { + set -x + + ipkgarchs="${PACKAGE_ARCHS}" + + if [ ! -z "${DEPLOY_KEEP_PACKAGES}" ]; then + return + fi + + touch ${DEPLOY_DIR_IPK}/Packages + ipkg-make-index -r ${DEPLOY_DIR_IPK}/Packages -p ${DEPLOY_DIR_IPK}/Packages -l ${DEPLOY_DIR_IPK}/Packages.filelist -m ${DEPLOY_DIR_IPK} + + for arch in $ipkgarchs; do + if [ -e ${DEPLOY_DIR_IPK}/$arch/ ] ; then + touch ${DEPLOY_DIR_IPK}/$arch/Packages + ipkg-make-index -r ${DEPLOY_DIR_IPK}/$arch/Packages -p ${DEPLOY_DIR_IPK}/$arch/Packages -l ${DEPLOY_DIR_IPK}/$arch/Packages.filelist -m ${DEPLOY_DIR_IPK}/$arch/ + fi + done +} + +# +# Generate an ipkg conf file ${IPKGCONF_TARGET} suitable for use against +# the target system and an ipkg conf file ${IPKGCONF_SDK} suitable for +# use against the host system in sdk builds +# +package_generate_ipkg_conf () { + mkdir -p ${STAGING_ETCDIR_NATIVE}/ + echo "src oe file:${DEPLOY_DIR_IPK}" > ${IPKGCONF_TARGET} + echo "src oe file:${DEPLOY_DIR_IPK}" > ${IPKGCONF_SDK} + ipkgarchs="${PACKAGE_ARCHS}" + priority=1 + for arch in $ipkgarchs; do + echo "arch $arch $priority" >> ${IPKGCONF_TARGET} + echo "arch ${BUILD_ARCH}-$arch-sdk $priority" >> ${IPKGCONF_SDK} + priority=$(expr $priority + 5) + if [ -e ${DEPLOY_DIR_IPK}/$arch/Packages ] ; then + echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${IPKGCONF_TARGET} + echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${IPKGCONF_SDK} + fi + done +} + python do_package_ipk () { - import copy # to back up env data - import sys - import re + import sys, re, fcntl, copy workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: @@ -96,16 +142,27 @@ python do_package_ipk () { tmpdir = bb.data.getVar('TMPDIR', d, 1) # Invalidate the packages file if os.access(os.path.join(tmpdir, "stamps", "do_packages"),os.R_OK): - os.unlink(os.path.join(tmpdir, "stamps" ,"do_packages")) + os.unlink(os.path.join(tmpdir, "stamps", "do_packages")) if packages == []: bb.debug(1, "No packages; nothing to do") return + def lockfile(name): + lf = open(name, "a+") + fcntl.flock(lf.fileno(), fcntl.LOCK_EX) + return lf + + def unlockfile(lf): + fcntl.flock(lf.fileno(), fcntl.LOCK_UN) + lf.close + for pkg in packages.split(): localdata = bb.data.createCopy(d) root = "%s/install/%s" % (workdir, pkg) + lf = lockfile(root + ".lock") + bb.data.setVar('ROOT', '', localdata) bb.data.setVar('ROOT_%s' % pkg, root, localdata) pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) @@ -134,6 +191,7 @@ python do_package_ipk () { if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1": from bb import note note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) + unlockfile(lf) continue controldir = os.path.join(root, 'CONTROL') @@ -154,7 +212,7 @@ python do_package_ipk () { fields.append(["Priority: %s\n", ['PRIORITY']]) fields.append(["Maintainer: %s\n", ['MAINTAINER']]) fields.append(["Architecture: %s\n", ['PACKAGE_ARCH']]) - fields.append(["OE: %s\n", ['P']]) + fields.append(["OE: %s\n", ['PN']]) fields.append(["Homepage: %s\n", ['HOMEPAGE']]) def pullData(l, d): @@ -241,4 +299,18 @@ python do_package_ipk () { os.rmdir(controldir) except OSError: pass + unlockfile(lf) } + +python () { + import bb + if bb.data.getVar('PACKAGES', d, True) != '': + bb.data.setVarFlag('do_package_write_ipk', 'depends', 'ipkg-utils-native:do_populate_staging fakeroot-native:do_populate_staging', d) +} + +python do_package_write_ipk () { + bb.build.exec_func("read_subpackage_metadata", d) + bb.build.exec_func("do_package_ipk", d) +} +do_package_write_ipk[dirs] = "${D}" + -- cgit v1.2.3 From 1ca50dd988f1cadd4984be6cc3db48e8c9a35b16 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 1 Sep 2007 23:02:56 +0000 Subject: rootfs_ipk.bbclass: Convert to use package_ipk function --- classes/rootfs_ipk.bbclass | 39 ++++----------------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) (limited to 'classes') diff --git a/classes/rootfs_ipk.bbclass b/classes/rootfs_ipk.bbclass index e445c0dd07..8154318311 100644 --- a/classes/rootfs_ipk.bbclass +++ b/classes/rootfs_ipk.bbclass @@ -8,50 +8,19 @@ do_rootfs[depends] += "ipkg-native:do_populate_staging ipkg-utils-native:do_populate_staging" do_rootfs[recrdeptask] += "do_package_write" -IPKG_ARGS = "-f ${T}/ipkg.conf -o ${IMAGE_ROOTFS} ${@base_conditional("PACKAGE_INSTALL_NO_DEPS", "1", "-nodeps", "", d)}" +IPKG_ARGS = "-f ${IPKGCONF_TARGET} -o ${IMAGE_ROOTFS} ${@base_conditional("PACKAGE_INSTALL_NO_DEPS", "1", "-nodeps", "", d)}" DISTRO_EXTRA_RDEPENDS += " ipkg ipkg-collateral " PACKAGE_INSTALL_NO_DEPS ?= "0" -rootfs_ipk_do_indexes () { - set -x - - ipkgarchs="${PACKAGE_ARCHS}" - - if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then - touch ${DEPLOY_DIR_IPK}/Packages - ipkg-make-index -r ${DEPLOY_DIR_IPK}/Packages -p ${DEPLOY_DIR_IPK}/Packages -l ${DEPLOY_DIR_IPK}/Packages.filelist -m ${DEPLOY_DIR_IPK} - fi - - for arch in $ipkgarchs; do - if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then - if [ -e ${DEPLOY_DIR_IPK}/$arch/ ] ; then - touch ${DEPLOY_DIR_IPK}/$arch/Packages - ipkg-make-index -r ${DEPLOY_DIR_IPK}/$arch/Packages -p ${DEPLOY_DIR_IPK}/$arch/Packages -l ${DEPLOY_DIR_IPK}/$arch/Packages.filelist -m ${DEPLOY_DIR_IPK}/$arch/ - fi - fi - done -} - fakeroot rootfs_ipk_do_rootfs () { set -x - rootfs_ipk_do_indexes + package_update_index_ipk + package_generate_ipkg_conf mkdir -p ${T} - #Add deploy/ipk as well for backward compat - echo "src oe file:${DEPLOY_DIR_IPK}" > ${T}/ipkg.conf - ipkgarchs="${PACKAGE_ARCHS}" - - priority=1 - for arch in $ipkgarchs; do - echo "arch $arch $priority" >> ${T}/ipkg.conf - priority=$(expr $priority + 5) - if [ -e ${DEPLOY_DIR_IPK}/$arch/Packages ] ; then - echo "src oe-$arch file:${DEPLOY_DIR_IPK}/$arch" >> ${T}/ipkg.conf - fi - done ipkg-cl ${IPKG_ARGS} update # Uclibc builds don't provide this stuff... @@ -71,7 +40,7 @@ fakeroot rootfs_ipk_do_rootfs () { export OFFLINE_ROOT=${IMAGE_ROOTFS} export IPKG_OFFLINE_ROOT=${IMAGE_ROOTFS} mkdir -p ${IMAGE_ROOTFS}/etc/ipkg/ - grep "^arch" ${T}/ipkg.conf >${IMAGE_ROOTFS}/etc/ipkg/arch.conf + grep "^arch" ${IPKGCONF_TARGET} >${IMAGE_ROOTFS}/etc/ipkg/arch.conf for i in ${IMAGE_ROOTFS}${libdir}/ipkg/info/*.preinst; do if [ -f $i ] && ! sh $i; then -- cgit v1.2.3 From 6d53edfbc3cc84c6ebf88de33fc4fa462ccce825 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 1 Sep 2007 23:39:49 +0000 Subject: sdk.bbclass: Remove uneeded code --- classes/sdk.bbclass | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'classes') diff --git a/classes/sdk.bbclass b/classes/sdk.bbclass index 0950e3293b..8067798000 100644 --- a/classes/sdk.bbclass +++ b/classes/sdk.bbclass @@ -24,23 +24,3 @@ FILES_${PN} = "${prefix}" FILES_${PN}-dbg += "${prefix}/bin/.debug \ ${prefix}/sbin/.debug \ " - -sdk_ipk_do_indexes () { - set -x - - ipkgarchs="${PACKAGE_ARCHS}" - - if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then - touch ${DEPLOY_DIR_IPK}/Packages - ipkg-make-index -r ${DEPLOY_DIR_IPK}/Packages -p ${DEPLOY_DIR_IPK}/Packages -l ${DEPLOY_DIR_IPK}/Packages.filelist -m ${DEPLOY_DIR_IPK} - fi - - for arch in $ipkgarchs; do - if [ -z "${DEPLOY_KEEP_PACKAGES}" ]; then - if [ -e ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/ ] ; then - touch ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages - ipkg-make-index -r ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages -p ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages -l ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages.filelist -m ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/ - fi - fi - done -} -- cgit v1.2.3 From 60ee4a5f135a084051d75dc34ac8987c31703d80 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 1 Sep 2007 23:40:47 +0000 Subject: package_x.bbclass: Sync with poky preparing for individual package writing tasks --- classes/package_deb.bbclass | 33 +++++++++++++++++++++++++++++---- classes/package_rpm.bbclass | 17 +++++++++++++++-- classes/package_tar.bbclass | 14 ++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) (limited to 'classes') diff --git a/classes/package_deb.bbclass b/classes/package_deb.bbclass index c322af1f15..94db9238c2 100644 --- a/classes/package_deb.bbclass +++ b/classes/package_deb.bbclass @@ -64,9 +64,7 @@ python do_package_deb_install () { } python do_package_deb () { - import copy # to back up env data - import sys - import re + import sys, re, fcntl, copy workdir = bb.data.getVar('WORKDIR', d, 1) if not workdir: @@ -99,10 +97,21 @@ python do_package_deb () { bb.debug(1, "No packages; nothing to do") return + def lockfile(name): + lf = open(name, "a+") + fcntl.flock(lf.fileno(), fcntl.LOCK_EX) + return lf + + def unlockfile(lf): + fcntl.flock(lf.fileno(), fcntl.LOCK_UN) + lf.close + for pkg in packages.split(): localdata = bb.data.createCopy(d) root = "%s/install/%s" % (workdir, pkg) + lf = lockfile(root + ".lock") + bb.data.setVar('ROOT', '', localdata) bb.data.setVar('ROOT_%s' % pkg, root, localdata) pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) @@ -133,6 +142,7 @@ python do_package_deb () { if not g and bb.data.getVar('ALLOW_EMPTY', localdata) != "1": from bb import note note("Not creating empty archive for %s-%s-%s" % (pkg, bb.data.getVar('PV', localdata, 1), bb.data.getVar('PR', localdata, 1))) + unlockfile(lf) continue controldir = os.path.join(root, 'DEBIAN') bb.mkdirhier(controldir) @@ -246,5 +256,20 @@ python do_package_deb () { os.rmdir(controldir) except OSError: pass - del localdata + + unlockfile(lf) } + +python () { + import bb + if bb.data.getVar('PACKAGES', d, True) != '': + bb.data.setVarFlag('do_package_write_deb', 'depends', 'dpkg-native:do_populate_staging fakeroot-native:do_populate_staging', d) +} + +python do_package_write_deb () { + bb.build.exec_func("read_subpackage_metadata", d) + bb.build.exec_func("do_package_deb", d) +} +do_package_write_deb[dirs] = "${D}" +#addtask package_write_deb before do_package_write after do_package + diff --git a/classes/package_rpm.bbclass b/classes/package_rpm.bbclass index 4955792916..bd4a0c2798 100644 --- a/classes/package_rpm.bbclass +++ b/classes/package_rpm.bbclass @@ -54,7 +54,6 @@ python write_specfile() { except OSError: raise bb.build.FuncFailed("unable to open spec file for writing.") -# fd = sys.__stdout__ fd = specfile for var in out_vartranslate.keys(): if out_vartranslate[var][0] == "%": @@ -123,7 +122,7 @@ python do_package_rpm () { bb.data.setVar('OVERRIDES', '%s:%s' % (overrides, pkg), localdata) bb.data.update_data(localdata) -# stuff + root = bb.data.getVar('ROOT', localdata) basedir = os.path.dirname(root) pkgoutdir = outdir @@ -132,3 +131,17 @@ python do_package_rpm () { bb.build.exec_func('write_specfile', localdata) del localdata } + +python () { + import bb + if bb.data.getVar('PACKAGES', d, True) != '': + bb.data.setVarFlag('do_package_write_rpm', 'depends', 'rpm-native:do_populate_staging', d) +} + + +python do_package_write_rpm () { + bb.build.exec_func("read_subpackage_metadata", d) + bb.build.exec_func("do_package_rpm", d) +} +do_package_write_rpm[dirs] = "${D}" +#addtask package_write_rpm before do_build after do_package diff --git a/classes/package_tar.bbclass b/classes/package_tar.bbclass index ced7400ac8..a56f2e2b00 100644 --- a/classes/package_tar.bbclass +++ b/classes/package_tar.bbclass @@ -98,3 +98,17 @@ python do_package_tar () { if ret != 0: bb.error("Creation of tar %s failed." % tarfn) } + +python () { + import bb + if bb.data.getVar('PACKAGES', d, True) != '': + bb.data.setVarFlag('do_package_write_tar', 'depends', 'tar-native:do_populate_staging', d) +} + + +python do_package_write_tar () { + bb.build.exec_func("read_subpackage_metadata", d) + bb.build.exec_func("do_package_tar", d) +} +do_package_write_tar[dirs] = "${D}" +#addtask package_write_tar before do_build after do_package -- cgit v1.2.3