blob: f260217b508f6ed579371c3538fa5dac35a96f8a [file] [log] [blame]
Andrew Geissler5199d832021-09-24 16:47:35 -05001PACKAGES = ""
2
3inherit image-postinst-intercepts image-artifact-names
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004
5# Wildcards specifying complementary packages to install for every package that has been explicitly
6# installed into the rootfs
7COMPLEMENTARY_GLOB[dev-pkgs] = '*-dev'
8COMPLEMENTARY_GLOB[staticdev-pkgs] = '*-staticdev'
9COMPLEMENTARY_GLOB[doc-pkgs] = '*-doc'
10COMPLEMENTARY_GLOB[dbg-pkgs] = '*-dbg'
Brad Bishop19323692019-04-05 15:28:33 -040011COMPLEMENTARY_GLOB[src-pkgs] = '*-src'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012COMPLEMENTARY_GLOB[ptest-pkgs] = '*-ptest'
Brad Bishop00e122a2019-10-05 11:10:57 -040013COMPLEMENTARY_GLOB[bash-completion-pkgs] = '*-bash-completion'
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014
15def complementary_globs(featurevar, d):
16 all_globs = d.getVarFlags('COMPLEMENTARY_GLOB')
17 globs = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018 features = set((d.getVar(featurevar) or '').split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 for name, glob in all_globs.items():
20 if name in features:
21 globs.append(glob)
22 return ' '.join(globs)
23
Brad Bishop19323692019-04-05 15:28:33 -040024SDKIMAGE_FEATURES ??= "dev-pkgs dbg-pkgs src-pkgs ${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', 'doc-pkgs', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025SDKIMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("SDKIMAGE_FEATURES", d)}'
Andrew Geissler82c905d2020-04-13 13:39:40 -050026SDKIMAGE_INSTALL_COMPLEMENTARY[vardeps] += "SDKIMAGE_FEATURES"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027
Patrick Williams213cb262021-08-07 19:21:33 -050028PACKAGE_ARCHS:append:task-populate-sdk = " sdk-provides-dummy-target"
Brad Bishop316dfdd2018-06-25 12:45:53 -040029SDK_PACKAGE_ARCHS += "sdk-provides-dummy-${SDKPKGSUFFIX}"
30
Brad Bishop00111322018-04-01 22:23:53 -040031# List of locales to install, or "all" for all of them, or unset for none.
32SDKIMAGE_LINGUAS ?= "all"
33
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034inherit rootfs_${IMAGE_PKGTYPE}
35
36SDK_DIR = "${WORKDIR}/sdk"
37SDK_OUTPUT = "${SDK_DIR}/image"
38SDK_DEPLOY = "${DEPLOY_DIR}/sdk"
39
Patrick Williamsc0f7c042017-02-23 20:41:17 -060040SDKDEPLOYDIR = "${WORKDIR}/${SDKMACHINE}-deploy-${PN}-populate-sdk"
41
Patrick Williams213cb262021-08-07 19:21:33 -050042B:task-populate-sdk = "${SDK_DIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043
44SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}"
45
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050046SDK_TOOLCHAIN_LANGS ??= ""
47SDK_TOOLCHAIN_LANGS:remove:sdkmingw32 = "rust"
48
49TOOLCHAIN_HOST_TASK ?= " \
50 nativesdk-packagegroup-sdk-host \
51 packagegroup-cross-canadian-${MACHINE} \
52 ${@bb.utils.contains('SDK_TOOLCHAIN_LANGS', 'go', 'packagegroup-go-cross-canadian-${MACHINE}', '', d)} \
53 ${@bb.utils.contains('SDK_TOOLCHAIN_LANGS', 'rust', 'packagegroup-rust-cross-canadian-${MACHINE}', '', d)} \
54"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= ""
Patrick Williamsdb4c27e2022-08-05 08:10:29 -050056TOOLCHAIN_TARGET_TASK ?= " \
57 ${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target')} \
58 ${@bb.utils.contains('SDK_TOOLCHAIN_LANGS', 'go', multilib_pkg_extend(d, 'packagegroup-go-sdk-target'), '', d)} \
59 ${@bb.utils.contains('SDK_TOOLCHAIN_LANGS', 'rust', multilib_pkg_extend(d, 'libstd-rs'), '', d)} \
60 target-sdk-provides-dummy \
61"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062TOOLCHAIN_TARGET_TASK_ATTEMPTONLY ?= ""
63TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}"
64
Brad Bishopc342db32019-05-15 21:57:59 -040065# Default archived SDK's suffix
66SDK_ARCHIVE_TYPE ?= "tar.xz"
Andrew Geissler82c905d2020-04-13 13:39:40 -050067SDK_XZ_COMPRESSION_LEVEL ?= "-9"
68SDK_XZ_OPTIONS ?= "${XZ_DEFAULTS} ${SDK_XZ_COMPRESSION_LEVEL}"
Brad Bishopc342db32019-05-15 21:57:59 -040069
70# To support different sdk type according to SDK_ARCHIVE_TYPE, now support zip and tar.xz
71python () {
72 if d.getVar('SDK_ARCHIVE_TYPE') == 'zip':
73 d.setVar('SDK_ARCHIVE_DEPENDS', 'zip-native')
74 # SDK_ARCHIVE_CMD used to generate archived sdk ${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} from input dir ${SDK_OUTPUT}/${SDKPATH} to output dir ${SDKDEPLOYDIR}
75 # recommand to cd into input dir first to avoid archive with buildpath
Andrew Geisslerc182c622020-05-15 14:13:32 -050076 d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; zip -r -y ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} .')
Brad Bishopc342db32019-05-15 21:57:59 -040077 else:
78 d.setVar('SDK_ARCHIVE_DEPENDS', 'xz-native')
Andrew Geissler82c905d2020-04-13 13:39:40 -050079 d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; tar ${SDKTAROPTS} -cf - . | xz ${SDK_XZ_OPTIONS} > ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}')
Brad Bishopc342db32019-05-15 21:57:59 -040080}
81
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}"
Brad Bishopc342db32019-05-15 21:57:59 -040083SDK_DEPENDS = "virtual/fakeroot-native ${SDK_ARCHIVE_DEPENDS} cross-localedef-native nativesdk-qemuwrapper-cross ${@' '.join(["%s-qemuwrapper-cross" % m for m in d.getVar("MULTILIB_VARIANTS").split()])} qemuwrapper-cross"
Patrick Williams213cb262021-08-07 19:21:33 -050084PATH:prepend = "${WORKDIR}/recipe-sysroot/${SDKPATHNATIVE}${bindir}/crossscripts:${@":".join(all_multilib_tune_values(d, 'STAGING_BINDIR_CROSS').split())}:"
Brad Bishopa34c0302019-09-23 22:34:48 -040085SDK_DEPENDS += "nativesdk-glibc-locale"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086
87# We want the MULTIARCH_TARGET_SYS to point to the TUNE_PKGARCH, not PACKAGE_ARCH as it
88# could be set to the MACHINE_ARCH
89REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}"
90
91PID = "${@os.getpid()}"
92
93EXCLUDE_FROM_WORLD = "1"
94
95SDK_PACKAGING_FUNC ?= "create_shar"
96SDK_PRE_INSTALL_COMMAND ?= ""
97SDK_POST_INSTALL_COMMAND ?= ""
98SDK_RELOCATE_AFTER_INSTALL ?= "1"
99
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800100SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk"
101SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600103SDK_TARGET_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"
104SDK_HOST_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500105SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"
106SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"
107
Andrew Geissler595f6302022-01-24 19:11:47 +0000108SDK_PRUNE_SYSROOT_DIRS ?= "/dev"
109
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110python write_target_sdk_manifest () {
111 from oe.sdk import sdk_list_installed_packages
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500112 from oe.utils import format_pkg_list
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113 sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST"))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500114 pkgs = sdk_list_installed_packages(d, True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115 if not os.path.exists(sdkmanifestdir):
116 bb.utils.mkdirhier(sdkmanifestdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500117 with open(d.getVar('SDK_TARGET_MANIFEST'), 'w') as output:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500118 output.write(format_pkg_list(pkgs, 'ver'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119}
120
Andrew Geissler595f6302022-01-24 19:11:47 +0000121sdk_prune_dirs () {
122 for d in ${SDK_PRUNE_SYSROOT_DIRS}; do
123 rm -rf ${SDK_OUTPUT}${SDKTARGETSYSROOT}$d
124 done
125}
126
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127python write_sdk_test_data() {
128 from oe.data import export2json
129 testdata = "%s/%s.testdata.json" % (d.getVar('SDKDEPLOYDIR'), d.getVar('TOOLCHAIN_OUTPUTNAME'))
130 bb.utils.mkdirhier(os.path.dirname(testdata))
131 export2json(d, testdata)
132}
133
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134python write_host_sdk_manifest () {
135 from oe.sdk import sdk_list_installed_packages
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500136 from oe.utils import format_pkg_list
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500137 sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST"))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500138 pkgs = sdk_list_installed_packages(d, False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139 if not os.path.exists(sdkmanifestdir):
140 bb.utils.mkdirhier(sdkmanifestdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500141 with open(d.getVar('SDK_HOST_MANIFEST'), 'w') as output:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500142 output.write(format_pkg_list(pkgs, 'ver'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143}
144
Patrick Williams213cb262021-08-07 19:21:33 -0500145POPULATE_SDK_POST_TARGET_COMMAND:append = " write_sdk_test_data ; "
Andrew Geissler595f6302022-01-24 19:11:47 +0000146POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk = " write_target_sdk_manifest; sdk_prune_dirs; "
Patrick Williams213cb262021-08-07 19:21:33 -0500147POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk = " write_host_sdk_manifest; "
Andrew Geissler595f6302022-01-24 19:11:47 +0000148
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500149SDK_PACKAGING_COMMAND = "${@'${SDK_PACKAGING_FUNC};' if '${SDK_PACKAGING_FUNC}' else ''}"
Brad Bishopc342db32019-05-15 21:57:59 -0400150SDK_POSTPROCESS_COMMAND = " create_sdk_files; check_sdk_sysroots; archive_sdk; ${SDK_PACKAGING_COMMAND} "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500151
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600152def populate_sdk_common(d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153 from oe.sdk import populate_sdk
154 from oe.manifest import create_manifest, Manifest
155
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500156 # Handle package exclusions
157 excl_pkgs = (d.getVar("PACKAGE_EXCLUDE") or "").split()
158 inst_pkgs = (d.getVar("PACKAGE_INSTALL") or "").split()
159 inst_attempt_pkgs = (d.getVar("PACKAGE_INSTALL_ATTEMPTONLY") or "").split()
160
161 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
162 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
163
164 for pkg in excl_pkgs:
165 if pkg in inst_pkgs:
166 bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs))
167 inst_pkgs.remove(pkg)
168
169 if pkg in inst_attempt_pkgs:
170 bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL_ATTEMPTONLY (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs))
171 inst_attempt_pkgs.remove(pkg)
172
173 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
174 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
175
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500176 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 runtime_mapping_rename("TOOLCHAIN_TARGET_TASK", pn, d)
178 runtime_mapping_rename("TOOLCHAIN_TARGET_TASK_ATTEMPTONLY", pn, d)
179
180 ld = bb.data.createCopy(d)
181 ld.setVar("PKGDATA_DIR", "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}/pkgdata")
182 runtime_mapping_rename("TOOLCHAIN_HOST_TASK", pn, ld)
183 runtime_mapping_rename("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", pn, ld)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500184 d.setVar("TOOLCHAIN_HOST_TASK", ld.getVar("TOOLCHAIN_HOST_TASK"))
185 d.setVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", ld.getVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186
187 # create target/host SDK manifests
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500188 create_manifest(d, manifest_dir=d.getVar('SDK_DIR'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189 manifest_type=Manifest.MANIFEST_TYPE_SDK_HOST)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500190 create_manifest(d, manifest_dir=d.getVar('SDK_DIR'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191 manifest_type=Manifest.MANIFEST_TYPE_SDK_TARGET)
192
193 populate_sdk(d)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600194
195fakeroot python do_populate_sdk() {
196 populate_sdk_common(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500197}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600198SSTATETASKS += "do_populate_sdk"
Patrick Williams213cb262021-08-07 19:21:33 -0500199SSTATE_SKIP_CREATION:task-populate-sdk = '1'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600200do_populate_sdk[cleandirs] = "${SDKDEPLOYDIR}"
201do_populate_sdk[sstate-inputdirs] = "${SDKDEPLOYDIR}"
202do_populate_sdk[sstate-outputdirs] = "${SDK_DEPLOY}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400203do_populate_sdk[stamp-extra-info] = "${MACHINE_ARCH}${SDKMACHINE}"
Andrew Geisslereff27472021-10-29 15:35:00 -0500204python do_populate_sdk_setscene () {
205 sstate_setscene(d)
206}
207addtask do_populate_sdk_setscene
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600209PSEUDO_IGNORE_PATHS .= ",${SDKDEPLOYDIR},${WORKDIR}/oe-sdk-repo,${WORKDIR}/sstate-build-populate_sdk"
Andrew Geisslerf0343792020-11-18 10:42:21 -0600210
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500211fakeroot create_sdk_files() {
212 cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/
213
214 # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern.
215 # Escape special characters like '+' and '.' in the SDKPATH
216 escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
217 sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
Andrew Geissler82c905d2020-04-13 13:39:40 -0500218
219 mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
220 echo '${SDKPATHNATIVE}${libdir_nativesdk}
221${SDKPATHNATIVE}${base_libdir_nativesdk}
222include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500223}
224
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500225python check_sdk_sysroots() {
226 # Fails build if there are broken or dangling symlinks in SDK sysroots
227
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500228 if d.getVar('CHECK_SDK_SYSROOTS') != '1':
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500229 # disabled, bail out
230 return
231
232 def norm_path(path):
233 return os.path.abspath(path)
234
235 # Get scan root
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500236 SCAN_ROOT = norm_path("%s/%s/sysroots/" % (d.getVar('SDK_OUTPUT'),
237 d.getVar('SDKPATH')))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500238
239 bb.note('Checking SDK sysroots at ' + SCAN_ROOT)
240
241 def check_symlink(linkPath):
242 if not os.path.islink(linkPath):
243 return
244
245 linkDirPath = os.path.dirname(linkPath)
246
247 targetPath = os.readlink(linkPath)
248 if not os.path.isabs(targetPath):
249 targetPath = os.path.join(linkDirPath, targetPath)
250 targetPath = norm_path(targetPath)
251
252 if SCAN_ROOT != os.path.commonprefix( [SCAN_ROOT, targetPath] ):
253 bb.error("Escaping symlink {0!s} --> {1!s}".format(linkPath, targetPath))
254 return
255
256 if not os.path.exists(targetPath):
257 bb.error("Broken symlink {0!s} --> {1!s}".format(linkPath, targetPath))
258 return
259
260 if os.path.isdir(targetPath):
261 dir_walk(targetPath)
262
263 def walk_error_handler(e):
264 bb.error(str(e))
265
266 def dir_walk(rootDir):
267 for dirPath,subDirEntries,fileEntries in os.walk(rootDir, followlinks=False, onerror=walk_error_handler):
268 entries = subDirEntries + fileEntries
269 for e in entries:
270 ePath = os.path.join(dirPath, e)
271 check_symlink(ePath)
272
273 # start
274 dir_walk(SCAN_ROOT)
275}
276
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500277SDKTAROPTS = "--owner=root --group=root"
278
Brad Bishopc342db32019-05-15 21:57:59 -0400279fakeroot archive_sdk() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280 # Package it up
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600281 mkdir -p ${SDKDEPLOYDIR}
Brad Bishopc342db32019-05-15 21:57:59 -0400282 ${SDK_ARCHIVE_CMD}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500283}
284
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800285TOOLCHAIN_SHAR_EXT_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-extract.sh"
286TOOLCHAIN_SHAR_REL_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-relocate.sh"
287
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500288fakeroot create_shar() {
289 # copy in the template shar extractor script
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800290 cp ${TOOLCHAIN_SHAR_EXT_TMPL} ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500291
292 rm -f ${T}/pre_install_command ${T}/post_install_command
293
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600294 if [ "${SDK_RELOCATE_AFTER_INSTALL}" = "1" ] ; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800295 cp ${TOOLCHAIN_SHAR_REL_TMPL} ${T}/post_install_command
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500296 fi
297 cat << "EOF" >> ${T}/pre_install_command
298${SDK_PRE_INSTALL_COMMAND}
299EOF
300
301 cat << "EOF" >> ${T}/post_install_command
302${SDK_POST_INSTALL_COMMAND}
303EOF
304 sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \
305 -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600306 ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500307
308 # substitute variables
309 sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \
310 -e 's#@SDKPATH@#${SDKPATH}#g' \
Patrick Williams213cb262021-08-07 19:21:33 -0500311 -e 's#@SDKPATHINSTALL@#${SDKPATHINSTALL}#g' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500312 -e 's#@SDKEXTPATH@#${SDKEXTPATH}#g' \
313 -e 's#@OLDEST_KERNEL@#${SDK_OLDEST_KERNEL}#g' \
314 -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \
Brad Bishop19323692019-04-05 15:28:33 -0400315 -e 's#@SDK_TITLE@#${@d.getVar("SDK_TITLE").replace('&', '\\&')}#g' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500316 -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \
317 -e '/@SDK_PRE_INSTALL_COMMAND@/d' \
318 -e '/@SDK_POST_INSTALL_COMMAND@/d' \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800319 -e 's#@SDK_GCC_VER@#${@oe.utils.host_gcc_version(d, taskcontextonly=True)}#g' \
Brad Bishopc342db32019-05-15 21:57:59 -0400320 -e 's#@SDK_ARCHIVE_TYPE@#${SDK_ARCHIVE_TYPE}#g' \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600321 ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500322
323 # add execution permission
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600324 chmod +x ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500325
326 # append the SDK tarball
Brad Bishopc342db32019-05-15 21:57:59 -0400327 cat ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} >> ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500328
329 # delete the old tarball, we don't need it anymore
Brad Bishopc342db32019-05-15 21:57:59 -0400330 rm ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500331}
332
333populate_sdk_log_check() {
334 for target in $*
335 do
336 lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}"
337
338 echo "log_check: Using $lf_path as logfile"
339
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500340 if [ -e "$lf_path" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500341 ${IMAGE_PKGTYPE}_log_check $target $lf_path
342 else
343 echo "Cannot find logfile [$lf_path]"
344 fi
345 echo "Logfile is clean"
346 done
347}
348
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500349def sdk_command_variables(d):
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500350 return ['OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','POPULATE_SDK_POST_HOST_COMMAND','POPULATE_SDK_PRE_TARGET_COMMAND','POPULATE_SDK_POST_TARGET_COMMAND','SDK_POSTPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS','RPM_POSTPROCESS_COMMANDS']
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500351
352def sdk_variables(d):
353 variables = ['BUILD_IMAGES_FROM_FEEDS','SDK_OS','SDK_OUTPUT','SDKPATHNATIVE','SDKTARGETSYSROOT','SDK_DIR','SDK_VENDOR','SDKIMAGE_INSTALL_COMPLEMENTARY','SDK_PACKAGE_ARCHS','SDK_OUTPUT',
354 'SDKTARGETSYSROOT','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS','PACKAGE_ARCHS',
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800355 'PACKAGE_CLASSES','TARGET_VENDOR','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'IMAGE_INSTALL_DEBUGFS']
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500356 variables.extend(sdk_command_variables(d))
357 return " ".join(variables)
358
359do_populate_sdk[vardeps] += "${@sdk_variables(d)}"
360
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500361python () {
362 variables = sdk_command_variables(d)
363 for var in variables:
364 if d.getVar(var, False):
365 d.setVarFlag(var, 'func', '1')
366}
367
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800368do_populate_sdk[file-checksums] += "${TOOLCHAIN_SHAR_REL_TMPL}:True \
369 ${TOOLCHAIN_SHAR_EXT_TMPL}:True"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500370
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500371do_populate_sdk[dirs] = "${PKGDATA_DIR} ${TOPDIR}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500372do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS').split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}"
373do_populate_sdk[rdepends] = "${@' '.join([x + ':do_package_write_${IMAGE_PKGTYPE} ' + x + ':do_packagedata' for x in d.getVar('SDK_RDEPENDS').split()])}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500374do_populate_sdk[recrdeptask] += "do_packagedata do_package_write_rpm do_package_write_ipk do_package_write_deb"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800375do_populate_sdk[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500376addtask populate_sdk