Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit meta |
| 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' |
| 9 | COMPLEMENTARY_GLOB[ptest-pkgs] = '*-ptest' |
| 10 | |
| 11 | def complementary_globs(featurevar, d): |
| 12 | all_globs = d.getVarFlags('COMPLEMENTARY_GLOB') |
| 13 | globs = [] |
| 14 | features = set((d.getVar(featurevar, True) or '').split()) |
| 15 | for name, glob in all_globs.items(): |
| 16 | if name in features: |
| 17 | globs.append(glob) |
| 18 | return ' '.join(globs) |
| 19 | |
| 20 | SDKIMAGE_FEATURES ??= "dev-pkgs dbg-pkgs" |
| 21 | SDKIMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("SDKIMAGE_FEATURES", d)}' |
| 22 | |
| 23 | inherit rootfs_${IMAGE_PKGTYPE} |
| 24 | |
| 25 | SDK_DIR = "${WORKDIR}/sdk" |
| 26 | SDK_OUTPUT = "${SDK_DIR}/image" |
| 27 | SDK_DEPLOY = "${DEPLOY_DIR}/sdk" |
| 28 | |
| 29 | B_task-populate-sdk = "${SDK_DIR}" |
| 30 | |
| 31 | SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}" |
| 32 | |
| 33 | TOOLCHAIN_HOST_TASK ?= "nativesdk-packagegroup-sdk-host packagegroup-cross-canadian-${MACHINE}" |
| 34 | TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= "" |
| 35 | TOOLCHAIN_TARGET_TASK ?= " \ |
| 36 | ${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target')} \ |
| 37 | ${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target-dbg')} \ |
| 38 | " |
| 39 | TOOLCHAIN_TARGET_TASK_ATTEMPTONLY ?= "" |
| 40 | TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}" |
| 41 | |
| 42 | SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}" |
| 43 | SDK_DEPENDS = "virtual/fakeroot-native pbzip2-native" |
| 44 | |
| 45 | # We want the MULTIARCH_TARGET_SYS to point to the TUNE_PKGARCH, not PACKAGE_ARCH as it |
| 46 | # could be set to the MACHINE_ARCH |
| 47 | REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}" |
| 48 | |
| 49 | PID = "${@os.getpid()}" |
| 50 | |
| 51 | EXCLUDE_FROM_WORLD = "1" |
| 52 | |
| 53 | SDK_PACKAGING_FUNC ?= "create_shar" |
| 54 | SDK_PRE_INSTALL_COMMAND ?= "" |
| 55 | SDK_POST_INSTALL_COMMAND ?= "" |
| 56 | SDK_RELOCATE_AFTER_INSTALL ?= "1" |
| 57 | |
| 58 | SDKEXTPATH ?= "~/${@d.getVar('DISTRO', True)}_sdk" |
| 59 | SDK_TITLE ?= "${@d.getVar('DISTRO_NAME', True) or d.getVar('DISTRO', True)} SDK" |
| 60 | |
| 61 | SDK_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest" |
| 62 | SDK_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest" |
| 63 | python write_target_sdk_manifest () { |
| 64 | from oe.sdk import sdk_list_installed_packages |
| 65 | sdkmanifestdir = os.path.dirname(d.getVar("SDK_TARGET_MANIFEST", True)) |
| 66 | if not os.path.exists(sdkmanifestdir): |
| 67 | bb.utils.mkdirhier(sdkmanifestdir) |
| 68 | with open(d.getVar('SDK_TARGET_MANIFEST', True), 'w') as output: |
| 69 | output.write(sdk_list_installed_packages(d, True, 'ver')) |
| 70 | } |
| 71 | |
| 72 | python write_host_sdk_manifest () { |
| 73 | from oe.sdk import sdk_list_installed_packages |
| 74 | sdkmanifestdir = os.path.dirname(d.getVar("SDK_HOST_MANIFEST", True)) |
| 75 | if not os.path.exists(sdkmanifestdir): |
| 76 | bb.utils.mkdirhier(sdkmanifestdir) |
| 77 | with open(d.getVar('SDK_HOST_MANIFEST', True), 'w') as output: |
| 78 | output.write(sdk_list_installed_packages(d, False, 'ver')) |
| 79 | } |
| 80 | |
| 81 | POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; " |
| 82 | POPULATE_SDK_POST_HOST_COMMAND_append = " write_host_sdk_manifest; " |
| 83 | |
| 84 | # Some archs override this, we need the nativesdk version |
| 85 | # turns out this is hard to get from the datastore due to TRANSLATED_TARGET_ARCH |
| 86 | # manipulation. |
| 87 | SDK_OLDEST_KERNEL = "2.6.32" |
| 88 | |
| 89 | fakeroot python do_populate_sdk() { |
| 90 | from oe.sdk import populate_sdk |
| 91 | from oe.manifest import create_manifest, Manifest |
| 92 | |
| 93 | pn = d.getVar('PN', True) |
| 94 | runtime_mapping_rename("TOOLCHAIN_TARGET_TASK", pn, d) |
| 95 | runtime_mapping_rename("TOOLCHAIN_TARGET_TASK_ATTEMPTONLY", pn, d) |
| 96 | |
| 97 | ld = bb.data.createCopy(d) |
| 98 | ld.setVar("PKGDATA_DIR", "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}/pkgdata") |
| 99 | runtime_mapping_rename("TOOLCHAIN_HOST_TASK", pn, ld) |
| 100 | runtime_mapping_rename("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", pn, ld) |
| 101 | d.setVar("TOOLCHAIN_HOST_TASK", ld.getVar("TOOLCHAIN_HOST_TASK", True)) |
| 102 | d.setVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", ld.getVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", True)) |
| 103 | |
| 104 | # create target/host SDK manifests |
| 105 | create_manifest(d, manifest_dir=d.getVar('SDK_DIR', True), |
| 106 | manifest_type=Manifest.MANIFEST_TYPE_SDK_HOST) |
| 107 | create_manifest(d, manifest_dir=d.getVar('SDK_DIR', True), |
| 108 | manifest_type=Manifest.MANIFEST_TYPE_SDK_TARGET) |
| 109 | |
| 110 | populate_sdk(d) |
| 111 | |
| 112 | # Process DEFAULTTUNE |
| 113 | bb.build.exec_func("create_sdk_files", d) |
| 114 | |
| 115 | bb.build.exec_func("tar_sdk", d) |
| 116 | |
| 117 | sdk_packaging_func = d.getVar("SDK_PACKAGING_FUNC", True) or "" |
| 118 | if sdk_packaging_func.strip(): |
| 119 | bb.build.exec_func(d.getVar("SDK_PACKAGING_FUNC", True), d) |
| 120 | } |
| 121 | |
| 122 | fakeroot create_sdk_files() { |
| 123 | cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/ |
| 124 | |
| 125 | # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern. |
| 126 | # Escape special characters like '+' and '.' in the SDKPATH |
| 127 | escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g") |
| 128 | sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py |
| 129 | } |
| 130 | |
| 131 | SDKTAROPTS = "--owner=root --group=root" |
| 132 | |
| 133 | fakeroot tar_sdk() { |
| 134 | # Package it up |
| 135 | mkdir -p ${SDK_DEPLOY} |
| 136 | cd ${SDK_OUTPUT}/${SDKPATH} |
| 137 | tar ${SDKTAROPTS} -cf - . | pbzip2 > ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 |
| 138 | } |
| 139 | |
| 140 | fakeroot create_shar() { |
| 141 | # copy in the template shar extractor script |
| 142 | cp ${COREBASE}/meta/files/toolchain-shar-extract.sh ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
| 143 | |
| 144 | rm -f ${T}/pre_install_command ${T}/post_install_command |
| 145 | |
| 146 | if [ ${SDK_RELOCATE_AFTER_INSTALL} -eq 1 ] ; then |
| 147 | cp ${COREBASE}/meta/files/toolchain-shar-relocate.sh ${T}/post_install_command |
| 148 | fi |
| 149 | cat << "EOF" >> ${T}/pre_install_command |
| 150 | ${SDK_PRE_INSTALL_COMMAND} |
| 151 | EOF |
| 152 | |
| 153 | cat << "EOF" >> ${T}/post_install_command |
| 154 | ${SDK_POST_INSTALL_COMMAND} |
| 155 | EOF |
| 156 | sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \ |
| 157 | -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \ |
| 158 | ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
| 159 | |
| 160 | # substitute variables |
| 161 | sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \ |
| 162 | -e 's#@SDKPATH@#${SDKPATH}#g' \ |
| 163 | -e 's#@SDKEXTPATH@#${SDKEXTPATH}#g' \ |
| 164 | -e 's#@OLDEST_KERNEL@#${SDK_OLDEST_KERNEL}#g' \ |
| 165 | -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \ |
| 166 | -e 's#@SDK_TITLE@#${SDK_TITLE}#g' \ |
| 167 | -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \ |
| 168 | -e '/@SDK_PRE_INSTALL_COMMAND@/d' \ |
| 169 | -e '/@SDK_POST_INSTALL_COMMAND@/d' \ |
| 170 | ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
| 171 | |
| 172 | # add execution permission |
| 173 | chmod +x ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
| 174 | |
| 175 | # append the SDK tarball |
| 176 | cat ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 >> ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh |
| 177 | |
| 178 | # delete the old tarball, we don't need it anymore |
| 179 | rm ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 |
| 180 | } |
| 181 | |
| 182 | populate_sdk_log_check() { |
| 183 | for target in $* |
| 184 | do |
| 185 | lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}" |
| 186 | |
| 187 | echo "log_check: Using $lf_path as logfile" |
| 188 | |
| 189 | if test -e "$lf_path" |
| 190 | then |
| 191 | ${IMAGE_PKGTYPE}_log_check $target $lf_path |
| 192 | else |
| 193 | echo "Cannot find logfile [$lf_path]" |
| 194 | fi |
| 195 | echo "Logfile is clean" |
| 196 | done |
| 197 | } |
| 198 | |
| 199 | do_populate_sdk[dirs] = "${TOPDIR}" |
| 200 | do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS', True).split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}" |
| 201 | do_populate_sdk[rdepends] = "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_RDEPENDS', True).split()])}" |
| 202 | do_populate_sdk[recrdeptask] += "do_packagedata do_package_write_rpm do_package_write_ipk do_package_write_deb" |
| 203 | addtask populate_sdk |