inherit package python package_tar_fn () { import os from oe import data fn = os.path.join(oe.data.getVar('DEPLOY_DIR_TAR', d), "%s-%s-%s.tar.gz" % (oe.data.getVar('PKG', d), oe.data.getVar('PV', d), oe.data.getVar('PR', d))) fn = oe.data.expand(fn, d) oe.data.setVar('PKGFN', fn, d) } python package_tar_install () { import os, sys pkg = oe.data.getVar('PKG', d, 1) pkgfn = oe.data.getVar('PKGFN', d, 1) rootfs = oe.data.getVar('IMAGE_ROOTFS', d, 1) if None in (pkg,pkgfn,rootfs): oe.error("missing variables (one or more of PKG, PKGFN, IMAGEROOTFS)") raise oe.build.FuncFailed try: oe.mkdirhier(rootfs) os.chdir(rootfs) except OSError: (type, value, traceback) = sys.exc_info() print value raise oe.build.FuncFailed if not os.access(pkgfn, os.R_OK): oe.debug(1, "%s does not exist, skipping" % pkgfn) raise oe.build.FuncFailed ret = os.system('zcat %s | tar -xf -' % pkgfn) if ret != 0: raise oe.build.FuncFailed } python do_package_tar () { workdir = oe.data.getVar('WORKDIR', d, 1) if not workdir: oe.error("WORKDIR not defined, unable to package") return import os # path manipulations outdir = oe.data.getVar('DEPLOY_DIR_TAR', d, 1) if not outdir: oe.error("DEPLOY_DIR_TAR not defined, unable to package") return oe.mkdirhier(outdir) dvar = oe.data.getVar('D', d, 1) if not dvar: oe.error("D not defined, unable to package") return oe.mkdirhier(dvar) packages = oe.data.getVar('PACKAGES', d, 1) if not packages: oe.debug(1, "PACKAGES not defined, nothing to package") return for pkg in packages.split(): from copy import copy, deepcopy localdata = deepcopy(d) root = "%s/install/%s" % (workdir, pkg) oe.data.setVar('ROOT', '', localdata) oe.data.setVar('ROOT_%s' % pkg, root, localdata) oe.data.setVar('PKG', pkg, localdata) overrides = oe.data.getVar('OVERRIDES', localdata) if not overrides: raise oe.build.FuncFailed('OVERRIDES not defined') overrides = oe.data.expand(overrides, localdata) oe.data.setVar('OVERRIDES', '%s:%s' % (overrides, pkg), localdata) oe.data.update_data(localdata) # stuff root = oe.data.getVar('ROOT', localdata) oe.mkdirhier(root) basedir = os.path.dirname(root) pkgoutdir = outdir oe.mkdirhier(pkgoutdir) oe.build.exec_func('package_tar_fn', localdata) tarfn = oe.data.getVar('PKGFN', localdata, 1) # if os.path.exists(tarfn): # del localdata # continue os.chdir(root) from glob import glob if not glob('*'): oe.note("Not creating empty archive for %s-%s-%s" % (pkg, oe.data.getVar('PV', localdata, 1), oe.data.getVar('PR', localdata, 1))) continue ret = os.system("tar -czvf %s %s" % (tarfn, '.')) if ret != 0: oe.error("Creation of tar %s failed." % tarfn) # end stuff del localdata } addtask package_tar after do_package before do_build