blob: 35e129b0685395e6ae4776a42affec0e501f417d [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit meta
2
3# Wildcards specifying complementary packages to install for every package that has been explicitly
4# installed into the rootfs
5COMPLEMENTARY_GLOB[dev-pkgs] = '*-dev'
6COMPLEMENTARY_GLOB[staticdev-pkgs] = '*-staticdev'
7COMPLEMENTARY_GLOB[doc-pkgs] = '*-doc'
8COMPLEMENTARY_GLOB[dbg-pkgs] = '*-dbg'
9COMPLEMENTARY_GLOB[ptest-pkgs] = '*-ptest'
10
11def 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
20SDKIMAGE_FEATURES ??= "dev-pkgs dbg-pkgs"
21SDKIMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("SDKIMAGE_FEATURES", d)}'
22
23inherit rootfs_${IMAGE_PKGTYPE}
24
25SDK_DIR = "${WORKDIR}/sdk"
26SDK_OUTPUT = "${SDK_DIR}/image"
27SDK_DEPLOY = "${DEPLOY_DIR}/sdk"
28
29B_task-populate-sdk = "${SDK_DIR}"
30
31SDKTARGETSYSROOT = "${SDKPATH}/sysroots/${REAL_MULTIMACH_TARGET_SYS}"
32
33TOOLCHAIN_HOST_TASK ?= "nativesdk-packagegroup-sdk-host packagegroup-cross-canadian-${MACHINE}"
34TOOLCHAIN_HOST_TASK_ATTEMPTONLY ?= ""
35TOOLCHAIN_TARGET_TASK ?= " \
36 ${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target')} \
37 ${@multilib_pkg_extend(d, 'packagegroup-core-standalone-sdk-target-dbg')} \
38 "
39TOOLCHAIN_TARGET_TASK_ATTEMPTONLY ?= ""
40TOOLCHAIN_OUTPUTNAME ?= "${SDK_NAME}-toolchain-${SDK_VERSION}"
41
42SDK_RDEPENDS = "${TOOLCHAIN_TARGET_TASK} ${TOOLCHAIN_HOST_TASK}"
43SDK_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
47REAL_MULTIMACH_TARGET_SYS = "${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}"
48
49PID = "${@os.getpid()}"
50
51EXCLUDE_FROM_WORLD = "1"
52
53SDK_PACKAGING_FUNC ?= "create_shar"
54SDK_PRE_INSTALL_COMMAND ?= ""
55SDK_POST_INSTALL_COMMAND ?= ""
56SDK_RELOCATE_AFTER_INSTALL ?= "1"
57
58SDKEXTPATH ?= "~/${@d.getVar('DISTRO', True)}_sdk"
59SDK_TITLE ?= "${@d.getVar('DISTRO_NAME', True) or d.getVar('DISTRO', True)} SDK"
60
61SDK_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.target.manifest"
62SDK_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.host.manifest"
63python 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
72python 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
81POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; "
82POPULATE_SDK_POST_HOST_COMMAND_append = " write_host_sdk_manifest; "
Patrick Williamsf1e5d692016-03-30 15:21:19 -050083SDK_POSTPROCESS_COMMAND = " create_sdk_files; tar_sdk; ${SDK_PACKAGING_FUNC}; "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084
85# Some archs override this, we need the nativesdk version
86# turns out this is hard to get from the datastore due to TRANSLATED_TARGET_ARCH
87# manipulation.
88SDK_OLDEST_KERNEL = "2.6.32"
89
90fakeroot python do_populate_sdk() {
91 from oe.sdk import populate_sdk
92 from oe.manifest import create_manifest, Manifest
93
94 pn = d.getVar('PN', True)
95 runtime_mapping_rename("TOOLCHAIN_TARGET_TASK", pn, d)
96 runtime_mapping_rename("TOOLCHAIN_TARGET_TASK_ATTEMPTONLY", pn, d)
97
98 ld = bb.data.createCopy(d)
99 ld.setVar("PKGDATA_DIR", "${STAGING_DIR}/${SDK_ARCH}-${SDKPKGSUFFIX}${SDK_VENDOR}-${SDK_OS}/pkgdata")
100 runtime_mapping_rename("TOOLCHAIN_HOST_TASK", pn, ld)
101 runtime_mapping_rename("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", pn, ld)
102 d.setVar("TOOLCHAIN_HOST_TASK", ld.getVar("TOOLCHAIN_HOST_TASK", True))
103 d.setVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", ld.getVar("TOOLCHAIN_HOST_TASK_ATTEMPTONLY", True))
104
105 # create target/host SDK manifests
106 create_manifest(d, manifest_dir=d.getVar('SDK_DIR', True),
107 manifest_type=Manifest.MANIFEST_TYPE_SDK_HOST)
108 create_manifest(d, manifest_dir=d.getVar('SDK_DIR', True),
109 manifest_type=Manifest.MANIFEST_TYPE_SDK_TARGET)
110
111 populate_sdk(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112}
113
114fakeroot create_sdk_files() {
115 cp ${COREBASE}/scripts/relocate_sdk.py ${SDK_OUTPUT}/${SDKPATH}/
116
117 # Replace the ##DEFAULT_INSTALL_DIR## with the correct pattern.
118 # Escape special characters like '+' and '.' in the SDKPATH
119 escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
120 sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
121}
122
123SDKTAROPTS = "--owner=root --group=root"
124
125fakeroot tar_sdk() {
126 # Package it up
127 mkdir -p ${SDK_DEPLOY}
128 cd ${SDK_OUTPUT}/${SDKPATH}
129 tar ${SDKTAROPTS} -cf - . | pbzip2 > ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2
130}
131
132fakeroot create_shar() {
133 # copy in the template shar extractor script
134 cp ${COREBASE}/meta/files/toolchain-shar-extract.sh ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
135
136 rm -f ${T}/pre_install_command ${T}/post_install_command
137
138 if [ ${SDK_RELOCATE_AFTER_INSTALL} -eq 1 ] ; then
139 cp ${COREBASE}/meta/files/toolchain-shar-relocate.sh ${T}/post_install_command
140 fi
141 cat << "EOF" >> ${T}/pre_install_command
142${SDK_PRE_INSTALL_COMMAND}
143EOF
144
145 cat << "EOF" >> ${T}/post_install_command
146${SDK_POST_INSTALL_COMMAND}
147EOF
148 sed -i -e '/@SDK_PRE_INSTALL_COMMAND@/r ${T}/pre_install_command' \
149 -e '/@SDK_POST_INSTALL_COMMAND@/r ${T}/post_install_command' \
150 ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
151
152 # substitute variables
153 sed -i -e 's#@SDK_ARCH@#${SDK_ARCH}#g' \
154 -e 's#@SDKPATH@#${SDKPATH}#g' \
155 -e 's#@SDKEXTPATH@#${SDKEXTPATH}#g' \
156 -e 's#@OLDEST_KERNEL@#${SDK_OLDEST_KERNEL}#g' \
157 -e 's#@REAL_MULTIMACH_TARGET_SYS@#${REAL_MULTIMACH_TARGET_SYS}#g' \
158 -e 's#@SDK_TITLE@#${SDK_TITLE}#g' \
159 -e 's#@SDK_VERSION@#${SDK_VERSION}#g' \
160 -e '/@SDK_PRE_INSTALL_COMMAND@/d' \
161 -e '/@SDK_POST_INSTALL_COMMAND@/d' \
162 ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
163
164 # add execution permission
165 chmod +x ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
166
167 # append the SDK tarball
168 cat ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2 >> ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
169
170 # delete the old tarball, we don't need it anymore
171 rm ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.tar.bz2
172}
173
174populate_sdk_log_check() {
175 for target in $*
176 do
177 lf_path="`dirname ${BB_LOGFILE}`/log.do_$target.${PID}"
178
179 echo "log_check: Using $lf_path as logfile"
180
181 if test -e "$lf_path"
182 then
183 ${IMAGE_PKGTYPE}_log_check $target $lf_path
184 else
185 echo "Cannot find logfile [$lf_path]"
186 fi
187 echo "Logfile is clean"
188 done
189}
190
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500191do_populate_sdk[dirs] = "${PKGDATA_DIR} ${TOPDIR}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192do_populate_sdk[depends] += "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_DEPENDS', True).split()])} ${@d.getVarFlag('do_rootfs', 'depends', False)}"
193do_populate_sdk[rdepends] = "${@' '.join([x + ':do_populate_sysroot' for x in d.getVar('SDK_RDEPENDS', True).split()])}"
194do_populate_sdk[recrdeptask] += "do_packagedata do_package_write_rpm do_package_write_ipk do_package_write_deb"
195addtask populate_sdk