Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | inherit meta image-postinst-intercepts |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 2 | |
| 3 | # Wildcards specifying complementary packages to install for every package that has been explicitly |
| 4 | # installed into the rootfs |
| 5 | COMPLEMENTARY_GLOB[dev-pkgs] = '*-dev' |
| 6 | COMPLEMENTARY_GLOB[staticdev-pkgs] = '*-staticdev' |
| 7 | COMPLEMENTARY_GLOB[doc-pkgs] = '*-doc' |
| 8 | COMPLEMENTARY_GLOB[dbg-pkgs] = '*-dbg' |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 9 | COMPLEMENTARY_GLOB[src-pkgs] = '*-src' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | COMPLEMENTARY_GLOB[ptest-pkgs] = '*-ptest' |
| 11 | |
| 12 | def complementary_globs(featurevar, d): |
| 13 | all_globs = d.getVarFlags('COMPLEMENTARY_GLOB') |
| 14 | globs = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 15 | features = set((d.getVar(featurevar) or '').split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | for name, glob in all_globs.items(): |
| 17 | if name in features: |
| 18 | globs.append(glob) |
| 19 | return ' '.join(globs) |
| 20 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 21 | 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] | 22 | SDKIMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("SDKIMAGE_FEATURES", d)}' |
| 23 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 24 | PACKAGE_ARCHS_append_task-populate-sdk = " sdk-provides-dummy-target" |
| 25 | SDK_PACKAGE_ARCHS += "sdk-provides-dummy-${SDKPKGSUFFIX}" |
| 26 | |
Brad Bishop | 0011132 | 2018-04-01 22:23:53 -0400 | [diff] [blame] | 27 | # List of locales to install, or "all" for all of them, or unset for none. |
| 28 | SDKIMAGE_LINGUAS ?= "all" |
| 29 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | inherit rootfs_${IMAGE_PKGTYPE} |
| 31 | |
| 32 | SDK_DIR = "${WORKDIR}/sdk" |
| 33 | SDK_OUTPUT = "${SDK_DIR}/image" |
| 34 | SDK_DEPLOY = "${DEPLOY_DIR}/sdk" |
| 35 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 36 | SDKDEPLOYDIR = "${WORKDIR}/${SDKMACHINE}-deploy-${PN}-populate-sdk" |
| 37 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | B_task-populate-sdk = "${SDK_DIR}" |
| 39 | |
| 40 | SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}" |
| 41 | |
| 42 | TOOLCHAIN_HOST_TASK ?= "nativesdk-packagegroup-sdk-host packagegroup-cross-canadian-${MACHINE}" |
| 43 | TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= "" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | 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] | 45 | TOOLCHAIN_TARGET_TASK_ATTEMPTONLY ?= "" |
| 46 | TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}" |
| 47 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 48 | # Default archived SDK's suffix |
| 49 | SDK_ARCHIVE_TYPE ?= "tar.xz" |
| 50 | |
| 51 | # To support different sdk type according to SDK_ARCHIVE_TYPE, now support zip and tar.xz |
| 52 | python () { |
| 53 | if d.getVar('SDK_ARCHIVE_TYPE') == 'zip': |
| 54 | d.setVar('SDK_ARCHIVE_DEPENDS', 'zip-native') |
| 55 | # SDK_ARCHIVE_CMD used to generate archived sdk ${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} from input dir ${SDK_OUTPUT}/${SDKPATH} to output dir ${SDKDEPLOYDIR} |
| 56 | # recommand to cd into input dir first to avoid archive with buildpath |
| 57 | d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; zip -r ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} .') |
| 58 | else: |
| 59 | d.setVar('SDK_ARCHIVE_DEPENDS', 'xz-native') |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 60 | d.setVar('SDK_ARCHIVE_CMD', 'cd ${SDK_OUTPUT}/${SDKPATH}; tar ${SDKTAROPTS} -cf - . | xz -T 0 -9 > ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE}') |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 61 | } |
| 62 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 64 | 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" |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 65 | PATH_prepend = "${STAGING_DIR_HOST}${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] | 66 | SDK_DEPENDS += "nativesdk-glibc-locale" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | |
| 68 | # We want the MULTIARCH_TARGET_SYS to point to the TUNE_PKGARCH, not PACKAGE_ARCH as it |
| 69 | # could be set to the MACHINE_ARCH |
| 70 | REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 71 | |
| 72 | PID = "${@os.getpid()}" |
| 73 | |
| 74 | EXCLUDE_FROM_WORLD = "1" |
| 75 | |
| 76 | SDK_PACKAGING_FUNC ?= "create_shar" |
| 77 | SDK_PRE_INSTALL_COMMAND ?= "" |
| 78 | SDK_POST_INSTALL_COMMAND ?= "" |
| 79 | SDK_RELOCATE_AFTER_INSTALL ?= "1" |
| 80 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 81 | SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk" |
| 82 | SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 83 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 84 | SDK_TARGET_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.target.manifest" |
| 85 | SDK_HOST_MANIFEST = "${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.host.manifest" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 86 | SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest" |
| 87 | SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest" |
| 88 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 89 | python write_target_sdk_manifest () { |
| 90 | from oe.sdk import sdk_list_installed_packages |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 91 | from oe.utils import format_pkg_list |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 92 | sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST")) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 93 | pkgs = sdk_list_installed_packages(d, True) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 94 | if not os.path.exists(sdkmanifestdir): |
| 95 | bb.utils.mkdirhier(sdkmanifestdir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 96 | with open(d.getVar('SDK_TARGET_MANIFEST'), 'w') as output: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 97 | output.write(format_pkg_list(pkgs, 'ver')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 98 | } |
| 99 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 100 | python write_sdk_test_data() { |
| 101 | from oe.data import export2json |
| 102 | testdata = "%s/%s.testdata.json" % (d.getVar('SDKDEPLOYDIR'), d.getVar('TOOLCHAIN_OUTPUTNAME')) |
| 103 | bb.utils.mkdirhier(os.path.dirname(testdata)) |
| 104 | export2json(d, testdata) |
| 105 | } |
| 106 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | python write_host_sdk_manifest () { |
| 108 | from oe.sdk import sdk_list_installed_packages |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 109 | from oe.utils import format_pkg_list |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 110 | sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST")) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 111 | pkgs = sdk_list_installed_packages(d, False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 112 | if not os.path.exists(sdkmanifestdir): |
| 113 | bb.utils.mkdirhier(sdkmanifestdir) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 114 | with open(d.getVar('SDK_HOST_MANIFEST'), 'w') as output: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 115 | output.write(format_pkg_list(pkgs, 'ver')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 116 | } |
| 117 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 118 | POPULATE_SDK_POST_TARGET_COMMAND_append = " write_sdk_test_data ; " |
| 119 | POPULATE_SDK_POST_TARGET_COMMAND_append_task-populate-sdk = " write_target_sdk_manifest ; " |
| 120 | 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] | 121 | SDK_PACKAGING_COMMAND = "${@'${SDK_PACKAGING_FUNC};' if '${SDK_PACKAGING_FUNC}' else ''}" |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 122 | 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] | 123 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 124 | def populate_sdk_common(d): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | from oe.sdk import populate_sdk |
| 126 | from oe.manifest import create_manifest, Manifest |
| 127 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 128 | # Handle package exclusions |
| 129 | excl_pkgs = (d.getVar("PACKAGE_EXCLUDE") or "").split() |
| 130 | inst_pkgs = (d.getVar("PACKAGE_INSTALL") or "").split() |
| 131 | inst_attempt_pkgs = (d.getVar("PACKAGE_INSTALL_ATTEMPTONLY") or "").split() |
| 132 | |
| 133 | d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs)) |
| 134 | d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs)) |
| 135 | |
| 136 | for pkg in excl_pkgs: |
| 137 | if pkg in inst_pkgs: |
| 138 | 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)) |
| 139 | inst_pkgs.remove(pkg) |
| 140 | |
| 141 | if pkg in inst_attempt_pkgs: |
| 142 | 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)) |
| 143 | inst_attempt_pkgs.remove(pkg) |
| 144 | |
| 145 | d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs)) |
| 146 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs)) |
| 147 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 148 | pn = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 149 | runtime_mapping_rename("TOOLCHAIN_TARGET_TASK", pn, d) |
| 150 | runtime_mapping_rename("TOOLCHAIN_TARGET_TASK_ATTEMPTONLY", pn, d) |
| 151 | |
| 152 | ld = bb.data.createCopy(d) |
| 153 | ld.setVar("PKGDATA_DIR", "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}/pkgdata") |
| 154 | runtime_mapping_rename("TOOLCHAIN_HOST_TASK", pn, ld) |
| 155 | runtime_mapping_rename("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", pn, ld) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 156 | d.setVar("TOOLCHAIN_HOST_TASK", ld.getVar("TOOLCHAIN_HOST_TASK")) |
| 157 | d.setVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", ld.getVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY")) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 158 | |
| 159 | # create target/host SDK manifests |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 160 | create_manifest(d, manifest_dir=d.getVar('SDK_DIR'), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 161 | manifest_type=Manifest.MANIFEST_TYPE_SDK_HOST) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 162 | create_manifest(d, manifest_dir=d.getVar('SDK_DIR'), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 163 | manifest_type=Manifest.MANIFEST_TYPE_SDK_TARGET) |
| 164 | |
| 165 | populate_sdk(d) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 166 | |
| 167 | fakeroot python do_populate_sdk() { |
| 168 | populate_sdk_common(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 169 | } |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 170 | SSTATETASKS += "do_populate_sdk" |
| 171 | SSTATE_SKIP_CREATION_task-populate-sdk = '1' |
| 172 | do_populate_sdk[cleandirs] = "${SDKDEPLOYDIR}" |
| 173 | do_populate_sdk[sstate-inputdirs] = "${SDKDEPLOYDIR}" |
| 174 | do_populate_sdk[sstate-outputdirs] = "${SDK_DEPLOY}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 175 | do_populate_sdk[stamp-extra-info] = "${MACHINE_ARCH}${SDKMACHINE}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | |
| 177 | fakeroot create_sdk_files() { |
| 178 | cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/ |
| 179 | |
| 180 | # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern. |
| 181 | # Escape special characters like '+' and '.' in the SDKPATH |
| 182 | escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g") |
| 183 | sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py |
| 184 | } |
| 185 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 186 | python check_sdk_sysroots() { |
| 187 | # Fails build if there are broken or dangling symlinks in SDK sysroots |
| 188 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 189 | if d.getVar('CHECK_SDK_SYSROOTS') != '1': |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 190 | # disabled, bail out |
| 191 | return |
| 192 | |
| 193 | def norm_path(path): |
| 194 | return os.path.abspath(path) |
| 195 | |
| 196 | # Get scan root |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 197 | SCAN_ROOT = norm_path("%s/%s/sysroots/" % (d.getVar('SDK_OUTPUT'), |
| 198 | d.getVar('SDKPATH'))) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 199 | |
| 200 | bb.note('Checking SDK sysroots at ' + SCAN_ROOT) |
| 201 | |
| 202 | def check_symlink(linkPath): |
| 203 | if not os.path.islink(linkPath): |
| 204 | return |
| 205 | |
| 206 | linkDirPath = os.path.dirname(linkPath) |
| 207 | |
| 208 | targetPath = os.readlink(linkPath) |
| 209 | if not os.path.isabs(targetPath): |
| 210 | targetPath = os.path.join(linkDirPath, targetPath) |
| 211 | targetPath = norm_path(targetPath) |
| 212 | |
| 213 | if SCAN_ROOT != os.path.commonprefix( [SCAN_ROOT, targetPath] ): |
| 214 | bb.error("Escaping symlink {0!s} --> {1!s}".format(linkPath, targetPath)) |
| 215 | return |
| 216 | |
| 217 | if not os.path.exists(targetPath): |
| 218 | bb.error("Broken symlink {0!s} --> {1!s}".format(linkPath, targetPath)) |
| 219 | return |
| 220 | |
| 221 | if os.path.isdir(targetPath): |
| 222 | dir_walk(targetPath) |
| 223 | |
| 224 | def walk_error_handler(e): |
| 225 | bb.error(str(e)) |
| 226 | |
| 227 | def dir_walk(rootDir): |
| 228 | for dirPath,subDirEntries,fileEntries in os.walk(rootDir, followlinks=False, onerror=walk_error_handler): |
| 229 | entries = subDirEntries + fileEntries |
| 230 | for e in entries: |
| 231 | ePath = os.path.join(dirPath, e) |
| 232 | check_symlink(ePath) |
| 233 | |
| 234 | # start |
| 235 | dir_walk(SCAN_ROOT) |
| 236 | } |
| 237 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 238 | SDKTAROPTS = "--owner=root --group=root" |
| 239 | |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 240 | fakeroot archive_sdk() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | # Package it up |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 242 | mkdir -p ${SDKDEPLOYDIR} |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 243 | ${SDK_ARCHIVE_CMD} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 244 | } |
| 245 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 246 | TOOLCHAIN_SHAR_EXT_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-extract.sh" |
| 247 | TOOLCHAIN_SHAR_REL_TMPL ?= "${COREBASE}/meta/files/toolchain-shar-relocate.sh" |
| 248 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 249 | fakeroot create_shar() { |
| 250 | # copy in the template shar extractor script |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 251 | cp ${TOOLCHAIN_SHAR_EXT_TMPL} ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | |
| 253 | rm -f ${T}/pre_install_command ${T}/post_install_command |
| 254 | |
| 255 | if [ ${SDK_RELOCATE_AFTER_INSTALL} -eq 1 ] ; then |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 256 | cp ${TOOLCHAIN_SHAR_REL_TMPL} ${T}/post_install_command |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 257 | fi |
| 258 | cat << "EOF" >> ${T}/pre_install_command |
| 259 | ${SDK_PRE_INSTALL_COMMAND} |
| 260 | EOF |
| 261 | |
| 262 | cat << "EOF" >> ${T}/post_install_command |
| 263 | ${SDK_POST_INSTALL_COMMAND} |
| 264 | EOF |
| 265 | sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \ |
| 266 | -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 267 | ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 268 | |
| 269 | # substitute variables |
| 270 | sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \ |
| 271 | -e 's#@SDKPATH@#${SDKPATH}#g' \ |
| 272 | -e 's#@SDKEXTPATH@#${SDKEXTPATH}#g' \ |
| 273 | -e 's#@OLDEST_KERNEL@#${SDK_OLDEST_KERNEL}#g' \ |
| 274 | -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 275 | -e 's#@SDK_TITLE@#${@d.getVar("SDK_TITLE").replace('&', '\\&')}#g' \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 276 | -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \ |
| 277 | -e '/@SDK_PRE_INSTALL_COMMAND@/d' \ |
| 278 | -e '/@SDK_POST_INSTALL_COMMAND@/d' \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 279 | -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] | 280 | -e 's#@SDK_ARCHIVE_TYPE@#${SDK_ARCHIVE_TYPE}#g' \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 281 | ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 282 | |
| 283 | # add execution permission |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 284 | chmod +x ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 285 | |
| 286 | # append the SDK tarball |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 287 | cat ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} >> ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.sh |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 288 | |
| 289 | # delete the old tarball, we don't need it anymore |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 290 | rm ${SDKDEPLOYDIR}/${TOOLCHAIN_OUTPUTNAME}.${SDK_ARCHIVE_TYPE} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | populate_sdk_log_check() { |
| 294 | for target in $* |
| 295 | do |
| 296 | lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}" |
| 297 | |
| 298 | echo "log_check: Using $lf_path as logfile" |
| 299 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 300 | if [ -e "$lf_path" ]; then |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 301 | ${IMAGE_PKGTYPE}_log_check $target $lf_path |
| 302 | else |
| 303 | echo "Cannot find logfile [$lf_path]" |
| 304 | fi |
| 305 | echo "Logfile is clean" |
| 306 | done |
| 307 | } |
| 308 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 309 | def sdk_command_variables(d): |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 310 | 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] | 311 | |
| 312 | def sdk_variables(d): |
| 313 | variables = ['BUILD_IMAGES_FROM_FEEDS','SDK_OS','SDK_OUTPUT','SDKPATHNATIVE','SDKTARGETSYSROOT','SDK_DIR','SDK_VENDOR','SDKIMAGE_INSTALL_COMPLEMENTARY','SDK_PACKAGE_ARCHS','SDK_OUTPUT', |
| 314 | '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] | 315 | '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] | 316 | variables.extend(sdk_command_variables(d)) |
| 317 | return " ".join(variables) |
| 318 | |
| 319 | do_populate_sdk[vardeps] += "${@sdk_variables(d)}" |
| 320 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 321 | do_populate_sdk[file-checksums] += "${TOOLCHAIN_SHAR_REL_TMPL}:True \ |
| 322 | ${TOOLCHAIN_SHAR_EXT_TMPL}:True" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 323 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 324 | do_populate_sdk[dirs] = "${PKGDATA_DIR} ${TOPDIR}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 325 | do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS').split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}" |
| 326 | 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] | 327 | 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] | 328 | do_populate_sdk[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 329 | addtask populate_sdk |