blob: bdb3ac33c671930abbc2a3f308f29261939a3ca0 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001BB_DEFAULT_TASK ?= "build"
2CLASSOVERRIDE ?= "class-target"
3
4inherit patch
5inherit staging
6
7inherit mirrors
8inherit utils
9inherit utility-tasks
10inherit metadata_scm
11inherit logging
12
Brad Bishop15ae2502019-06-18 21:44:24 -040013OE_EXTRA_IMPORTS ?= ""
14
Andrew Jefferyecdf5f12022-03-01 01:09:46 +103015OE_IMPORTS += "os sys time oe.path oe.utils oe.types oe.package oe.packagegroup oe.sstatesig oe.lsb oe.cachedpath oe.license oe.qa oe.reproducible oe.rust ${OE_EXTRA_IMPORTS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016OE_IMPORTS[type] = "list"
17
Brad Bishopf3fd2882019-06-21 08:06:37 -040018PACKAGECONFIG_CONFARGS ??= ""
19
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020def oe_import(d):
21 import sys
22
Patrick Williams45852732022-04-02 08:58:32 -050023 bbpath = [os.path.join(dir, "lib") for dir in d.getVar("BBPATH").split(":")]
24 sys.path[0:0] = [dir for dir in bbpath if dir not in sys.path]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025
26 import oe.data
27 for toimport in oe.data.typed_value("OE_IMPORTS", d):
Brad Bishop00e122a2019-10-05 11:10:57 -040028 try:
Patrick Williams45852732022-04-02 08:58:32 -050029 # Make a python object accessible from the metadata
30 bb.utils._context[toimport.split(".", 1)[0]] = __import__(toimport)
Brad Bishop00e122a2019-10-05 11:10:57 -040031 except AttributeError as e:
32 bb.error("Error importing OE modules: %s" % str(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 return ""
34
35# We need the oe module name space early (before INHERITs get added)
36OE_IMPORTED := "${@oe_import(d)}"
37
38def lsb_distro_identifier(d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039 adjust = d.getVar('LSB_DISTRO_ADJUST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040 adjust_func = None
41 if adjust:
42 try:
43 adjust_func = globals()[adjust]
44 except KeyError:
45 pass
46 return oe.lsb.distro_identifier(adjust_func)
47
48die() {
49 bbfatal_log "$*"
50}
51
52oe_runmake_call() {
53 bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
54 ${MAKE} ${EXTRA_OEMAKE} "$@"
55}
56
57oe_runmake() {
58 oe_runmake_call "$@" || die "oe_runmake failed"
59}
60
61
Patrick Williams213cb262021-08-07 19:21:33 -050062def get_base_dep(d):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050063 if d.getVar('INHIBIT_DEFAULT_DEPS', False):
64 return ""
65 return "${BASE_DEFAULT_DEPS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000067BASE_DEFAULT_DEPS = "virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}compilerlibs virtual/libc"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068
Brad Bishopd7bf8c12018-02-25 22:55:05 -050069BASEDEPENDS = ""
Patrick Williams213cb262021-08-07 19:21:33 -050070BASEDEPENDS:class-target = "${@get_base_dep(d)}"
71BASEDEPENDS:class-nativesdk = "${@get_base_dep(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072
Patrick Williams213cb262021-08-07 19:21:33 -050073DEPENDS:prepend="${BASEDEPENDS} "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074
75FILESPATH = "${@base_set_filespath(["${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files"], d)}"
76# THISDIR only works properly with imediate expansion as it has to run
77# in the context of the location its used (:=)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078THISDIR = "${@os.path.dirname(d.getVar('FILE'))}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079
80def extra_path_elements(d):
81 path = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050082 elements = (d.getVar('EXTRANATIVEPATH') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 for e in elements:
84 path = path + "${STAGING_BINDIR_NATIVE}/" + e + ":"
85 return path
86
Patrick Williams213cb262021-08-07 19:21:33 -050087PATH:prepend = "${@extra_path_elements(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088
89def get_lic_checksum_file_list(d):
90 filelist = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -050091 lic_files = d.getVar("LIC_FILES_CHKSUM") or ''
92 tmpdir = d.getVar("TMPDIR")
93 s = d.getVar("S")
94 b = d.getVar("B")
95 workdir = d.getVar("WORKDIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096
97 urls = lic_files.split()
98 for url in urls:
99 # We only care about items that are absolute paths since
100 # any others should be covered by SRC_URI.
101 try:
Brad Bishop220d5532018-08-14 00:59:39 +0100102 (method, host, path, user, pswd, parm) = bb.fetch.decodeurl(url)
103 if method != "file" or not path:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600104 raise bb.fetch.MalformedUrl(url)
105
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500106 if path[0] == '/':
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107 if path.startswith((tmpdir, s, b, workdir)):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108 continue
109 filelist.append(path + ":" + str(os.path.exists(path)))
110 except bb.fetch.MalformedUrl:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500111 bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112 return " ".join(filelist)
113
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500114def setup_hosttools_dir(dest, toolsvar, d, fatal=True):
115 tools = d.getVar(toolsvar).split()
116 origbbenv = d.getVar("BB_ORIGENV", False)
117 path = origbbenv.getVar("PATH")
Andrew Geisslerd5838332022-05-27 11:33:10 -0500118 # Need to ignore our own scripts directories to avoid circular links
119 for p in path.split(":"):
120 if p.endswith("/scripts"):
121 path = path.replace(p, "/ignoreme")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500122 bb.utils.mkdirhier(dest)
123 notfound = []
124 for tool in tools:
125 desttool = os.path.join(dest, tool)
126 if not os.path.exists(desttool):
Andrew Geissler82c905d2020-04-13 13:39:40 -0500127 # clean up dead symlink
128 if os.path.islink(desttool):
129 os.unlink(desttool)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500130 srctool = bb.utils.which(path, tool, executable=True)
Brad Bishop19323692019-04-05 15:28:33 -0400131 # gcc/g++ may link to ccache on some hosts, e.g.,
132 # /usr/local/bin/ccache/gcc -> /usr/bin/ccache, then which(gcc)
133 # would return /usr/local/bin/ccache/gcc, but what we need is
134 # /usr/bin/gcc, this code can check and fix that.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500135 if "ccache" in srctool:
136 srctool = bb.utils.which(path, tool, executable=True, direction=1)
137 if srctool:
138 os.symlink(srctool, desttool)
139 else:
140 notfound.append(tool)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800141
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500142 if notfound and fatal:
143 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))
144
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145addtask fetch
146do_fetch[dirs] = "${DL_DIR}"
147do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
148do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}"
149do_fetch[vardeps] += "SRCREV"
Andrew Geissler595f6302022-01-24 19:11:47 +0000150do_fetch[network] = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151python base_do_fetch() {
152
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500153 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500154 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155 return
156
157 try:
158 fetcher = bb.fetch2.Fetch(src_uri, d)
159 fetcher.download()
160 except bb.fetch2.BBFetchException as e:
Andrew Geisslereff27472021-10-29 15:35:00 -0500161 bb.fatal("Bitbake Fetcher Error: " + repr(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162}
163
164addtask unpack after do_fetch
165do_unpack[dirs] = "${WORKDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600166
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800167do_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 Bishop316dfdd2018-06-25 12:45:53 -0400168
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169python base_do_unpack() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500170 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500171 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172 return
173
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 try:
175 fetcher = bb.fetch2.Fetch(src_uri, d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500176 fetcher.unpack(d.getVar('WORKDIR'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 except bb.fetch2.BBFetchException as e:
Andrew Geisslereff27472021-10-29 15:35:00 -0500178 bb.fatal("Bitbake Fetcher Error: " + repr(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179}
180
Andrew Geisslereff27472021-10-29 15:35:00 -0500181SSTATETASKS += "do_deploy_source_date_epoch"
182
183do_deploy_source_date_epoch () {
184 mkdir -p ${SDE_DEPLOYDIR}
185 if [ -e ${SDE_FILE} ]; then
186 echo "Deploying SDE from ${SDE_FILE} -> ${SDE_DEPLOYDIR}."
187 cp -p ${SDE_FILE} ${SDE_DEPLOYDIR}/__source_date_epoch.txt
188 else
189 echo "${SDE_FILE} not found!"
190 fi
191}
192
193python do_deploy_source_date_epoch_setscene () {
194 sstate_setscene(d)
195 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
196 sde_file = os.path.join(d.getVar('SDE_DEPLOYDIR'), '__source_date_epoch.txt')
197 if os.path.exists(sde_file):
198 target = d.getVar('SDE_FILE')
199 bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
200 bb.utils.rename(sde_file, target)
201 else:
202 bb.debug(1, "%s not found!" % sde_file)
203}
204
205do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}"
206do_deploy_source_date_epoch[sstate-plaindirs] = "${SDE_DEPLOYDIR}"
207addtask do_deploy_source_date_epoch_setscene
208addtask do_deploy_source_date_epoch before do_configure after do_patch
209
210python create_source_date_epoch_stamp() {
211 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
212 oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d)
213}
214do_unpack[postfuncs] += "create_source_date_epoch_stamp"
215
216def get_source_date_epoch_value(d):
217 return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
218
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500219def get_layers_branch_rev(d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500220 layers = (d.getVar("BBLAYERS") or "").split()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500221 layers_branch_rev = ["%-20s = \"%s:%s\"" % (os.path.basename(i), \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500222 base_get_metadata_git_branch(i, None).strip(), \
223 base_get_metadata_git_revision(i, None)) \
224 for i in layers]
225 i = len(layers_branch_rev)-1
226 p1 = layers_branch_rev[i].find("=")
227 s1 = layers_branch_rev[i][p1:]
228 while i > 0:
229 p2 = layers_branch_rev[i-1].find("=")
230 s2= layers_branch_rev[i-1][p2:]
231 if s1 == s2:
232 layers_branch_rev[i-1] = layers_branch_rev[i-1][0:p2]
233 i -= 1
234 else:
235 i -= 1
236 p1 = layers_branch_rev[i].find("=")
237 s1= layers_branch_rev[i][p1:]
238 return layers_branch_rev
239
240
241BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars"
242BUILDCFG_FUNCS[type] = "list"
243
244def buildcfg_vars(d):
245 statusvars = oe.data.typed_value('BUILDCFG_VARS', d)
246 for var in statusvars:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500247 value = d.getVar(var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500248 if value is not None:
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500249 yield '%-20s = "%s"' % (var, value)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500250
251def buildcfg_neededvars(d):
252 needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", d)
253 pesteruser = []
254 for v in needed_vars:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500255 val = d.getVar(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500256 if not val or val == 'INVALID':
257 pesteruser.append(v)
258
259 if pesteruser:
260 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))
261
262addhandler base_eventhandler
Brad Bishop19323692019-04-05 15:28:33 -0400263base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500264python base_eventhandler() {
265 import bb.runqueue
266
267 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400268 if not d.getVar("NATIVELSBSTRING", False):
269 d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600270 d.setVar("ORIGNATIVELSBSTRING", d.getVar("NATIVELSBSTRING", False))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400271 d.setVar('BB_VERSION', bb.__version__)
Brad Bishop19323692019-04-05 15:28:33 -0400272
273 # There might be no bb.event.ConfigParsed event if bitbake server is
274 # running, so check bb.event.BuildStarted too to make sure ${HOSTTOOLS_DIR}
275 # exists.
276 if isinstance(e, bb.event.ConfigParsed) or \
277 (isinstance(e, bb.event.BuildStarted) and not os.path.exists(d.getVar('HOSTTOOLS_DIR'))):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500278 # Works with the line in layer.conf which changes PATH to point here
279 setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d)
280 setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500282 if isinstance(e, bb.event.MultiConfigParsed):
283 # We need to expand SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS in each of the multiconfig data stores
284 # own contexts so the variables get expanded correctly for that arch, then inject back into
285 # the main data store.
286 deps = []
287 for config in e.mcdata:
288 deps.append(e.mcdata[config].getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS"))
289 deps = " ".join(deps)
290 e.mcdata[''].setVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", deps)
291
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500292 if isinstance(e, bb.event.BuildStarted):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400293 localdata = bb.data.createCopy(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500294 statuslines = []
295 for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata):
296 g = globals()
297 if func not in g:
298 bb.warn("Build configuration function '%s' does not exist" % func)
299 else:
300 flines = g[func](localdata)
301 if flines:
302 statuslines.extend(flines)
303
Brad Bishop316dfdd2018-06-25 12:45:53 -0400304 statusheader = d.getVar('BUILDCFG_HEADER')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500305 if statusheader:
306 bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500307
308 # This code is to silence warnings where the SDK variables overwrite the
309 # target ones and we'd see dulpicate key names overwriting each other
310 # for various PREFERRED_PROVIDERS
311 if isinstance(e, bb.event.RecipePreFinalise):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400312 if d.getVar("TARGET_PREFIX") == d.getVar("SDK_PREFIX"):
313 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400314 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc")
315 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++")
316 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500317
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500318 if isinstance(e, bb.event.RecipeParsed):
319 #
320 # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set
321 # skip parsing for all the other providers which will mean they get uninstalled from the
322 # sysroot since they're now "unreachable". This makes switching virtual/kernel work in
323 # particular.
324 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500325 pn = d.getVar('PN')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500326 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False)
327 if not source_mirror_fetch:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500328 provs = (d.getVar("PROVIDES") or "").split()
Andrew Geissler9aee5002022-03-30 16:27:02 +0000329 multiprovidersallowed = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500330 for p in provs:
Andrew Geissler9aee5002022-03-30 16:27:02 +0000331 if p.startswith("virtual/") and p not in multiprovidersallowed:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500332 profprov = d.getVar("PREFERRED_PROVIDER_" + p)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500333 if profprov and pn != profprov:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400334 raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (p, profprov, pn))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500335}
336
337CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
338CLEANBROKEN = "0"
339
340addtask configure after do_patch
341do_configure[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500342base_do_configure() {
343 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
344 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
345 cd ${B}
346 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
347 oe_runmake clean
348 fi
Brad Bishopc4ea0752018-11-15 14:30:15 -0800349 # -ignore_readdir_race does not work correctly with -delete;
350 # use xargs to avoid spurious build failures
351 find ${B} -ignore_readdir_race -name \*.la -type f -print0 | xargs -0 rm -f
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500352 fi
353 fi
354 if [ -n "${CONFIGURESTAMPFILE}" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500355 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500356 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
357 fi
358}
359
360addtask compile after do_configure
361do_compile[dirs] = "${B}"
362base_do_compile() {
363 if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then
364 oe_runmake || die "make failed"
365 else
366 bbnote "nothing to compile"
367 fi
368}
369
370addtask install after do_compile
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600371do_install[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500372# Remove and re-create ${D} so that is it guaranteed to be empty
373do_install[cleandirs] = "${D}"
374
375base_do_install() {
376 :
377}
378
379base_do_package() {
380 :
381}
382
383addtask build after do_populate_sysroot
384do_build[noexec] = "1"
385do_build[recrdeptask] += "do_deploy"
386do_build () {
387 :
388}
389
390def set_packagetriplet(d):
391 archs = []
392 tos = []
393 tvs = []
394
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500395 archs.append(d.getVar("PACKAGE_ARCHS").split())
396 tos.append(d.getVar("TARGET_OS"))
397 tvs.append(d.getVar("TARGET_VENDOR"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500398
399 def settriplet(d, varname, archs, tos, tvs):
400 triplets = []
401 for i in range(len(archs)):
402 for arch in archs[i]:
403 triplets.append(arch + tvs[i] + "-" + tos[i])
404 triplets.reverse()
405 d.setVar(varname, " ".join(triplets))
406
407 settriplet(d, "PKGTRIPLETS", archs, tos, tvs)
408
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500409 variants = d.getVar("MULTILIB_VARIANTS") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500410 for item in variants.split():
411 localdata = bb.data.createCopy(d)
412 overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
413 localdata.setVar("OVERRIDES", overrides)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500414
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500415 archs.append(localdata.getVar("PACKAGE_ARCHS").split())
416 tos.append(localdata.getVar("TARGET_OS"))
417 tvs.append(localdata.getVar("TARGET_VENDOR"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500418
419 settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs)
420
421python () {
422 import string, re
423
Brad Bishop316dfdd2018-06-25 12:45:53 -0400424 # Handle backfilling
425 oe.utils.features_backfill("DISTRO_FEATURES", d)
426 oe.utils.features_backfill("MACHINE_FEATURES", d)
427
Andrew Geisslerf0343792020-11-18 10:42:21 -0600428 if d.getVar("S")[-1] == '/':
429 bb.warn("Recipe %s sets S variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("S")))
430 if d.getVar("B")[-1] == '/':
431 bb.warn("Recipe %s sets B variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("B")))
432
433 if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("S")):
434 d.appendVar("PSEUDO_IGNORE_PATHS", ",${S}")
435 if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("B")):
436 d.appendVar("PSEUDO_IGNORE_PATHS", ",${B}")
437
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000438 # To add a recipe to the skip list , set:
439 # SKIP_RECIPE[pn] = "message"
440 pn = d.getVar('PN')
441 skip_msg = d.getVarFlag('SKIP_RECIPE', pn)
442 if skip_msg:
443 bb.debug(1, "Skipping %s %s" % (pn, skip_msg))
444 raise bb.parse.SkipRecipe("Recipe will be skipped because: %s" % (skip_msg))
445
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500446 # Handle PACKAGECONFIG
447 #
448 # These take the form:
449 #
450 # PACKAGECONFIG ??= "<default options>"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500451 # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends,foo_runtime_recommends,foo_conflict_packageconfig"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500452 pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {}
453 if pkgconfigflags:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500454 pkgconfig = (d.getVar('PACKAGECONFIG') or "").split()
455 pn = d.getVar("PN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500456
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500457 mlprefix = d.getVar("MLPREFIX")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500458
459 def expandFilter(appends, extension, prefix):
460 appends = bb.utils.explode_deps(d.expand(" ".join(appends)))
461 newappends = []
462 for a in appends:
463 if a.endswith("-native") or ("-cross-" in a):
464 newappends.append(a)
465 elif a.startswith("virtual/"):
466 subs = a.split("/", 1)[1]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500467 if subs.startswith(prefix):
468 newappends.append(a + extension)
469 else:
470 newappends.append("virtual/" + prefix + subs + extension)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500471 else:
472 if a.startswith(prefix):
473 newappends.append(a + extension)
474 else:
475 newappends.append(prefix + a + extension)
476 return newappends
477
478 def appendVar(varname, appends):
479 if not appends:
480 return
481 if varname.find("DEPENDS") != -1:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500482 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) :
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500483 appends = expandFilter(appends, "", "nativesdk-")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500484 elif bb.data.inherits_class('native', d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500485 appends = expandFilter(appends, "-native", "")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500486 elif mlprefix:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500487 appends = expandFilter(appends, "", mlprefix)
488 varname = d.expand(varname)
489 d.appendVar(varname, " " + " ".join(appends))
490
491 extradeps = []
492 extrardeps = []
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500493 extrarrecs = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500494 extraconf = []
495 for flag, flagval in sorted(pkgconfigflags.items()):
496 items = flagval.split(",")
497 num = len(items)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500498 if num > 6:
499 bb.error("%s: PACKAGECONFIG[%s] Only enable,disable,depend,rdepend,rrecommend,conflict_packageconfig can be specified!"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500500 % (d.getVar('PN'), flag))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500501
502 if flag in pkgconfig:
503 if num >= 3 and items[2]:
504 extradeps.append(items[2])
505 if num >= 4 and items[3]:
506 extrardeps.append(items[3])
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500507 if num >= 5 and items[4]:
508 extrarrecs.append(items[4])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500509 if num >= 1 and items[0]:
510 extraconf.append(items[0])
511 elif num >= 2 and items[1]:
512 extraconf.append(items[1])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500513
514 if num >= 6 and items[5]:
515 conflicts = set(items[5].split())
516 invalid = conflicts.difference(set(pkgconfigflags.keys()))
517 if invalid:
518 bb.error("%s: PACKAGECONFIG[%s] Invalid conflict package config%s '%s' specified."
519 % (d.getVar('PN'), flag, 's' if len(invalid) > 1 else '', ' '.join(invalid)))
520
521 if flag in pkgconfig:
522 intersec = conflicts.intersection(set(pkgconfig))
523 if intersec:
524 bb.fatal("%s: PACKAGECONFIG[%s] Conflict package config%s '%s' set in PACKAGECONFIG."
525 % (d.getVar('PN'), flag, 's' if len(intersec) > 1 else '', ' '.join(intersec)))
526
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500527 appendVar('DEPENDS', extradeps)
Patrick Williams213cb262021-08-07 19:21:33 -0500528 appendVar('RDEPENDS:${PN}', extrardeps)
529 appendVar('RRECOMMENDS:${PN}', extrarrecs)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500530 appendVar('PACKAGECONFIG_CONFARGS', extraconf)
531
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500532 pn = d.getVar('PN')
533 license = d.getVar('LICENSE')
Brad Bishop316dfdd2018-06-25 12:45:53 -0400534 if license == "INVALID" and pn != "defaultpkgname":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500535 bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn)
536
537 if bb.data.inherits_class('license', d):
538 check_license_format(d)
Brad Bishop19323692019-04-05 15:28:33 -0400539 unmatched_license_flags = check_license_flags(d)
540 if unmatched_license_flags:
541 if len(unmatched_license_flags) == 1:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000542 message = "because it has a restricted license '{0}'. Which is not listed in LICENSE_FLAGS_ACCEPTED".format(unmatched_license_flags[0])
Brad Bishop19323692019-04-05 15:28:33 -0400543 else:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000544 message = "because it has restricted licenses {0}. Which are not listed in LICENSE_FLAGS_ACCEPTED".format(
Brad Bishop19323692019-04-05 15:28:33 -0400545 ", ".join("'{0}'".format(f) for f in unmatched_license_flags))
546 bb.debug(1, "Skipping %s %s" % (pn, message))
547 raise bb.parse.SkipRecipe(message)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500548
549 # If we're building a target package we need to use fakeroot (pseudo)
550 # in order to capture permissions, owners, groups and special files
551 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
Brad Bishop64c979e2019-11-04 13:55:29 -0500552 d.appendVarFlag('do_prepare_recipe_sysroot', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500553 d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500554 d.setVarFlag('do_install', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500555 d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500556 d.setVarFlag('do_package', 'fakeroot', '1')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500557 d.setVarFlag('do_package_setscene', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500558 d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500559 d.setVarFlag('do_devshell', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500560 d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500561
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500562 need_machine = d.getVar('COMPATIBLE_MACHINE')
Andrew Geissler82c905d2020-04-13 13:39:40 -0500563 if need_machine and not d.getVar('PARSE_ALL_RECIPES', False):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500564 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500565 compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500566 for m in compat_machines:
567 if re.match(need_machine, m):
568 break
569 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400570 raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE'))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500571
Andrew Geissler82c905d2020-04-13 13:39:40 -0500572 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) or d.getVar('PARSE_ALL_RECIPES', False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500573 if not source_mirror_fetch:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500574 need_host = d.getVar('COMPATIBLE_HOST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500575 if need_host:
576 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500577 this_host = d.getVar('HOST_SYS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500578 if not re.match(need_host, this_host):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400579 raise bb.parse.SkipRecipe("incompatible with host %s (not in COMPATIBLE_HOST)" % this_host)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500580
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500581 bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500582
583 check_license = False if pn.startswith("nativesdk-") else True
584 for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}",
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600585 "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500586 "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]:
587 if pn.endswith(d.expand(t)):
588 check_license = False
589 if pn.startswith("gcc-source-"):
590 check_license = False
591
592 if check_license and bad_licenses:
593 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
594
Andrew Geissler9aee5002022-03-30 16:27:02 +0000595 exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
Andrew Geissler82c905d2020-04-13 13:39:40 -0500596
Andrew Geissler9aee5002022-03-30 16:27:02 +0000597 for lic_exception in exceptions:
598 if ":" in lic_exception:
599 lic_exception.split(":")[0]
600 if lic_exception in oe.license.obsolete_license_list():
601 bb.fatal("Invalid license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
602
603 pkgs = d.getVar('PACKAGES').split()
604 skipped_pkgs = {}
605 unskipped_pkgs = []
606 for pkg in pkgs:
607 remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
608
609 incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg)
610 if incompatible_lic:
611 skipped_pkgs[pkg] = incompatible_lic
Andrew Geissler82c905d2020-04-13 13:39:40 -0500612 else:
Andrew Geissler9aee5002022-03-30 16:27:02 +0000613 unskipped_pkgs.append(pkg)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500614
Andrew Geissler9aee5002022-03-30 16:27:02 +0000615 if unskipped_pkgs:
616 for pkg in skipped_pkgs:
617 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
618 d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
619 for pkg in unskipped_pkgs:
620 bb.debug(1, "Including the package %s" % pkg)
621 else:
622 incompatible_lic = incompatible_license(d, bad_licenses)
623 for pkg in skipped_pkgs:
624 incompatible_lic += skipped_pkgs[pkg]
625 incompatible_lic = sorted(list(set(incompatible_lic)))
626
627 if incompatible_lic:
628 bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic)))
629 raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500630
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500631 needsrcrev = False
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500632 srcuri = d.getVar('SRC_URI')
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600633 for uri_string in srcuri.split():
634 uri = bb.fetch.URI(uri_string)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500635 # Also check downloadfilename as the URL path might not be useful for sniffing
636 path = uri.params.get("downloadfilename", uri.path)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500637
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500638 # HTTP/FTP use the wget fetcher
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600639 if uri.scheme in ("http", "https", "ftp"):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500640 d.appendVarFlag('do_fetch', 'depends', ' wget-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500641
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500642 # Svn packages should DEPEND on subversion-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600643 if uri.scheme == "svn":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500644 needsrcrev = True
645 d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500646
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500647 # Git packages should DEPEND on git-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600648 elif uri.scheme in ("git", "gitsm"):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500649 needsrcrev = True
650 d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500651
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500652 # Mercurial packages should DEPEND on mercurial-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600653 elif uri.scheme == "hg":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500654 needsrcrev = True
Andrew Geissler82c905d2020-04-13 13:39:40 -0500655 d.appendVar("EXTRANATIVEPATH", ' python3-native ')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500656 d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500657
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600658 # Perforce packages support SRCREV = "${AUTOREV}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600659 elif uri.scheme == "p4":
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600660 needsrcrev = True
661
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500662 # OSC packages should DEPEND on osc-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600663 elif uri.scheme == "osc":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500664 d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500665
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600666 elif uri.scheme == "npm":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500667 d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500668
Andrew Geissler595f6302022-01-24 19:11:47 +0000669 elif uri.scheme == "repo":
670 needsrcrev = True
671 d.appendVarFlag('do_fetch', 'depends', ' repo-native:do_populate_sysroot')
672
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500673 # *.lz4 should DEPEND on lz4-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500674 if path.endswith('.lz4'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500675 d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot')
676
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500677 # *.zst should DEPEND on zstd-native for unpacking
678 elif path.endswith('.zst'):
679 d.appendVarFlag('do_unpack', 'depends', ' zstd-native:do_populate_sysroot')
680
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500681 # *.lz should DEPEND on lzip-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500682 elif path.endswith('.lz'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500683 d.appendVarFlag('do_unpack', 'depends', ' lzip-native:do_populate_sysroot')
684
685 # *.xz should DEPEND on xz-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500686 elif path.endswith('.xz') or path.endswith('.txz'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500687 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
688
689 # .zip should DEPEND on unzip-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500690 elif path.endswith('.zip') or path.endswith('.jar'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500691 d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot')
692
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800693 # Some rpm files may be compressed internally using xz (for example, rpms from Fedora)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500694 elif path.endswith('.rpm'):
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500695 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500696
Brad Bishop316dfdd2018-06-25 12:45:53 -0400697 # *.deb should DEPEND on xz-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500698 elif path.endswith('.deb'):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400699 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
700
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500701 if needsrcrev:
702 d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500703
Brad Bishop15ae2502019-06-18 21:44:24 -0400704 # Gather all named SRCREVs to add to the sstate hash calculation
705 # This anonymous python snippet is called multiple times so we
706 # need to be careful to not double up the appends here and cause
707 # the base hash to mismatch the task hash
708 for uri in srcuri.split():
709 parm = bb.fetch.decodeurl(uri)[5]
710 uri_names = parm.get("name", "").split(",")
711 for uri_name in filter(None, uri_names):
712 srcrev_name = "SRCREV_{}".format(uri_name)
713 if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split():
714 d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name))
715
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500716 set_packagetriplet(d)
717
718 # 'multimachine' handling
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500719 mach_arch = d.getVar('MACHINE_ARCH')
720 pkg_arch = d.getVar('PACKAGE_ARCH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500721
722 if (pkg_arch == mach_arch):
723 # Already machine specific - nothing further to do
724 return
725
726 #
727 # We always try to scan SRC_URI for urls with machine overrides
728 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
729 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500730 override = d.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500731 if override != '0':
732 paths = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500733 fpaths = (d.getVar('FILESPATH') or '').split(':')
734 machine = d.getVar('MACHINE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500735 for p in fpaths:
736 if os.path.basename(p) == machine and os.path.isdir(p):
737 paths.append(p)
738
Andrew Geisslereff27472021-10-29 15:35:00 -0500739 if paths:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500740 for s in srcuri.split():
741 if not s.startswith("file://"):
742 continue
743 fetcher = bb.fetch2.Fetch([s], d)
744 local = fetcher.localpath(s)
745 for mp in paths:
746 if local.startswith(mp):
747 #bb.note("overriding PACKAGE_ARCH from %s to %s for %s" % (pkg_arch, mach_arch, pn))
748 d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}")
749 return
750
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500751 packages = d.getVar('PACKAGES').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500752 for pkg in packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500753 pkgarch = d.getVar("PACKAGE_ARCH_%s" % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500754
755 # We could look for != PACKAGE_ARCH here but how to choose
756 # if multiple differences are present?
757 # Look through PACKAGE_ARCHS for the priority order?
758 if pkgarch and pkgarch == mach_arch:
759 d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500760 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 Williamsc124f4f2015-09-15 14:41:29 -0500761}
762
763addtask cleansstate after do_clean
764python do_cleansstate() {
765 sstate_clean_cachefiles(d)
766}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500767addtask cleanall after do_cleansstate
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500768do_cleansstate[nostamp] = "1"
769
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500770python do_cleanall() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500771 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500772 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500773 return
774
775 try:
776 fetcher = bb.fetch2.Fetch(src_uri, d)
777 fetcher.clean()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600778 except bb.fetch2.BBFetchException as e:
779 bb.fatal(str(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500780}
781do_cleanall[nostamp] = "1"
782
783
784EXPORT_FUNCTIONS do_fetch do_unpack do_configure do_compile do_install do_package