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