Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Extensible SDK |
| 2 | |
| 3 | inherit populate_sdk_base |
| 4 | |
| 5 | # NOTE: normally you cannot use task overrides for this kind of thing - this |
| 6 | # only works because of get_sdk_ext_rdepends() |
| 7 | |
| 8 | TOOLCHAIN_HOST_TASK_task-populate-sdk-ext = " \ |
| 9 | meta-environment-extsdk-${MACHINE} \ |
| 10 | " |
| 11 | |
| 12 | TOOLCHAIN_TARGET_TASK_task-populate-sdk-ext = "" |
| 13 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 14 | SDK_RELOCATE_AFTER_INSTALL_task-populate-sdk-ext = "0" |
| 15 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 16 | SDK_EXT = "" |
| 17 | SDK_EXT_task-populate-sdk-ext = "-ext" |
| 18 | |
| 19 | # Options are full or minimal |
| 20 | SDK_EXT_TYPE ?= "full" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 21 | SDK_INCLUDE_PKGDATA ?= "0" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 22 | SDK_INCLUDE_TOOLCHAIN ?= "${@'1' if d.getVar('SDK_EXT_TYPE') == 'full' else '0'}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 23 | |
| 24 | SDK_RECRDEP_TASKS ?= "" |
| 25 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | SDK_LOCAL_CONF_WHITELIST ?= "" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 27 | SDK_LOCAL_CONF_BLACKLIST ?= "CONF_VERSION \ |
| 28 | BB_NUMBER_THREADS \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 29 | BB_NUMBER_PARSE_THREADS \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 30 | PARALLEL_MAKE \ |
| 31 | PRSERV_HOST \ |
| 32 | SSTATE_MIRRORS \ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | DL_DIR \ |
| 34 | SSTATE_DIR \ |
| 35 | TMPDIR \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | BB_SERVER_TIMEOUT \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 37 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 38 | SDK_INHERIT_BLACKLIST ?= "buildhistory icecc" |
| 39 | SDK_UPDATE_URL ?= "" |
| 40 | |
| 41 | SDK_TARGETS ?= "${PN}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 42 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 43 | def get_sdk_install_targets(d, images_only=False): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 44 | sdk_install_targets = '' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 45 | if images_only or d.getVar('SDK_EXT_TYPE') != 'minimal': |
| 46 | sdk_install_targets = d.getVar('SDK_TARGETS') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 47 | |
| 48 | depd = d.getVar('BB_TASKDEPDATA', False) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d) |
| 50 | tasklist.remove('do_build') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 51 | for v in depd.values(): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | if v[1] in tasklist: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 53 | if v[0] not in sdk_install_targets: |
| 54 | sdk_install_targets += ' {}'.format(v[0]) |
| 55 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 56 | if not images_only: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | if d.getVar('SDK_INCLUDE_PKGDATA') == '1': |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 58 | sdk_install_targets += ' meta-world-pkgdata:do_allpackagedata' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 59 | if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1': |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 60 | sdk_install_targets += ' meta-extsdk-toolchain:do_populate_sysroot' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 61 | |
| 62 | return sdk_install_targets |
| 63 | |
| 64 | get_sdk_install_targets[vardepsexclude] = "BB_TASKDEPDATA" |
| 65 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 66 | OE_INIT_ENV_SCRIPT ?= "oe-init-build-env" |
| 67 | |
| 68 | # The files from COREBASE that you want preserved in the COREBASE copied |
| 69 | # into the sdk. This allows someone to have their own setup scripts in |
| 70 | # COREBASE be preserved as well as untracked files. |
| 71 | COREBASE_FILES ?= " \ |
| 72 | oe-init-build-env \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | scripts \ |
| 74 | LICENSE \ |
| 75 | .templateconf \ |
| 76 | " |
| 77 | |
| 78 | SDK_DIR_task-populate-sdk-ext = "${WORKDIR}/sdk-ext" |
| 79 | B_task-populate-sdk-ext = "${SDK_DIR}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 80 | TOOLCHAINEXT_OUTPUTNAME ?= "${SDK_NAME}-toolchain-ext-${SDK_VERSION}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 81 | TOOLCHAIN_OUTPUTNAME_task-populate-sdk-ext = "${TOOLCHAINEXT_OUTPUTNAME}" |
| 82 | |
| 83 | SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest" |
| 84 | SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 86 | python write_target_sdk_ext_manifest () { |
| 87 | from oe.sdk import get_extra_sdkinfo |
| 88 | sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache') |
| 89 | extra_info = get_extra_sdkinfo(sstate_dir) |
| 90 | |
| 91 | target = d.getVar('TARGET_SYS') |
| 92 | target_multimach = d.getVar('MULTIMACH_TARGET_SYS') |
| 93 | real_target_multimach = d.getVar('REAL_MULTIMACH_TARGET_SYS') |
| 94 | |
| 95 | pkgs = {} |
| 96 | with open(d.getVar('SDK_EXT_TARGET_MANIFEST'), 'w') as f: |
| 97 | for fn in extra_info['filesizes']: |
| 98 | info = fn.split(':') |
| 99 | if info[2] in (target, target_multimach, real_target_multimach) \ |
| 100 | or info[5] == 'allarch': |
| 101 | if not info[1] in pkgs: |
| 102 | f.write("%s %s %s\n" % (info[1], info[2], info[3])) |
| 103 | pkgs[info[1]] = {} |
| 104 | } |
| 105 | python write_host_sdk_ext_manifest () { |
| 106 | from oe.sdk import get_extra_sdkinfo |
| 107 | sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache') |
| 108 | extra_info = get_extra_sdkinfo(sstate_dir) |
| 109 | host = d.getVar('BUILD_SYS') |
| 110 | with open(d.getVar('SDK_EXT_HOST_MANIFEST'), 'w') as f: |
| 111 | for fn in extra_info['filesizes']: |
| 112 | info = fn.split(':') |
| 113 | if info[2] == host: |
| 114 | f.write("%s %s %s\n" % (info[1], info[2], info[3])) |
| 115 | } |
| 116 | |
| 117 | SDK_POSTPROCESS_COMMAND_append_task-populate-sdk-ext = "write_target_sdk_ext_manifest; write_host_sdk_ext_manifest; " |
| 118 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 119 | SDK_TITLE_task-populate-sdk-ext = "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} Extensible SDK" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 121 | def clean_esdk_builddir(d, sdkbasepath): |
| 122 | """Clean up traces of the fake build for create_filtered_tasklist()""" |
| 123 | import shutil |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 124 | cleanpaths = 'cache conf/sanity_info tmp'.split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 125 | for pth in cleanpaths: |
| 126 | fullpth = os.path.join(sdkbasepath, pth) |
| 127 | if os.path.isdir(fullpth): |
| 128 | shutil.rmtree(fullpth) |
| 129 | elif os.path.isfile(fullpth): |
| 130 | os.remove(fullpth) |
| 131 | |
| 132 | def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath): |
| 133 | """ |
| 134 | Create a filtered list of tasks. Also double-checks that the build system |
| 135 | within the SDK basically works and required sstate artifacts are available. |
| 136 | """ |
| 137 | import tempfile |
| 138 | import shutil |
| 139 | import oe.copy_buildsystem |
| 140 | |
| 141 | # Create a temporary build directory that we can pass to the env setup script |
| 142 | shutil.copyfile(sdkbasepath + '/conf/local.conf', sdkbasepath + '/conf/local.conf.bak') |
| 143 | try: |
| 144 | with open(sdkbasepath + '/conf/local.conf', 'a') as f: |
| 145 | # Force the use of sstate from the build system |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 146 | f.write('\nSSTATE_DIR_forcevariable = "%s"\n' % d.getVar('SSTATE_DIR')) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 147 | f.write('SSTATE_MIRRORS_forcevariable = "file://universal/(.*) file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 148 | # Ensure TMPDIR is the default so that clean_esdk_builddir() can delete it |
| 149 | f.write('TMPDIR_forcevariable = "${TOPDIR}/tmp"\n') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 150 | f.write('TCLIBCAPPEND_forcevariable = ""\n') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 151 | # Drop uninative if the build isn't using it (or else NATIVELSBSTRING will |
| 152 | # be different and we won't be able to find our native sstate) |
| 153 | if not bb.data.inherits_class('uninative', d): |
| 154 | f.write('INHERIT_remove = "uninative"\n') |
| 155 | |
| 156 | # Unfortunately the default SDKPATH (or even a custom value) may contain characters that bitbake |
| 157 | # will not allow in its COREBASE path, so we need to rename the directory temporarily |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 158 | temp_sdkbasepath = d.getVar('SDK_OUTPUT') + '/tmp-renamed-sdk' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 159 | # Delete any existing temp dir |
| 160 | try: |
| 161 | shutil.rmtree(temp_sdkbasepath) |
| 162 | except FileNotFoundError: |
| 163 | pass |
| 164 | os.rename(sdkbasepath, temp_sdkbasepath) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 165 | cmdprefix = '. %s .; ' % conf_initpath |
| 166 | logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 167 | try: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 168 | oe.copy_buildsystem.check_sstate_task_list(d, get_sdk_install_targets(d), tasklistfile, cmdprefix=cmdprefix, cwd=temp_sdkbasepath, logfile=logfile) |
| 169 | except bb.process.ExecutionError as e: |
| 170 | msg = 'Failed to generate filtered task list for extensible SDK:\n%s' % e.stdout.rstrip() |
| 171 | if 'attempted to execute unexpectedly and should have been setscened' in e.stdout: |
| 172 | msg += '\n----------\n\nNOTE: "attempted to execute unexpectedly and should have been setscened" errors indicate this may be caused by missing sstate artifacts that were likely produced in earlier builds, but have been subsequently deleted for some reason.\n' |
| 173 | bb.fatal(msg) |
| 174 | os.rename(temp_sdkbasepath, sdkbasepath) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 175 | # Clean out residue of running bitbake, which check_sstate_task_list() |
| 176 | # will effectively do |
| 177 | clean_esdk_builddir(d, sdkbasepath) |
| 178 | finally: |
| 179 | os.replace(sdkbasepath + '/conf/local.conf.bak', sdkbasepath + '/conf/local.conf') |
| 180 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 181 | python copy_buildsystem () { |
| 182 | import re |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 183 | import shutil |
| 184 | import glob |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 185 | import oe.copy_buildsystem |
| 186 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 187 | oe_init_env_script = d.getVar('OE_INIT_ENV_SCRIPT') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 188 | |
| 189 | conf_bbpath = '' |
| 190 | conf_initpath = '' |
| 191 | core_meta_subdir = '' |
| 192 | |
| 193 | # Copy in all metadata layers + bitbake (as repositories) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 194 | buildsystem = oe.copy_buildsystem.BuildSystem('extensible SDK', d) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 195 | baseoutpath = d.getVar('SDK_OUTPUT') + '/' + d.getVar('SDKPATH') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 196 | |
| 197 | # Determine if we're building a derivative extensible SDK (from devtool build-sdk) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 198 | derivative = (d.getVar('SDK_DERIVATIVE') or '') == '1' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 199 | if derivative: |
| 200 | workspace_name = 'orig-workspace' |
| 201 | else: |
| 202 | workspace_name = None |
| 203 | layers_copied = buildsystem.copy_bitbake_and_layers(baseoutpath + '/layers', workspace_name) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 204 | |
| 205 | sdkbblayers = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 206 | corebase = os.path.basename(d.getVar('COREBASE')) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 207 | for layer in layers_copied: |
| 208 | if corebase == os.path.basename(layer): |
| 209 | conf_bbpath = os.path.join('layers', layer, 'bitbake') |
| 210 | else: |
| 211 | sdkbblayers.append(layer) |
| 212 | |
| 213 | for path in os.listdir(baseoutpath + '/layers'): |
| 214 | relpath = os.path.join('layers', path, oe_init_env_script) |
| 215 | if os.path.exists(os.path.join(baseoutpath, relpath)): |
| 216 | conf_initpath = relpath |
| 217 | |
| 218 | relpath = os.path.join('layers', path, 'scripts', 'devtool') |
| 219 | if os.path.exists(os.path.join(baseoutpath, relpath)): |
| 220 | scriptrelpath = os.path.dirname(relpath) |
| 221 | |
| 222 | relpath = os.path.join('layers', path, 'meta') |
| 223 | if os.path.exists(os.path.join(baseoutpath, relpath, 'lib', 'oe')): |
| 224 | core_meta_subdir = relpath |
| 225 | |
| 226 | d.setVar('oe_init_build_env_path', conf_initpath) |
| 227 | d.setVar('scriptrelpath', scriptrelpath) |
| 228 | |
| 229 | # Write out config file for devtool |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 230 | import configparser |
| 231 | config = configparser.SafeConfigParser() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 232 | config.add_section('General') |
| 233 | config.set('General', 'bitbake_subdir', conf_bbpath) |
| 234 | config.set('General', 'init_path', conf_initpath) |
| 235 | config.set('General', 'core_meta_subdir', core_meta_subdir) |
| 236 | config.add_section('SDK') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 237 | config.set('SDK', 'sdk_targets', d.getVar('SDK_TARGETS')) |
| 238 | updateurl = d.getVar('SDK_UPDATE_URL') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 239 | if updateurl: |
| 240 | config.set('SDK', 'updateserver', updateurl) |
| 241 | bb.utils.mkdirhier(os.path.join(baseoutpath, 'conf')) |
| 242 | with open(os.path.join(baseoutpath, 'conf', 'devtool.conf'), 'w') as f: |
| 243 | config.write(f) |
| 244 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 245 | unlockedsigs = os.path.join(baseoutpath, 'conf', 'unlocked-sigs.inc') |
| 246 | with open(unlockedsigs, 'w') as f: |
| 247 | pass |
| 248 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 249 | # Create a layer for new recipes / appends |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 250 | bbpath = d.getVar('BBPATH') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 251 | bb.process.run(['devtool', '--bbpath', bbpath, '--basepath', baseoutpath, 'create-workspace', '--create-only', os.path.join(baseoutpath, 'workspace')]) |
| 252 | |
| 253 | # Create bblayers.conf |
| 254 | bb.utils.mkdirhier(baseoutpath + '/conf') |
| 255 | with open(baseoutpath + '/conf/bblayers.conf', 'w') as f: |
| 256 | f.write('# WARNING: this configuration has been automatically generated and in\n') |
| 257 | f.write('# most cases should not be edited. If you need more flexibility than\n') |
| 258 | f.write('# this configuration provides, it is strongly suggested that you set\n') |
| 259 | f.write('# up a proper instance of the full build system and use that instead.\n\n') |
| 260 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 261 | # LCONF_VERSION may not be set, for example when using meta-poky |
| 262 | # so don't error if it isn't found |
| 263 | lconf_version = d.getVar('LCONF_VERSION', False) |
| 264 | if lconf_version is not None: |
| 265 | f.write('LCONF_VERSION = "%s"\n\n' % lconf_version) |
| 266 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 267 | f.write('BBPATH = "$' + '{TOPDIR}"\n') |
| 268 | f.write('SDKBASEMETAPATH = "$' + '{TOPDIR}"\n') |
| 269 | f.write('BBLAYERS := " \\\n') |
| 270 | for layerrelpath in sdkbblayers: |
| 271 | f.write(' $' + '{SDKBASEMETAPATH}/layers/%s \\\n' % layerrelpath) |
| 272 | f.write(' $' + '{SDKBASEMETAPATH}/workspace \\\n') |
| 273 | f.write(' "\n') |
| 274 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 275 | # Copy uninative tarball |
| 276 | # For now this is where uninative.bbclass expects the tarball |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 277 | if bb.data.inherits_class('uninative', d): |
| 278 | uninative_file = d.expand('${UNINATIVE_DLDIR}/' + d.getVarFlag("UNINATIVE_CHECKSUM", d.getVar("BUILD_ARCH")) + '/${UNINATIVE_TARBALL}') |
| 279 | uninative_checksum = bb.utils.sha256_file(uninative_file) |
| 280 | uninative_outdir = '%s/downloads/uninative/%s' % (baseoutpath, uninative_checksum) |
| 281 | bb.utils.mkdirhier(uninative_outdir) |
| 282 | shutil.copy(uninative_file, uninative_outdir) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 283 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 284 | env_whitelist = (d.getVar('BB_ENV_EXTRAWHITE') or '').split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 285 | env_whitelist_values = {} |
| 286 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 287 | # Create local.conf |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 288 | builddir = d.getVar('TOPDIR') |
| 289 | if derivative and os.path.exists(builddir + '/conf/auto.conf'): |
| 290 | shutil.copyfile(builddir + '/conf/auto.conf', baseoutpath + '/conf/auto.conf') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 291 | if derivative: |
| 292 | shutil.copyfile(builddir + '/conf/local.conf', baseoutpath + '/conf/local.conf') |
| 293 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 294 | local_conf_whitelist = (d.getVar('SDK_LOCAL_CONF_WHITELIST') or '').split() |
| 295 | local_conf_blacklist = (d.getVar('SDK_LOCAL_CONF_BLACKLIST') or '').split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 296 | def handle_var(varname, origvalue, op, newlines): |
| 297 | if varname in local_conf_blacklist or (origvalue.strip().startswith('/') and not varname in local_conf_whitelist): |
| 298 | newlines.append('# Removed original setting of %s\n' % varname) |
| 299 | return None, op, 0, True |
| 300 | else: |
| 301 | if varname in env_whitelist: |
| 302 | env_whitelist_values[varname] = origvalue |
| 303 | return origvalue, op, 0, True |
| 304 | varlist = ['[^#=+ ]*'] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 305 | oldlines = [] |
| 306 | if os.path.exists(builddir + '/conf/auto.conf'): |
| 307 | with open(builddir + '/conf/auto.conf', 'r') as f: |
| 308 | oldlines += f.readlines() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 309 | with open(builddir + '/conf/local.conf', 'r') as f: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 310 | oldlines += f.readlines() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 311 | (updated, newlines) = bb.utils.edit_metadata(oldlines, varlist, handle_var) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 312 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 313 | with open(baseoutpath + '/conf/local.conf', 'w') as f: |
| 314 | f.write('# WARNING: this configuration has been automatically generated and in\n') |
| 315 | f.write('# most cases should not be edited. If you need more flexibility than\n') |
| 316 | f.write('# this configuration provides, it is strongly suggested that you set\n') |
| 317 | f.write('# up a proper instance of the full build system and use that instead.\n\n') |
| 318 | for line in newlines: |
| 319 | if line.strip() and not line.startswith('#'): |
| 320 | f.write(line) |
| 321 | # Write a newline just in case there's none at the end of the original |
| 322 | f.write('\n') |
| 323 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 324 | f.write('TMPDIR = "${TOPDIR}/tmp"\n') |
| 325 | f.write('TCLIBCAPPEND = ""\n') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 326 | f.write('DL_DIR = "${TOPDIR}/downloads"\n') |
| 327 | |
| 328 | f.write('INHERIT += "%s"\n' % 'uninative') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 329 | f.write('UNINATIVE_CHECKSUM[%s] = "%s"\n\n' % (d.getVar('BUILD_ARCH'), uninative_checksum)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 330 | f.write('CONF_VERSION = "%s"\n\n' % d.getVar('CONF_VERSION', False)) |
| 331 | |
| 332 | # Some classes are not suitable for SDK, remove them from INHERIT |
| 333 | f.write('INHERIT_remove = "%s"\n' % d.getVar('SDK_INHERIT_BLACKLIST', False)) |
| 334 | |
| 335 | # Bypass the default connectivity check if any |
| 336 | f.write('CONNECTIVITY_CHECK_URIS = ""\n\n') |
| 337 | |
| 338 | # This warning will come out if reverse dependencies for a task |
| 339 | # don't have sstate as well as the task itself. We already know |
| 340 | # this will be the case for the extensible sdk, so turn off the |
| 341 | # warning. |
| 342 | f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n') |
| 343 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 344 | # Warn if the sigs in the locked-signature file don't match |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 345 | # the sig computed from the metadata. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 346 | f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"\n\n') |
| 347 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 348 | # We want to be able to set this without a full reparse |
| 349 | f.write('BB_HASHCONFIG_WHITELIST_append = " SIGGEN_UNLOCKED_RECIPES"\n\n') |
| 350 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 351 | # Set up whitelist for run on install |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 352 | f.write('BB_SETSCENE_ENFORCE_WHITELIST = "%:* *:do_shared_workdir *:do_rm_work wic-tools:* *:do_addto_recipe_sysroot"\n\n') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 353 | |
| 354 | # Hide the config information from bitbake output (since it's fixed within the SDK) |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 355 | f.write('BUILDCFG_HEADER = ""\n\n') |
| 356 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 357 | f.write('# Provide a flag to indicate we are in the EXT_SDK Context\n') |
| 358 | f.write('WITHIN_EXT_SDK = "1"\n\n') |
| 359 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 360 | # Map gcc-dependent uninative sstate cache for installer usage |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 361 | f.write('SSTATE_MIRRORS += " file://universal/(.*) file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n\n') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 362 | |
| 363 | # Allow additional config through sdk-extra.conf |
| 364 | fn = bb.cookerdata.findConfigFile('sdk-extra.conf', d) |
| 365 | if fn: |
| 366 | with open(fn, 'r') as xf: |
| 367 | for line in xf: |
| 368 | f.write(line) |
| 369 | |
| 370 | # If you define a sdk_extraconf() function then it can contain additional config |
| 371 | # (Though this is awkward; sdk-extra.conf should probably be used instead) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 372 | extraconf = (d.getVar('sdk_extraconf') or '').strip() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 373 | if extraconf: |
| 374 | # Strip off any leading / trailing spaces |
| 375 | for line in extraconf.splitlines(): |
| 376 | f.write(line.strip() + '\n') |
| 377 | |
| 378 | f.write('require conf/locked-sigs.inc\n') |
| 379 | f.write('require conf/unlocked-sigs.inc\n') |
| 380 | |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 381 | # Write a templateconf.cfg |
| 382 | with open(baseoutpath + '/conf/templateconf.cfg', 'w') as f: |
| 383 | f.write('meta/conf\n') |
| 384 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 385 | # Ensure any variables set from the external environment (by way of |
| 386 | # BB_ENV_EXTRAWHITE) are set in the SDK's configuration |
| 387 | extralines = [] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 388 | for name, value in env_whitelist_values.items(): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 389 | actualvalue = d.getVar(name) or '' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 390 | if value != actualvalue: |
| 391 | extralines.append('%s = "%s"\n' % (name, actualvalue)) |
| 392 | if extralines: |
| 393 | with open(baseoutpath + '/conf/local.conf', 'a') as f: |
| 394 | f.write('\n') |
| 395 | f.write('# Extra settings from environment:\n') |
| 396 | for line in extralines: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 397 | f.write(line) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 398 | f.write('\n') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 399 | |
| 400 | # Filter the locked signatures file to just the sstate tasks we are interested in |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 401 | excluded_targets = get_sdk_install_targets(d, images_only=True) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 402 | sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 403 | lockedsigs_pruned = baseoutpath + '/conf/locked-sigs.inc' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 404 | oe.copy_buildsystem.prune_lockedsigs([], |
| 405 | excluded_targets.split(), |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 406 | sigfile, |
| 407 | lockedsigs_pruned) |
| 408 | |
| 409 | sstate_out = baseoutpath + '/sstate-cache' |
| 410 | bb.utils.remove(sstate_out, True) |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 411 | |
| 412 | # uninative.bbclass sets NATIVELSBSTRING to 'universal%s' % oe.utils.host_gcc_version(d) |
| 413 | fixedlsbstring = "universal%s" % oe.utils.host_gcc_version(d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 414 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 415 | sdk_include_toolchain = (d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1') |
| 416 | sdk_ext_type = d.getVar('SDK_EXT_TYPE') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 417 | if sdk_ext_type != 'minimal' or sdk_include_toolchain or derivative: |
| 418 | # Create the filtered task list used to generate the sstate cache shipped with the SDK |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 419 | tasklistfn = d.getVar('WORKDIR') + '/tasklist.txt' |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 420 | create_filtered_tasklist(d, baseoutpath, tasklistfn, conf_initpath) |
| 421 | else: |
| 422 | tasklistfn = None |
| 423 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 424 | # Add packagedata if enabled |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 425 | if d.getVar('SDK_INCLUDE_PKGDATA') == '1': |
| 426 | lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base.inc' |
| 427 | lockedsigs_copy = d.getVar('WORKDIR') + '/locked-sigs-copy.inc' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 428 | shutil.move(lockedsigs_pruned, lockedsigs_base) |
| 429 | oe.copy_buildsystem.merge_lockedsigs(['do_packagedata'], |
| 430 | lockedsigs_base, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 431 | d.getVar('STAGING_DIR_HOST') + '/world-pkgdata/locked-sigs-pkgdata.inc', |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 432 | lockedsigs_pruned, |
| 433 | lockedsigs_copy) |
| 434 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 435 | if sdk_include_toolchain: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 436 | lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base2.inc' |
| 437 | lockedsigs_toolchain = d.expand("${STAGING_DIR}/${TUNE_PKGARCH}/meta-extsdk-toolchain/locked-sigs/locked-sigs-extsdk-toolchain.inc") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 438 | shutil.move(lockedsigs_pruned, lockedsigs_base) |
| 439 | oe.copy_buildsystem.merge_lockedsigs([], |
| 440 | lockedsigs_base, |
| 441 | lockedsigs_toolchain, |
| 442 | lockedsigs_pruned) |
| 443 | oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_toolchain, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 444 | d.getVar('SSTATE_DIR'), |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 445 | sstate_out, d, |
| 446 | fixedlsbstring, |
| 447 | filterfile=tasklistfn) |
| 448 | |
| 449 | if sdk_ext_type == 'minimal': |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 450 | if derivative: |
| 451 | # Assume the user is not going to set up an additional sstate |
| 452 | # mirror, thus we need to copy the additional artifacts (from |
| 453 | # workspace recipes) into the derivative SDK |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 454 | lockedsigs_orig = d.getVar('TOPDIR') + '/conf/locked-sigs.inc' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 455 | if os.path.exists(lockedsigs_orig): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 456 | lockedsigs_extra = d.getVar('WORKDIR') + '/locked-sigs-extra.inc' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 457 | oe.copy_buildsystem.merge_lockedsigs(None, |
| 458 | lockedsigs_orig, |
| 459 | lockedsigs_pruned, |
| 460 | None, |
| 461 | lockedsigs_extra) |
| 462 | oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_extra, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 463 | d.getVar('SSTATE_DIR'), |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 464 | sstate_out, d, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 465 | fixedlsbstring, |
| 466 | filterfile=tasklistfn) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 467 | else: |
| 468 | oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_pruned, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 469 | d.getVar('SSTATE_DIR'), |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 470 | sstate_out, d, |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 471 | fixedlsbstring, |
| 472 | filterfile=tasklistfn) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 473 | |
| 474 | # We don't need sstate do_package files |
| 475 | for root, dirs, files in os.walk(sstate_out): |
| 476 | for name in files: |
| 477 | if name.endswith("_package.tgz"): |
| 478 | f = os.path.join(root, name) |
| 479 | os.remove(f) |
| 480 | |
| 481 | # Write manifest file |
| 482 | # Note: at the moment we cannot include the env setup script here to keep |
| 483 | # it updated, since it gets modified during SDK installation (see |
| 484 | # sdk_ext_postinst() below) thus the checksum we take here would always |
| 485 | # be different. |
| 486 | manifest_file_list = ['conf/*'] |
| 487 | manifest_file = os.path.join(baseoutpath, 'conf', 'sdk-conf-manifest') |
| 488 | with open(manifest_file, 'w') as f: |
| 489 | for item in manifest_file_list: |
| 490 | for fn in glob.glob(os.path.join(baseoutpath, item)): |
| 491 | if fn == manifest_file: |
| 492 | continue |
| 493 | chksum = bb.utils.sha256_file(fn) |
| 494 | f.write('%s\t%s\n' % (chksum, os.path.relpath(fn, baseoutpath))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 495 | } |
| 496 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 497 | def get_current_buildtools(d): |
| 498 | """Get the file name of the current buildtools installer""" |
| 499 | import glob |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 500 | btfiles = glob.glob(os.path.join(d.getVar('SDK_DEPLOY'), '*-buildtools-nativesdk-standalone-*.sh')) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 501 | btfiles.sort(key=os.path.getctime) |
| 502 | return os.path.basename(btfiles[-1]) |
| 503 | |
| 504 | def get_sdk_required_utilities(buildtools_fn, d): |
| 505 | """Find required utilities that aren't provided by the buildtools""" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 506 | sanity_required_utilities = (d.getVar('SANITY_REQUIRED_UTILITIES') or '').split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 507 | sanity_required_utilities.append(d.expand('${BUILD_PREFIX}gcc')) |
| 508 | sanity_required_utilities.append(d.expand('${BUILD_PREFIX}g++')) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 509 | buildtools_installer = os.path.join(d.getVar('SDK_DEPLOY'), buildtools_fn) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 510 | filelist, _ = bb.process.run('%s -l' % buildtools_installer) |
| 511 | localdata = bb.data.createCopy(d) |
| 512 | localdata.setVar('SDKPATH', '.') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 513 | sdkpathnative = localdata.getVar('SDKPATHNATIVE') |
| 514 | sdkbindirs = [localdata.getVar('bindir_nativesdk'), |
| 515 | localdata.getVar('sbindir_nativesdk'), |
| 516 | localdata.getVar('base_bindir_nativesdk'), |
| 517 | localdata.getVar('base_sbindir_nativesdk')] |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 518 | for line in filelist.splitlines(): |
| 519 | splitline = line.split() |
| 520 | if len(splitline) > 5: |
| 521 | fn = splitline[5] |
| 522 | if not fn.startswith('./'): |
| 523 | fn = './%s' % fn |
| 524 | if fn.startswith(sdkpathnative): |
| 525 | relpth = '/' + os.path.relpath(fn, sdkpathnative) |
| 526 | for bindir in sdkbindirs: |
| 527 | if relpth.startswith(bindir): |
| 528 | relpth = os.path.relpath(relpth, bindir) |
| 529 | if relpth in sanity_required_utilities: |
| 530 | sanity_required_utilities.remove(relpth) |
| 531 | break |
| 532 | return ' '.join(sanity_required_utilities) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 533 | |
| 534 | install_tools() { |
| 535 | install -d ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 536 | scripts="devtool recipetool oe-find-native-sysroot runqemu* wic" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 537 | for script in $scripts; do |
| 538 | for scriptfn in `find ${SDK_OUTPUT}/${SDKPATH}/${scriptrelpath} -maxdepth 1 -executable -name "$script"`; do |
| 539 | lnr ${scriptfn} ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/`basename $scriptfn` |
| 540 | done |
| 541 | done |
| 542 | # We can't use the same method as above because files in the sysroot won't exist at this point |
| 543 | # (they get populated from sstate on installation) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 544 | unfsd_path="${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/unfsd" |
| 545 | if [ "${SDK_INCLUDE_TOOLCHAIN}" = "1" -a ! -e $unfsd_path ] ; then |
| 546 | binrelpath=${@os.path.relpath(d.getVar('STAGING_BINDIR_NATIVE'), d.getVar('TMPDIR'))} |
| 547 | lnr ${SDK_OUTPUT}/${SDKPATH}/tmp/$binrelpath/unfsd $unfsd_path |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 548 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 549 | touch ${SDK_OUTPUT}/${SDKPATH}/.devtoolbase |
| 550 | |
| 551 | # find latest buildtools-tarball and install it |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 552 | install ${SDK_DEPLOY}/${SDK_BUILDTOOLS_INSTALLER} ${SDK_OUTPUT}/${SDKPATH} |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 553 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 554 | install -m 0644 ${COREBASE}/meta/files/ext-sdk-prepare.py ${SDK_OUTPUT}/${SDKPATH} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 555 | } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 556 | do_populate_sdk_ext[file-checksums] += "${COREBASE}/meta/files/ext-sdk-prepare.py:True" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 557 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 558 | sdk_ext_preinst() { |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 559 | # Since bitbake won't run as root it doesn't make sense to try and install |
| 560 | # the extensible sdk as root. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 561 | if [ "`id -u`" = "0" ]; then |
| 562 | echo "ERROR: The extensible sdk cannot be installed as root." |
| 563 | exit 1 |
| 564 | fi |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 565 | if ! command -v locale > /dev/null; then |
| 566 | echo "ERROR: The installer requires the locale command, please install it first" |
| 567 | exit 1 |
| 568 | fi |
| 569 | # Check setting of LC_ALL set above |
| 570 | canonicalised_locale=`echo $LC_ALL | sed 's/UTF-8/utf8/'` |
| 571 | if ! locale -a | grep -q $canonicalised_locale ; then |
| 572 | echo "ERROR: the installer requires the $LC_ALL locale to be installed (but not selected), please install it first" |
| 573 | exit 1 |
| 574 | fi |
| 575 | # The relocation script used by buildtools installer requires python |
| 576 | if ! command -v python > /dev/null; then |
| 577 | echo "ERROR: The installer requires python, please install it first" |
| 578 | exit 1 |
| 579 | fi |
| 580 | missing_utils="" |
| 581 | for util in ${SDK_REQUIRED_UTILITIES}; do |
| 582 | if ! command -v $util > /dev/null; then |
| 583 | missing_utils="$missing_utils $util" |
| 584 | fi |
| 585 | done |
| 586 | if [ -n "$missing_utils" ] ; then |
| 587 | echo "ERROR: the SDK requires the following missing utilities, please install them: $missing_utils" |
| 588 | exit 1 |
| 589 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 590 | SDK_EXTENSIBLE="1" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 591 | if [ "$publish" = "1" ] ; then |
| 592 | EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=ext-sdk-prepare.py" |
| 593 | if [ "${SDK_EXT_TYPE}" = "minimal" ] ; then |
| 594 | EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=sstate-cache" |
| 595 | fi |
| 596 | fi |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 597 | } |
| 598 | SDK_PRE_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_preinst}" |
| 599 | |
| 600 | # FIXME this preparation should be done as part of the SDK construction |
| 601 | sdk_ext_postinst() { |
| 602 | printf "\nExtracting buildtools...\n" |
| 603 | cd $target_sdk_dir |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 604 | env_setup_script="$target_sdk_dir/environment-setup-${REAL_MULTIMACH_TARGET_SYS}" |
| 605 | printf "buildtools\ny" | ./${SDK_BUILDTOOLS_INSTALLER} > buildtools.log || { printf 'ERROR: buildtools installation failed:\n' ; cat buildtools.log ; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 606 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 607 | # Delete the buildtools tar file since it won't be used again |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 608 | rm -f ./${SDK_BUILDTOOLS_INSTALLER} |
| 609 | # We don't need the log either since it succeeded |
| 610 | rm -f buildtools.log |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 611 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 612 | # Make sure when the user sets up the environment, they also get |
| 613 | # the buildtools-tarball tools in their path. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 614 | echo ". $target_sdk_dir/buildtools/environment-setup*" >> $env_setup_script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 615 | |
| 616 | # Allow bitbake environment setup to be ran as part of this sdk. |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 617 | echo "export OE_SKIP_SDK_CHECK=1" >> $env_setup_script |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 618 | # Work around runqemu not knowing how to get this information within the eSDK |
| 619 | echo "export DEPLOY_DIR_IMAGE=$target_sdk_dir/tmp/${@os.path.relpath(d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('TMPDIR'))}" >> $env_setup_script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 620 | |
| 621 | # A bit of another hack, but we need this in the path only for devtool |
| 622 | # so put it at the end of $PATH. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 623 | echo "export PATH=$target_sdk_dir/sysroots/${SDK_SYS}${bindir_nativesdk}:\$PATH" >> $env_setup_script |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 624 | |
| 625 | echo "printf 'SDK environment now set up; additionally you may now run devtool to perform development tasks.\nRun devtool --help for further details.\n'" >> $env_setup_script |
| 626 | |
| 627 | # Warn if trying to use external bitbake and the ext SDK together |
| 628 | echo "(which bitbake > /dev/null 2>&1 && echo 'WARNING: attempting to use the extensible SDK in an environment set up to run bitbake - this may lead to unexpected results. Please source this script in a new shell session instead.') || true" >> $env_setup_script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 629 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 630 | if [ "$prepare_buildsystem" != "no" ]; then |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 631 | printf "Preparing build system...\n" |
| 632 | # dash which is /bin/sh on Ubuntu will not preserve the |
| 633 | # current working directory when first ran, nor will it set $1 when |
| 634 | # sourcing a script. That is why this has to look so ugly. |
| 635 | LOGFILE="$target_sdk_dir/preparing_build_system.log" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 636 | sh -c ". buildtools/environment-setup* > $LOGFILE && cd $target_sdk_dir/`dirname ${oe_init_build_env_path}` && set $target_sdk_dir && . $target_sdk_dir/${oe_init_build_env_path} $target_sdk_dir >> $LOGFILE && python $target_sdk_dir/ext-sdk-prepare.py $LOGFILE '${SDK_INSTALL_TARGETS}'" || { echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 637 | rm $target_sdk_dir/ext-sdk-prepare.py |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 638 | fi |
| 639 | echo done |
| 640 | } |
| 641 | |
| 642 | SDK_POST_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_postinst}" |
| 643 | |
| 644 | SDK_POSTPROCESS_COMMAND_prepend_task-populate-sdk-ext = "copy_buildsystem; install_tools; " |
| 645 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 646 | SDK_INSTALL_TARGETS = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 647 | fakeroot python do_populate_sdk_ext() { |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 648 | # FIXME hopefully we can remove this restriction at some point, but uninative |
| 649 | # currently forces this upon us |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 650 | if d.getVar('SDK_ARCH') != d.getVar('BUILD_ARCH'): |
| 651 | bb.fatal('The extensible SDK can currently only be built for the same architecture as the machine being built on - SDK_ARCH is set to %s (likely via setting SDKMACHINE) which is different from the architecture of the build machine (%s). Unable to continue.' % (d.getVar('SDK_ARCH'), d.getVar('BUILD_ARCH'))) |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 652 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 653 | d.setVar('SDK_INSTALL_TARGETS', get_sdk_install_targets(d)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 654 | buildtools_fn = get_current_buildtools(d) |
| 655 | d.setVar('SDK_REQUIRED_UTILITIES', get_sdk_required_utilities(buildtools_fn, d)) |
| 656 | d.setVar('SDK_BUILDTOOLS_INSTALLER', buildtools_fn) |
| 657 | d.setVar('SDKDEPLOYDIR', '${SDKEXTDEPLOYDIR}') |
Brad Bishop | 0011132 | 2018-04-01 22:23:53 -0400 | [diff] [blame] | 658 | # ESDKs have a libc from the buildtools so ensure we don't ship linguas twice |
| 659 | d.delVar('SDKIMAGE_LINGUAS') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 660 | populate_sdk_common(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 661 | } |
| 662 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 663 | def get_ext_sdk_depends(d): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 664 | # Note: the deps varflag is a list not a string, so we need to specify expand=False |
| 665 | deps = d.getVarFlag('do_image_complete', 'deps', False) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 666 | pn = d.getVar('PN') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 667 | deplist = ['%s:%s' % (pn, dep) for dep in deps] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 668 | tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d) |
| 669 | tasklist.append('do_rootfs') |
| 670 | for task in tasklist: |
| 671 | deplist.extend((d.getVarFlag(task, 'depends') or '').split()) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 672 | return ' '.join(deplist) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 673 | |
| 674 | python do_sdk_depends() { |
| 675 | # We have to do this separately in its own task so we avoid recursing into |
| 676 | # dependencies we don't need to (e.g. buildtools-tarball) and bringing those |
| 677 | # into the SDK's sstate-cache |
| 678 | import oe.copy_buildsystem |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 679 | sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 680 | oe.copy_buildsystem.generate_locked_sigs(sigfile, d) |
| 681 | } |
| 682 | addtask sdk_depends |
| 683 | |
| 684 | do_sdk_depends[dirs] = "${WORKDIR}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 685 | do_sdk_depends[depends] = "${@get_ext_sdk_depends(d)} meta-extsdk-toolchain:do_populate_sysroot" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 686 | do_sdk_depends[recrdeptask] = "${@d.getVarFlag('do_populate_sdk', 'recrdeptask', False)}" |
| 687 | do_sdk_depends[recrdeptask] += "do_populate_lic do_package_qa do_populate_sysroot do_deploy ${SDK_RECRDEP_TASKS}" |
| 688 | do_sdk_depends[rdepends] = "${@get_sdk_ext_rdepends(d)}" |
| 689 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 690 | def get_sdk_ext_rdepends(d): |
| 691 | localdata = d.createCopy() |
| 692 | localdata.appendVar('OVERRIDES', ':task-populate-sdk-ext') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 693 | return localdata.getVarFlag('do_populate_sdk', 'rdepends') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 694 | |
| 695 | do_populate_sdk_ext[dirs] = "${@d.getVarFlag('do_populate_sdk', 'dirs', False)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 696 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 697 | do_populate_sdk_ext[depends] = "${@d.getVarFlag('do_populate_sdk', 'depends', False)} \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 698 | buildtools-tarball:do_populate_sdk \ |
| 699 | ${@'meta-world-pkgdata:do_collect_packagedata' if d.getVar('SDK_INCLUDE_PKGDATA') == '1' else ''} \ |
| 700 | ${@'meta-extsdk-toolchain:do_locked_sigs' if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1' else ''}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 701 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 702 | # We must avoid depending on do_build here if rm_work.bbclass is active, |
| 703 | # because otherwise do_rm_work may run before do_populate_sdk_ext itself. |
| 704 | # We can't mark do_populate_sdk_ext and do_sdk_depends as having to |
| 705 | # run before do_rm_work, because then they would also run as part |
| 706 | # of normal builds. |
| 707 | do_populate_sdk_ext[rdepends] += "${@' '.join([x + ':' + (d.getVar('RM_WORK_BUILD_WITHOUT') or 'do_build') for x in d.getVar('SDK_TARGETS').split()])}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 708 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 709 | # Make sure code changes can result in rebuild |
| 710 | do_populate_sdk_ext[vardeps] += "copy_buildsystem \ |
| 711 | sdk_ext_postinst" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 712 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 713 | # Since any change in the metadata of any layer should cause a rebuild of the |
| 714 | # sdk(since the layers are put in the sdk) set the task to nostamp so it |
| 715 | # always runs. |
| 716 | do_populate_sdk_ext[nostamp] = "1" |
| 717 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 718 | SDKEXTDEPLOYDIR = "${WORKDIR}/deploy-${PN}-populate-sdk-ext" |
| 719 | |
| 720 | SSTATETASKS += "do_populate_sdk_ext" |
| 721 | SSTATE_SKIP_CREATION_task-populate-sdk-ext = '1' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 722 | do_populate_sdk_ext[cleandirs] = "${SDKEXTDEPLOYDIR}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 723 | do_populate_sdk_ext[sstate-inputdirs] = "${SDKEXTDEPLOYDIR}" |
| 724 | do_populate_sdk_ext[sstate-outputdirs] = "${SDK_DEPLOY}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 725 | do_populate_sdk_ext[stamp-extra-info] = "${MACHINE_ARCH}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 726 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 727 | addtask populate_sdk_ext after do_sdk_depends |