diff options
Diffstat (limited to 'classes/package_ipk.bbclass')
-rw-r--r-- | classes/package_ipk.bbclass | 96 |
1 files changed, 84 insertions, 12 deletions
diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass index 9200055495..0b7f274a96 100644 --- a/classes/package_ipk.bbclass +++ b/classes/package_ipk.bbclass @@ -1,11 +1,11 @@ inherit package -PACKAGE_EXTRA_DEPENDS += "ipkg-utils-native fakeroot-native" - 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 +53,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 +62,59 @@ 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 + 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 + 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} + fi + if [ -e ${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk/Packages ] ; then + echo "src oe-${BUILD_ARCH}-$arch-sdk file:${DEPLOY_DIR_IPK}/${BUILD_ARCH}-$arch-sdk" >> ${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 +145,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 +194,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 +215,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): @@ -231,8 +292,6 @@ python do_package_ipk () { if ret != 0: raise bb.build.FuncFailed("ipkg-build execution failed") - file(bb.data.expand('${STAGING_DIR}/pkgdata/runtime/%s.packaged' % pkg, d), 'w').close() - for script in ["preinst", "postinst", "prerm", "postrm", "control" ]: scriptfile = os.path.join(controldir, script) try: @@ -243,5 +302,18 @@ python do_package_ipk () { 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_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}" +addtask package_write_ipk before do_package_write after do_package |