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