blob: fafdd96749c2a6c200df801f591be4d3d93c9729 [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
46TOOLCHAIN_HOST_TASK ?= "nativesdk-packagegroup-sdk-host packagegroup-cross-canadian-${MACHINE}"
47TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= ""
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080048TOOLCHAIN_TARGET_TASK ?= "${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target')} target-sdk-provides-dummy"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049TOOLCHAIN_TARGET_TASK_ATTEMPTONLY ?= ""
50TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}"
51
Brad Bishopc342db32019-05-15 21:57:59 -040052# Default archived SDK's suffix
53SDK_ARCHIVE_TYPE ?= "tar.xz"
Andrew Geissler82c905d2020-04-13 13:39:40 -050054SDK_XZ_COMPRESSION_LEVEL ?= "-9"
55SDK_XZ_OPTIONS ?= "${XZ_DEFAULTS} ${SDK_XZ_COMPRESSION_LEVEL}"
Brad Bishopc342db32019-05-15 21:57:59 -040056
57# To support different sdk type according to SDK_ARCHIVE_TYPE, now support zip and tar.xz
58python () {
59 if d.getVar('SDK_ARCHIVE_TYPE') == 'zip':
60 d.setVar('SDK_ARCHIVE_DEPENDS', 'zip-native')
61 # SDK_ARCHIVE_CMD used to generate archived sdk ${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} from input dir ${SDK_OUTPUT}/${SDKPATH} to output dir ${SDKDEPLOYDIR}
62 # recommand to cd into input dir first to avoid archive with buildpath
Andrew Geisslerc182c622020-05-15 14:13:32 -050063 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 -040064 else:
65 d.setVar('SDK_ARCHIVE_DEPENDS', 'xz-native')
Andrew Geissler82c905d2020-04-13 13:39:40 -050066 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 -040067}
68
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}"
Brad Bishopc342db32019-05-15 21:57:59 -040070SDK_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 -050071PATH:prepend = "${WORKDIR}/recipe-sysroot/${SDKPATHNATIVE}${bindir}/crossscripts:${@":".join(all_multilib_tune_values(d, 'STAGING_BINDIR_CROSS').split())}:"
Brad Bishopa34c0302019-09-23 22:34:48 -040072SDK_DEPENDS += "nativesdk-glibc-locale"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073
74# We want the MULTIARCH_TARGET_SYS to point to the TUNE_PKGARCH, not PACKAGE_ARCH as it
75# could be set to the MACHINE_ARCH
76REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}"
77
78PID = "${@os.getpid()}"
79
80EXCLUDE_FROM_WORLD = "1"
81
82SDK_PACKAGING_FUNC ?= "create_shar"
83SDK_PRE_INSTALL_COMMAND ?= ""
84SDK_POST_INSTALL_COMMAND ?= ""
85SDK_RELOCATE_AFTER_INSTALL ?= "1"
86
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080087SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk"
88SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089
Patrick Williamsc0f7c042017-02-23 20:41:17 -060090SDK_TARGET_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"
91SDK_HOST_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050092SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"
93SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"
94
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095python write_target_sdk_manifest () {
96 from oe.sdk import sdk_list_installed_packages
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050097 from oe.utils import format_pkg_list
Brad Bishop6e60e8b2018-02-01 10:27:11 -050098 sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST"))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050099 pkgs = sdk_list_installed_packages(d, True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100 if not os.path.exists(sdkmanifestdir):
101 bb.utils.mkdirhier(sdkmanifestdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500102 with open(d.getVar('SDK_TARGET_MANIFEST'), 'w') as output:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500103 output.write(format_pkg_list(pkgs, 'ver'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500104}
105
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500106python write_sdk_test_data() {
107 from oe.data import export2json
108 testdata = "%s/%s.testdata.json" % (d.getVar('SDKDEPLOYDIR'), d.getVar('TOOLCHAIN_OUTPUTNAME'))
109 bb.utils.mkdirhier(os.path.dirname(testdata))
110 export2json(d, testdata)
111}
112
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113python write_host_sdk_manifest () {
114 from oe.sdk import sdk_list_installed_packages
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500115 from oe.utils import format_pkg_list
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500116 sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST"))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500117 pkgs = sdk_list_installed_packages(d, False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118 if not os.path.exists(sdkmanifestdir):
119 bb.utils.mkdirhier(sdkmanifestdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500120 with open(d.getVar('SDK_HOST_MANIFEST'), 'w') as output:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500121 output.write(format_pkg_list(pkgs, 'ver'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122}
123
Patrick Williams213cb262021-08-07 19:21:33 -0500124POPULATE_SDK_POST_TARGET_COMMAND:append = " write_sdk_test_data ; "
125POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk = " write_target_sdk_manifest ; "
126POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk = " write_host_sdk_manifest; "
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500127SDK_PACKAGING_COMMAND = "${@'${SDK_PACKAGING_FUNC};' if '${SDK_PACKAGING_FUNC}' else ''}"
Brad Bishopc342db32019-05-15 21:57:59 -0400128SDK_POSTPROCESS_COMMAND = " create_sdk_files; check_sdk_sysroots; archive_sdk; ${SDK_PACKAGING_COMMAND} "
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600130def populate_sdk_common(d):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500131 from oe.sdk import populate_sdk
132 from oe.manifest import create_manifest, Manifest
133
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500134 # Handle package exclusions
135 excl_pkgs = (d.getVar("PACKAGE_EXCLUDE") or "").split()
136 inst_pkgs = (d.getVar("PACKAGE_INSTALL") or "").split()
137 inst_attempt_pkgs = (d.getVar("PACKAGE_INSTALL_ATTEMPTONLY") or "").split()
138
139 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
140 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
141
142 for pkg in excl_pkgs:
143 if pkg in inst_pkgs:
144 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))
145 inst_pkgs.remove(pkg)
146
147 if pkg in inst_attempt_pkgs:
148 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))
149 inst_attempt_pkgs.remove(pkg)
150
151 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
152 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
153
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500155 runtime_mapping_rename("TOOLCHAIN_TARGET_TASK", pn, d)
156 runtime_mapping_rename("TOOLCHAIN_TARGET_TASK_ATTEMPTONLY", pn, d)
157
158 ld = bb.data.createCopy(d)
159 ld.setVar("PKGDATA_DIR", "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}/pkgdata")
160 runtime_mapping_rename("TOOLCHAIN_HOST_TASK", pn, ld)
161 runtime_mapping_rename("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", pn, ld)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500162 d.setVar("TOOLCHAIN_HOST_TASK", ld.getVar("TOOLCHAIN_HOST_TASK"))
163 d.setVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", ld.getVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164
165 # create target/host SDK manifests
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500166 create_manifest(d, manifest_dir=d.getVar('SDK_DIR'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167 manifest_type=Manifest.MANIFEST_TYPE_SDK_HOST)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500168 create_manifest(d, manifest_dir=d.getVar('SDK_DIR'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169 manifest_type=Manifest.MANIFEST_TYPE_SDK_TARGET)
170
171 populate_sdk(d)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600172
173fakeroot python do_populate_sdk() {
174 populate_sdk_common(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500175}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600176SSTATETASKS += "do_populate_sdk"
Patrick Williams213cb262021-08-07 19:21:33 -0500177SSTATE_SKIP_CREATION:task-populate-sdk = '1'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600178do_populate_sdk[cleandirs] = "${SDKDEPLOYDIR}"
179do_populate_sdk[sstate-inputdirs] = "${SDKDEPLOYDIR}"
180do_populate_sdk[sstate-outputdirs] = "${SDK_DEPLOY}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400181do_populate_sdk[stamp-extra-info] = "${MACHINE_ARCH}${SDKMACHINE}"
Andrew Geisslereff27472021-10-29 15:35:00 -0500182python do_populate_sdk_setscene () {
183 sstate_setscene(d)
184}
185addtask do_populate_sdk_setscene
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600187PSEUDO_IGNORE_PATHS .= ",${SDKDEPLOYDIR},${WORKDIR}/oe-sdk-repo,${WORKDIR}/sstate-build-populate_sdk"
Andrew Geisslerf0343792020-11-18 10:42:21 -0600188
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189fakeroot create_sdk_files() {
190 cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/
191
192 # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern.
193 # Escape special characters like '+' and '.' in the SDKPATH
194 escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
195 sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
Andrew Geissler82c905d2020-04-13 13:39:40 -0500196
197 mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
198 echo '${SDKPATHNATIVE}${libdir_nativesdk}
199${SDKPATHNATIVE}${base_libdir_nativesdk}
200include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500201}
202
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500203python check_sdk_sysroots() {
204 # Fails build if there are broken or dangling symlinks in SDK sysroots
205
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500206 if d.getVar('CHECK_SDK_SYSROOTS') != '1':
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500207 # disabled, bail out
208 return
209
210 def norm_path(path):
211 return os.path.abspath(path)
212
213 # Get scan root
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500214 SCAN_ROOT = norm_path("%s/%s/sysroots/" % (d.getVar('SDK_OUTPUT'),
215 d.getVar('SDKPATH')))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500216
217 bb.note('Checking SDK sysroots at ' + SCAN_ROOT)
218
219 def check_symlink(linkPath):
220 if not os.path.islink(linkPath):
221 return
222
223 linkDirPath = os.path.dirname(linkPath)
224
225 targetPath = os.readlink(linkPath)
226 if not os.path.isabs(targetPath):
227 targetPath = os.path.join(linkDirPath, targetPath)
228 targetPath = norm_path(targetPath)
229
230 if SCAN_ROOT != os.path.commonprefix( [SCAN_ROOT, targetPath] ):
231 bb.error("Escaping symlink {0!s} --> {1!s}".format(linkPath, targetPath))
232 return
233
234 if not os.path.exists(targetPath):
235 bb.error("Broken symlink {0!s} --> {1!s}".format(linkPath, targetPath))
236 return
237
238 if os.path.isdir(targetPath):
239 dir_walk(targetPath)
240
241 def walk_error_handler(e):
242 bb.error(str(e))
243
244 def dir_walk(rootDir):
245 for dirPath,subDirEntries,fileEntries in os.walk(rootDir, followlinks=False, onerror=walk_error_handler):
246 entries = subDirEntries + fileEntries
247 for e in entries:
248 ePath = os.path.join(dirPath, e)
249 check_symlink(ePath)
250
251 # start
252 dir_walk(SCAN_ROOT)
253}
254
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500255SDKTAROPTS = "--owner=root --group=root"
256
Brad Bishopc342db32019-05-15 21:57:59 -0400257fakeroot archive_sdk() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500258 # Package it up
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600259 mkdir -p ${SDKDEPLOYDIR}
Brad Bishopc342db32019-05-15 21:57:59 -0400260 ${SDK_ARCHIVE_CMD}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500261}
262
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800263TOOLCHAIN_SHAR_EXT_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-extract.sh"
264TOOLCHAIN_SHAR_REL_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-relocate.sh"
265
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500266fakeroot create_shar() {
267 # copy in the template shar extractor script
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800268 cp ${TOOLCHAIN_SHAR_EXT_TMPL} ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500269
270 rm -f ${T}/pre_install_command ${T}/post_install_command
271
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600272 if [ "${SDK_RELOCATE_AFTER_INSTALL}" = "1" ] ; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800273 cp ${TOOLCHAIN_SHAR_REL_TMPL} ${T}/post_install_command
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500274 fi
275 cat << "EOF" >> ${T}/pre_install_command
276${SDK_PRE_INSTALL_COMMAND}
277EOF
278
279 cat << "EOF" >> ${T}/post_install_command
280${SDK_POST_INSTALL_COMMAND}
281EOF
282 sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \
283 -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600284 ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500285
286 # substitute variables
287 sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \
288 -e 's#@SDKPATH@#${SDKPATH}#g' \
Patrick Williams213cb262021-08-07 19:21:33 -0500289 -e 's#@SDKPATHINSTALL@#${SDKPATHINSTALL}#g' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500290 -e 's#@SDKEXTPATH@#${SDKEXTPATH}#g' \
291 -e 's#@OLDEST_KERNEL@#${SDK_OLDEST_KERNEL}#g' \
292 -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \
Brad Bishop19323692019-04-05 15:28:33 -0400293 -e 's#@SDK_TITLE@#${@d.getVar("SDK_TITLE").replace('&', '\\&')}#g' \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500294 -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \
295 -e '/@SDK_PRE_INSTALL_COMMAND@/d' \
296 -e '/@SDK_POST_INSTALL_COMMAND@/d' \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800297 -e 's#@SDK_GCC_VER@#${@oe.utils.host_gcc_version(d, taskcontextonly=True)}#g' \
Brad Bishopc342db32019-05-15 21:57:59 -0400298 -e 's#@SDK_ARCHIVE_TYPE@#${SDK_ARCHIVE_TYPE}#g' \
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600299 ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500300
301 # add execution permission
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600302 chmod +x ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500303
304 # append the SDK tarball
Brad Bishopc342db32019-05-15 21:57:59 -0400305 cat ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} >> ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500306
307 # delete the old tarball, we don't need it anymore
Brad Bishopc342db32019-05-15 21:57:59 -0400308 rm ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500309}
310
311populate_sdk_log_check() {
312 for target in $*
313 do
314 lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}"
315
316 echo "log_check: Using $lf_path as logfile"
317
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500318 if [ -e "$lf_path" ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500319 ${IMAGE_PKGTYPE}_log_check $target $lf_path
320 else
321 echo "Cannot find logfile [$lf_path]"
322 fi
323 echo "Logfile is clean"
324 done
325}
326
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500327def sdk_command_variables(d):
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500328 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 -0500329
330def sdk_variables(d):
331 variables = ['BUILD_IMAGES_FROM_FEEDS','SDK_OS','SDK_OUTPUT','SDKPATHNATIVE','SDKTARGETSYSROOT','SDK_DIR','SDK_VENDOR','SDKIMAGE_INSTALL_COMPLEMENTARY','SDK_PACKAGE_ARCHS','SDK_OUTPUT',
332 'SDKTARGETSYSROOT','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS','PACKAGE_ARCHS',
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800333 '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 -0500334 variables.extend(sdk_command_variables(d))
335 return " ".join(variables)
336
337do_populate_sdk[vardeps] += "${@sdk_variables(d)}"
338
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500339python () {
340 variables = sdk_command_variables(d)
341 for var in variables:
342 if d.getVar(var, False):
343 d.setVarFlag(var, 'func', '1')
344}
345
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800346do_populate_sdk[file-checksums] += "${TOOLCHAIN_SHAR_REL_TMPL}:True \
347 ${TOOLCHAIN_SHAR_EXT_TMPL}:True"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500348
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500349do_populate_sdk[dirs] = "${PKGDATA_DIR} ${TOPDIR}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500350do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS').split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}"
351do_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 -0500352do_populate_sdk[recrdeptask] += "do_packagedata do_package_write_rpm do_package_write_ipk do_package_write_deb"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800353do_populate_sdk[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354addtask populate_sdk