Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2006-2008 OpenedHand Ltd. |
| 3 | # |
| 4 | |
| 5 | inherit package |
| 6 | |
| 7 | IMAGE_PKGTYPE ?= "deb" |
| 8 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 9 | DPKG_ARCH ?= "${@debian_arch_map(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'))}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10 | DPKG_ARCH[vardepvalue] = "${DPKG_ARCH}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 11 | |
| 12 | PKGWRITEDIRDEB = "${WORKDIR}/deploy-debs" |
| 13 | |
| 14 | APTCONF_TARGET = "${WORKDIR}" |
| 15 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 16 | APT_ARGS = "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS") == "1"]}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 18 | def debian_arch_map(arch, tune): |
| 19 | tune_features = tune.split() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 20 | if arch == "allarch": |
| 21 | return "all" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 22 | if arch in ["i586", "i686"]: |
| 23 | return "i386" |
| 24 | if arch == "x86_64": |
| 25 | if "mx32" in tune_features: |
| 26 | return "x32" |
| 27 | return "amd64" |
| 28 | if arch.startswith("mips"): |
| 29 | endian = ["el", ""]["bigendian" in tune_features] |
| 30 | if "n64" in tune_features: |
| 31 | return "mips64" + endian |
| 32 | if "n32" in tune_features: |
| 33 | return "mipsn32" + endian |
| 34 | return "mips" + endian |
| 35 | if arch == "powerpc": |
| 36 | return arch + ["", "spe"]["spe" in tune_features] |
| 37 | if arch == "aarch64": |
| 38 | return "arm64" |
| 39 | if arch == "arm": |
| 40 | return arch + ["el", "hf"]["callconvention-hard" in tune_features] |
| 41 | return arch |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | # |
| 43 | # install a bunch of packages using apt |
| 44 | # the following shell variables needs to be set before calling this func: |
| 45 | # INSTALL_ROOTFS_DEB - install root dir |
| 46 | # INSTALL_BASEARCH_DEB - install base architecutre |
| 47 | # INSTALL_ARCHS_DEB - list of available archs |
| 48 | # INSTALL_PACKAGES_NORMAL_DEB - packages to be installed |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 49 | # INSTALL_PACKAGES_ATTEMPTONLY_DEB - packages attempted to be installed only |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | # INSTALL_PACKAGES_LINGUAS_DEB - additional packages for uclibc |
| 51 | # INSTALL_TASK_DEB - task name |
| 52 | |
| 53 | python do_package_deb () { |
| 54 | import re, copy |
| 55 | import textwrap |
| 56 | import subprocess |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 57 | import collections |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 58 | import codecs |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 59 | |
| 60 | oldcwd = os.getcwd() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 62 | workdir = d.getVar('WORKDIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | if not workdir: |
| 64 | bb.error("WORKDIR not defined, unable to package") |
| 65 | return |
| 66 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 67 | outdir = d.getVar('PKGWRITEDIRDEB') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 68 | if not outdir: |
| 69 | bb.error("PKGWRITEDIRDEB not defined, unable to package") |
| 70 | return |
| 71 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 72 | packages = d.getVar('PACKAGES') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | if not packages: |
| 74 | bb.debug(1, "PACKAGES not defined, nothing to package") |
| 75 | return |
| 76 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 77 | tmpdir = d.getVar('TMPDIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 78 | |
| 79 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): |
| 80 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) |
| 81 | |
| 82 | if packages == []: |
| 83 | bb.debug(1, "No packages; nothing to do") |
| 84 | return |
| 85 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 86 | pkgdest = d.getVar('PKGDEST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 87 | |
| 88 | def cleanupcontrol(root): |
| 89 | for p in ['CONTROL', 'DEBIAN']: |
| 90 | p = os.path.join(root, p) |
| 91 | if os.path.exists(p): |
| 92 | bb.utils.prunedir(p) |
| 93 | |
| 94 | for pkg in packages.split(): |
| 95 | localdata = bb.data.createCopy(d) |
| 96 | root = "%s/%s" % (pkgdest, pkg) |
| 97 | |
| 98 | lf = bb.utils.lockfile(root + ".lock") |
| 99 | |
| 100 | localdata.setVar('ROOT', '') |
| 101 | localdata.setVar('ROOT_%s' % pkg, root) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 102 | pkgname = localdata.getVar('PKG_%s' % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | if not pkgname: |
| 104 | pkgname = pkg |
| 105 | localdata.setVar('PKG', pkgname) |
| 106 | |
| 107 | localdata.setVar('OVERRIDES', d.getVar("OVERRIDES", False) + ":" + pkg) |
| 108 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | basedir = os.path.join(os.path.dirname(root)) |
| 110 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 111 | pkgoutdir = os.path.join(outdir, localdata.getVar('PACKAGE_ARCH')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 | bb.utils.mkdirhier(pkgoutdir) |
| 113 | |
| 114 | os.chdir(root) |
| 115 | cleanupcontrol(root) |
| 116 | from glob import glob |
| 117 | g = glob('*') |
| 118 | if not g and localdata.getVar('ALLOW_EMPTY', False) != "1": |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 119 | bb.note("Not creating empty archive for %s-%s-%s" % (pkg, localdata.getVar('PKGV'), localdata.getVar('PKGR'))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | bb.utils.unlockfile(lf) |
| 121 | continue |
| 122 | |
| 123 | controldir = os.path.join(root, 'DEBIAN') |
| 124 | bb.utils.mkdirhier(controldir) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 125 | os.chmod(controldir, 0o755) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 126 | |
| 127 | ctrlfile = codecs.open(os.path.join(controldir, 'control'), 'w', 'utf-8') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 128 | |
| 129 | fields = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 130 | pe = d.getVar('PKGE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 131 | if pe and int(pe) > 0: |
| 132 | fields.append(["Version: %s:%s-%s\n", ['PKGE', 'PKGV', 'PKGR']]) |
| 133 | else: |
| 134 | fields.append(["Version: %s-%s\n", ['PKGV', 'PKGR']]) |
| 135 | fields.append(["Description: %s\n", ['DESCRIPTION']]) |
| 136 | fields.append(["Section: %s\n", ['SECTION']]) |
| 137 | fields.append(["Priority: %s\n", ['PRIORITY']]) |
| 138 | fields.append(["Maintainer: %s\n", ['MAINTAINER']]) |
| 139 | fields.append(["Architecture: %s\n", ['DPKG_ARCH']]) |
| 140 | fields.append(["OE: %s\n", ['PN']]) |
| 141 | fields.append(["PackageArch: %s\n", ['PACKAGE_ARCH']]) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 142 | if d.getVar('HOMEPAGE'): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 143 | fields.append(["Homepage: %s\n", ['HOMEPAGE']]) |
| 144 | |
| 145 | # Package, Version, Maintainer, Description - mandatory |
| 146 | # Section, Priority, Essential, Architecture, Source, Depends, Pre-Depends, Recommends, Suggests, Conflicts, Replaces, Provides - Optional |
| 147 | |
| 148 | |
| 149 | def pullData(l, d): |
| 150 | l2 = [] |
| 151 | for i in l: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 152 | data = d.getVar(i) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 153 | if data is None: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 154 | raise KeyError(i) |
| 155 | if i == 'DPKG_ARCH' and d.getVar('PACKAGE_ARCH') == 'all': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | data = 'all' |
| 157 | elif i == 'PACKAGE_ARCH' or i == 'DPKG_ARCH': |
| 158 | # The params in deb package control don't allow character |
| 159 | # `_', so change the arch's `_' to `-'. Such as `x86_64' |
| 160 | # -->`x86-64' |
| 161 | data = data.replace('_', '-') |
| 162 | l2.append(data) |
| 163 | return l2 |
| 164 | |
| 165 | ctrlfile.write("Package: %s\n" % pkgname) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 166 | if d.getVar('PACKAGE_ARCH') == "all": |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 167 | ctrlfile.write("Multi-Arch: foreign\n") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 168 | # check for required fields |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 169 | for (c, fs) in fields: |
| 170 | # Special behavior for description... |
| 171 | if 'DESCRIPTION' in fs: |
| 172 | summary = localdata.getVar('SUMMARY') or localdata.getVar('DESCRIPTION') or "." |
| 173 | ctrlfile.write('Description: %s\n' % summary) |
| 174 | description = localdata.getVar('DESCRIPTION') or "." |
| 175 | description = textwrap.dedent(description).strip() |
| 176 | if '\\n' in description: |
| 177 | # Manually indent |
| 178 | for t in description.split('\\n'): |
| 179 | ctrlfile.write(' %s\n' % (t.strip() or '.')) |
| 180 | else: |
| 181 | # Auto indent |
| 182 | ctrlfile.write('%s\n' % textwrap.fill(description.strip(), width=74, initial_indent=' ', subsequent_indent=' ')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 183 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 184 | else: |
| 185 | ctrlfile.write(c % tuple(pullData(fs, localdata))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 186 | |
| 187 | # more fields |
| 188 | |
| 189 | custom_fields_chunk = get_package_additional_metadata("deb", localdata) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 190 | if custom_fields_chunk: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 191 | ctrlfile.write(custom_fields_chunk) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 192 | ctrlfile.write("\n") |
| 193 | |
| 194 | mapping_rename_hook(localdata) |
| 195 | |
| 196 | def debian_cmp_remap(var): |
| 197 | # dpkg does not allow for '(' or ')' in a dependency name |
| 198 | # replace these instances with '__' and '__' |
| 199 | # |
| 200 | # In debian '>' and '<' do not mean what it appears they mean |
| 201 | # '<' = less or equal |
| 202 | # '>' = greater or equal |
| 203 | # adjust these to the '<<' and '>>' equivalents |
| 204 | # |
| 205 | for dep in var: |
| 206 | if '(' in dep: |
| 207 | newdep = dep.replace('(', '__') |
| 208 | newdep = newdep.replace(')', '__') |
| 209 | if newdep != dep: |
| 210 | var[newdep] = var[dep] |
| 211 | del var[dep] |
| 212 | for dep in var: |
| 213 | for i, v in enumerate(var[dep]): |
| 214 | if (v or "").startswith("< "): |
| 215 | var[dep][i] = var[dep][i].replace("< ", "<< ") |
| 216 | elif (v or "").startswith("> "): |
| 217 | var[dep][i] = var[dep][i].replace("> ", ">> ") |
| 218 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 219 | rdepends = bb.utils.explode_dep_versions2(localdata.getVar("RDEPENDS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | debian_cmp_remap(rdepends) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 221 | for dep in list(rdepends.keys()): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 222 | if dep == pkg: |
| 223 | del rdepends[dep] |
| 224 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 225 | if '*' in dep: |
| 226 | del rdepends[dep] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 227 | rrecommends = bb.utils.explode_dep_versions2(localdata.getVar("RRECOMMENDS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | debian_cmp_remap(rrecommends) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 229 | for dep in list(rrecommends.keys()): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 230 | if '*' in dep: |
| 231 | del rrecommends[dep] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 232 | rsuggests = bb.utils.explode_dep_versions2(localdata.getVar("RSUGGESTS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 233 | debian_cmp_remap(rsuggests) |
| 234 | # Deliberately drop version information here, not wanted/supported by deb |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 235 | rprovides = dict.fromkeys(bb.utils.explode_dep_versions2(localdata.getVar("RPROVIDES") or ""), []) |
| 236 | # Remove file paths if any from rprovides, debian does not support custom providers |
| 237 | for key in list(rprovides.keys()): |
| 238 | if key.startswith('/'): |
| 239 | del rprovides[key] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 240 | rprovides = collections.OrderedDict(sorted(rprovides.items(), key=lambda x: x[0])) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | debian_cmp_remap(rprovides) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 242 | rreplaces = bb.utils.explode_dep_versions2(localdata.getVar("RREPLACES") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 243 | debian_cmp_remap(rreplaces) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 244 | rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 245 | debian_cmp_remap(rconflicts) |
| 246 | if rdepends: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 247 | ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 248 | if rsuggests: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 249 | ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 250 | if rrecommends: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 251 | ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | if rprovides: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 253 | ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 254 | if rreplaces: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 255 | ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 256 | if rconflicts: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 257 | ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 258 | ctrlfile.close() |
| 259 | |
| 260 | for script in ["preinst", "postinst", "prerm", "postrm"]: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 261 | scriptvar = localdata.getVar('pkg_%s' % script) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 262 | if not scriptvar: |
| 263 | continue |
| 264 | scriptvar = scriptvar.strip() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 265 | scriptfile = open(os.path.join(controldir, script), 'w') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 266 | |
| 267 | if scriptvar.startswith("#!"): |
| 268 | pos = scriptvar.find("\n") + 1 |
| 269 | scriptfile.write(scriptvar[:pos]) |
| 270 | else: |
| 271 | pos = 0 |
| 272 | scriptfile.write("#!/bin/sh\n") |
| 273 | |
| 274 | # Prevent the prerm/postrm scripts from being run during an upgrade |
| 275 | if script in ('prerm', 'postrm'): |
| 276 | scriptfile.write('[ "$1" != "upgrade" ] || exit 0\n') |
| 277 | |
| 278 | scriptfile.write(scriptvar[pos:]) |
| 279 | scriptfile.write('\n') |
| 280 | scriptfile.close() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 281 | os.chmod(os.path.join(controldir, script), 0o755) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 282 | |
| 283 | conffiles_str = ' '.join(get_conffiles(pkg, d)) |
| 284 | if conffiles_str: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 285 | conffiles = open(os.path.join(controldir, 'conffiles'), 'w') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 286 | for f in conffiles_str.split(): |
| 287 | if os.path.exists(oe.path.join(root, f)): |
| 288 | conffiles.write('%s\n' % f) |
| 289 | conffiles.close() |
| 290 | |
| 291 | os.chdir(basedir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 292 | subprocess.check_output("PATH=\"%s\" dpkg-deb -b %s %s" % (localdata.getVar("PATH"), root, pkgoutdir), shell=True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 293 | |
| 294 | cleanupcontrol(root) |
| 295 | bb.utils.unlockfile(lf) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 296 | os.chdir(oldcwd) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 297 | } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 298 | # Indirect references to these vars |
| 299 | do_package_write_deb[vardeps] += "PKGV PKGR PKGV DESCRIPTION SECTION PRIORITY MAINTAINER DPKG_ARCH PN HOMEPAGE" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 300 | # Otherwise allarch packages may change depending on override configuration |
| 301 | do_package_deb[vardepsexclude] = "OVERRIDES" |
| 302 | |
| 303 | |
| 304 | SSTATETASKS += "do_package_write_deb" |
| 305 | do_package_write_deb[sstate-inputdirs] = "${PKGWRITEDIRDEB}" |
| 306 | do_package_write_deb[sstate-outputdirs] = "${DEPLOY_DIR_DEB}" |
| 307 | |
| 308 | python do_package_write_deb_setscene () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 309 | tmpdir = d.getVar('TMPDIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 310 | |
| 311 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): |
| 312 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) |
| 313 | |
| 314 | sstate_setscene(d) |
| 315 | } |
| 316 | addtask do_package_write_deb_setscene |
| 317 | |
| 318 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 319 | if d.getVar('PACKAGES') != '': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 320 | deps = ' dpkg-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot' |
| 321 | d.appendVarFlag('do_package_write_deb', 'depends', deps) |
| 322 | d.setVarFlag('do_package_write_deb', 'fakeroot', "1") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | python do_package_write_deb () { |
| 326 | bb.build.exec_func("read_subpackage_metadata", d) |
| 327 | bb.build.exec_func("do_package_deb", d) |
| 328 | } |
| 329 | do_package_write_deb[dirs] = "${PKGWRITEDIRDEB}" |
| 330 | do_package_write_deb[cleandirs] = "${PKGWRITEDIRDEB}" |
| 331 | do_package_write_deb[umask] = "022" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 332 | do_package_write_deb[depends] += "${@oe.utils.build_depends_string(d.getVar('PACKAGE_WRITE_DEPS'), 'do_populate_sysroot')}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 333 | addtask package_write_deb after do_packagedata do_package |
| 334 | |
| 335 | |
| 336 | PACKAGEINDEXDEPS += "dpkg-native:do_populate_sysroot" |
| 337 | PACKAGEINDEXDEPS += "apt-native:do_populate_sysroot" |
| 338 | |
| 339 | do_build[recrdeptask] += "do_package_write_deb" |