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