Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit package |
| 2 | |
| 3 | IMAGE_PKGTYPE ?= "tar" |
| 4 | |
| 5 | python do_package_tar () { |
| 6 | import subprocess |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 7 | |
| 8 | oldcwd = os.getcwd() |
| 9 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 55 | |
| 56 | os.chdir(oldcwd) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | python () { |
| 60 | if d.getVar('PACKAGES', True) != '': |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 61 | deps = (d.getVarFlag('do_package_write_tar', 'depends', True) or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 62 | 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 | |
| 69 | python do_package_write_tar () { |
| 70 | bb.build.exec_func("read_subpackage_metadata", d) |
| 71 | bb.build.exec_func("do_package_tar", d) |
| 72 | } |
| 73 | do_package_write_tar[dirs] = "${D}" |
| 74 | addtask package_write_tar before do_build after do_packagedata do_package |