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