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 |
Patrick Williams | 5877637 | 2022-04-13 09:07:35 -0500 | [diff] [blame] | 185 | # Also, "=" specifiers only work if they have the PR in, so 1.2.3 != 1.2.3-r0 |
| 186 | # so to avoid issues, map this to ">= 1.2.3 << 1.2.3.0" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 187 | for dep in list(var.keys()): |
| 188 | if '(' in dep or '/' in dep: |
| 189 | newdep = re.sub(r'[(:)/]', '__', dep) |
| 190 | if newdep.startswith("__"): |
| 191 | newdep = "A" + newdep |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 192 | if newdep != dep: |
| 193 | var[newdep] = var[dep] |
| 194 | del var[dep] |
| 195 | for dep in var: |
| 196 | for i, v in enumerate(var[dep]): |
| 197 | if (v or "").startswith("< "): |
| 198 | var[dep][i] = var[dep][i].replace("< ", "<< ") |
| 199 | elif (v or "").startswith("> "): |
| 200 | var[dep][i] = var[dep][i].replace("> ", ">> ") |
Patrick Williams | 5877637 | 2022-04-13 09:07:35 -0500 | [diff] [blame] | 201 | elif (v or "").startswith("= ") and "-r" not in v: |
| 202 | ver = var[dep][i].replace("= ", "") |
| 203 | var[dep][i] = var[dep][i].replace("= ", ">= ") |
| 204 | var[dep].append("<< " + ver + ".0") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 205 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 206 | rdepends = bb.utils.explode_dep_versions2(localdata.getVar("RDEPENDS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 207 | debian_cmp_remap(rdepends) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 208 | for dep in list(rdepends.keys()): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 209 | if dep == pkg: |
| 210 | del rdepends[dep] |
| 211 | continue |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 212 | if '*' in dep: |
| 213 | del rdepends[dep] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 214 | rrecommends = bb.utils.explode_dep_versions2(localdata.getVar("RRECOMMENDS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | debian_cmp_remap(rrecommends) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 216 | for dep in list(rrecommends.keys()): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 217 | if '*' in dep: |
| 218 | del rrecommends[dep] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 219 | rsuggests = bb.utils.explode_dep_versions2(localdata.getVar("RSUGGESTS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | debian_cmp_remap(rsuggests) |
| 221 | # Deliberately drop version information here, not wanted/supported by deb |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 222 | rprovides = dict.fromkeys(bb.utils.explode_dep_versions2(localdata.getVar("RPROVIDES") or ""), []) |
| 223 | # Remove file paths if any from rprovides, debian does not support custom providers |
| 224 | for key in list(rprovides.keys()): |
| 225 | if key.startswith('/'): |
| 226 | del rprovides[key] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 227 | rprovides = collections.OrderedDict(sorted(rprovides.items(), key=lambda x: x[0])) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | debian_cmp_remap(rprovides) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 229 | rreplaces = bb.utils.explode_dep_versions2(localdata.getVar("RREPLACES") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 230 | debian_cmp_remap(rreplaces) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 231 | rconflicts = bb.utils.explode_dep_versions2(localdata.getVar("RCONFLICTS") or "") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 232 | debian_cmp_remap(rconflicts) |
| 233 | if rdepends: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 234 | ctrlfile.write("Depends: %s\n" % bb.utils.join_deps(rdepends)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 235 | if rsuggests: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 236 | ctrlfile.write("Suggests: %s\n" % bb.utils.join_deps(rsuggests)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | if rrecommends: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 238 | ctrlfile.write("Recommends: %s\n" % bb.utils.join_deps(rrecommends)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 239 | if rprovides: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 240 | ctrlfile.write("Provides: %s\n" % bb.utils.join_deps(rprovides)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | if rreplaces: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 242 | ctrlfile.write("Replaces: %s\n" % bb.utils.join_deps(rreplaces)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 243 | if rconflicts: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 244 | ctrlfile.write("Conflicts: %s\n" % bb.utils.join_deps(rconflicts)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 245 | ctrlfile.close() |
| 246 | |
| 247 | for script in ["preinst", "postinst", "prerm", "postrm"]: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 248 | scriptvar = localdata.getVar('pkg_%s' % script) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 249 | if not scriptvar: |
| 250 | continue |
| 251 | scriptvar = scriptvar.strip() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 252 | scriptfile = open(os.path.join(controldir, script), 'w') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 253 | |
| 254 | if scriptvar.startswith("#!"): |
| 255 | pos = scriptvar.find("\n") + 1 |
| 256 | scriptfile.write(scriptvar[:pos]) |
| 257 | else: |
| 258 | pos = 0 |
| 259 | scriptfile.write("#!/bin/sh\n") |
| 260 | |
| 261 | # Prevent the prerm/postrm scripts from being run during an upgrade |
| 262 | if script in ('prerm', 'postrm'): |
| 263 | scriptfile.write('[ "$1" != "upgrade" ] || exit 0\n') |
| 264 | |
| 265 | scriptfile.write(scriptvar[pos:]) |
| 266 | scriptfile.write('\n') |
| 267 | scriptfile.close() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 268 | os.chmod(os.path.join(controldir, script), 0o755) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 269 | |
| 270 | conffiles_str = ' '.join(get_conffiles(pkg, d)) |
| 271 | if conffiles_str: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 272 | conffiles = open(os.path.join(controldir, 'conffiles'), 'w') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 273 | for f in conffiles_str.split(): |
| 274 | if os.path.exists(oe.path.join(root, f)): |
| 275 | conffiles.write('%s\n' % f) |
| 276 | conffiles.close() |
| 277 | |
| 278 | os.chdir(basedir) |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 279 | subprocess.check_output("PATH=\"%s\" %s -b %s %s" % (localdata.getVar("PATH"), localdata.getVar("DPKG_BUILDCMD"), |
| 280 | root, pkgoutdir), |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 281 | stderr=subprocess.STDOUT, |
| 282 | shell=True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 283 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 284 | finally: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 285 | cleanupcontrol(root) |
| 286 | bb.utils.unlockfile(lf) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 287 | |
| 288 | # Otherwise allarch packages may change depending on override configuration |
| 289 | deb_write_pkg[vardepsexclude] = "OVERRIDES" |
| 290 | |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 291 | # Have to list any variables referenced as X_<pkg> that aren't in pkgdata here |
| 292 | DEBEXTRAVARS = "PKGV PKGR PKGV DESCRIPTION SECTION PRIORITY MAINTAINER DPKG_ARCH PN HOMEPAGE PACKAGE_ADD_METADATA_DEB" |
| 293 | do_package_write_deb[vardeps] += "${@gen_packagevar(d, 'DEBEXTRAVARS')}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 294 | |
| 295 | SSTATETASKS += "do_package_write_deb" |
| 296 | do_package_write_deb[sstate-inputdirs] = "${PKGWRITEDIRDEB}" |
| 297 | do_package_write_deb[sstate-outputdirs] = "${DEPLOY_DIR_DEB}" |
| 298 | |
| 299 | python do_package_write_deb_setscene () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 300 | tmpdir = d.getVar('TMPDIR') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 301 | |
| 302 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): |
| 303 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) |
| 304 | |
| 305 | sstate_setscene(d) |
| 306 | } |
| 307 | addtask do_package_write_deb_setscene |
| 308 | |
| 309 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 310 | if d.getVar('PACKAGES') != '': |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 311 | deps = ' dpkg-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot' |
| 312 | d.appendVarFlag('do_package_write_deb', 'depends', deps) |
| 313 | d.setVarFlag('do_package_write_deb', 'fakeroot', "1") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | python do_package_write_deb () { |
| 317 | bb.build.exec_func("read_subpackage_metadata", d) |
| 318 | bb.build.exec_func("do_package_deb", d) |
| 319 | } |
| 320 | do_package_write_deb[dirs] = "${PKGWRITEDIRDEB}" |
| 321 | do_package_write_deb[cleandirs] = "${PKGWRITEDIRDEB}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 322 | 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] | 323 | addtask package_write_deb after do_packagedata do_package do_deploy_source_date_epoch before do_build |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 324 | do_build[rdeptask] += "do_package_write_deb" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 325 | |
| 326 | PACKAGEINDEXDEPS += "dpkg-native:do_populate_sysroot" |
| 327 | PACKAGEINDEXDEPS += "apt-native:do_populate_sysroot" |