Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame^] | 1 | PACKAGES = "" |
| 2 | |
| 3 | inherit image-postinst-intercepts image-artifact-names |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | |
| 5 | # Wildcards specifying complementary packages to install for every package that has been explicitly |
| 6 | # installed into the rootfs |
| 7 | COMPLEMENTARY_GLOB[dev-pkgs] = '*-dev' |
| 8 | COMPLEMENTARY_GLOB[staticdev-pkgs] = '*-staticdev' |
| 9 | COMPLEMENTARY_GLOB[doc-pkgs] = '*-doc' |
| 10 | COMPLEMENTARY_GLOB[dbg-pkgs] = '*-dbg' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 11 | COMPLEMENTARY_GLOB[src-pkgs] = '*-src' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | COMPLEMENTARY_GLOB[ptest-pkgs] = '*-ptest' |
Brad Bishop | 00e122a | 2019-10-05 11:10:57 -0400 | [diff] [blame] | 13 | COMPLEMENTARY_GLOB[bash-completion-pkgs] = '*-bash-completion' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 | |
| 15 | def complementary_globs(featurevar, d): |
| 16 | all_globs = d.getVarFlags('COMPLEMENTARY_GLOB') |
| 17 | globs = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 18 | features = set((d.getVar(featurevar) or '').split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | for name, glob in all_globs.items(): |
| 20 | if name in features: |
| 21 | globs.append(glob) |
| 22 | return ' '.join(globs) |
| 23 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | SDKIMAGE_FEATURES ??= "dev-pkgs dbg-pkgs src-pkgs ${@bb.utils.contains('DISTRO_FEATURES', 'api-documentation', 'doc-pkgs', '', d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | SDKIMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("SDKIMAGE_FEATURES", d)}' |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 26 | SDKIMAGE_INSTALL_COMPLEMENTARY[vardeps] += "SDKIMAGE_FEATURES" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 28 | PACKAGE_ARCHS:append:task-populate-sdk = " sdk-provides-dummy-target" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 29 | SDK_PACKAGE_ARCHS += "sdk-provides-dummy-${SDKPKGSUFFIX}" |
| 30 | |
Brad Bishop | 0011132 | 2018-04-01 22:23:53 -0400 | [diff] [blame] | 31 | # List of locales to install, or "all" for all of them, or unset for none. |
| 32 | SDKIMAGE_LINGUAS ?= "all" |
| 33 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | inherit rootfs_${IMAGE_PKGTYPE} |
| 35 | |
| 36 | SDK_DIR = "${WORKDIR}/sdk" |
| 37 | SDK_OUTPUT = "${SDK_DIR}/image" |
| 38 | SDK_DEPLOY = "${DEPLOY_DIR}/sdk" |
| 39 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 40 | SDKDEPLOYDIR = "${WORKDIR}/${SDKMACHINE}-deploy-${PN}-populate-sdk" |
| 41 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 42 | B:task-populate-sdk = "${SDK_DIR}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 43 | |
| 44 | SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}" |
| 45 | |
| 46 | TOOLCHAIN_HOST_TASK ?= "nativesdk-packagegroup-sdk-host packagegroup-cross-canadian-${MACHINE}" |
| 47 | TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= "" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | TOOLCHAIN_TARGET_TASK ?= "${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target')} target-sdk-provides-dummy" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 49 | TOOLCHAIN_TARGET_TASK_ATTEMPTONLY ?= "" |
| 50 | TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}" |
| 51 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 52 | # Default archived SDK's suffix |
| 53 | SDK_ARCHIVE_TYPE ?= "tar.xz" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 54 | SDK_XZ_COMPRESSION_LEVEL ?= "-9" |
| 55 | SDK_XZ_OPTIONS ?= "${XZ_DEFAULTS} ${SDK_XZ_COMPRESSION_LEVEL}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 56 | |
| 57 | # To support different sdk type according to SDK_ARCHIVE_TYPE, now support zip and tar.xz |
| 58 | python () { |
| 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 Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 63 | d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; zip -r -y ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} .') |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 64 | else: |
| 65 | d.setVar('SDK_ARCHIVE_DEPENDS', 'xz-native') |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 66 | d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; tar ${SDKTAROPTS} -cf - . | xz ${SDK_XZ_OPTIONS} > ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}') |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 67 | } |
| 68 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 70 | SDK_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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 71 | PATH:prepend = "${WORKDIR}/recipe-sysroot/${SDKPATHNATIVE}${bindir}/crossscripts:${@":".join(all_multilib_tune_values(d, 'STAGING_BINDIR_CROSS').split())}:" |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 72 | SDK_DEPENDS += "nativesdk-glibc-locale" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | |
| 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 |
| 76 | REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 77 | |
| 78 | PID = "${@os.getpid()}" |
| 79 | |
| 80 | EXCLUDE_FROM_WORLD = "1" |
| 81 | |
| 82 | SDK_PACKAGING_FUNC ?= "create_shar" |
| 83 | SDK_PRE_INSTALL_COMMAND ?= "" |
| 84 | SDK_POST_INSTALL_COMMAND ?= "" |
| 85 | SDK_RELOCATE_AFTER_INSTALL ?= "1" |
| 86 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 87 | SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk" |
| 88 | SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 90 | SDK_TARGET_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.target.manifest" |
| 91 | SDK_HOST_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.host.manifest" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest" |
| 93 | SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest" |
| 94 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 95 | python write_target_sdk_manifest () { |
| 96 | from oe.sdk import sdk_list_installed_packages |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 97 | from oe.utils import format_pkg_list |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 98 | sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST")) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 99 | pkgs = sdk_list_installed_packages(d, True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 100 | if not os.path.exists(sdkmanifestdir): |
| 101 | bb.utils.mkdirhier(sdkmanifestdir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | with open(d.getVar('SDK_TARGET_MANIFEST'), 'w') as output: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 103 | output.write(format_pkg_list(pkgs, 'ver')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | } |
| 105 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 106 | python 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 113 | python write_host_sdk_manifest () { |
| 114 | from oe.sdk import sdk_list_installed_packages |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 115 | from oe.utils import format_pkg_list |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 116 | sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST")) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 117 | pkgs = sdk_list_installed_packages(d, False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | if not os.path.exists(sdkmanifestdir): |
| 119 | bb.utils.mkdirhier(sdkmanifestdir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 120 | with open(d.getVar('SDK_HOST_MANIFEST'), 'w') as output: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 121 | output.write(format_pkg_list(pkgs, 'ver')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | } |
| 123 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 124 | POPULATE_SDK_POST_TARGET_COMMAND:append = " write_sdk_test_data ; " |
| 125 | POPULATE_SDK_POST_TARGET_COMMAND:append:task-populate-sdk = " write_target_sdk_manifest ; " |
| 126 | POPULATE_SDK_POST_HOST_COMMAND:append:task-populate-sdk = " write_host_sdk_manifest; " |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 127 | SDK_PACKAGING_COMMAND = "${@'${SDK_PACKAGING_FUNC};' if '${SDK_PACKAGING_FUNC}' else ''}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 128 | SDK_POSTPROCESS_COMMAND = " create_sdk_files; check_sdk_sysroots; archive_sdk; ${SDK_PACKAGING_COMMAND} " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 129 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 130 | def populate_sdk_common(d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 131 | from oe.sdk import populate_sdk |
| 132 | from oe.manifest import create_manifest, Manifest |
| 133 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 134 | # 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 154 | pn = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 155 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 162 | d.setVar("TOOLCHAIN_HOST_TASK", ld.getVar("TOOLCHAIN_HOST_TASK")) |
| 163 | d.setVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", ld.getVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 164 | |
| 165 | # create target/host SDK manifests |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 166 | create_manifest(d, manifest_dir=d.getVar('SDK_DIR'), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 167 | manifest_type=Manifest.MANIFEST_TYPE_SDK_HOST) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 168 | create_manifest(d, manifest_dir=d.getVar('SDK_DIR'), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | manifest_type=Manifest.MANIFEST_TYPE_SDK_TARGET) |
| 170 | |
| 171 | populate_sdk(d) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 172 | |
| 173 | fakeroot python do_populate_sdk() { |
| 174 | populate_sdk_common(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 175 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 176 | SSTATETASKS += "do_populate_sdk" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 177 | SSTATE_SKIP_CREATION:task-populate-sdk = '1' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 178 | do_populate_sdk[cleandirs] = "${SDKDEPLOYDIR}" |
| 179 | do_populate_sdk[sstate-inputdirs] = "${SDKDEPLOYDIR}" |
| 180 | do_populate_sdk[sstate-outputdirs] = "${SDK_DEPLOY}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 181 | do_populate_sdk[stamp-extra-info] = "${MACHINE_ARCH}${SDKMACHINE}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 182 | |
Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 183 | PSEUDO_IGNORE_PATHS .= ",${SDKDEPLOYDIR},${WORKDIR}/oe-sdk-repo,${WORKDIR}/sstate-build-populate_sdk" |
Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 184 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 185 | fakeroot create_sdk_files() { |
| 186 | cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/ |
| 187 | |
| 188 | # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern. |
| 189 | # Escape special characters like '+' and '.' in the SDKPATH |
| 190 | escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g") |
| 191 | sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 192 | |
| 193 | mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ |
| 194 | echo '${SDKPATHNATIVE}${libdir_nativesdk} |
| 195 | ${SDKPATHNATIVE}${base_libdir_nativesdk} |
| 196 | include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | } |
| 198 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 199 | python check_sdk_sysroots() { |
| 200 | # Fails build if there are broken or dangling symlinks in SDK sysroots |
| 201 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 202 | if d.getVar('CHECK_SDK_SYSROOTS') != '1': |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 203 | # disabled, bail out |
| 204 | return |
| 205 | |
| 206 | def norm_path(path): |
| 207 | return os.path.abspath(path) |
| 208 | |
| 209 | # Get scan root |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 210 | SCAN_ROOT = norm_path("%s/%s/sysroots/" % (d.getVar('SDK_OUTPUT'), |
| 211 | d.getVar('SDKPATH'))) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 212 | |
| 213 | bb.note('Checking SDK sysroots at ' + SCAN_ROOT) |
| 214 | |
| 215 | def check_symlink(linkPath): |
| 216 | if not os.path.islink(linkPath): |
| 217 | return |
| 218 | |
| 219 | linkDirPath = os.path.dirname(linkPath) |
| 220 | |
| 221 | targetPath = os.readlink(linkPath) |
| 222 | if not os.path.isabs(targetPath): |
| 223 | targetPath = os.path.join(linkDirPath, targetPath) |
| 224 | targetPath = norm_path(targetPath) |
| 225 | |
| 226 | if SCAN_ROOT != os.path.commonprefix( [SCAN_ROOT, targetPath] ): |
| 227 | bb.error("Escaping symlink {0!s} --> {1!s}".format(linkPath, targetPath)) |
| 228 | return |
| 229 | |
| 230 | if not os.path.exists(targetPath): |
| 231 | bb.error("Broken symlink {0!s} --> {1!s}".format(linkPath, targetPath)) |
| 232 | return |
| 233 | |
| 234 | if os.path.isdir(targetPath): |
| 235 | dir_walk(targetPath) |
| 236 | |
| 237 | def walk_error_handler(e): |
| 238 | bb.error(str(e)) |
| 239 | |
| 240 | def dir_walk(rootDir): |
| 241 | for dirPath,subDirEntries,fileEntries in os.walk(rootDir, followlinks=False, onerror=walk_error_handler): |
| 242 | entries = subDirEntries + fileEntries |
| 243 | for e in entries: |
| 244 | ePath = os.path.join(dirPath, e) |
| 245 | check_symlink(ePath) |
| 246 | |
| 247 | # start |
| 248 | dir_walk(SCAN_ROOT) |
| 249 | } |
| 250 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 251 | SDKTAROPTS = "--owner=root --group=root" |
| 252 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 253 | fakeroot archive_sdk() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 254 | # Package it up |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 255 | mkdir -p ${SDKDEPLOYDIR} |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 256 | ${SDK_ARCHIVE_CMD} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 257 | } |
| 258 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 259 | TOOLCHAIN_SHAR_EXT_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-extract.sh" |
| 260 | TOOLCHAIN_SHAR_REL_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-relocate.sh" |
| 261 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 262 | fakeroot create_shar() { |
| 263 | # copy in the template shar extractor script |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 264 | cp ${TOOLCHAIN_SHAR_EXT_TMPL} ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 265 | |
| 266 | rm -f ${T}/pre_install_command ${T}/post_install_command |
| 267 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 268 | if [ "${SDK_RELOCATE_AFTER_INSTALL}" = "1" ] ; then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 269 | cp ${TOOLCHAIN_SHAR_REL_TMPL} ${T}/post_install_command |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 270 | fi |
| 271 | cat << "EOF" >> ${T}/pre_install_command |
| 272 | ${SDK_PRE_INSTALL_COMMAND} |
| 273 | EOF |
| 274 | |
| 275 | cat << "EOF" >> ${T}/post_install_command |
| 276 | ${SDK_POST_INSTALL_COMMAND} |
| 277 | EOF |
| 278 | sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \ |
| 279 | -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 280 | ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 281 | |
| 282 | # substitute variables |
| 283 | sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \ |
| 284 | -e 's#@SDKPATH@#${SDKPATH}#g' \ |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 285 | -e 's#@SDKPATHINSTALL@#${SDKPATHINSTALL}#g' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 286 | -e 's#@SDKEXTPATH@#${SDKEXTPATH}#g' \ |
| 287 | -e 's#@OLDEST_KERNEL@#${SDK_OLDEST_KERNEL}#g' \ |
| 288 | -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 289 | -e 's#@SDK_TITLE@#${@d.getVar("SDK_TITLE").replace('&', '\\&')}#g' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 290 | -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \ |
| 291 | -e '/@SDK_PRE_INSTALL_COMMAND@/d' \ |
| 292 | -e '/@SDK_POST_INSTALL_COMMAND@/d' \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 293 | -e 's#@SDK_GCC_VER@#${@oe.utils.host_gcc_version(d, taskcontextonly=True)}#g' \ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 294 | -e 's#@SDK_ARCHIVE_TYPE@#${SDK_ARCHIVE_TYPE}#g' \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 295 | ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 296 | |
| 297 | # add execution permission |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 298 | chmod +x ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 299 | |
| 300 | # append the SDK tarball |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 301 | cat ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} >> ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 302 | |
| 303 | # delete the old tarball, we don't need it anymore |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 304 | rm ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | populate_sdk_log_check() { |
| 308 | for target in $* |
| 309 | do |
| 310 | lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}" |
| 311 | |
| 312 | echo "log_check: Using $lf_path as logfile" |
| 313 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 314 | if [ -e "$lf_path" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 315 | ${IMAGE_PKGTYPE}_log_check $target $lf_path |
| 316 | else |
| 317 | echo "Cannot find logfile [$lf_path]" |
| 318 | fi |
| 319 | echo "Logfile is clean" |
| 320 | done |
| 321 | } |
| 322 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 323 | def sdk_command_variables(d): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 324 | 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 325 | |
| 326 | def sdk_variables(d): |
| 327 | variables = ['BUILD_IMAGES_FROM_FEEDS','SDK_OS','SDK_OUTPUT','SDKPATHNATIVE','SDKTARGETSYSROOT','SDK_DIR','SDK_VENDOR','SDKIMAGE_INSTALL_COMPLEMENTARY','SDK_PACKAGE_ARCHS','SDK_OUTPUT', |
| 328 | 'SDKTARGETSYSROOT','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS','PACKAGE_ARCHS', |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 329 | 'PACKAGE_CLASSES','TARGET_VENDOR','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'IMAGE_INSTALL_DEBUGFS'] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 330 | variables.extend(sdk_command_variables(d)) |
| 331 | return " ".join(variables) |
| 332 | |
| 333 | do_populate_sdk[vardeps] += "${@sdk_variables(d)}" |
| 334 | |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 335 | python () { |
| 336 | variables = sdk_command_variables(d) |
| 337 | for var in variables: |
| 338 | if d.getVar(var, False): |
| 339 | d.setVarFlag(var, 'func', '1') |
| 340 | } |
| 341 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 342 | do_populate_sdk[file-checksums] += "${TOOLCHAIN_SHAR_REL_TMPL}:True \ |
| 343 | ${TOOLCHAIN_SHAR_EXT_TMPL}:True" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 344 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 345 | do_populate_sdk[dirs] = "${PKGDATA_DIR} ${TOPDIR}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 346 | do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS').split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}" |
| 347 | do_populate_sdk[rdepends] = "${@' '.join([x + ':do_package_write_${IMAGE_PKGTYPE} ' + x + ':do_packagedata' for x in d.getVar('SDK_RDEPENDS').split()])}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 348 | do_populate_sdk[recrdeptask] += "do_packagedata do_package_write_rpm do_package_write_ipk do_package_write_deb" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 349 | do_populate_sdk[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 350 | addtask populate_sdk |