diff options
Diffstat (limited to 'meta/classes/base.bbclass')
| -rw-r--r-- | meta/classes/base.bbclass | 661 |
1 files changed, 661 insertions, 0 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass new file mode 100644 index 0000000000..f4f5321ac8 --- /dev/null +++ b/meta/classes/base.bbclass | |||
| @@ -0,0 +1,661 @@ | |||
| 1 | BB_DEFAULT_TASK ?= "build" | ||
| 2 | CLASSOVERRIDE ?= "class-target" | ||
| 3 | |||
| 4 | inherit patch | ||
| 5 | inherit staging | ||
| 6 | |||
| 7 | inherit mirrors | ||
| 8 | inherit utils | ||
| 9 | inherit utility-tasks | ||
| 10 | inherit metadata_scm | ||
| 11 | inherit logging | ||
| 12 | |||
| 13 | OE_IMPORTS += "os sys time oe.path oe.utils oe.data oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath" | ||
| 14 | OE_IMPORTS[type] = "list" | ||
| 15 | |||
| 16 | def oe_import(d): | ||
| 17 | import sys | ||
| 18 | |||
| 19 | bbpath = d.getVar("BBPATH", True).split(":") | ||
| 20 | sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath] | ||
| 21 | |||
| 22 | def inject(name, value): | ||
| 23 | """Make a python object accessible from the metadata""" | ||
| 24 | if hasattr(bb.utils, "_context"): | ||
| 25 | bb.utils._context[name] = value | ||
| 26 | else: | ||
| 27 | __builtins__[name] = value | ||
| 28 | |||
| 29 | import oe.data | ||
| 30 | for toimport in oe.data.typed_value("OE_IMPORTS", d): | ||
| 31 | imported = __import__(toimport) | ||
| 32 | inject(toimport.split(".", 1)[0], imported) | ||
| 33 | |||
| 34 | return "" | ||
| 35 | |||
| 36 | # We need the oe module name space early (before INHERITs get added) | ||
| 37 | OE_IMPORTED := "${@oe_import(d)}" | ||
| 38 | |||
| 39 | def lsb_distro_identifier(d): | ||
| 40 | adjust = d.getVar('LSB_DISTRO_ADJUST', True) | ||
| 41 | adjust_func = None | ||
| 42 | if adjust: | ||
| 43 | try: | ||
| 44 | adjust_func = globals()[adjust] | ||
| 45 | except KeyError: | ||
| 46 | pass | ||
| 47 | return oe.lsb.distro_identifier(adjust_func) | ||
| 48 | |||
| 49 | die() { | ||
| 50 | bbfatal "$*" | ||
| 51 | } | ||
| 52 | |||
| 53 | oe_runmake_call() { | ||
| 54 | bbnote ${MAKE} ${EXTRA_OEMAKE} "$@" | ||
| 55 | ${MAKE} ${EXTRA_OEMAKE} "$@" | ||
| 56 | } | ||
| 57 | |||
| 58 | oe_runmake() { | ||
| 59 | oe_runmake_call "$@" || die "oe_runmake failed" | ||
| 60 | } | ||
| 61 | |||
| 62 | |||
| 63 | def base_dep_prepend(d): | ||
| 64 | # | ||
| 65 | # Ideally this will check a flag so we will operate properly in | ||
| 66 | # the case where host == build == target, for now we don't work in | ||
| 67 | # that case though. | ||
| 68 | # | ||
| 69 | |||
| 70 | deps = "" | ||
| 71 | # INHIBIT_DEFAULT_DEPS doesn't apply to the patch command. Whether or not | ||
| 72 | # we need that built is the responsibility of the patch function / class, not | ||
| 73 | # the application. | ||
| 74 | if not d.getVar('INHIBIT_DEFAULT_DEPS'): | ||
| 75 | if (d.getVar('HOST_SYS', True) != d.getVar('BUILD_SYS', True)): | ||
| 76 | deps += " virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc " | ||
| 77 | return deps | ||
| 78 | |||
| 79 | BASEDEPENDS = "${@base_dep_prepend(d)}" | ||
| 80 | |||
| 81 | DEPENDS_prepend="${BASEDEPENDS} " | ||
| 82 | |||
| 83 | FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}" | ||
| 84 | # THISDIR only works properly with imediate expansion as it has to run | ||
| 85 | # in the context of the location its used (:=) | ||
| 86 | THISDIR = "${@os.path.dirname(d.getVar('FILE', True))}" | ||
| 87 | |||
| 88 | def extra_path_elements(d): | ||
| 89 | path = "" | ||
| 90 | elements = (d.getVar('EXTRANATIVEPATH', True) or "").split() | ||
| 91 | for e in elements: | ||
| 92 | path = path + "${STAGING_BINDIR_NATIVE}/" + e + ":" | ||
| 93 | return path | ||
| 94 | |||
| 95 | PATH_prepend = "${@extra_path_elements(d)}" | ||
| 96 | |||
| 97 | addtask fetch | ||
| 98 | do_fetch[dirs] = "${DL_DIR}" | ||
| 99 | do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}" | ||
| 100 | python base_do_fetch() { | ||
| 101 | |||
| 102 | src_uri = (d.getVar('SRC_URI', True) or "").split() | ||
| 103 | if len(src_uri) == 0: | ||
| 104 | return | ||
| 105 | |||
| 106 | try: | ||
| 107 | fetcher = bb.fetch2.Fetch(src_uri, d) | ||
| 108 | fetcher.download() | ||
| 109 | except bb.fetch2.BBFetchException as e: | ||
| 110 | raise bb.build.FuncFailed(e) | ||
| 111 | } | ||
| 112 | |||
| 113 | addtask unpack after do_fetch | ||
| 114 | do_unpack[dirs] = "${WORKDIR}" | ||
| 115 | do_unpack[cleandirs] = "${S}/patches" | ||
| 116 | python base_do_unpack() { | ||
| 117 | src_uri = (d.getVar('SRC_URI', True) or "").split() | ||
| 118 | if len(src_uri) == 0: | ||
| 119 | return | ||
| 120 | |||
| 121 | rootdir = d.getVar('WORKDIR', True) | ||
| 122 | |||
| 123 | try: | ||
| 124 | fetcher = bb.fetch2.Fetch(src_uri, d) | ||
| 125 | fetcher.unpack(rootdir) | ||
| 126 | except bb.fetch2.BBFetchException as e: | ||
| 127 | raise bb.build.FuncFailed(e) | ||
| 128 | } | ||
| 129 | |||
| 130 | def pkgarch_mapping(d): | ||
| 131 | # Compatibility mappings of TUNE_PKGARCH (opt in) | ||
| 132 | if d.getVar("PKGARCHCOMPAT_ARMV7A", True): | ||
| 133 | if d.getVar("TUNE_PKGARCH", True) == "armv7a-vfp-neon": | ||
| 134 | d.setVar("TUNE_PKGARCH", "armv7a") | ||
| 135 | |||
| 136 | def preferred_ml_updates(d): | ||
| 137 | # If any PREFERRED_PROVIDER or PREFERRED_VERSION are set, | ||
| 138 | # we need to mirror these variables in the multilib case; | ||
| 139 | multilibs = d.getVar('MULTILIBS', True) or "" | ||
| 140 | if not multilibs: | ||
| 141 | return | ||
| 142 | |||
| 143 | prefixes = [] | ||
| 144 | for ext in multilibs.split(): | ||
| 145 | eext = ext.split(':') | ||
| 146 | if len(eext) > 1 and eext[0] == 'multilib': | ||
| 147 | prefixes.append(eext[1]) | ||
| 148 | |||
| 149 | versions = [] | ||
| 150 | providers = [] | ||
| 151 | for v in d.keys(): | ||
| 152 | if v.startswith("PREFERRED_VERSION_"): | ||
| 153 | versions.append(v) | ||
| 154 | if v.startswith("PREFERRED_PROVIDER_"): | ||
| 155 | providers.append(v) | ||
| 156 | |||
| 157 | for v in versions: | ||
| 158 | val = d.getVar(v, False) | ||
| 159 | pkg = v.replace("PREFERRED_VERSION_", "") | ||
| 160 | if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith(("nativesdk-", "virtual/nativesdk-")): | ||
| 161 | continue | ||
| 162 | if 'cross-canadian' in pkg: | ||
| 163 | for p in prefixes: | ||
| 164 | localdata = bb.data.createCopy(d) | ||
| 165 | override = ":virtclass-multilib-" + p | ||
| 166 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) | ||
| 167 | bb.data.update_data(localdata) | ||
| 168 | newname = localdata.expand(v) | ||
| 169 | if newname != v: | ||
| 170 | newval = localdata.expand(val) | ||
| 171 | d.setVar(newname, newval) | ||
| 172 | # Avoid future variable key expansion | ||
| 173 | vexp = d.expand(v) | ||
| 174 | if v != vexp and d.getVar(v, False): | ||
| 175 | d.renameVar(v, vexp) | ||
| 176 | continue | ||
| 177 | for p in prefixes: | ||
| 178 | newname = "PREFERRED_VERSION_" + p + "-" + pkg | ||
| 179 | if not d.getVar(newname, False): | ||
| 180 | d.setVar(newname, val) | ||
| 181 | |||
| 182 | for prov in providers: | ||
| 183 | val = d.getVar(prov, False) | ||
| 184 | pkg = prov.replace("PREFERRED_PROVIDER_", "") | ||
| 185 | if pkg.endswith(("-native", "-crosssdk")) or pkg.startswith(("nativesdk-", "virtual/nativesdk-")): | ||
| 186 | continue | ||
| 187 | if 'cross-canadian' in pkg: | ||
| 188 | for p in prefixes: | ||
| 189 | localdata = bb.data.createCopy(d) | ||
| 190 | override = ":virtclass-multilib-" + p | ||
| 191 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) | ||
| 192 | bb.data.update_data(localdata) | ||
| 193 | newname = localdata.expand(prov) | ||
| 194 | if newname != prov: | ||
| 195 | newval = localdata.expand(val) | ||
| 196 | d.setVar(newname, newval) | ||
| 197 | # Avoid future variable key expansion | ||
| 198 | provexp = d.expand(prov) | ||
| 199 | if prov != provexp and d.getVar(prov, False): | ||
| 200 | d.renameVar(prov, provexp) | ||
| 201 | continue | ||
| 202 | virt = "" | ||
| 203 | if pkg.startswith("virtual/"): | ||
| 204 | pkg = pkg.replace("virtual/", "") | ||
| 205 | virt = "virtual/" | ||
| 206 | for p in prefixes: | ||
| 207 | if pkg != "kernel": | ||
| 208 | newval = p + "-" + val | ||
| 209 | |||
| 210 | # implement variable keys | ||
| 211 | localdata = bb.data.createCopy(d) | ||
| 212 | override = ":virtclass-multilib-" + p | ||
| 213 | localdata.setVar("OVERRIDES", localdata.getVar("OVERRIDES", False) + override) | ||
| 214 | bb.data.update_data(localdata) | ||
| 215 | newname = localdata.expand(prov) | ||
| 216 | if newname != prov and not d.getVar(newname, False): | ||
| 217 | d.setVar(newname, localdata.expand(newval)) | ||
| 218 | |||
| 219 | # implement alternative multilib name | ||
| 220 | newname = localdata.expand("PREFERRED_PROVIDER_" + virt + p + "-" + pkg) | ||
| 221 | if not d.getVar(newname, False): | ||
| 222 | d.setVar(newname, newval) | ||
| 223 | # Avoid future variable key expansion | ||
| 224 | provexp = d.expand(prov) | ||
| 225 | if prov != provexp and d.getVar(prov, False): | ||
| 226 | d.renameVar(prov, provexp) | ||
| 227 | |||
| 228 | |||
| 229 | mp = (d.getVar("MULTI_PROVIDER_WHITELIST", True) or "").split() | ||
| 230 | extramp = [] | ||
| 231 | for p in mp: | ||
| 232 | if p.endswith(("-native", "-crosssdk")) or p.startswith(("nativesdk-", "virtual/nativesdk-")) or 'cross-canadian' in p: | ||
| 233 | continue | ||
| 234 | virt = "" | ||
| 235 | if p.startswith("virtual/"): | ||
| 236 | p = p.replace("virtual/", "") | ||
| 237 | virt = "virtual/" | ||
| 238 | for pref in prefixes: | ||
| 239 | extramp.append(virt + pref + "-" + p) | ||
| 240 | d.setVar("MULTI_PROVIDER_WHITELIST", " ".join(mp + extramp)) | ||
| 241 | |||
| 242 | |||
| 243 | def get_layers_branch_rev(d): | ||
| 244 | layers = (d.getVar("BBLAYERS", True) or "").split() | ||
| 245 | layers_branch_rev = ["%-17s = \"%s:%s\"" % (os.path.basename(i), \ | ||
| 246 | base_get_metadata_git_branch(i, None).strip(), \ | ||
| 247 | base_get_metadata_git_revision(i, None)) \ | ||
| 248 | for i in layers] | ||
| 249 | i = len(layers_branch_rev)-1 | ||
| 250 | p1 = layers_branch_rev[i].find("=") | ||
| 251 | s1 = layers_branch_rev[i][p1:] | ||
| 252 | while i > 0: | ||
| 253 | p2 = layers_branch_rev[i-1].find("=") | ||
| 254 | s2= layers_branch_rev[i-1][p2:] | ||
| 255 | if s1 == s2: | ||
| 256 | layers_branch_rev[i-1] = layers_branch_rev[i-1][0:p2] | ||
| 257 | i -= 1 | ||
| 258 | else: | ||
| 259 | i -= 1 | ||
| 260 | p1 = layers_branch_rev[i].find("=") | ||
| 261 | s1= layers_branch_rev[i][p1:] | ||
| 262 | return layers_branch_rev | ||
| 263 | |||
| 264 | |||
| 265 | BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars" | ||
| 266 | BUILDCFG_FUNCS[type] = "list" | ||
| 267 | |||
| 268 | def buildcfg_vars(d): | ||
| 269 | statusvars = oe.data.typed_value('BUILDCFG_VARS', d) | ||
| 270 | for var in statusvars: | ||
| 271 | value = d.getVar(var, True) | ||
| 272 | if value is not None: | ||
| 273 | yield '%-17s = "%s"' % (var, value) | ||
| 274 | |||
| 275 | def buildcfg_neededvars(d): | ||
| 276 | needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", d) | ||
| 277 | pesteruser = [] | ||
| 278 | for v in needed_vars: | ||
| 279 | val = d.getVar(v, True) | ||
| 280 | if not val or val == 'INVALID': | ||
| 281 | pesteruser.append(v) | ||
| 282 | |||
| 283 | if pesteruser: | ||
| 284 | bb.fatal('The following variable(s) were not set: %s\nPlease set them directly, or choose a MACHINE or DISTRO that sets them.' % ', '.join(pesteruser)) | ||
| 285 | |||
| 286 | addhandler base_eventhandler | ||
| 287 | base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.BuildStarted" | ||
| 288 | python base_eventhandler() { | ||
| 289 | if isinstance(e, bb.event.ConfigParsed): | ||
| 290 | e.data.setVar("NATIVELSBSTRING", lsb_distro_identifier(e.data)) | ||
| 291 | e.data.setVar('BB_VERSION', bb.__version__) | ||
| 292 | pkgarch_mapping(e.data) | ||
| 293 | preferred_ml_updates(e.data) | ||
| 294 | oe.utils.features_backfill("DISTRO_FEATURES", e.data) | ||
| 295 | oe.utils.features_backfill("MACHINE_FEATURES", e.data) | ||
| 296 | |||
| 297 | if isinstance(e, bb.event.BuildStarted): | ||
| 298 | localdata = bb.data.createCopy(e.data) | ||
| 299 | bb.data.update_data(localdata) | ||
| 300 | statuslines = [] | ||
| 301 | for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata): | ||
| 302 | g = globals() | ||
| 303 | if func not in g: | ||
| 304 | bb.warn("Build configuration function '%s' does not exist" % func) | ||
| 305 | else: | ||
| 306 | flines = g[func](localdata) | ||
| 307 | if flines: | ||
| 308 | statuslines.extend(flines) | ||
| 309 | |||
| 310 | statusheader = e.data.getVar('BUILDCFG_HEADER', True) | ||
| 311 | bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) | ||
| 312 | } | ||
| 313 | |||
| 314 | addtask configure after do_patch | ||
| 315 | do_configure[dirs] = "${S} ${B}" | ||
| 316 | do_configure[deptask] = "do_populate_sysroot" | ||
| 317 | base_do_configure() { | ||
| 318 | : | ||
| 319 | } | ||
| 320 | |||
| 321 | addtask compile after do_configure | ||
| 322 | do_compile[dirs] = "${S} ${B}" | ||
| 323 | base_do_compile() { | ||
| 324 | if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then | ||
| 325 | oe_runmake || die "make failed" | ||
| 326 | else | ||
| 327 | bbnote "nothing to compile" | ||
| 328 | fi | ||
| 329 | } | ||
| 330 | |||
| 331 | addtask install after do_compile | ||
| 332 | do_install[dirs] = "${D} ${S} ${B}" | ||
| 333 | # Remove and re-create ${D} so that is it guaranteed to be empty | ||
| 334 | do_install[cleandirs] = "${D}" | ||
| 335 | |||
| 336 | base_do_install() { | ||
| 337 | : | ||
| 338 | } | ||
| 339 | |||
| 340 | base_do_package() { | ||
| 341 | : | ||
| 342 | } | ||
| 343 | |||
| 344 | addtask build after do_populate_sysroot | ||
| 345 | do_build = "" | ||
| 346 | do_build[func] = "1" | ||
| 347 | do_build[noexec] = "1" | ||
| 348 | do_build[recrdeptask] += "do_deploy" | ||
| 349 | do_build () { | ||
| 350 | : | ||
| 351 | } | ||
| 352 | |||
| 353 | def set_packagetriplet(d): | ||
| 354 | archs = [] | ||
| 355 | tos = [] | ||
| 356 | tvs = [] | ||
| 357 | |||
| 358 | archs.append(d.getVar("PACKAGE_ARCHS", True).split()) | ||
| 359 | tos.append(d.getVar("TARGET_OS", True)) | ||
| 360 | tvs.append(d.getVar("TARGET_VENDOR", True)) | ||
| 361 | |||
| 362 | def settriplet(d, varname, archs, tos, tvs): | ||
| 363 | triplets = [] | ||
| 364 | for i in range(len(archs)): | ||
| 365 | for arch in archs[i]: | ||
| 366 | triplets.append(arch + tvs[i] + "-" + tos[i]) | ||
| 367 | triplets.reverse() | ||
| 368 | d.setVar(varname, " ".join(triplets)) | ||
| 369 | |||
| 370 | settriplet(d, "PKGTRIPLETS", archs, tos, tvs) | ||
| 371 | |||
| 372 | variants = d.getVar("MULTILIB_VARIANTS", True) or "" | ||
| 373 | for item in variants.split(): | ||
| 374 | localdata = bb.data.createCopy(d) | ||
| 375 | overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item | ||
| 376 | localdata.setVar("OVERRIDES", overrides) | ||
| 377 | bb.data.update_data(localdata) | ||
| 378 | |||
| 379 | archs.append(localdata.getVar("PACKAGE_ARCHS", True).split()) | ||
| 380 | tos.append(localdata.getVar("TARGET_OS", True)) | ||
| 381 | tvs.append(localdata.getVar("TARGET_VENDOR", True)) | ||
| 382 | |||
| 383 | settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs) | ||
| 384 | |||
| 385 | python () { | ||
| 386 | import string, re | ||
| 387 | |||
| 388 | # Handle PACKAGECONFIG | ||
| 389 | # | ||
| 390 | # These take the form: | ||
| 391 | # | ||
| 392 | # PACKAGECONFIG ??= "<default options>" | ||
| 393 | # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends" | ||
| 394 | pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {} | ||
| 395 | if pkgconfigflags: | ||
| 396 | pkgconfig = (d.getVar('PACKAGECONFIG', True) or "").split() | ||
| 397 | pn = d.getVar("PN", True) | ||
| 398 | mlprefix = d.getVar("MLPREFIX", True) | ||
| 399 | |||
| 400 | def expandFilter(appends, extension, prefix): | ||
| 401 | appends = bb.utils.explode_deps(d.expand(" ".join(appends))) | ||
| 402 | newappends = [] | ||
| 403 | for a in appends: | ||
| 404 | if a.endswith("-native") or a.endswith("-cross"): | ||
| 405 | newappends.append(a) | ||
| 406 | elif a.startswith("virtual/"): | ||
| 407 | subs = a.split("/", 1)[1] | ||
| 408 | newappends.append("virtual/" + prefix + subs + extension) | ||
| 409 | else: | ||
| 410 | if a.startswith(prefix): | ||
| 411 | newappends.append(a + extension) | ||
| 412 | else: | ||
| 413 | newappends.append(prefix + a + extension) | ||
| 414 | return newappends | ||
| 415 | |||
| 416 | def appendVar(varname, appends): | ||
| 417 | if not appends: | ||
| 418 | return | ||
| 419 | if varname.find("DEPENDS") != -1: | ||
| 420 | if pn.startswith("nativesdk-"): | ||
| 421 | appends = expandFilter(appends, "", "nativesdk-") | ||
| 422 | if pn.endswith("-native"): | ||
| 423 | appends = expandFilter(appends, "-native", "") | ||
| 424 | if mlprefix: | ||
| 425 | appends = expandFilter(appends, "", mlprefix) | ||
| 426 | varname = d.expand(varname) | ||
| 427 | d.appendVar(varname, " " + " ".join(appends)) | ||
| 428 | |||
| 429 | extradeps = [] | ||
| 430 | extrardeps = [] | ||
| 431 | extraconf = [] | ||
| 432 | for flag, flagval in sorted(pkgconfigflags.items()): | ||
| 433 | if flag == "defaultval": | ||
| 434 | continue | ||
| 435 | items = flagval.split(",") | ||
| 436 | num = len(items) | ||
| 437 | if num > 4: | ||
| 438 | bb.error("Only enable,disable,depend,rdepend can be specified!") | ||
| 439 | |||
| 440 | if flag in pkgconfig: | ||
| 441 | if num >= 3 and items[2]: | ||
| 442 | extradeps.append(items[2]) | ||
| 443 | if num >= 4 and items[3]: | ||
| 444 | extrardeps.append(items[3]) | ||
| 445 | if num >= 1 and items[0]: | ||
| 446 | extraconf.append(items[0]) | ||
| 447 | elif num >= 2 and items[1]: | ||
| 448 | extraconf.append(items[1]) | ||
| 449 | appendVar('DEPENDS', extradeps) | ||
| 450 | appendVar('RDEPENDS_${PN}', extrardeps) | ||
| 451 | if bb.data.inherits_class('cmake', d): | ||
| 452 | appendVar('EXTRA_OECMAKE', extraconf) | ||
| 453 | else: | ||
| 454 | appendVar('EXTRA_OECONF', extraconf) | ||
| 455 | |||
| 456 | # If PRINC is set, try and increase the PR value by the amount specified | ||
| 457 | # The PR server is now the preferred way to handle PR changes based on | ||
| 458 | # the checksum of the recipe (including bbappend). The PRINC is now | ||
| 459 | # obsolete. Return a warning to the user. | ||
| 460 | princ = d.getVar('PRINC', True) | ||
| 461 | if princ and princ != "0": | ||
| 462 | bb.warn("Use of PRINC %s was detected in the recipe %s (or one of its .bbappends)\nUse of PRINC is deprecated. The PR server should be used to automatically increment the PR. See: https://wiki.yoctoproject.org/wiki/PR_Service." % (princ, d.getVar("FILE", True))) | ||
| 463 | pr = d.getVar('PR', True) | ||
| 464 | pr_prefix = re.search("\D+",pr) | ||
| 465 | prval = re.search("\d+",pr) | ||
| 466 | if pr_prefix is None or prval is None: | ||
| 467 | bb.error("Unable to analyse format of PR variable: %s" % pr) | ||
| 468 | nval = int(prval.group(0)) + int(princ) | ||
| 469 | pr = pr_prefix.group(0) + str(nval) + pr[prval.end():] | ||
| 470 | d.setVar('PR', pr) | ||
| 471 | |||
| 472 | pn = d.getVar('PN', True) | ||
| 473 | license = d.getVar('LICENSE', True) | ||
| 474 | if license == "INVALID": | ||
| 475 | bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn) | ||
| 476 | |||
| 477 | if bb.data.inherits_class('license', d): | ||
| 478 | unmatched_license_flag = check_license_flags(d) | ||
| 479 | if unmatched_license_flag: | ||
| 480 | bb.debug(1, "Skipping %s because it has a restricted license not" | ||
| 481 | " whitelisted in LICENSE_FLAGS_WHITELIST" % pn) | ||
| 482 | raise bb.parse.SkipPackage("because it has a restricted license not" | ||
| 483 | " whitelisted in LICENSE_FLAGS_WHITELIST") | ||
| 484 | |||
| 485 | # If we're building a target package we need to use fakeroot (pseudo) | ||
| 486 | # in order to capture permissions, owners, groups and special files | ||
| 487 | if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d): | ||
| 488 | d.setVarFlag('do_unpack', 'umask', '022') | ||
| 489 | d.setVarFlag('do_configure', 'umask', '022') | ||
| 490 | d.setVarFlag('do_compile', 'umask', '022') | ||
| 491 | d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') | ||
| 492 | d.setVarFlag('do_install', 'fakeroot', 1) | ||
| 493 | d.setVarFlag('do_install', 'umask', '022') | ||
| 494 | d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') | ||
| 495 | d.setVarFlag('do_package', 'fakeroot', 1) | ||
| 496 | d.setVarFlag('do_package', 'umask', '022') | ||
| 497 | d.setVarFlag('do_package_setscene', 'fakeroot', 1) | ||
| 498 | d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') | ||
| 499 | d.setVarFlag('do_devshell', 'fakeroot', 1) | ||
| 500 | d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') | ||
| 501 | source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', 0) | ||
| 502 | if not source_mirror_fetch: | ||
| 503 | need_host = d.getVar('COMPATIBLE_HOST', True) | ||
| 504 | if need_host: | ||
| 505 | import re | ||
| 506 | this_host = d.getVar('HOST_SYS', True) | ||
| 507 | if not re.match(need_host, this_host): | ||
| 508 | raise bb.parse.SkipPackage("incompatible with host %s (not in COMPATIBLE_HOST)" % this_host) | ||
| 509 | |||
| 510 | need_machine = d.getVar('COMPATIBLE_MACHINE', True) | ||
| 511 | if need_machine: | ||
| 512 | import re | ||
| 513 | compat_machines = (d.getVar('MACHINEOVERRIDES', True) or "").split(":") | ||
| 514 | for m in compat_machines: | ||
| 515 | if re.match(need_machine, m): | ||
| 516 | break | ||
| 517 | else: | ||
| 518 | raise bb.parse.SkipPackage("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE', True)) | ||
| 519 | |||
| 520 | |||
| 521 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE', True) or "").split() | ||
| 522 | |||
| 523 | check_license = False if pn.startswith("nativesdk-") else True | ||
| 524 | for t in ["-native", "-cross", "-cross-initial", "-cross-intermediate", | ||
| 525 | "-crosssdk-intermediate", "-crosssdk", "-crosssdk-initial", | ||
| 526 | "-cross-canadian-" + d.getVar('TRANSLATED_TARGET_ARCH', True)]: | ||
| 527 | if pn.endswith(t): | ||
| 528 | check_license = False | ||
| 529 | |||
| 530 | if check_license and bad_licenses: | ||
| 531 | whitelist = [] | ||
| 532 | for lic in bad_licenses: | ||
| 533 | for w in ["HOSTTOOLS_WHITELIST_", "LGPLv2_WHITELIST_", "WHITELIST_"]: | ||
| 534 | whitelist.extend((d.getVar(w + lic, True) or "").split()) | ||
| 535 | spdx_license = return_spdx(d, lic) | ||
| 536 | if spdx_license: | ||
| 537 | whitelist.extend((d.getVar('HOSTTOOLS_WHITELIST_%s' % spdx_license, True) or "").split()) | ||
| 538 | if not pn in whitelist: | ||
| 539 | recipe_license = d.getVar('LICENSE', True) | ||
| 540 | pkgs = d.getVar('PACKAGES', True).split() | ||
| 541 | skipped_pkgs = [] | ||
| 542 | unskipped_pkgs = [] | ||
| 543 | for pkg in pkgs: | ||
| 544 | if incompatible_license(d, bad_licenses, pkg): | ||
| 545 | skipped_pkgs.append(pkg) | ||
| 546 | else: | ||
| 547 | unskipped_pkgs.append(pkg) | ||
| 548 | all_skipped = skipped_pkgs and not unskipped_pkgs | ||
| 549 | if unskipped_pkgs: | ||
| 550 | for pkg in skipped_pkgs: | ||
| 551 | bb.debug(1, "SKIPPING the package " + pkg + " at do_rootfs because it's " + recipe_license) | ||
| 552 | d.setVar('LICENSE_EXCLUSION-' + pkg, 1) | ||
| 553 | for pkg in unskipped_pkgs: | ||
| 554 | bb.debug(1, "INCLUDING the package " + pkg) | ||
| 555 | elif all_skipped or incompatible_license(d, bad_licenses): | ||
| 556 | bb.debug(1, "SKIPPING recipe %s because it's %s" % (pn, recipe_license)) | ||
| 557 | raise bb.parse.SkipPackage("incompatible with license %s" % recipe_license) | ||
| 558 | |||
| 559 | srcuri = d.getVar('SRC_URI', True) | ||
| 560 | # Svn packages should DEPEND on subversion-native | ||
| 561 | if "svn://" in srcuri: | ||
| 562 | d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot') | ||
| 563 | |||
| 564 | # Git packages should DEPEND on git-native | ||
| 565 | if "git://" in srcuri: | ||
| 566 | d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot') | ||
| 567 | |||
| 568 | # Mercurial packages should DEPEND on mercurial-native | ||
| 569 | elif "hg://" in srcuri: | ||
| 570 | d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot') | ||
| 571 | |||
| 572 | # OSC packages should DEPEND on osc-native | ||
| 573 | elif "osc://" in srcuri: | ||
| 574 | d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot') | ||
| 575 | |||
| 576 | # *.lz4 should depends on lz4-native for unpacking | ||
| 577 | # Not endswith because of "*.patch.lz4;patch=1". Need bb.fetch.decodeurl in future | ||
| 578 | if '.lz4' in srcuri: | ||
| 579 | d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot') | ||
| 580 | |||
| 581 | # *.xz should depends on xz-native for unpacking | ||
| 582 | # Not endswith because of "*.patch.xz;patch=1". Need bb.fetch.decodeurl in future | ||
| 583 | if '.xz' in srcuri: | ||
| 584 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') | ||
| 585 | |||
| 586 | # unzip-native should already be staged before unpacking ZIP recipes | ||
| 587 | if ".zip" in srcuri: | ||
| 588 | d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot') | ||
| 589 | |||
| 590 | # file is needed by rpm2cpio.sh | ||
| 591 | if ".src.rpm" in srcuri: | ||
| 592 | d.appendVarFlag('do_unpack', 'depends', ' file-native:do_populate_sysroot') | ||
| 593 | |||
| 594 | set_packagetriplet(d) | ||
| 595 | |||
| 596 | # 'multimachine' handling | ||
| 597 | mach_arch = d.getVar('MACHINE_ARCH', True) | ||
| 598 | pkg_arch = d.getVar('PACKAGE_ARCH', True) | ||
| 599 | |||
| 600 | if (pkg_arch == mach_arch): | ||
| 601 | # Already machine specific - nothing further to do | ||
| 602 | return | ||
| 603 | |||
| 604 | # | ||
| 605 | # We always try to scan SRC_URI for urls with machine overrides | ||
| 606 | # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0 | ||
| 607 | # | ||
| 608 | override = d.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH', True) | ||
| 609 | if override != '0': | ||
| 610 | paths = [] | ||
| 611 | fpaths = (d.getVar('FILESPATH', True) or '').split(':') | ||
| 612 | machine = d.getVar('MACHINE', True) | ||
| 613 | for p in fpaths: | ||
| 614 | if os.path.basename(p) == machine and os.path.isdir(p): | ||
| 615 | paths.append(p) | ||
| 616 | |||
| 617 | if len(paths) != 0: | ||
| 618 | for s in srcuri.split(): | ||
| 619 | if not s.startswith("file://"): | ||
| 620 | continue | ||
| 621 | fetcher = bb.fetch2.Fetch([s], d) | ||
| 622 | local = fetcher.localpath(s) | ||
| 623 | for mp in paths: | ||
| 624 | if local.startswith(mp): | ||
| 625 | #bb.note("overriding PACKAGE_ARCH from %s to %s for %s" % (pkg_arch, mach_arch, pn)) | ||
| 626 | d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}") | ||
| 627 | return | ||
| 628 | |||
| 629 | packages = d.getVar('PACKAGES', True).split() | ||
| 630 | for pkg in packages: | ||
| 631 | pkgarch = d.getVar("PACKAGE_ARCH_%s" % pkg, True) | ||
| 632 | |||
| 633 | # We could look for != PACKAGE_ARCH here but how to choose | ||
| 634 | # if multiple differences are present? | ||
| 635 | # Look through PACKAGE_ARCHS for the priority order? | ||
| 636 | if pkgarch and pkgarch == mach_arch: | ||
| 637 | d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}") | ||
| 638 | bb.warn("Recipe %s is marked as only being architecture specific but seems to have machine specific packages?! The recipe may as well mark itself as machine specific directly." % d.getVar("PN", True)) | ||
| 639 | } | ||
| 640 | |||
| 641 | addtask cleansstate after do_clean | ||
| 642 | python do_cleansstate() { | ||
| 643 | sstate_clean_cachefiles(d) | ||
| 644 | } | ||
| 645 | |||
| 646 | addtask cleanall after do_cleansstate | ||
| 647 | python do_cleanall() { | ||
| 648 | src_uri = (d.getVar('SRC_URI', True) or "").split() | ||
| 649 | if len(src_uri) == 0: | ||
| 650 | return | ||
| 651 | |||
| 652 | try: | ||
| 653 | fetcher = bb.fetch2.Fetch(src_uri, d) | ||
| 654 | fetcher.clean() | ||
| 655 | except bb.fetch2.BBFetchException, e: | ||
| 656 | raise bb.build.FuncFailed(e) | ||
| 657 | } | ||
| 658 | do_cleanall[nostamp] = "1" | ||
| 659 | |||
| 660 | |||
| 661 | EXPORT_FUNCTIONS do_fetch do_unpack do_configure do_compile do_install do_package | ||
