Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 13 | OE_EXTRA_IMPORTS ?= "" |
| 14 | |
| 15 | OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license ${OE_EXTRA_IMPORTS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | OE_IMPORTS[type] = "list" |
| 17 | |
Brad Bishop | f3fd288 | 2019-06-21 08:06:37 -0400 | [diff] [blame] | 18 | PACKAGECONFIG_CONFARGS ??= "" |
| 19 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 20 | def oe_import(d): |
| 21 | import sys |
| 22 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 23 | bbpath = d.getVar("BBPATH").split(":") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 24 | sys.path[0:0] = [os.path.join(dir, "lib") for dir in bbpath] |
| 25 | |
| 26 | def inject(name, value): |
| 27 | """Make a python object accessible from the metadata""" |
| 28 | if hasattr(bb.utils, "_context"): |
| 29 | bb.utils._context[name] = value |
| 30 | else: |
| 31 | __builtins__[name] = value |
| 32 | |
| 33 | import oe.data |
| 34 | for toimport in oe.data.typed_value("OE_IMPORTS", d): |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 35 | try: |
| 36 | imported = __import__(toimport) |
| 37 | inject(toimport.split(".", 1)[0], imported) |
| 38 | except AttributeError as e: |
| 39 | bb.error("Error importing OE modules: %s" % str(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | return "" |
| 41 | |
| 42 | # We need the oe module name space early (before INHERITs get added) |
| 43 | OE_IMPORTED := "${@oe_import(d)}" |
| 44 | |
| 45 | def lsb_distro_identifier(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 46 | adjust = d.getVar('LSB_DISTRO_ADJUST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | adjust_func = None |
| 48 | if adjust: |
| 49 | try: |
| 50 | adjust_func = globals()[adjust] |
| 51 | except KeyError: |
| 52 | pass |
| 53 | return oe.lsb.distro_identifier(adjust_func) |
| 54 | |
| 55 | die() { |
| 56 | bbfatal_log "$*" |
| 57 | } |
| 58 | |
| 59 | oe_runmake_call() { |
| 60 | bbnote ${MAKE} ${EXTRA_OEMAKE} "$@" |
| 61 | ${MAKE} ${EXTRA_OEMAKE} "$@" |
| 62 | } |
| 63 | |
| 64 | oe_runmake() { |
| 65 | oe_runmake_call "$@" || die "oe_runmake failed" |
| 66 | } |
| 67 | |
| 68 | |
| 69 | def base_dep_prepend(d): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | if d.getVar('INHIBIT_DEFAULT_DEPS', False): |
| 71 | return "" |
| 72 | return "${BASE_DEFAULT_DEPS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 74 | BASE_DEFAULT_DEPS = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}compilerlibs virtual/libc" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 75 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 76 | BASEDEPENDS = "" |
| 77 | BASEDEPENDS_class-target = "${@base_dep_prepend(d)}" |
| 78 | BASEDEPENDS_class-nativesdk = "${@base_dep_prepend(d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | |
| 80 | DEPENDS_prepend="${BASEDEPENDS} " |
| 81 | |
| 82 | FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}" |
| 83 | # THISDIR only works properly with imediate expansion as it has to run |
| 84 | # in the context of the location its used (:=) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 85 | THISDIR = "${@os.path.dirname(d.getVar('FILE'))}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | |
| 87 | def extra_path_elements(d): |
| 88 | path = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 89 | elements = (d.getVar('EXTRANATIVEPATH') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | for e in elements: |
| 91 | path = path + "${STAGING_BINDIR_NATIVE}/" + e + ":" |
| 92 | return path |
| 93 | |
| 94 | PATH_prepend = "${@extra_path_elements(d)}" |
| 95 | |
| 96 | def get_lic_checksum_file_list(d): |
| 97 | filelist = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 98 | lic_files = d.getVar("LIC_FILES_CHKSUM") or '' |
| 99 | tmpdir = d.getVar("TMPDIR") |
| 100 | s = d.getVar("S") |
| 101 | b = d.getVar("B") |
| 102 | workdir = d.getVar("WORKDIR") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | |
| 104 | urls = lic_files.split() |
| 105 | for url in urls: |
| 106 | # We only care about items that are absolute paths since |
| 107 | # any others should be covered by SRC_URI. |
| 108 | try: |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 109 | (method, host, path, user, pswd, parm) = bb.fetch.decodeurl(url) |
| 110 | if method != "file" or not path: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 111 | raise bb.fetch.MalformedUrl(url) |
| 112 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | if path[0] == '/': |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 114 | if path.startswith((tmpdir, s, b, workdir)): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | continue |
| 116 | filelist.append(path + ":" + str(os.path.exists(path))) |
| 117 | except bb.fetch.MalformedUrl: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 118 | bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | return " ".join(filelist) |
| 120 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | def setup_hosttools_dir(dest, toolsvar, d, fatal=True): |
| 122 | tools = d.getVar(toolsvar).split() |
| 123 | origbbenv = d.getVar("BB_ORIGENV", False) |
| 124 | path = origbbenv.getVar("PATH") |
| 125 | bb.utils.mkdirhier(dest) |
| 126 | notfound = [] |
| 127 | for tool in tools: |
| 128 | desttool = os.path.join(dest, tool) |
| 129 | if not os.path.exists(desttool): |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 130 | # clean up dead symlink |
| 131 | if os.path.islink(desttool): |
| 132 | os.unlink(desttool) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 133 | srctool = bb.utils.which(path, tool, executable=True) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 134 | # gcc/g++ may link to ccache on some hosts, e.g., |
| 135 | # /usr/local/bin/ccache/gcc -> /usr/bin/ccache, then which(gcc) |
| 136 | # would return /usr/local/bin/ccache/gcc, but what we need is |
| 137 | # /usr/bin/gcc, this code can check and fix that. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 138 | if "ccache" in srctool: |
| 139 | srctool = bb.utils.which(path, tool, executable=True, direction=1) |
| 140 | if srctool: |
| 141 | os.symlink(srctool, desttool) |
| 142 | else: |
| 143 | notfound.append(tool) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 144 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 145 | if notfound and fatal: |
| 146 | bb.fatal("The following required tools (as specified by HOSTTOOLS) appear to be unavailable in PATH, please install them in order to proceed:\n %s" % " ".join(notfound)) |
| 147 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 148 | addtask fetch |
| 149 | do_fetch[dirs] = "${DL_DIR}" |
| 150 | do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}" |
| 151 | do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}" |
| 152 | do_fetch[vardeps] += "SRCREV" |
| 153 | python base_do_fetch() { |
| 154 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 155 | src_uri = (d.getVar('SRC_URI') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 156 | if len(src_uri) == 0: |
| 157 | return |
| 158 | |
| 159 | try: |
| 160 | fetcher = bb.fetch2.Fetch(src_uri, d) |
| 161 | fetcher.download() |
| 162 | except bb.fetch2.BBFetchException as e: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 163 | bb.fatal(str(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | addtask unpack after do_fetch |
| 167 | do_unpack[dirs] = "${WORKDIR}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 168 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 169 | do_unpack[cleandirs] = "${@d.getVar('S') if os.path.normpath(d.getVar('S')) != os.path.normpath(d.getVar('WORKDIR')) else os.path.join('${S}', 'patches')}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 170 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | python base_do_unpack() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 172 | src_uri = (d.getVar('SRC_URI') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | if len(src_uri) == 0: |
| 174 | return |
| 175 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | try: |
| 177 | fetcher = bb.fetch2.Fetch(src_uri, d) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 178 | fetcher.unpack(d.getVar('WORKDIR')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 179 | except bb.fetch2.BBFetchException as e: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 180 | bb.fatal(str(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 181 | } |
| 182 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 183 | def get_layers_branch_rev(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 184 | layers = (d.getVar("BBLAYERS") or "").split() |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 185 | layers_branch_rev = ["%-20s = \"%s:%s\"" % (os.path.basename(i), \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 186 | base_get_metadata_git_branch(i, None).strip(), \ |
| 187 | base_get_metadata_git_revision(i, None)) \ |
| 188 | for i in layers] |
| 189 | i = len(layers_branch_rev)-1 |
| 190 | p1 = layers_branch_rev[i].find("=") |
| 191 | s1 = layers_branch_rev[i][p1:] |
| 192 | while i > 0: |
| 193 | p2 = layers_branch_rev[i-1].find("=") |
| 194 | s2= layers_branch_rev[i-1][p2:] |
| 195 | if s1 == s2: |
| 196 | layers_branch_rev[i-1] = layers_branch_rev[i-1][0:p2] |
| 197 | i -= 1 |
| 198 | else: |
| 199 | i -= 1 |
| 200 | p1 = layers_branch_rev[i].find("=") |
| 201 | s1= layers_branch_rev[i][p1:] |
| 202 | return layers_branch_rev |
| 203 | |
| 204 | |
| 205 | BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars" |
| 206 | BUILDCFG_FUNCS[type] = "list" |
| 207 | |
| 208 | def buildcfg_vars(d): |
| 209 | statusvars = oe.data.typed_value('BUILDCFG_VARS', d) |
| 210 | for var in statusvars: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 211 | value = d.getVar(var) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 212 | if value is not None: |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 213 | yield '%-20s = "%s"' % (var, value) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 214 | |
| 215 | def buildcfg_neededvars(d): |
| 216 | needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", d) |
| 217 | pesteruser = [] |
| 218 | for v in needed_vars: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 219 | val = d.getVar(v) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | if not val or val == 'INVALID': |
| 221 | pesteruser.append(v) |
| 222 | |
| 223 | if pesteruser: |
| 224 | 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)) |
| 225 | |
| 226 | addhandler base_eventhandler |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 227 | base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 228 | python base_eventhandler() { |
| 229 | import bb.runqueue |
| 230 | |
| 231 | if isinstance(e, bb.event.ConfigParsed): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 232 | if not d.getVar("NATIVELSBSTRING", False): |
| 233 | d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d)) |
| 234 | d.setVar('BB_VERSION', bb.__version__) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 235 | |
| 236 | # There might be no bb.event.ConfigParsed event if bitbake server is |
| 237 | # running, so check bb.event.BuildStarted too to make sure ${HOSTTOOLS_DIR} |
| 238 | # exists. |
| 239 | if isinstance(e, bb.event.ConfigParsed) or \ |
| 240 | (isinstance(e, bb.event.BuildStarted) and not os.path.exists(d.getVar('HOSTTOOLS_DIR'))): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 241 | # Works with the line in layer.conf which changes PATH to point here |
| 242 | setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d) |
| 243 | setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 244 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 245 | if isinstance(e, bb.event.MultiConfigParsed): |
| 246 | # We need to expand SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS in each of the multiconfig data stores |
| 247 | # own contexts so the variables get expanded correctly for that arch, then inject back into |
| 248 | # the main data store. |
| 249 | deps = [] |
| 250 | for config in e.mcdata: |
| 251 | deps.append(e.mcdata[config].getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS")) |
| 252 | deps = " ".join(deps) |
| 253 | e.mcdata[''].setVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", deps) |
| 254 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 255 | if isinstance(e, bb.event.BuildStarted): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 256 | localdata = bb.data.createCopy(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 257 | statuslines = [] |
| 258 | for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata): |
| 259 | g = globals() |
| 260 | if func not in g: |
| 261 | bb.warn("Build configuration function '%s' does not exist" % func) |
| 262 | else: |
| 263 | flines = g[func](localdata) |
| 264 | if flines: |
| 265 | statuslines.extend(flines) |
| 266 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 267 | statusheader = d.getVar('BUILDCFG_HEADER') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 268 | if statusheader: |
| 269 | bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 270 | |
| 271 | # This code is to silence warnings where the SDK variables overwrite the |
| 272 | # target ones and we'd see dulpicate key names overwriting each other |
| 273 | # for various PREFERRED_PROVIDERS |
| 274 | if isinstance(e, bb.event.RecipePreFinalise): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 275 | if d.getVar("TARGET_PREFIX") == d.getVar("SDK_PREFIX"): |
| 276 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 277 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc") |
| 278 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++") |
| 279 | d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 280 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 281 | if isinstance(e, bb.event.RecipeParsed): |
| 282 | # |
| 283 | # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set |
| 284 | # skip parsing for all the other providers which will mean they get uninstalled from the |
| 285 | # sysroot since they're now "unreachable". This makes switching virtual/kernel work in |
| 286 | # particular. |
| 287 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 288 | pn = d.getVar('PN') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 289 | source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) |
| 290 | if not source_mirror_fetch: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 291 | provs = (d.getVar("PROVIDES") or "").split() |
| 292 | multiwhitelist = (d.getVar("MULTI_PROVIDER_WHITELIST") or "").split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 293 | for p in provs: |
| 294 | if p.startswith("virtual/") and p not in multiwhitelist: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 295 | profprov = d.getVar("PREFERRED_PROVIDER_" + p) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 296 | if profprov and pn != profprov: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 297 | raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (p, profprov, pn)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate" |
| 301 | CLEANBROKEN = "0" |
| 302 | |
| 303 | addtask configure after do_patch |
| 304 | do_configure[dirs] = "${B}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 305 | base_do_configure() { |
| 306 | if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then |
| 307 | if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then |
| 308 | cd ${B} |
| 309 | if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then |
| 310 | oe_runmake clean |
| 311 | fi |
Brad Bishop | c4ea075 | 2018-11-15 14:30:15 -0800 | [diff] [blame] | 312 | # -ignore_readdir_race does not work correctly with -delete; |
| 313 | # use xargs to avoid spurious build failures |
| 314 | find ${B} -ignore_readdir_race -name \*.la -type f -print0 | xargs -0 rm -f |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 315 | fi |
| 316 | fi |
| 317 | if [ -n "${CONFIGURESTAMPFILE}" ]; then |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 318 | mkdir -p `dirname ${CONFIGURESTAMPFILE}` |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 319 | echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE} |
| 320 | fi |
| 321 | } |
| 322 | |
| 323 | addtask compile after do_configure |
| 324 | do_compile[dirs] = "${B}" |
| 325 | base_do_compile() { |
| 326 | if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then |
| 327 | oe_runmake || die "make failed" |
| 328 | else |
| 329 | bbnote "nothing to compile" |
| 330 | fi |
| 331 | } |
| 332 | |
| 333 | addtask install after do_compile |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 334 | do_install[dirs] = "${B}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 335 | # Remove and re-create ${D} so that is it guaranteed to be empty |
| 336 | do_install[cleandirs] = "${D}" |
| 337 | |
| 338 | base_do_install() { |
| 339 | : |
| 340 | } |
| 341 | |
| 342 | base_do_package() { |
| 343 | : |
| 344 | } |
| 345 | |
| 346 | addtask build after do_populate_sysroot |
| 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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 358 | archs.append(d.getVar("PACKAGE_ARCHS").split()) |
| 359 | tos.append(d.getVar("TARGET_OS")) |
| 360 | tvs.append(d.getVar("TARGET_VENDOR")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 372 | variants = d.getVar("MULTILIB_VARIANTS") or "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 377 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 378 | archs.append(localdata.getVar("PACKAGE_ARCHS").split()) |
| 379 | tos.append(localdata.getVar("TARGET_OS")) |
| 380 | tvs.append(localdata.getVar("TARGET_VENDOR")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 381 | |
| 382 | settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs) |
| 383 | |
| 384 | python () { |
| 385 | import string, re |
| 386 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 387 | # Handle backfilling |
| 388 | oe.utils.features_backfill("DISTRO_FEATURES", d) |
| 389 | oe.utils.features_backfill("MACHINE_FEATURES", d) |
| 390 | |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 391 | if d.getVar("S")[-1] == '/': |
| 392 | bb.warn("Recipe %s sets S variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("S"))) |
| 393 | if d.getVar("B")[-1] == '/': |
| 394 | bb.warn("Recipe %s sets B variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("B"))) |
| 395 | |
| 396 | if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("S")): |
| 397 | d.appendVar("PSEUDO_IGNORE_PATHS", ",${S}") |
| 398 | if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("B")): |
| 399 | d.appendVar("PSEUDO_IGNORE_PATHS", ",${B}") |
| 400 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 401 | # Handle PACKAGECONFIG |
| 402 | # |
| 403 | # These take the form: |
| 404 | # |
| 405 | # PACKAGECONFIG ??= "<default options>" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 406 | # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends,foo_runtime_recommends,foo_conflict_packageconfig" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 407 | pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {} |
| 408 | if pkgconfigflags: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 409 | pkgconfig = (d.getVar('PACKAGECONFIG') or "").split() |
| 410 | pn = d.getVar("PN") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 411 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 412 | mlprefix = d.getVar("MLPREFIX") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 413 | |
| 414 | def expandFilter(appends, extension, prefix): |
| 415 | appends = bb.utils.explode_deps(d.expand(" ".join(appends))) |
| 416 | newappends = [] |
| 417 | for a in appends: |
| 418 | if a.endswith("-native") or ("-cross-" in a): |
| 419 | newappends.append(a) |
| 420 | elif a.startswith("virtual/"): |
| 421 | subs = a.split("/", 1)[1] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 422 | if subs.startswith(prefix): |
| 423 | newappends.append(a + extension) |
| 424 | else: |
| 425 | newappends.append("virtual/" + prefix + subs + extension) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 426 | else: |
| 427 | if a.startswith(prefix): |
| 428 | newappends.append(a + extension) |
| 429 | else: |
| 430 | newappends.append(prefix + a + extension) |
| 431 | return newappends |
| 432 | |
| 433 | def appendVar(varname, appends): |
| 434 | if not appends: |
| 435 | return |
| 436 | if varname.find("DEPENDS") != -1: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 437 | if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) : |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 438 | appends = expandFilter(appends, "", "nativesdk-") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 439 | elif bb.data.inherits_class('native', d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 440 | appends = expandFilter(appends, "-native", "") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 441 | elif mlprefix: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 442 | appends = expandFilter(appends, "", mlprefix) |
| 443 | varname = d.expand(varname) |
| 444 | d.appendVar(varname, " " + " ".join(appends)) |
| 445 | |
| 446 | extradeps = [] |
| 447 | extrardeps = [] |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 448 | extrarrecs = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 449 | extraconf = [] |
| 450 | for flag, flagval in sorted(pkgconfigflags.items()): |
| 451 | items = flagval.split(",") |
| 452 | num = len(items) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 453 | if num > 6: |
| 454 | bb.error("%s: PACKAGECONFIG[%s] Only enable,disable,depend,rdepend,rrecommend,conflict_packageconfig can be specified!" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 455 | % (d.getVar('PN'), flag)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 456 | |
| 457 | if flag in pkgconfig: |
| 458 | if num >= 3 and items[2]: |
| 459 | extradeps.append(items[2]) |
| 460 | if num >= 4 and items[3]: |
| 461 | extrardeps.append(items[3]) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 462 | if num >= 5 and items[4]: |
| 463 | extrarrecs.append(items[4]) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 464 | if num >= 1 and items[0]: |
| 465 | extraconf.append(items[0]) |
| 466 | elif num >= 2 and items[1]: |
| 467 | extraconf.append(items[1]) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 468 | |
| 469 | if num >= 6 and items[5]: |
| 470 | conflicts = set(items[5].split()) |
| 471 | invalid = conflicts.difference(set(pkgconfigflags.keys())) |
| 472 | if invalid: |
| 473 | bb.error("%s: PACKAGECONFIG[%s] Invalid conflict package config%s '%s' specified." |
| 474 | % (d.getVar('PN'), flag, 's' if len(invalid) > 1 else '', ' '.join(invalid))) |
| 475 | |
| 476 | if flag in pkgconfig: |
| 477 | intersec = conflicts.intersection(set(pkgconfig)) |
| 478 | if intersec: |
| 479 | bb.fatal("%s: PACKAGECONFIG[%s] Conflict package config%s '%s' set in PACKAGECONFIG." |
| 480 | % (d.getVar('PN'), flag, 's' if len(intersec) > 1 else '', ' '.join(intersec))) |
| 481 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 482 | appendVar('DEPENDS', extradeps) |
| 483 | appendVar('RDEPENDS_${PN}', extrardeps) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 484 | appendVar('RRECOMMENDS_${PN}', extrarrecs) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 485 | appendVar('PACKAGECONFIG_CONFARGS', extraconf) |
| 486 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 487 | pn = d.getVar('PN') |
| 488 | license = d.getVar('LICENSE') |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 489 | if license == "INVALID" and pn != "defaultpkgname": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 490 | bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn) |
| 491 | |
| 492 | if bb.data.inherits_class('license', d): |
| 493 | check_license_format(d) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 494 | unmatched_license_flags = check_license_flags(d) |
| 495 | if unmatched_license_flags: |
| 496 | if len(unmatched_license_flags) == 1: |
| 497 | message = "because it has a restricted license '{0}'. Which is not whitelisted in LICENSE_FLAGS_WHITELIST".format(unmatched_license_flags[0]) |
| 498 | else: |
| 499 | message = "because it has restricted licenses {0}. Which are not whitelisted in LICENSE_FLAGS_WHITELIST".format( |
| 500 | ", ".join("'{0}'".format(f) for f in unmatched_license_flags)) |
| 501 | bb.debug(1, "Skipping %s %s" % (pn, message)) |
| 502 | raise bb.parse.SkipRecipe(message) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 503 | |
| 504 | # If we're building a target package we need to use fakeroot (pseudo) |
| 505 | # in order to capture permissions, owners, groups and special files |
| 506 | if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d): |
Brad Bishop | 64c979e | 2019-11-04 13:55:29 -0500 | [diff] [blame] | 507 | d.appendVarFlag('do_prepare_recipe_sysroot', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 508 | d.setVarFlag('do_unpack', 'umask', '022') |
| 509 | d.setVarFlag('do_configure', 'umask', '022') |
| 510 | d.setVarFlag('do_compile', 'umask', '022') |
| 511 | d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 512 | d.setVarFlag('do_install', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 513 | d.setVarFlag('do_install', 'umask', '022') |
| 514 | d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 515 | d.setVarFlag('do_package', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 516 | d.setVarFlag('do_package', 'umask', '022') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 517 | d.setVarFlag('do_package_setscene', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 518 | d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 519 | d.setVarFlag('do_devshell', 'fakeroot', '1') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 520 | d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 521 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 522 | need_machine = d.getVar('COMPATIBLE_MACHINE') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 523 | if need_machine and not d.getVar('PARSE_ALL_RECIPES', False): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 524 | import re |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 525 | compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 526 | for m in compat_machines: |
| 527 | if re.match(need_machine, m): |
| 528 | break |
| 529 | else: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 530 | raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE')) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 531 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 532 | source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) or d.getVar('PARSE_ALL_RECIPES', False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 533 | if not source_mirror_fetch: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 534 | need_host = d.getVar('COMPATIBLE_HOST') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 535 | if need_host: |
| 536 | import re |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 537 | this_host = d.getVar('HOST_SYS') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 538 | if not re.match(need_host, this_host): |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 539 | raise bb.parse.SkipRecipe("incompatible with host %s (not in COMPATIBLE_HOST)" % this_host) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 540 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 541 | bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 542 | |
| 543 | check_license = False if pn.startswith("nativesdk-") else True |
| 544 | for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}", |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 545 | "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}", |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 546 | "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]: |
| 547 | if pn.endswith(d.expand(t)): |
| 548 | check_license = False |
| 549 | if pn.startswith("gcc-source-"): |
| 550 | check_license = False |
| 551 | |
| 552 | if check_license and bad_licenses: |
| 553 | bad_licenses = expand_wildcard_licenses(d, bad_licenses) |
| 554 | |
| 555 | whitelist = [] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 556 | for lic in bad_licenses: |
| 557 | spdx_license = return_spdx(d, lic) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 558 | whitelist.extend((d.getVar("WHITELIST_" + lic) or "").split()) |
| 559 | if spdx_license: |
| 560 | whitelist.extend((d.getVar("WHITELIST_" + spdx_license) or "").split()) |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 561 | |
| 562 | if pn in whitelist: |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 563 | ''' |
| 564 | We need to track what we are whitelisting and why. If pn is |
| 565 | incompatible we need to be able to note that the image that |
| 566 | is created may infact contain incompatible licenses despite |
| 567 | INCOMPATIBLE_LICENSE being set. |
| 568 | ''' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 569 | bb.note("Including %s as buildable despite it having an incompatible license because it has been whitelisted" % pn) |
| 570 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 571 | pkgs = d.getVar('PACKAGES').split() |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 572 | skipped_pkgs = {} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 573 | unskipped_pkgs = [] |
| 574 | for pkg in pkgs: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 575 | incompatible_lic = incompatible_license(d, bad_licenses, pkg) |
| 576 | if incompatible_lic: |
| 577 | skipped_pkgs[pkg] = incompatible_lic |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 578 | else: |
| 579 | unskipped_pkgs.append(pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 580 | if unskipped_pkgs: |
| 581 | for pkg in skipped_pkgs: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 582 | bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg]))) |
Andrew Geissler | 1e34c2d | 2020-05-29 16:02:59 -0500 | [diff] [blame] | 583 | d.setVar('LICENSE_EXCLUSION-' + pkg, ' '.join(skipped_pkgs[pkg])) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 584 | for pkg in unskipped_pkgs: |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 585 | bb.debug(1, "Including the package %s" % pkg) |
| 586 | else: |
| 587 | incompatible_lic = incompatible_license(d, bad_licenses) |
| 588 | for pkg in skipped_pkgs: |
| 589 | incompatible_lic += skipped_pkgs[pkg] |
| 590 | incompatible_lic = sorted(list(set(incompatible_lic))) |
| 591 | |
| 592 | if incompatible_lic: |
| 593 | bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic))) |
| 594 | raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 595 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 596 | needsrcrev = False |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 597 | srcuri = d.getVar('SRC_URI') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 598 | for uri in srcuri.split(): |
| 599 | (scheme, _ , path) = bb.fetch.decodeurl(uri)[:3] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 600 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 601 | # HTTP/FTP use the wget fetcher |
| 602 | if scheme in ("http", "https", "ftp"): |
| 603 | d.appendVarFlag('do_fetch', 'depends', ' wget-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 604 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 605 | # Svn packages should DEPEND on subversion-native |
| 606 | if scheme == "svn": |
| 607 | needsrcrev = True |
| 608 | d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 609 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 610 | # Git packages should DEPEND on git-native |
| 611 | elif scheme in ("git", "gitsm"): |
| 612 | needsrcrev = True |
| 613 | d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 614 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 615 | # Mercurial packages should DEPEND on mercurial-native |
| 616 | elif scheme == "hg": |
| 617 | needsrcrev = True |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 618 | d.appendVar("EXTRANATIVEPATH", ' python3-native ') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 619 | d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 620 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 621 | # Perforce packages support SRCREV = "${AUTOREV}" |
| 622 | elif scheme == "p4": |
| 623 | needsrcrev = True |
| 624 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 625 | # OSC packages should DEPEND on osc-native |
| 626 | elif scheme == "osc": |
| 627 | d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 628 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 629 | elif scheme == "npm": |
| 630 | d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 631 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 632 | # *.lz4 should DEPEND on lz4-native for unpacking |
| 633 | if path.endswith('.lz4'): |
| 634 | d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot') |
| 635 | |
| 636 | # *.lz should DEPEND on lzip-native for unpacking |
| 637 | elif path.endswith('.lz'): |
| 638 | d.appendVarFlag('do_unpack', 'depends', ' lzip-native:do_populate_sysroot') |
| 639 | |
| 640 | # *.xz should DEPEND on xz-native for unpacking |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 641 | elif path.endswith('.xz') or path.endswith('.txz'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 642 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
| 643 | |
| 644 | # .zip should DEPEND on unzip-native for unpacking |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 645 | elif path.endswith('.zip') or path.endswith('.jar'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 646 | d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot') |
| 647 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 648 | # Some rpm files may be compressed internally using xz (for example, rpms from Fedora) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 649 | elif path.endswith('.rpm'): |
| 650 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 651 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 652 | # *.deb should DEPEND on xz-native for unpacking |
| 653 | elif path.endswith('.deb'): |
| 654 | d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot') |
| 655 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 656 | if needsrcrev: |
| 657 | d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 658 | |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 659 | # Gather all named SRCREVs to add to the sstate hash calculation |
| 660 | # This anonymous python snippet is called multiple times so we |
| 661 | # need to be careful to not double up the appends here and cause |
| 662 | # the base hash to mismatch the task hash |
| 663 | for uri in srcuri.split(): |
| 664 | parm = bb.fetch.decodeurl(uri)[5] |
| 665 | uri_names = parm.get("name", "").split(",") |
| 666 | for uri_name in filter(None, uri_names): |
| 667 | srcrev_name = "SRCREV_{}".format(uri_name) |
| 668 | if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split(): |
| 669 | d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name)) |
| 670 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 671 | set_packagetriplet(d) |
| 672 | |
| 673 | # 'multimachine' handling |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 674 | mach_arch = d.getVar('MACHINE_ARCH') |
| 675 | pkg_arch = d.getVar('PACKAGE_ARCH') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 676 | |
| 677 | if (pkg_arch == mach_arch): |
| 678 | # Already machine specific - nothing further to do |
| 679 | return |
| 680 | |
| 681 | # |
| 682 | # We always try to scan SRC_URI for urls with machine overrides |
| 683 | # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0 |
| 684 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 685 | override = d.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 686 | if override != '0': |
| 687 | paths = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 688 | fpaths = (d.getVar('FILESPATH') or '').split(':') |
| 689 | machine = d.getVar('MACHINE') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 690 | for p in fpaths: |
| 691 | if os.path.basename(p) == machine and os.path.isdir(p): |
| 692 | paths.append(p) |
| 693 | |
| 694 | if len(paths) != 0: |
| 695 | for s in srcuri.split(): |
| 696 | if not s.startswith("file://"): |
| 697 | continue |
| 698 | fetcher = bb.fetch2.Fetch([s], d) |
| 699 | local = fetcher.localpath(s) |
| 700 | for mp in paths: |
| 701 | if local.startswith(mp): |
| 702 | #bb.note("overriding PACKAGE_ARCH from %s to %s for %s" % (pkg_arch, mach_arch, pn)) |
| 703 | d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}") |
| 704 | return |
| 705 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 706 | packages = d.getVar('PACKAGES').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 707 | for pkg in packages: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 708 | pkgarch = d.getVar("PACKAGE_ARCH_%s" % pkg) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 709 | |
| 710 | # We could look for != PACKAGE_ARCH here but how to choose |
| 711 | # if multiple differences are present? |
| 712 | # Look through PACKAGE_ARCHS for the priority order? |
| 713 | if pkgarch and pkgarch == mach_arch: |
| 714 | d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}") |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 715 | 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")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | addtask cleansstate after do_clean |
| 719 | python do_cleansstate() { |
| 720 | sstate_clean_cachefiles(d) |
| 721 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 722 | addtask cleanall after do_cleansstate |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 723 | do_cleansstate[nostamp] = "1" |
| 724 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 725 | python do_cleanall() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 726 | src_uri = (d.getVar('SRC_URI') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 727 | if len(src_uri) == 0: |
| 728 | return |
| 729 | |
| 730 | try: |
| 731 | fetcher = bb.fetch2.Fetch(src_uri, d) |
| 732 | fetcher.clean() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 733 | except bb.fetch2.BBFetchException as e: |
| 734 | bb.fatal(str(e)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 735 | } |
| 736 | do_cleanall[nostamp] = "1" |
| 737 | |
| 738 | |
| 739 | EXPORT_FUNCTIONS do_fetch do_unpack do_configure do_compile do_install do_package |