blob: 571b6754f22185bc103bccc1859fcc6010e2a9d6 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010inherit logging
11
Brad Bishop15ae2502019-06-18 21:44:24 -040012OE_EXTRA_IMPORTS ?= ""
13
Andrew Geissler78b72792022-06-14 06:47:25 -050014OE_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.buildcfg ${OE_EXTRA_IMPORTS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015OE_IMPORTS[type] = "list"
16
Brad Bishopf3fd2882019-06-21 08:06:37 -040017PACKAGECONFIG_CONFARGS ??= ""
18
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019def oe_import(d):
20 import sys
21
Patrick Williams45852732022-04-02 08:58:32 -050022 bbpath = [os.path.join(dir, "lib") for dir in d.getVar("BBPATH").split(":")]
23 sys.path[0:0] = [dir for dir in bbpath if dir not in sys.path]
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024
25 import oe.data
26 for toimport in oe.data.typed_value("OE_IMPORTS", d):
Brad Bishop00e122a2019-10-05 11:10:57 -040027 try:
Patrick Williams45852732022-04-02 08:58:32 -050028 # Make a python object accessible from the metadata
29 bb.utils._context[toimport.split(".", 1)[0]] = __import__(toimport)
Brad Bishop00e122a2019-10-05 11:10:57 -040030 except AttributeError as e:
31 bb.error("Error importing OE modules: %s" % str(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 return ""
33
34# We need the oe module name space early (before INHERITs get added)
35OE_IMPORTED := "${@oe_import(d)}"
36
Andrew Geissler78b72792022-06-14 06:47:25 -050037inherit metadata_scm
38
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039def lsb_distro_identifier(d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040 adjust = d.getVar('LSB_DISTRO_ADJUST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041 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
49die() {
50 bbfatal_log "$*"
51}
52
53oe_runmake_call() {
54 bbnote ${MAKE} ${EXTRA_OEMAKE} "$@"
55 ${MAKE} ${EXTRA_OEMAKE} "$@"
56}
57
58oe_runmake() {
59 oe_runmake_call "$@" || die "oe_runmake failed"
60}
61
62
Patrick Williams213cb262021-08-07 19:21:33 -050063def get_base_dep(d):
Brad Bishopd7bf8c12018-02-25 22:55:05 -050064 if d.getVar('INHIBIT_DEFAULT_DEPS', False):
65 return ""
66 return "${BASE_DEFAULT_DEPS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000068BASE_DEFAULT_DEPS = "virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}compilerlibs virtual/libc"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069
Brad Bishopd7bf8c12018-02-25 22:55:05 -050070BASEDEPENDS = ""
Patrick Williams213cb262021-08-07 19:21:33 -050071BASEDEPENDS:class-target = "${@get_base_dep(d)}"
72BASEDEPENDS:class-nativesdk = "${@get_base_dep(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073
Patrick Williams213cb262021-08-07 19:21:33 -050074DEPENDS:prepend="${BASEDEPENDS} "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075
76FILESPATH = "${@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 Bishop6e60e8b2018-02-01 10:27:11 -050079THISDIR = "${@os.path.dirname(d.getVar('FILE'))}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080
81def extra_path_elements(d):
82 path = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083 elements = (d.getVar('EXTRANATIVEPATH') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 for e in elements:
85 path = path + "${STAGING_BINDIR_NATIVE}/" + e + ":"
86 return path
87
Patrick Williams213cb262021-08-07 19:21:33 -050088PATH:prepend = "${@extra_path_elements(d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089
90def get_lic_checksum_file_list(d):
91 filelist = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092 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 Williamsc124f4f2015-09-15 14:41:29 -050097
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 Bishop220d5532018-08-14 00:59:39 +0100103 (method, host, path, user, pswd, parm) = bb.fetch.decodeurl(url)
104 if method != "file" or not path:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600105 raise bb.fetch.MalformedUrl(url)
106
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107 if path[0] == '/':
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500108 if path.startswith((tmpdir, s, b, workdir)):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109 continue
110 filelist.append(path + ":" + str(os.path.exists(path)))
111 except bb.fetch.MalformedUrl:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112 bb.fatal(d.getVar('PN') + ": LIC_FILES_CHKSUM contains an invalid URL: " + url)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 return " ".join(filelist)
114
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500115def 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")
Andrew Geisslerd5838332022-05-27 11:33:10 -0500119 # Need to ignore our own scripts directories to avoid circular links
120 for p in path.split(":"):
121 if p.endswith("/scripts"):
122 path = path.replace(p, "/ignoreme")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500123 bb.utils.mkdirhier(dest)
124 notfound = []
125 for tool in tools:
126 desttool = os.path.join(dest, tool)
127 if not os.path.exists(desttool):
Andrew Geissler82c905d2020-04-13 13:39:40 -0500128 # clean up dead symlink
129 if os.path.islink(desttool):
130 os.unlink(desttool)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500131 srctool = bb.utils.which(path, tool, executable=True)
Brad Bishop19323692019-04-05 15:28:33 -0400132 # gcc/g++ may link to ccache on some hosts, e.g.,
133 # /usr/local/bin/ccache/gcc -> /usr/bin/ccache, then which(gcc)
134 # would return /usr/local/bin/ccache/gcc, but what we need is
135 # /usr/bin/gcc, this code can check and fix that.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500136 if "ccache" in srctool:
137 srctool = bb.utils.which(path, tool, executable=True, direction=1)
138 if srctool:
139 os.symlink(srctool, desttool)
140 else:
141 notfound.append(tool)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800142
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500143 if notfound and fatal:
144 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))
145
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146addtask fetch
147do_fetch[dirs] = "${DL_DIR}"
148do_fetch[file-checksums] = "${@bb.fetch.get_checksum_file_list(d)}"
149do_fetch[file-checksums] += " ${@get_lic_checksum_file_list(d)}"
150do_fetch[vardeps] += "SRCREV"
Andrew Geissler595f6302022-01-24 19:11:47 +0000151do_fetch[network] = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500152python base_do_fetch() {
153
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500155 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156 return
157
158 try:
159 fetcher = bb.fetch2.Fetch(src_uri, d)
160 fetcher.download()
161 except bb.fetch2.BBFetchException as e:
Andrew Geisslereff27472021-10-29 15:35:00 -0500162 bb.fatal("Bitbake Fetcher Error: " + repr(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500163}
164
165addtask unpack after do_fetch
166do_unpack[dirs] = "${WORKDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600167
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800168do_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 -0400169
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170python base_do_unpack() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500171 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500172 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173 return
174
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175 try:
176 fetcher = bb.fetch2.Fetch(src_uri, d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500177 fetcher.unpack(d.getVar('WORKDIR'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178 except bb.fetch2.BBFetchException as e:
Andrew Geisslereff27472021-10-29 15:35:00 -0500179 bb.fatal("Bitbake Fetcher Error: " + repr(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180}
181
Andrew Geisslereff27472021-10-29 15:35:00 -0500182SSTATETASKS += "do_deploy_source_date_epoch"
183
184do_deploy_source_date_epoch () {
185 mkdir -p ${SDE_DEPLOYDIR}
186 if [ -e ${SDE_FILE} ]; then
187 echo "Deploying SDE from ${SDE_FILE} -> ${SDE_DEPLOYDIR}."
188 cp -p ${SDE_FILE} ${SDE_DEPLOYDIR}/__source_date_epoch.txt
189 else
190 echo "${SDE_FILE} not found!"
191 fi
192}
193
194python do_deploy_source_date_epoch_setscene () {
195 sstate_setscene(d)
196 bb.utils.mkdirhier(d.getVar('SDE_DIR'))
197 sde_file = os.path.join(d.getVar('SDE_DEPLOYDIR'), '__source_date_epoch.txt')
198 if os.path.exists(sde_file):
199 target = d.getVar('SDE_FILE')
200 bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
201 bb.utils.rename(sde_file, target)
202 else:
203 bb.debug(1, "%s not found!" % sde_file)
204}
205
206do_deploy_source_date_epoch[dirs] = "${SDE_DEPLOYDIR}"
207do_deploy_source_date_epoch[sstate-plaindirs] = "${SDE_DEPLOYDIR}"
208addtask do_deploy_source_date_epoch_setscene
209addtask do_deploy_source_date_epoch before do_configure after do_patch
210
211python create_source_date_epoch_stamp() {
Patrick Williamsdb4c27e2022-08-05 08:10:29 -0500212 # Version: 1
Andrew Geisslereff27472021-10-29 15:35:00 -0500213 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
214 oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d)
215}
216do_unpack[postfuncs] += "create_source_date_epoch_stamp"
217
218def get_source_date_epoch_value(d):
219 return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
220
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500221def get_layers_branch_rev(d):
Andrew Geissler78b72792022-06-14 06:47:25 -0500222 revisions = oe.buildcfg.get_layer_revisions(d)
223 layers_branch_rev = ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500224 i = len(layers_branch_rev)-1
225 p1 = layers_branch_rev[i].find("=")
226 s1 = layers_branch_rev[i][p1:]
227 while i > 0:
228 p2 = layers_branch_rev[i-1].find("=")
229 s2= layers_branch_rev[i-1][p2:]
230 if s1 == s2:
231 layers_branch_rev[i-1] = layers_branch_rev[i-1][0:p2]
232 i -= 1
233 else:
234 i -= 1
235 p1 = layers_branch_rev[i].find("=")
236 s1= layers_branch_rev[i][p1:]
237 return layers_branch_rev
238
239
240BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars"
241BUILDCFG_FUNCS[type] = "list"
242
243def buildcfg_vars(d):
244 statusvars = oe.data.typed_value('BUILDCFG_VARS', d)
245 for var in statusvars:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500246 value = d.getVar(var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500247 if value is not None:
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500248 yield '%-20s = "%s"' % (var, value)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500249
250def buildcfg_neededvars(d):
251 needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", d)
252 pesteruser = []
253 for v in needed_vars:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500254 val = d.getVar(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500255 if not val or val == 'INVALID':
256 pesteruser.append(v)
257
258 if pesteruser:
259 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))
260
261addhandler base_eventhandler
Brad Bishop19323692019-04-05 15:28:33 -0400262base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500263python base_eventhandler() {
264 import bb.runqueue
265
266 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400267 if not d.getVar("NATIVELSBSTRING", False):
268 d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600269 d.setVar("ORIGNATIVELSBSTRING", d.getVar("NATIVELSBSTRING", False))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400270 d.setVar('BB_VERSION', bb.__version__)
Brad Bishop19323692019-04-05 15:28:33 -0400271
272 # There might be no bb.event.ConfigParsed event if bitbake server is
273 # running, so check bb.event.BuildStarted too to make sure ${HOSTTOOLS_DIR}
274 # exists.
275 if isinstance(e, bb.event.ConfigParsed) or \
276 (isinstance(e, bb.event.BuildStarted) and not os.path.exists(d.getVar('HOSTTOOLS_DIR'))):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500277 # Works with the line in layer.conf which changes PATH to point here
278 setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d)
279 setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500281 if isinstance(e, bb.event.MultiConfigParsed):
282 # We need to expand SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS in each of the multiconfig data stores
283 # own contexts so the variables get expanded correctly for that arch, then inject back into
284 # the main data store.
285 deps = []
286 for config in e.mcdata:
287 deps.append(e.mcdata[config].getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS"))
288 deps = " ".join(deps)
289 e.mcdata[''].setVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", deps)
290
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500291 if isinstance(e, bb.event.BuildStarted):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400292 localdata = bb.data.createCopy(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500293 statuslines = []
294 for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata):
295 g = globals()
296 if func not in g:
297 bb.warn("Build configuration function '%s' does not exist" % func)
298 else:
299 flines = g[func](localdata)
300 if flines:
301 statuslines.extend(flines)
302
Brad Bishop316dfdd2018-06-25 12:45:53 -0400303 statusheader = d.getVar('BUILDCFG_HEADER')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500304 if statusheader:
305 bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500306
307 # This code is to silence warnings where the SDK variables overwrite the
308 # target ones and we'd see dulpicate key names overwriting each other
309 # for various PREFERRED_PROVIDERS
310 if isinstance(e, bb.event.RecipePreFinalise):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400311 if d.getVar("TARGET_PREFIX") == d.getVar("SDK_PREFIX"):
312 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400313 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc")
314 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++")
315 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500316
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500317 if isinstance(e, bb.event.RecipeParsed):
318 #
319 # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set
320 # skip parsing for all the other providers which will mean they get uninstalled from the
321 # sysroot since they're now "unreachable". This makes switching virtual/kernel work in
322 # particular.
323 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500324 pn = d.getVar('PN')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500325 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False)
326 if not source_mirror_fetch:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500327 provs = (d.getVar("PROVIDES") or "").split()
Andrew Geissler9aee5002022-03-30 16:27:02 +0000328 multiprovidersallowed = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500329 for p in provs:
Andrew Geissler9aee5002022-03-30 16:27:02 +0000330 if p.startswith("virtual/") and p not in multiprovidersallowed:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500331 profprov = d.getVar("PREFERRED_PROVIDER_" + p)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500332 if profprov and pn != profprov:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400333 raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (p, profprov, pn))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500334}
335
336CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
337CLEANBROKEN = "0"
338
339addtask configure after do_patch
340do_configure[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500341base_do_configure() {
342 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
343 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
344 cd ${B}
345 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
346 oe_runmake clean
347 fi
Brad Bishopc4ea0752018-11-15 14:30:15 -0800348 # -ignore_readdir_race does not work correctly with -delete;
349 # use xargs to avoid spurious build failures
350 find ${B} -ignore_readdir_race -name \*.la -type f -print0 | xargs -0 rm -f
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500351 fi
352 fi
353 if [ -n "${CONFIGURESTAMPFILE}" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500354 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500355 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
356 fi
357}
358
359addtask compile after do_configure
360do_compile[dirs] = "${B}"
361base_do_compile() {
362 if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then
363 oe_runmake || die "make failed"
364 else
365 bbnote "nothing to compile"
366 fi
367}
368
369addtask install after do_compile
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600370do_install[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500371# Remove and re-create ${D} so that is it guaranteed to be empty
372do_install[cleandirs] = "${D}"
373
374base_do_install() {
375 :
376}
377
378base_do_package() {
379 :
380}
381
382addtask build after do_populate_sysroot
383do_build[noexec] = "1"
384do_build[recrdeptask] += "do_deploy"
385do_build () {
386 :
387}
388
389def set_packagetriplet(d):
390 archs = []
391 tos = []
392 tvs = []
393
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500394 archs.append(d.getVar("PACKAGE_ARCHS").split())
395 tos.append(d.getVar("TARGET_OS"))
396 tvs.append(d.getVar("TARGET_VENDOR"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500397
398 def settriplet(d, varname, archs, tos, tvs):
399 triplets = []
400 for i in range(len(archs)):
401 for arch in archs[i]:
402 triplets.append(arch + tvs[i] + "-" + tos[i])
403 triplets.reverse()
404 d.setVar(varname, " ".join(triplets))
405
406 settriplet(d, "PKGTRIPLETS", archs, tos, tvs)
407
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500408 variants = d.getVar("MULTILIB_VARIANTS") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500409 for item in variants.split():
410 localdata = bb.data.createCopy(d)
411 overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
412 localdata.setVar("OVERRIDES", overrides)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500413
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500414 archs.append(localdata.getVar("PACKAGE_ARCHS").split())
415 tos.append(localdata.getVar("TARGET_OS"))
416 tvs.append(localdata.getVar("TARGET_VENDOR"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500417
418 settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs)
419
420python () {
421 import string, re
422
Brad Bishop316dfdd2018-06-25 12:45:53 -0400423 # Handle backfilling
424 oe.utils.features_backfill("DISTRO_FEATURES", d)
425 oe.utils.features_backfill("MACHINE_FEATURES", d)
426
Andrew Geisslerf0343792020-11-18 10:42:21 -0600427 if d.getVar("S")[-1] == '/':
428 bb.warn("Recipe %s sets S variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("S")))
429 if d.getVar("B")[-1] == '/':
430 bb.warn("Recipe %s sets B variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("B")))
431
432 if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("S")):
433 d.appendVar("PSEUDO_IGNORE_PATHS", ",${S}")
434 if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("B")):
435 d.appendVar("PSEUDO_IGNORE_PATHS", ",${B}")
436
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000437 # To add a recipe to the skip list , set:
438 # SKIP_RECIPE[pn] = "message"
439 pn = d.getVar('PN')
440 skip_msg = d.getVarFlag('SKIP_RECIPE', pn)
441 if skip_msg:
442 bb.debug(1, "Skipping %s %s" % (pn, skip_msg))
443 raise bb.parse.SkipRecipe("Recipe will be skipped because: %s" % (skip_msg))
444
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500445 # Handle PACKAGECONFIG
446 #
447 # These take the form:
448 #
449 # PACKAGECONFIG ??= "<default options>"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500450 # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends,foo_runtime_recommends,foo_conflict_packageconfig"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500451 pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {}
452 if pkgconfigflags:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500453 pkgconfig = (d.getVar('PACKAGECONFIG') or "").split()
454 pn = d.getVar("PN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500455
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500456 mlprefix = d.getVar("MLPREFIX")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500457
458 def expandFilter(appends, extension, prefix):
459 appends = bb.utils.explode_deps(d.expand(" ".join(appends)))
460 newappends = []
461 for a in appends:
462 if a.endswith("-native") or ("-cross-" in a):
463 newappends.append(a)
464 elif a.startswith("virtual/"):
465 subs = a.split("/", 1)[1]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500466 if subs.startswith(prefix):
467 newappends.append(a + extension)
468 else:
469 newappends.append("virtual/" + prefix + subs + extension)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500470 else:
471 if a.startswith(prefix):
472 newappends.append(a + extension)
473 else:
474 newappends.append(prefix + a + extension)
475 return newappends
476
477 def appendVar(varname, appends):
478 if not appends:
479 return
480 if varname.find("DEPENDS") != -1:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500481 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) :
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500482 appends = expandFilter(appends, "", "nativesdk-")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500483 elif bb.data.inherits_class('native', d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500484 appends = expandFilter(appends, "-native", "")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500485 elif mlprefix:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500486 appends = expandFilter(appends, "", mlprefix)
487 varname = d.expand(varname)
488 d.appendVar(varname, " " + " ".join(appends))
489
490 extradeps = []
491 extrardeps = []
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500492 extrarrecs = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500493 extraconf = []
494 for flag, flagval in sorted(pkgconfigflags.items()):
495 items = flagval.split(",")
496 num = len(items)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500497 if num > 6:
498 bb.error("%s: PACKAGECONFIG[%s] Only enable,disable,depend,rdepend,rrecommend,conflict_packageconfig can be specified!"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500499 % (d.getVar('PN'), flag))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500500
501 if flag in pkgconfig:
502 if num >= 3 and items[2]:
503 extradeps.append(items[2])
504 if num >= 4 and items[3]:
505 extrardeps.append(items[3])
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500506 if num >= 5 and items[4]:
507 extrarrecs.append(items[4])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500508 if num >= 1 and items[0]:
509 extraconf.append(items[0])
510 elif num >= 2 and items[1]:
511 extraconf.append(items[1])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500512
513 if num >= 6 and items[5]:
514 conflicts = set(items[5].split())
515 invalid = conflicts.difference(set(pkgconfigflags.keys()))
516 if invalid:
517 bb.error("%s: PACKAGECONFIG[%s] Invalid conflict package config%s '%s' specified."
518 % (d.getVar('PN'), flag, 's' if len(invalid) > 1 else '', ' '.join(invalid)))
519
520 if flag in pkgconfig:
521 intersec = conflicts.intersection(set(pkgconfig))
522 if intersec:
523 bb.fatal("%s: PACKAGECONFIG[%s] Conflict package config%s '%s' set in PACKAGECONFIG."
524 % (d.getVar('PN'), flag, 's' if len(intersec) > 1 else '', ' '.join(intersec)))
525
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500526 appendVar('DEPENDS', extradeps)
Patrick Williams213cb262021-08-07 19:21:33 -0500527 appendVar('RDEPENDS:${PN}', extrardeps)
528 appendVar('RRECOMMENDS:${PN}', extrarrecs)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500529 appendVar('PACKAGECONFIG_CONFARGS', extraconf)
530
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500531 pn = d.getVar('PN')
532 license = d.getVar('LICENSE')
Brad Bishop316dfdd2018-06-25 12:45:53 -0400533 if license == "INVALID" and pn != "defaultpkgname":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500534 bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn)
535
536 if bb.data.inherits_class('license', d):
537 check_license_format(d)
Brad Bishop19323692019-04-05 15:28:33 -0400538 unmatched_license_flags = check_license_flags(d)
539 if unmatched_license_flags:
540 if len(unmatched_license_flags) == 1:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000541 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 -0400542 else:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000543 message = "because it has restricted licenses {0}. Which are not listed in LICENSE_FLAGS_ACCEPTED".format(
Brad Bishop19323692019-04-05 15:28:33 -0400544 ", ".join("'{0}'".format(f) for f in unmatched_license_flags))
545 bb.debug(1, "Skipping %s %s" % (pn, message))
546 raise bb.parse.SkipRecipe(message)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500547
548 # If we're building a target package we need to use fakeroot (pseudo)
549 # in order to capture permissions, owners, groups and special files
550 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
Brad Bishop64c979e2019-11-04 13:55:29 -0500551 d.appendVarFlag('do_prepare_recipe_sysroot', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500552 d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500553 d.setVarFlag('do_install', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500554 d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500555 d.setVarFlag('do_package', 'fakeroot', '1')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500556 d.setVarFlag('do_package_setscene', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500557 d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500558 d.setVarFlag('do_devshell', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500559 d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500560
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500561 need_machine = d.getVar('COMPATIBLE_MACHINE')
Andrew Geissler82c905d2020-04-13 13:39:40 -0500562 if need_machine and not d.getVar('PARSE_ALL_RECIPES', False):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500563 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500564 compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500565 for m in compat_machines:
566 if re.match(need_machine, m):
567 break
568 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400569 raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE'))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500570
Andrew Geissler82c905d2020-04-13 13:39:40 -0500571 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) or d.getVar('PARSE_ALL_RECIPES', False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500572 if not source_mirror_fetch:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500573 need_host = d.getVar('COMPATIBLE_HOST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500574 if need_host:
575 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500576 this_host = d.getVar('HOST_SYS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500577 if not re.match(need_host, this_host):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400578 raise bb.parse.SkipRecipe("incompatible with host %s (not in COMPATIBLE_HOST)" % this_host)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500579
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500580 bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500581
582 check_license = False if pn.startswith("nativesdk-") else True
583 for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}",
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600584 "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500585 "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]:
586 if pn.endswith(d.expand(t)):
587 check_license = False
588 if pn.startswith("gcc-source-"):
589 check_license = False
590
591 if check_license and bad_licenses:
592 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
593
Andrew Geissler9aee5002022-03-30 16:27:02 +0000594 exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
Andrew Geissler82c905d2020-04-13 13:39:40 -0500595
Andrew Geissler9aee5002022-03-30 16:27:02 +0000596 for lic_exception in exceptions:
597 if ":" in lic_exception:
Andrew Geissler615f2f12022-07-15 14:00:58 -0500598 lic_exception = lic_exception.split(":")[1]
Andrew Geissler9aee5002022-03-30 16:27:02 +0000599 if lic_exception in oe.license.obsolete_license_list():
Andrew Geissler615f2f12022-07-15 14:00:58 -0500600 bb.fatal("Obsolete license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
Andrew Geissler9aee5002022-03-30 16:27:02 +0000601
602 pkgs = d.getVar('PACKAGES').split()
603 skipped_pkgs = {}
604 unskipped_pkgs = []
605 for pkg in pkgs:
606 remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
607
608 incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg)
609 if incompatible_lic:
610 skipped_pkgs[pkg] = incompatible_lic
Andrew Geissler82c905d2020-04-13 13:39:40 -0500611 else:
Andrew Geissler9aee5002022-03-30 16:27:02 +0000612 unskipped_pkgs.append(pkg)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500613
Andrew Geissler9aee5002022-03-30 16:27:02 +0000614 if unskipped_pkgs:
615 for pkg in skipped_pkgs:
616 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
617 d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
618 for pkg in unskipped_pkgs:
619 bb.debug(1, "Including the package %s" % pkg)
620 else:
621 incompatible_lic = incompatible_license(d, bad_licenses)
622 for pkg in skipped_pkgs:
623 incompatible_lic += skipped_pkgs[pkg]
624 incompatible_lic = sorted(list(set(incompatible_lic)))
625
626 if incompatible_lic:
627 bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic)))
628 raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500629
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500630 needsrcrev = False
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500631 srcuri = d.getVar('SRC_URI')
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600632 for uri_string in srcuri.split():
633 uri = bb.fetch.URI(uri_string)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500634 # Also check downloadfilename as the URL path might not be useful for sniffing
635 path = uri.params.get("downloadfilename", uri.path)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500636
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500637 # HTTP/FTP use the wget fetcher
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600638 if uri.scheme in ("http", "https", "ftp"):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500639 d.appendVarFlag('do_fetch', 'depends', ' wget-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500640
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500641 # Svn packages should DEPEND on subversion-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600642 if uri.scheme == "svn":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500643 needsrcrev = True
644 d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500645
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500646 # Git packages should DEPEND on git-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600647 elif uri.scheme in ("git", "gitsm"):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500648 needsrcrev = True
649 d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500650
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500651 # Mercurial packages should DEPEND on mercurial-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600652 elif uri.scheme == "hg":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500653 needsrcrev = True
Andrew Geissler82c905d2020-04-13 13:39:40 -0500654 d.appendVar("EXTRANATIVEPATH", ' python3-native ')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500655 d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500656
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600657 # Perforce packages support SRCREV = "${AUTOREV}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600658 elif uri.scheme == "p4":
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600659 needsrcrev = True
660
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500661 # OSC packages should DEPEND on osc-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600662 elif uri.scheme == "osc":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500663 d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500664
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600665 elif uri.scheme == "npm":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500666 d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500667
Andrew Geissler595f6302022-01-24 19:11:47 +0000668 elif uri.scheme == "repo":
669 needsrcrev = True
670 d.appendVarFlag('do_fetch', 'depends', ' repo-native:do_populate_sysroot')
671
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500672 # *.lz4 should DEPEND on lz4-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500673 if path.endswith('.lz4'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500674 d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot')
675
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500676 # *.zst should DEPEND on zstd-native for unpacking
677 elif path.endswith('.zst'):
678 d.appendVarFlag('do_unpack', 'depends', ' zstd-native:do_populate_sysroot')
679
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500680 # *.lz should DEPEND on lzip-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500681 elif path.endswith('.lz'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500682 d.appendVarFlag('do_unpack', 'depends', ' lzip-native:do_populate_sysroot')
683
684 # *.xz should DEPEND on xz-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500685 elif path.endswith('.xz') or path.endswith('.txz'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500686 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
687
688 # .zip should DEPEND on unzip-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500689 elif path.endswith('.zip') or path.endswith('.jar'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500690 d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot')
691
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800692 # Some rpm files may be compressed internally using xz (for example, rpms from Fedora)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500693 elif path.endswith('.rpm'):
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500694 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500695
Brad Bishop316dfdd2018-06-25 12:45:53 -0400696 # *.deb should DEPEND on xz-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500697 elif path.endswith('.deb'):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400698 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
699
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500700 if needsrcrev:
701 d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500702
Brad Bishop15ae2502019-06-18 21:44:24 -0400703 # Gather all named SRCREVs to add to the sstate hash calculation
704 # This anonymous python snippet is called multiple times so we
705 # need to be careful to not double up the appends here and cause
706 # the base hash to mismatch the task hash
707 for uri in srcuri.split():
708 parm = bb.fetch.decodeurl(uri)[5]
709 uri_names = parm.get("name", "").split(",")
710 for uri_name in filter(None, uri_names):
711 srcrev_name = "SRCREV_{}".format(uri_name)
712 if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split():
713 d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name))
714
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500715 set_packagetriplet(d)
716
717 # 'multimachine' handling
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500718 mach_arch = d.getVar('MACHINE_ARCH')
719 pkg_arch = d.getVar('PACKAGE_ARCH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500720
721 if (pkg_arch == mach_arch):
722 # Already machine specific - nothing further to do
723 return
724
725 #
726 # We always try to scan SRC_URI for urls with machine overrides
727 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
728 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500729 override = d.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500730 if override != '0':
731 paths = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500732 fpaths = (d.getVar('FILESPATH') or '').split(':')
733 machine = d.getVar('MACHINE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500734 for p in fpaths:
735 if os.path.basename(p) == machine and os.path.isdir(p):
736 paths.append(p)
737
Andrew Geisslereff27472021-10-29 15:35:00 -0500738 if paths:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500739 for s in srcuri.split():
740 if not s.startswith("file://"):
741 continue
742 fetcher = bb.fetch2.Fetch([s], d)
743 local = fetcher.localpath(s)
744 for mp in paths:
745 if local.startswith(mp):
746 #bb.note("overriding PACKAGE_ARCH from %s to %s for %s" % (pkg_arch, mach_arch, pn))
747 d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}")
748 return
749
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500750 packages = d.getVar('PACKAGES').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500751 for pkg in packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500752 pkgarch = d.getVar("PACKAGE_ARCH_%s" % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500753
754 # We could look for != PACKAGE_ARCH here but how to choose
755 # if multiple differences are present?
756 # Look through PACKAGE_ARCHS for the priority order?
757 if pkgarch and pkgarch == mach_arch:
758 d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500759 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 -0500760}
761
762addtask cleansstate after do_clean
763python do_cleansstate() {
764 sstate_clean_cachefiles(d)
765}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500766addtask cleanall after do_cleansstate
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500767do_cleansstate[nostamp] = "1"
768
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500769python do_cleanall() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500770 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500771 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500772 return
773
774 try:
775 fetcher = bb.fetch2.Fetch(src_uri, d)
776 fetcher.clean()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600777 except bb.fetch2.BBFetchException as e:
778 bb.fatal(str(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500779}
780do_cleanall[nostamp] = "1"
781
782
783EXPORT_FUNCTIONS do_fetch do_unpack do_configure do_compile do_install do_package