blob: f9e2292debfa3c3c1d7bc27c2f354c4e8a6f4a05 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit package
2
3IMAGE_PKGTYPE ?= "tar"
4
5python do_package_tar () {
6 import subprocess
7 workdir = d.getVar('WORKDIR', True)
8 if not workdir:
9 bb.error("WORKDIR not defined, unable to package")
10 return
11
12 outdir = d.getVar('DEPLOY_DIR_TAR', True)
13 if not outdir:
14 bb.error("DEPLOY_DIR_TAR not defined, unable to package")
15 return
16
17 dvar = d.getVar('D', True)
18 if not dvar:
19 bb.error("D not defined, unable to package")
20 return
21
22 packages = d.getVar('PACKAGES', True)
23 if not packages:
24 bb.debug(1, "PACKAGES not defined, nothing to package")
25 return
26
27 pkgdest = d.getVar('PKGDEST', True)
28
29 bb.utils.mkdirhier(outdir)
30 bb.utils.mkdirhier(dvar)
31
32 for pkg in packages.split():
33 localdata = bb.data.createCopy(d)
34 root = "%s/%s" % (pkgdest, pkg)
35
36 overrides = localdata.getVar('OVERRIDES', False)
37 localdata.setVar('OVERRIDES', '%s:%s' % (overrides, pkg))
38 bb.data.update_data(localdata)
39
40 bb.utils.mkdirhier(root)
41 basedir = os.path.dirname(root)
42 tarfn = localdata.expand("${DEPLOY_DIR_TAR}/${PKG}-${PKGV}-${PKGR}.tar.gz")
43 os.chdir(root)
44 dlist = os.listdir(root)
45 if not dlist:
46 bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV', True), localdata.getVar('PKGR', True)))
47 continue
48 args = "tar -cz --exclude=CONTROL --exclude=DEBIAN -f".split()
49 ret = subprocess.call(args + [tarfn] + dlist)
50 if ret != 0:
51 bb.error("Creation of tar %s failed." % tarfn)
52}
53
54python () {
55 if d.getVar('PACKAGES', True) != '':
56 deps = (d.getVarFlag('do_package_write_tar', 'depends') or "").split()
57 deps.append('tar-native:do_populate_sysroot')
58 deps.append('virtual/fakeroot-native:do_populate_sysroot')
59 d.setVarFlag('do_package_write_tar', 'depends', " ".join(deps))
60 d.setVarFlag('do_package_write_tar', 'fakeroot', "1")
61}
62
63
64python do_package_write_tar () {
65 bb.build.exec_func("read_subpackage_metadata", d)
66 bb.build.exec_func("do_package_tar", d)
67}
68do_package_write_tar[dirs] = "${D}"
69addtask package_write_tar before do_build after do_packagedata do_package