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