blob: 20968a5076687b1d80b461854158e6a4e9fff3ff [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() {
212 source_date_epoch = oe.reproducible.get_source_date_epoch(d, d.getVar('S'))
213 oe.reproducible.epochfile_write(source_date_epoch, d.getVar('SDE_FILE'), d)
214}
215do_unpack[postfuncs] += "create_source_date_epoch_stamp"
216
217def get_source_date_epoch_value(d):
218 return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
219
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220def get_layers_branch_rev(d):
Andrew Geissler78b72792022-06-14 06:47:25 -0500221 revisions = oe.buildcfg.get_layer_revisions(d)
222 layers_branch_rev = ["%-20s = \"%s:%s\"" % (r[1], r[2], r[3]) for r in revisions]
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500223 i = len(layers_branch_rev)-1
224 p1 = layers_branch_rev[i].find("=")
225 s1 = layers_branch_rev[i][p1:]
226 while i > 0:
227 p2 = layers_branch_rev[i-1].find("=")
228 s2= layers_branch_rev[i-1][p2:]
229 if s1 == s2:
230 layers_branch_rev[i-1] = layers_branch_rev[i-1][0:p2]
231 i -= 1
232 else:
233 i -= 1
234 p1 = layers_branch_rev[i].find("=")
235 s1= layers_branch_rev[i][p1:]
236 return layers_branch_rev
237
238
239BUILDCFG_FUNCS ??= "buildcfg_vars get_layers_branch_rev buildcfg_neededvars"
240BUILDCFG_FUNCS[type] = "list"
241
242def buildcfg_vars(d):
243 statusvars = oe.data.typed_value('BUILDCFG_VARS', d)
244 for var in statusvars:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500245 value = d.getVar(var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500246 if value is not None:
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500247 yield '%-20s = "%s"' % (var, value)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500248
249def buildcfg_neededvars(d):
250 needed_vars = oe.data.typed_value("BUILDCFG_NEEDEDVARS", d)
251 pesteruser = []
252 for v in needed_vars:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500253 val = d.getVar(v)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500254 if not val or val == 'INVALID':
255 pesteruser.append(v)
256
257 if pesteruser:
258 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))
259
260addhandler base_eventhandler
Brad Bishop19323692019-04-05 15:28:33 -0400261base_eventhandler[eventmask] = "bb.event.ConfigParsed bb.event.MultiConfigParsed bb.event.BuildStarted bb.event.RecipePreFinalise bb.event.RecipeParsed"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500262python base_eventhandler() {
263 import bb.runqueue
264
265 if isinstance(e, bb.event.ConfigParsed):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400266 if not d.getVar("NATIVELSBSTRING", False):
267 d.setVar("NATIVELSBSTRING", lsb_distro_identifier(d))
Andrew Geissler6ce62a22020-11-30 19:58:47 -0600268 d.setVar("ORIGNATIVELSBSTRING", d.getVar("NATIVELSBSTRING", False))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400269 d.setVar('BB_VERSION', bb.__version__)
Brad Bishop19323692019-04-05 15:28:33 -0400270
271 # There might be no bb.event.ConfigParsed event if bitbake server is
272 # running, so check bb.event.BuildStarted too to make sure ${HOSTTOOLS_DIR}
273 # exists.
274 if isinstance(e, bb.event.ConfigParsed) or \
275 (isinstance(e, bb.event.BuildStarted) and not os.path.exists(d.getVar('HOSTTOOLS_DIR'))):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500276 # Works with the line in layer.conf which changes PATH to point here
277 setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS', d)
278 setup_hosttools_dir(d.getVar('HOSTTOOLS_DIR'), 'HOSTTOOLS_NONFATAL', d, fatal=False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500279
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500280 if isinstance(e, bb.event.MultiConfigParsed):
281 # We need to expand SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS in each of the multiconfig data stores
282 # own contexts so the variables get expanded correctly for that arch, then inject back into
283 # the main data store.
284 deps = []
285 for config in e.mcdata:
286 deps.append(e.mcdata[config].getVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS"))
287 deps = " ".join(deps)
288 e.mcdata[''].setVar("SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS", deps)
289
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500290 if isinstance(e, bb.event.BuildStarted):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400291 localdata = bb.data.createCopy(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500292 statuslines = []
293 for func in oe.data.typed_value('BUILDCFG_FUNCS', localdata):
294 g = globals()
295 if func not in g:
296 bb.warn("Build configuration function '%s' does not exist" % func)
297 else:
298 flines = g[func](localdata)
299 if flines:
300 statuslines.extend(flines)
301
Brad Bishop316dfdd2018-06-25 12:45:53 -0400302 statusheader = d.getVar('BUILDCFG_HEADER')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500303 if statusheader:
304 bb.plain('\n%s\n%s\n' % (statusheader, '\n'.join(statuslines)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500305
306 # This code is to silence warnings where the SDK variables overwrite the
307 # target ones and we'd see dulpicate key names overwriting each other
308 # for various PREFERRED_PROVIDERS
309 if isinstance(e, bb.event.RecipePreFinalise):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400310 if d.getVar("TARGET_PREFIX") == d.getVar("SDK_PREFIX"):
311 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}binutils")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400312 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc")
313 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}g++")
314 d.delVar("PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}compilerlibs")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500315
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500316 if isinstance(e, bb.event.RecipeParsed):
317 #
318 # If we have multiple providers of virtual/X and a PREFERRED_PROVIDER_virtual/X is set
319 # skip parsing for all the other providers which will mean they get uninstalled from the
320 # sysroot since they're now "unreachable". This makes switching virtual/kernel work in
321 # particular.
322 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500323 pn = d.getVar('PN')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500324 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False)
325 if not source_mirror_fetch:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500326 provs = (d.getVar("PROVIDES") or "").split()
Andrew Geissler9aee5002022-03-30 16:27:02 +0000327 multiprovidersallowed = (d.getVar("BB_MULTI_PROVIDER_ALLOWED") or "").split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500328 for p in provs:
Andrew Geissler9aee5002022-03-30 16:27:02 +0000329 if p.startswith("virtual/") and p not in multiprovidersallowed:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500330 profprov = d.getVar("PREFERRED_PROVIDER_" + p)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500331 if profprov and pn != profprov:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400332 raise bb.parse.SkipRecipe("PREFERRED_PROVIDER_%s set to %s, not %s" % (p, profprov, pn))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500333}
334
335CONFIGURESTAMPFILE = "${WORKDIR}/configure.sstate"
336CLEANBROKEN = "0"
337
338addtask configure after do_patch
339do_configure[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500340base_do_configure() {
341 if [ -n "${CONFIGURESTAMPFILE}" -a -e "${CONFIGURESTAMPFILE}" ]; then
342 if [ "`cat ${CONFIGURESTAMPFILE}`" != "${BB_TASKHASH}" ]; then
343 cd ${B}
344 if [ "${CLEANBROKEN}" != "1" -a \( -e Makefile -o -e makefile -o -e GNUmakefile \) ]; then
345 oe_runmake clean
346 fi
Brad Bishopc4ea0752018-11-15 14:30:15 -0800347 # -ignore_readdir_race does not work correctly with -delete;
348 # use xargs to avoid spurious build failures
349 find ${B} -ignore_readdir_race -name \*.la -type f -print0 | xargs -0 rm -f
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500350 fi
351 fi
352 if [ -n "${CONFIGURESTAMPFILE}" ]; then
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500353 mkdir -p `dirname ${CONFIGURESTAMPFILE}`
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354 echo ${BB_TASKHASH} > ${CONFIGURESTAMPFILE}
355 fi
356}
357
358addtask compile after do_configure
359do_compile[dirs] = "${B}"
360base_do_compile() {
361 if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then
362 oe_runmake || die "make failed"
363 else
364 bbnote "nothing to compile"
365 fi
366}
367
368addtask install after do_compile
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600369do_install[dirs] = "${B}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500370# Remove and re-create ${D} so that is it guaranteed to be empty
371do_install[cleandirs] = "${D}"
372
373base_do_install() {
374 :
375}
376
377base_do_package() {
378 :
379}
380
381addtask build after do_populate_sysroot
382do_build[noexec] = "1"
383do_build[recrdeptask] += "do_deploy"
384do_build () {
385 :
386}
387
388def set_packagetriplet(d):
389 archs = []
390 tos = []
391 tvs = []
392
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500393 archs.append(d.getVar("PACKAGE_ARCHS").split())
394 tos.append(d.getVar("TARGET_OS"))
395 tvs.append(d.getVar("TARGET_VENDOR"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500396
397 def settriplet(d, varname, archs, tos, tvs):
398 triplets = []
399 for i in range(len(archs)):
400 for arch in archs[i]:
401 triplets.append(arch + tvs[i] + "-" + tos[i])
402 triplets.reverse()
403 d.setVar(varname, " ".join(triplets))
404
405 settriplet(d, "PKGTRIPLETS", archs, tos, tvs)
406
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500407 variants = d.getVar("MULTILIB_VARIANTS") or ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500408 for item in variants.split():
409 localdata = bb.data.createCopy(d)
410 overrides = localdata.getVar("OVERRIDES", False) + ":virtclass-multilib-" + item
411 localdata.setVar("OVERRIDES", overrides)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500412
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500413 archs.append(localdata.getVar("PACKAGE_ARCHS").split())
414 tos.append(localdata.getVar("TARGET_OS"))
415 tvs.append(localdata.getVar("TARGET_VENDOR"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500416
417 settriplet(d, "PKGMLTRIPLETS", archs, tos, tvs)
418
419python () {
420 import string, re
421
Brad Bishop316dfdd2018-06-25 12:45:53 -0400422 # Handle backfilling
423 oe.utils.features_backfill("DISTRO_FEATURES", d)
424 oe.utils.features_backfill("MACHINE_FEATURES", d)
425
Andrew Geisslerf0343792020-11-18 10:42:21 -0600426 if d.getVar("S")[-1] == '/':
427 bb.warn("Recipe %s sets S variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("S")))
428 if d.getVar("B")[-1] == '/':
429 bb.warn("Recipe %s sets B variable with trailing slash '%s', remove it" % (d.getVar("PN"), d.getVar("B")))
430
431 if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("S")):
432 d.appendVar("PSEUDO_IGNORE_PATHS", ",${S}")
433 if os.path.normpath(d.getVar("WORKDIR")) != os.path.normpath(d.getVar("B")):
434 d.appendVar("PSEUDO_IGNORE_PATHS", ",${B}")
435
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000436 # To add a recipe to the skip list , set:
437 # SKIP_RECIPE[pn] = "message"
438 pn = d.getVar('PN')
439 skip_msg = d.getVarFlag('SKIP_RECIPE', pn)
440 if skip_msg:
441 bb.debug(1, "Skipping %s %s" % (pn, skip_msg))
442 raise bb.parse.SkipRecipe("Recipe will be skipped because: %s" % (skip_msg))
443
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500444 # Handle PACKAGECONFIG
445 #
446 # These take the form:
447 #
448 # PACKAGECONFIG ??= "<default options>"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500449 # PACKAGECONFIG[foo] = "--enable-foo,--disable-foo,foo_depends,foo_runtime_depends,foo_runtime_recommends,foo_conflict_packageconfig"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500450 pkgconfigflags = d.getVarFlags("PACKAGECONFIG") or {}
451 if pkgconfigflags:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500452 pkgconfig = (d.getVar('PACKAGECONFIG') or "").split()
453 pn = d.getVar("PN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500454
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500455 mlprefix = d.getVar("MLPREFIX")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500456
457 def expandFilter(appends, extension, prefix):
458 appends = bb.utils.explode_deps(d.expand(" ".join(appends)))
459 newappends = []
460 for a in appends:
461 if a.endswith("-native") or ("-cross-" in a):
462 newappends.append(a)
463 elif a.startswith("virtual/"):
464 subs = a.split("/", 1)[1]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500465 if subs.startswith(prefix):
466 newappends.append(a + extension)
467 else:
468 newappends.append("virtual/" + prefix + subs + extension)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500469 else:
470 if a.startswith(prefix):
471 newappends.append(a + extension)
472 else:
473 newappends.append(prefix + a + extension)
474 return newappends
475
476 def appendVar(varname, appends):
477 if not appends:
478 return
479 if varname.find("DEPENDS") != -1:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500480 if bb.data.inherits_class('nativesdk', d) or bb.data.inherits_class('cross-canadian', d) :
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500481 appends = expandFilter(appends, "", "nativesdk-")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500482 elif bb.data.inherits_class('native', d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500483 appends = expandFilter(appends, "-native", "")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500484 elif mlprefix:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500485 appends = expandFilter(appends, "", mlprefix)
486 varname = d.expand(varname)
487 d.appendVar(varname, " " + " ".join(appends))
488
489 extradeps = []
490 extrardeps = []
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500491 extrarrecs = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500492 extraconf = []
493 for flag, flagval in sorted(pkgconfigflags.items()):
494 items = flagval.split(",")
495 num = len(items)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500496 if num > 6:
497 bb.error("%s: PACKAGECONFIG[%s] Only enable,disable,depend,rdepend,rrecommend,conflict_packageconfig can be specified!"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500498 % (d.getVar('PN'), flag))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500499
500 if flag in pkgconfig:
501 if num >= 3 and items[2]:
502 extradeps.append(items[2])
503 if num >= 4 and items[3]:
504 extrardeps.append(items[3])
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500505 if num >= 5 and items[4]:
506 extrarrecs.append(items[4])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500507 if num >= 1 and items[0]:
508 extraconf.append(items[0])
509 elif num >= 2 and items[1]:
510 extraconf.append(items[1])
Andrew Geissler82c905d2020-04-13 13:39:40 -0500511
512 if num >= 6 and items[5]:
513 conflicts = set(items[5].split())
514 invalid = conflicts.difference(set(pkgconfigflags.keys()))
515 if invalid:
516 bb.error("%s: PACKAGECONFIG[%s] Invalid conflict package config%s '%s' specified."
517 % (d.getVar('PN'), flag, 's' if len(invalid) > 1 else '', ' '.join(invalid)))
518
519 if flag in pkgconfig:
520 intersec = conflicts.intersection(set(pkgconfig))
521 if intersec:
522 bb.fatal("%s: PACKAGECONFIG[%s] Conflict package config%s '%s' set in PACKAGECONFIG."
523 % (d.getVar('PN'), flag, 's' if len(intersec) > 1 else '', ' '.join(intersec)))
524
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500525 appendVar('DEPENDS', extradeps)
Patrick Williams213cb262021-08-07 19:21:33 -0500526 appendVar('RDEPENDS:${PN}', extrardeps)
527 appendVar('RRECOMMENDS:${PN}', extrarrecs)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500528 appendVar('PACKAGECONFIG_CONFARGS', extraconf)
529
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500530 pn = d.getVar('PN')
531 license = d.getVar('LICENSE')
Brad Bishop316dfdd2018-06-25 12:45:53 -0400532 if license == "INVALID" and pn != "defaultpkgname":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500533 bb.fatal('This recipe does not have the LICENSE field set (%s)' % pn)
534
535 if bb.data.inherits_class('license', d):
536 check_license_format(d)
Brad Bishop19323692019-04-05 15:28:33 -0400537 unmatched_license_flags = check_license_flags(d)
538 if unmatched_license_flags:
539 if len(unmatched_license_flags) == 1:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000540 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 -0400541 else:
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000542 message = "because it has restricted licenses {0}. Which are not listed in LICENSE_FLAGS_ACCEPTED".format(
Brad Bishop19323692019-04-05 15:28:33 -0400543 ", ".join("'{0}'".format(f) for f in unmatched_license_flags))
544 bb.debug(1, "Skipping %s %s" % (pn, message))
545 raise bb.parse.SkipRecipe(message)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500546
547 # If we're building a target package we need to use fakeroot (pseudo)
548 # in order to capture permissions, owners, groups and special files
549 if not bb.data.inherits_class('native', d) and not bb.data.inherits_class('cross', d):
Brad Bishop64c979e2019-11-04 13:55:29 -0500550 d.appendVarFlag('do_prepare_recipe_sysroot', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500551 d.appendVarFlag('do_install', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500552 d.setVarFlag('do_install', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500553 d.appendVarFlag('do_package', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500554 d.setVarFlag('do_package', 'fakeroot', '1')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500555 d.setVarFlag('do_package_setscene', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500556 d.appendVarFlag('do_package_setscene', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500557 d.setVarFlag('do_devshell', 'fakeroot', '1')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500558 d.appendVarFlag('do_devshell', 'depends', ' virtual/fakeroot-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500559
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500560 need_machine = d.getVar('COMPATIBLE_MACHINE')
Andrew Geissler82c905d2020-04-13 13:39:40 -0500561 if need_machine and not d.getVar('PARSE_ALL_RECIPES', False):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500562 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500563 compat_machines = (d.getVar('MACHINEOVERRIDES') or "").split(":")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500564 for m in compat_machines:
565 if re.match(need_machine, m):
566 break
567 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400568 raise bb.parse.SkipRecipe("incompatible with machine %s (not in COMPATIBLE_MACHINE)" % d.getVar('MACHINE'))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500569
Andrew Geissler82c905d2020-04-13 13:39:40 -0500570 source_mirror_fetch = d.getVar('SOURCE_MIRROR_FETCH', False) or d.getVar('PARSE_ALL_RECIPES', False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500571 if not source_mirror_fetch:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500572 need_host = d.getVar('COMPATIBLE_HOST')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500573 if need_host:
574 import re
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500575 this_host = d.getVar('HOST_SYS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500576 if not re.match(need_host, this_host):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400577 raise bb.parse.SkipRecipe("incompatible with host %s (not in COMPATIBLE_HOST)" % this_host)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500578
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500579 bad_licenses = (d.getVar('INCOMPATIBLE_LICENSE') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500580
581 check_license = False if pn.startswith("nativesdk-") else True
582 for t in ["-native", "-cross-${TARGET_ARCH}", "-cross-initial-${TARGET_ARCH}",
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600583 "-crosssdk-${SDK_SYS}", "-crosssdk-initial-${SDK_SYS}",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500584 "-cross-canadian-${TRANSLATED_TARGET_ARCH}"]:
585 if pn.endswith(d.expand(t)):
586 check_license = False
587 if pn.startswith("gcc-source-"):
588 check_license = False
589
590 if check_license and bad_licenses:
591 bad_licenses = expand_wildcard_licenses(d, bad_licenses)
592
Andrew Geissler9aee5002022-03-30 16:27:02 +0000593 exceptions = (d.getVar("INCOMPATIBLE_LICENSE_EXCEPTIONS") or "").split()
Andrew Geissler82c905d2020-04-13 13:39:40 -0500594
Andrew Geissler9aee5002022-03-30 16:27:02 +0000595 for lic_exception in exceptions:
596 if ":" in lic_exception:
597 lic_exception.split(":")[0]
598 if lic_exception in oe.license.obsolete_license_list():
599 bb.fatal("Invalid license %s used in INCOMPATIBLE_LICENSE_EXCEPTIONS" % lic_exception)
600
601 pkgs = d.getVar('PACKAGES').split()
602 skipped_pkgs = {}
603 unskipped_pkgs = []
604 for pkg in pkgs:
605 remaining_bad_licenses = oe.license.apply_pkg_license_exception(pkg, bad_licenses, exceptions)
606
607 incompatible_lic = incompatible_license(d, remaining_bad_licenses, pkg)
608 if incompatible_lic:
609 skipped_pkgs[pkg] = incompatible_lic
Andrew Geissler82c905d2020-04-13 13:39:40 -0500610 else:
Andrew Geissler9aee5002022-03-30 16:27:02 +0000611 unskipped_pkgs.append(pkg)
Andrew Geissler82c905d2020-04-13 13:39:40 -0500612
Andrew Geissler9aee5002022-03-30 16:27:02 +0000613 if unskipped_pkgs:
614 for pkg in skipped_pkgs:
615 bb.debug(1, "Skipping the package %s at do_rootfs because of incompatible license(s): %s" % (pkg, ' '.join(skipped_pkgs[pkg])))
616 d.setVar('_exclude_incompatible-' + pkg, ' '.join(skipped_pkgs[pkg]))
617 for pkg in unskipped_pkgs:
618 bb.debug(1, "Including the package %s" % pkg)
619 else:
620 incompatible_lic = incompatible_license(d, bad_licenses)
621 for pkg in skipped_pkgs:
622 incompatible_lic += skipped_pkgs[pkg]
623 incompatible_lic = sorted(list(set(incompatible_lic)))
624
625 if incompatible_lic:
626 bb.debug(1, "Skipping recipe %s because of incompatible license(s): %s" % (pn, ' '.join(incompatible_lic)))
627 raise bb.parse.SkipRecipe("it has incompatible license(s): %s" % ' '.join(incompatible_lic))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500628
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500629 needsrcrev = False
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500630 srcuri = d.getVar('SRC_URI')
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600631 for uri_string in srcuri.split():
632 uri = bb.fetch.URI(uri_string)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500633 # Also check downloadfilename as the URL path might not be useful for sniffing
634 path = uri.params.get("downloadfilename", uri.path)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500635
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500636 # HTTP/FTP use the wget fetcher
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600637 if uri.scheme in ("http", "https", "ftp"):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500638 d.appendVarFlag('do_fetch', 'depends', ' wget-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500639
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500640 # Svn packages should DEPEND on subversion-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600641 if uri.scheme == "svn":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500642 needsrcrev = True
643 d.appendVarFlag('do_fetch', 'depends', ' subversion-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500644
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500645 # Git packages should DEPEND on git-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600646 elif uri.scheme in ("git", "gitsm"):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500647 needsrcrev = True
648 d.appendVarFlag('do_fetch', 'depends', ' git-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500649
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500650 # Mercurial packages should DEPEND on mercurial-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600651 elif uri.scheme == "hg":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500652 needsrcrev = True
Andrew Geissler82c905d2020-04-13 13:39:40 -0500653 d.appendVar("EXTRANATIVEPATH", ' python3-native ')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500654 d.appendVarFlag('do_fetch', 'depends', ' mercurial-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500655
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600656 # Perforce packages support SRCREV = "${AUTOREV}"
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600657 elif uri.scheme == "p4":
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600658 needsrcrev = True
659
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500660 # OSC packages should DEPEND on osc-native
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600661 elif uri.scheme == "osc":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500662 d.appendVarFlag('do_fetch', 'depends', ' osc-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500663
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600664 elif uri.scheme == "npm":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500665 d.appendVarFlag('do_fetch', 'depends', ' nodejs-native:do_populate_sysroot')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500666
Andrew Geissler595f6302022-01-24 19:11:47 +0000667 elif uri.scheme == "repo":
668 needsrcrev = True
669 d.appendVarFlag('do_fetch', 'depends', ' repo-native:do_populate_sysroot')
670
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500671 # *.lz4 should DEPEND on lz4-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500672 if path.endswith('.lz4'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500673 d.appendVarFlag('do_unpack', 'depends', ' lz4-native:do_populate_sysroot')
674
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500675 # *.zst should DEPEND on zstd-native for unpacking
676 elif path.endswith('.zst'):
677 d.appendVarFlag('do_unpack', 'depends', ' zstd-native:do_populate_sysroot')
678
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500679 # *.lz should DEPEND on lzip-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500680 elif path.endswith('.lz'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500681 d.appendVarFlag('do_unpack', 'depends', ' lzip-native:do_populate_sysroot')
682
683 # *.xz should DEPEND on xz-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500684 elif path.endswith('.xz') or path.endswith('.txz'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500685 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
686
687 # .zip should DEPEND on unzip-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500688 elif path.endswith('.zip') or path.endswith('.jar'):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500689 d.appendVarFlag('do_unpack', 'depends', ' unzip-native:do_populate_sysroot')
690
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800691 # Some rpm files may be compressed internally using xz (for example, rpms from Fedora)
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500692 elif path.endswith('.rpm'):
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500693 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500694
Brad Bishop316dfdd2018-06-25 12:45:53 -0400695 # *.deb should DEPEND on xz-native for unpacking
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500696 elif path.endswith('.deb'):
Brad Bishop316dfdd2018-06-25 12:45:53 -0400697 d.appendVarFlag('do_unpack', 'depends', ' xz-native:do_populate_sysroot')
698
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500699 if needsrcrev:
700 d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500701
Brad Bishop15ae2502019-06-18 21:44:24 -0400702 # Gather all named SRCREVs to add to the sstate hash calculation
703 # This anonymous python snippet is called multiple times so we
704 # need to be careful to not double up the appends here and cause
705 # the base hash to mismatch the task hash
706 for uri in srcuri.split():
707 parm = bb.fetch.decodeurl(uri)[5]
708 uri_names = parm.get("name", "").split(",")
709 for uri_name in filter(None, uri_names):
710 srcrev_name = "SRCREV_{}".format(uri_name)
711 if srcrev_name not in (d.getVarFlag("do_fetch", "vardeps") or "").split():
712 d.appendVarFlag("do_fetch", "vardeps", " {}".format(srcrev_name))
713
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500714 set_packagetriplet(d)
715
716 # 'multimachine' handling
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500717 mach_arch = d.getVar('MACHINE_ARCH')
718 pkg_arch = d.getVar('PACKAGE_ARCH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500719
720 if (pkg_arch == mach_arch):
721 # Already machine specific - nothing further to do
722 return
723
724 #
725 # We always try to scan SRC_URI for urls with machine overrides
726 # unless the package sets SRC_URI_OVERRIDES_PACKAGE_ARCH=0
727 #
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500728 override = d.getVar('SRC_URI_OVERRIDES_PACKAGE_ARCH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500729 if override != '0':
730 paths = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500731 fpaths = (d.getVar('FILESPATH') or '').split(':')
732 machine = d.getVar('MACHINE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500733 for p in fpaths:
734 if os.path.basename(p) == machine and os.path.isdir(p):
735 paths.append(p)
736
Andrew Geisslereff27472021-10-29 15:35:00 -0500737 if paths:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500738 for s in srcuri.split():
739 if not s.startswith("file://"):
740 continue
741 fetcher = bb.fetch2.Fetch([s], d)
742 local = fetcher.localpath(s)
743 for mp in paths:
744 if local.startswith(mp):
745 #bb.note("overriding PACKAGE_ARCH from %s to %s for %s" % (pkg_arch, mach_arch, pn))
746 d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}")
747 return
748
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500749 packages = d.getVar('PACKAGES').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500750 for pkg in packages:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500751 pkgarch = d.getVar("PACKAGE_ARCH_%s" % pkg)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500752
753 # We could look for != PACKAGE_ARCH here but how to choose
754 # if multiple differences are present?
755 # Look through PACKAGE_ARCHS for the priority order?
756 if pkgarch and pkgarch == mach_arch:
757 d.setVar('PACKAGE_ARCH', "${MACHINE_ARCH}")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500758 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 -0500759}
760
761addtask cleansstate after do_clean
762python do_cleansstate() {
763 sstate_clean_cachefiles(d)
764}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500765addtask cleanall after do_cleansstate
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500766do_cleansstate[nostamp] = "1"
767
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500768python do_cleanall() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500769 src_uri = (d.getVar('SRC_URI') or "").split()
Andrew Geisslereff27472021-10-29 15:35:00 -0500770 if not src_uri:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500771 return
772
773 try:
774 fetcher = bb.fetch2.Fetch(src_uri, d)
775 fetcher.clean()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600776 except bb.fetch2.BBFetchException as e:
777 bb.fatal(str(e))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500778}
779do_cleanall[nostamp] = "1"
780
781
782EXPORT_FUNCTIONS do_fetch do_unpack do_configure do_compile do_install do_package