Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit rootfs_${IMAGE_PKGTYPE} |
| 2 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 3 | # Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk |
| 4 | # in the non-Linux SDK_OS case, such as mingw32 |
| 5 | SDKEXTCLASS ?= "${@['populate_sdk', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS", True)]}" |
| 6 | inherit ${SDKEXTCLASS} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | |
| 8 | TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}" |
| 9 | TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}" |
| 10 | POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_sysroot_relativelinks; " |
| 11 | |
| 12 | inherit gzipnative |
| 13 | |
| 14 | LICENSE = "MIT" |
| 15 | PACKAGES = "" |
| 16 | DEPENDS += "${MLPREFIX}qemuwrapper-cross ${MLPREFIX}depmodwrapper-cross" |
| 17 | RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL}" |
| 18 | RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}" |
| 19 | |
| 20 | INHIBIT_DEFAULT_DEPS = "1" |
| 21 | |
| 22 | TESTIMAGECLASS = "${@base_conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}" |
| 23 | inherit ${TESTIMAGECLASS} |
| 24 | |
| 25 | # IMAGE_FEATURES may contain any available package group |
| 26 | IMAGE_FEATURES ?= "" |
| 27 | IMAGE_FEATURES[type] = "list" |
| 28 | IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs empty-root-password allow-empty-password post-install-logging" |
| 29 | |
| 30 | # Generate companion debugfs? |
| 31 | IMAGE_GEN_DEBUGFS ?= "0" |
| 32 | |
| 33 | # rootfs bootstrap install |
| 34 | ROOTFS_BOOTSTRAP_INSTALL = "${@bb.utils.contains("IMAGE_FEATURES", "package-management", "", "${ROOTFS_PKGMANAGE_BOOTSTRAP}",d)}" |
| 35 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 36 | # These packages will be removed from a read-only rootfs after all other |
| 37 | # packages have been installed |
| 38 | ROOTFS_RO_UNNEEDED = "update-rc.d base-passwd shadow ${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}" |
| 39 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | # packages to install from features |
| 41 | FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}" |
| 42 | FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}" |
| 43 | FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}" |
| 44 | FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}" |
| 45 | |
| 46 | # Define some very basic feature package groups |
| 47 | FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}" |
| 48 | SPLASH ?= "psplash" |
| 49 | FEATURE_PACKAGES_splash = "${SPLASH}" |
| 50 | |
| 51 | IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}' |
| 52 | |
| 53 | def check_image_features(d): |
| 54 | valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems', True) or "").split() |
| 55 | valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys() |
| 56 | for var in d: |
| 57 | if var.startswith("PACKAGE_GROUP_"): |
| 58 | bb.warn("PACKAGE_GROUP is deprecated, please use FEATURE_PACKAGES instead") |
| 59 | valid_features.append(var[14:]) |
| 60 | elif var.startswith("FEATURE_PACKAGES_"): |
| 61 | valid_features.append(var[17:]) |
| 62 | valid_features.sort() |
| 63 | |
| 64 | features = set(oe.data.typed_value('IMAGE_FEATURES', d)) |
| 65 | for feature in features: |
| 66 | if feature not in valid_features: |
| 67 | if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d): |
| 68 | raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES (added via EXTRA_IMAGE_FEATURES) is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features))) |
| 69 | else: |
| 70 | raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features))) |
| 71 | |
| 72 | IMAGE_INSTALL ?= "" |
| 73 | IMAGE_INSTALL[type] = "list" |
| 74 | export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}" |
| 75 | PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}" |
| 76 | |
| 77 | # Images are generally built explicitly, do not need to be part of world. |
| 78 | EXCLUDE_FROM_WORLD = "1" |
| 79 | |
| 80 | USE_DEVFS ?= "1" |
| 81 | USE_DEPMOD ?= "1" |
| 82 | |
| 83 | PID = "${@os.getpid()}" |
| 84 | |
| 85 | PACKAGE_ARCH = "${MACHINE_ARCH}" |
| 86 | |
| 87 | LDCONFIGDEPEND ?= "ldconfig-native:do_populate_sysroot" |
| 88 | LDCONFIGDEPEND_libc-uclibc = "" |
| 89 | LDCONFIGDEPEND_libc-musl = "" |
| 90 | |
| 91 | # This is needed to have depmod data in PKGDATA_DIR, |
| 92 | # but if you're building small initramfs image |
| 93 | # e.g. to include it in your kernel, you probably |
| 94 | # don't want this dependency, which is causing dependency loop |
| 95 | KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata" |
| 96 | |
| 97 | do_rootfs[depends] += " \ |
| 98 | makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \ |
| 99 | virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \ |
| 100 | ${KERNELDEPMODDEPEND} \ |
| 101 | " |
| 102 | do_rootfs[recrdeptask] += "do_packagedata" |
| 103 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 104 | def rootfs_command_variables(d): |
| 105 | return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','ROOTFS_POSTUNINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND', |
| 106 | 'IMAGE_PREPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS','RPM_POSTPROCESS_COMMANDS','DEB_PREPROCESS_COMMANDS','DEB_POSTPROCESS_COMMANDS'] |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 107 | |
| 108 | python () { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 109 | variables = rootfs_command_variables(d) + sdk_command_variables(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | for var in variables: |
| 111 | if d.getVar(var, False): |
| 112 | d.setVarFlag(var, 'func', '1') |
| 113 | } |
| 114 | |
| 115 | def rootfs_variables(d): |
| 116 | from oe.rootfs import variable_depends |
Patrick Williams | d7e9631 | 2015-09-22 08:09:05 -0500 | [diff] [blame] | 117 | variables = ['IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE','IMAGE_ROOTFS_EXTRA_SPACE', |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 118 | 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','RM_OLD_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', |
| 119 | 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS', |
| 120 | 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS', |
| 121 | 'COMPRESSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED'] |
| 122 | variables.extend(rootfs_command_variables(d)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | variables.extend(variable_depends(d)) |
| 124 | return " ".join(variables) |
| 125 | |
| 126 | do_rootfs[vardeps] += "${@rootfs_variables(d)}" |
| 127 | |
| 128 | do_build[depends] += "virtual/kernel:do_deploy" |
| 129 | |
| 130 | def build_live(d): |
| 131 | if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg |
| 132 | d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d)) |
| 133 | d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d)) |
| 134 | if d.getVar('NOISO', True) == "0" or d.getVar('NOHDD', True) == "0": |
| 135 | return "image-live" |
| 136 | return "" |
| 137 | return "image-live" |
| 138 | |
| 139 | IMAGE_TYPE_live = "${@build_live(d)}" |
| 140 | inherit ${IMAGE_TYPE_live} |
| 141 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 142 | IMAGE_TYPE_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi", "qcow2", "hdddirect"], "image-vm", "", d)}' |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 143 | inherit ${IMAGE_TYPE_vm} |
| 144 | |
| 145 | python () { |
| 146 | deps = " " + imagetypes_getdepends(d) |
| 147 | d.appendVarFlag('do_rootfs', 'depends', deps) |
| 148 | |
| 149 | deps = "" |
| 150 | for dep in (d.getVar('EXTRA_IMAGEDEPENDS', True) or "").split(): |
| 151 | deps += " %s:do_populate_sysroot" % dep |
| 152 | d.appendVarFlag('do_build', 'depends', deps) |
| 153 | |
| 154 | #process IMAGE_FEATURES, we must do this before runtime_mapping_rename |
| 155 | #Check for replaces image features |
| 156 | features = set(oe.data.typed_value('IMAGE_FEATURES', d)) |
| 157 | remain_features = features.copy() |
| 158 | for feature in features: |
| 159 | replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature, True) or "").split()) |
| 160 | remain_features -= replaces |
| 161 | |
| 162 | #Check for conflict image features |
| 163 | for feature in remain_features: |
| 164 | conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature, True) or "").split()) |
| 165 | temp = conflicts & remain_features |
| 166 | if temp: |
| 167 | bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN', True), feature, ' '.join(list(temp)))) |
| 168 | |
| 169 | d.setVar('IMAGE_FEATURES', ' '.join(list(remain_features))) |
| 170 | |
| 171 | check_image_features(d) |
| 172 | initramfs_image = d.getVar('INITRAMFS_IMAGE', True) or "" |
| 173 | if initramfs_image != "": |
| 174 | d.appendVarFlag('do_build', 'depends', " %s:do_bundle_initramfs" % d.getVar('PN', True)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 175 | d.appendVarFlag('do_bundle_initramfs', 'depends', " %s:do_image_complete" % initramfs_image) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | IMAGE_CLASSES += "image_types" |
| 179 | inherit ${IMAGE_CLASSES} |
| 180 | |
| 181 | IMAGE_POSTPROCESS_COMMAND ?= "" |
| 182 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 183 | # some default locales |
| 184 | IMAGE_LINGUAS ?= "de-de fr-fr en-gb" |
| 185 | |
| 186 | LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS', True).split()))}" |
| 187 | |
| 188 | # Prefer image, but use the fallback files for lookups if the image ones |
| 189 | # aren't yet available. |
| 190 | PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}" |
| 191 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 192 | inherit rootfs-postcommands |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 193 | |
| 194 | PACKAGE_EXCLUDE ??= "" |
| 195 | PACKAGE_EXCLUDE[type] = "list" |
| 196 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 197 | fakeroot python do_rootfs () { |
| 198 | from oe.rootfs import create_rootfs |
| 199 | from oe.manifest import create_manifest |
| 200 | |
| 201 | # Handle package exclusions |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 202 | excl_pkgs = d.getVar("PACKAGE_EXCLUDE", True).split() |
| 203 | inst_pkgs = d.getVar("PACKAGE_INSTALL", True).split() |
| 204 | inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY", True).split() |
| 205 | |
| 206 | d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs)) |
| 207 | d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs)) |
| 208 | |
| 209 | for pkg in excl_pkgs: |
| 210 | if pkg in inst_pkgs: |
| 211 | 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', True), inst_pkgs)) |
| 212 | inst_pkgs.remove(pkg) |
| 213 | |
| 214 | if pkg in inst_attempt_pkgs: |
| 215 | 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', True), inst_pkgs)) |
| 216 | inst_attempt_pkgs.remove(pkg) |
| 217 | |
| 218 | d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs)) |
| 219 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 220 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 221 | # Ensure we handle package name remapping |
| 222 | # We have to delay the runtime_mapping_rename until just before rootfs runs |
| 223 | # otherwise, the multilib renaming could step in and squash any fixups that |
| 224 | # may have occurred. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 225 | pn = d.getVar('PN', True) |
| 226 | runtime_mapping_rename("PACKAGE_INSTALL", pn, d) |
| 227 | runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d) |
| 228 | runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 229 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 230 | # Generate the initial manifest |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 231 | create_manifest(d) |
| 232 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 233 | # Generate rootfs |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 234 | create_rootfs(d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 235 | } |
| 236 | do_rootfs[dirs] = "${TOPDIR}" |
| 237 | do_rootfs[cleandirs] += "${S}" |
| 238 | do_rootfs[umask] = "022" |
| 239 | addtask rootfs before do_build |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 240 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 241 | fakeroot python do_image () { |
| 242 | from oe.utils import execute_pre_post_process |
| 243 | |
| 244 | pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND", True) |
| 245 | |
| 246 | execute_pre_post_process(d, pre_process_cmds) |
| 247 | } |
| 248 | do_image[dirs] = "${TOPDIR}" |
| 249 | do_image[umask] = "022" |
| 250 | addtask do_image after do_rootfs before do_build |
| 251 | |
| 252 | fakeroot python do_image_complete () { |
| 253 | from oe.utils import execute_pre_post_process |
| 254 | |
| 255 | post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND", True) |
| 256 | |
| 257 | execute_pre_post_process(d, post_process_cmds) |
| 258 | } |
| 259 | do_image_complete[dirs] = "${TOPDIR}" |
| 260 | do_image_complete[umask] = "022" |
| 261 | addtask do_image_complete after do_image before do_build |
| 262 | |
| 263 | # |
| 264 | # Write environment variables used by wic |
| 265 | # to tmp/sysroots/<machine>/imgdata/<image>.env |
| 266 | # |
| 267 | python do_rootfs_wicenv () { |
| 268 | wicvars = d.getVar('WICVARS', True) |
| 269 | if not wicvars: |
| 270 | return |
| 271 | |
| 272 | stdir = d.getVar('STAGING_DIR_TARGET', True) |
| 273 | outdir = os.path.join(stdir, 'imgdata') |
| 274 | bb.utils.mkdirhier(outdir) |
| 275 | basename = d.getVar('IMAGE_BASENAME', True) |
| 276 | with open(os.path.join(outdir, basename) + '.env', 'w') as envf: |
| 277 | for var in wicvars.split(): |
| 278 | value = d.getVar(var, True) |
| 279 | if value: |
| 280 | envf.write('%s="%s"\n' % (var, value.strip())) |
| 281 | } |
| 282 | addtask do_rootfs_wicenv after do_image before do_image_wic |
| 283 | do_rootfs_wicenv[vardeps] += "${WICVARS}" |
| 284 | do_rootfs_wicenv[prefuncs] = 'set_image_size' |
| 285 | |
| 286 | def setup_debugfs_variables(d): |
| 287 | d.appendVar('IMAGE_ROOTFS', '-dbg') |
| 288 | d.appendVar('IMAGE_LINK_NAME', '-dbg') |
| 289 | d.appendVar('IMAGE_NAME','-dbg') |
| 290 | debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS', True) |
| 291 | if debugfs_image_fstypes: |
| 292 | d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes) |
| 293 | |
| 294 | python setup_debugfs () { |
| 295 | setup_debugfs_variables(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 296 | } |
| 297 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 298 | python () { |
| 299 | vardeps = set() |
| 300 | ctypes = d.getVar('COMPRESSIONTYPES', True).split() |
| 301 | old_overrides = d.getVar('OVERRIDES', 0) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 302 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 303 | def _image_base_type(type): |
| 304 | basetype = type |
| 305 | for ctype in ctypes: |
| 306 | if type.endswith("." + ctype): |
| 307 | basetype = type[:-len("." + ctype)] |
| 308 | break |
| 309 | |
| 310 | if basetype != type: |
| 311 | # New base type itself might be generated by a conversion command. |
| 312 | basetype = _image_base_type(basetype) |
| 313 | |
| 314 | return basetype |
| 315 | |
| 316 | basetypes = {} |
| 317 | alltypes = d.getVar('IMAGE_FSTYPES', True).split() |
| 318 | typedeps = {} |
| 319 | |
| 320 | if d.getVar('IMAGE_GEN_DEBUGFS', True) == "1": |
| 321 | debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS', True).split() |
| 322 | for t in debugfs_fstypes: |
| 323 | alltypes.append("debugfs_" + t) |
| 324 | |
| 325 | def _add_type(t): |
| 326 | baset = _image_base_type(t) |
| 327 | input_t = t |
| 328 | if baset not in basetypes: |
| 329 | basetypes[baset]= [] |
| 330 | if t not in basetypes[baset]: |
| 331 | basetypes[baset].append(t) |
| 332 | debug = "" |
| 333 | if t.startswith("debugfs_"): |
| 334 | t = t[8:] |
| 335 | debug = "debugfs_" |
| 336 | deps = (d.getVar('IMAGE_TYPEDEP_' + t, True) or "").split() |
| 337 | vardeps.add('IMAGE_TYPEDEP_' + t) |
| 338 | if baset not in typedeps: |
| 339 | typedeps[baset] = set() |
| 340 | deps = [debug + dep for dep in deps] |
| 341 | for dep in deps: |
| 342 | if dep not in alltypes: |
| 343 | alltypes.append(dep) |
| 344 | _add_type(dep) |
| 345 | basedep = _image_base_type(dep) |
| 346 | typedeps[baset].add(basedep) |
| 347 | |
| 348 | if baset != input_t: |
| 349 | _add_type(baset) |
| 350 | |
| 351 | for t in alltypes[:]: |
| 352 | _add_type(t) |
| 353 | |
| 354 | d.appendVarFlag('do_image', 'vardeps', ' '.join(vardeps)) |
| 355 | |
| 356 | maskedtypes = (d.getVar('IMAGE_TYPES_MASKED', True) or "").split() |
| 357 | |
| 358 | for t in basetypes: |
| 359 | vardeps = set() |
| 360 | cmds = [] |
| 361 | subimages = [] |
| 362 | realt = t |
| 363 | |
| 364 | if t in maskedtypes: |
| 365 | continue |
| 366 | |
| 367 | localdata = bb.data.createCopy(d) |
| 368 | debug = "" |
| 369 | if t.startswith("debugfs_"): |
| 370 | setup_debugfs_variables(localdata) |
| 371 | debug = "setup_debugfs " |
| 372 | realt = t[8:] |
| 373 | localdata.setVar('OVERRIDES', '%s:%s' % (realt, old_overrides)) |
| 374 | bb.data.update_data(localdata) |
| 375 | localdata.setVar('type', realt) |
| 376 | # Delete DATETIME so we don't expand any references to it now |
| 377 | # This means the task's hash can be stable rather than having hardcoded |
| 378 | # date/time values. It will get expanded at execution time. |
| 379 | # Similarly TMPDIR since otherwise we see QA stamp comparision problems |
| 380 | localdata.delVar('DATETIME') |
| 381 | localdata.delVar('TMPDIR') |
| 382 | |
| 383 | image_cmd = localdata.getVar("IMAGE_CMD", True) |
| 384 | vardeps.add('IMAGE_CMD_' + realt) |
| 385 | if image_cmd: |
| 386 | cmds.append("\t" + image_cmd) |
| 387 | else: |
| 388 | bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t) |
| 389 | cmds.append(localdata.expand("\tcd ${DEPLOY_DIR_IMAGE}")) |
| 390 | |
| 391 | rm_tmp_images = set() |
| 392 | def gen_conversion_cmds(bt): |
| 393 | for ctype in ctypes: |
| 394 | if bt.endswith("." + ctype): |
| 395 | type = bt[0:-len(ctype) - 1] |
| 396 | if type.startswith("debugfs_"): |
| 397 | type = type[8:] |
| 398 | # Create input image first. |
| 399 | gen_conversion_cmds(type) |
| 400 | localdata.setVar('type', type) |
| 401 | cmds.append("\t" + localdata.getVar("COMPRESS_CMD_" + ctype, True)) |
| 402 | vardeps.add('COMPRESS_CMD_' + ctype) |
| 403 | subimages.append(type + "." + ctype) |
| 404 | if type not in alltypes: |
| 405 | rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}")) |
| 406 | |
| 407 | for bt in basetypes[t]: |
| 408 | gen_conversion_cmds(bt) |
| 409 | |
| 410 | localdata.setVar('type', realt) |
| 411 | if t not in alltypes: |
| 412 | rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}")) |
| 413 | else: |
| 414 | subimages.append(realt) |
| 415 | |
| 416 | # Clean up after applying all conversion commands. Some of them might |
| 417 | # use the same input, therefore we cannot delete sooner without applying |
| 418 | # some complex dependency analysis. |
| 419 | for image in rm_tmp_images: |
| 420 | cmds.append("\trm " + image) |
| 421 | |
| 422 | after = 'do_image' |
| 423 | for dep in typedeps[t]: |
| 424 | after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_") |
| 425 | |
| 426 | t = t.replace("-", "_").replace(".", "_") |
| 427 | |
| 428 | d.setVar('do_image_%s' % t, '\n'.join(cmds)) |
| 429 | d.setVarFlag('do_image_%s' % t, 'func', '1') |
| 430 | d.setVarFlag('do_image_%s' % t, 'fakeroot', '1') |
| 431 | d.setVarFlag('do_image_%s' % t, 'prefuncs', debug + 'set_image_size') |
| 432 | d.setVarFlag('do_image_%s' % t, 'postfuncs', 'create_symlinks') |
| 433 | d.setVarFlag('do_image_%s' % t, 'subimages', ' '.join(subimages)) |
| 434 | d.appendVarFlag('do_image_%s' % t, 'vardeps', ' '.join(vardeps)) |
| 435 | d.appendVarFlag('do_image_%s' % t, 'vardepsexclude', 'DATETIME') |
| 436 | |
| 437 | bb.debug(2, "Adding type %s before %s, after %s" % (t, 'do_image_complete', after)) |
| 438 | bb.build.addtask('do_image_%s' % t, 'do_image_complete', after, d) |
| 439 | } |
| 440 | |
| 441 | # |
| 442 | # Compute the rootfs size |
| 443 | # |
| 444 | def get_rootfs_size(d): |
| 445 | import subprocess |
| 446 | |
| 447 | rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT', True)) |
| 448 | overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR', True)) |
| 449 | rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE', True)) |
| 450 | rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE', True)) |
| 451 | rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE', True) |
| 452 | image_fstypes = d.getVar('IMAGE_FSTYPES', True) or '' |
| 453 | initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES', True) or '' |
| 454 | initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE', True) |
| 455 | |
| 456 | output = subprocess.check_output(['du', '-ks', |
| 457 | d.getVar('IMAGE_ROOTFS', True)]) |
| 458 | size_kb = int(output.split()[0]) |
| 459 | base_size = size_kb * overhead_factor |
| 460 | base_size = max(base_size, rootfs_req_size) + rootfs_extra_space |
| 461 | |
| 462 | if base_size != int(base_size): |
| 463 | base_size = int(base_size + 1) |
| 464 | else: |
| 465 | base_size = int(base_size) |
| 466 | |
| 467 | base_size += rootfs_alignment - 1 |
| 468 | base_size -= base_size % rootfs_alignment |
| 469 | |
| 470 | # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set) |
| 471 | if rootfs_maxsize: |
| 472 | rootfs_maxsize_int = int(rootfs_maxsize) |
| 473 | if base_size > rootfs_maxsize_int: |
| 474 | bb.fatal("The rootfs size %d(K) overrides IMAGE_ROOTFS_MAXSIZE: %d(K)" % \ |
| 475 | (base_size, rootfs_maxsize_int)) |
| 476 | |
| 477 | # Check the initramfs size against INITRAMFS_MAXSIZE (if set) |
| 478 | if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize: |
| 479 | initramfs_maxsize_int = int(initramfs_maxsize) |
| 480 | if base_size > initramfs_maxsize_int: |
| 481 | bb.error("The initramfs size %d(K) overrides INITRAMFS_MAXSIZE: %d(K)" % \ |
| 482 | (base_size, initramfs_maxsize_int)) |
| 483 | bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should") |
| 484 | bb.fatal("be less than 1/2 of ram size, or you may fail to boot it.\n") |
| 485 | return base_size |
| 486 | |
| 487 | python set_image_size () { |
| 488 | rootfs_size = get_rootfs_size(d) |
| 489 | d.setVar('ROOTFS_SIZE', str(rootfs_size)) |
| 490 | d.setVarFlag('ROOTFS_SIZE', 'export', '1') |
| 491 | } |
| 492 | |
| 493 | # |
| 494 | # Create symlinks to the newly created image |
| 495 | # |
| 496 | python create_symlinks() { |
| 497 | |
| 498 | deploy_dir = d.getVar('DEPLOY_DIR_IMAGE', True) |
| 499 | img_name = d.getVar('IMAGE_NAME', True) |
| 500 | link_name = d.getVar('IMAGE_LINK_NAME', True) |
| 501 | manifest_name = d.getVar('IMAGE_MANIFEST', True) |
| 502 | taskname = d.getVar("BB_CURRENTTASK", True) |
| 503 | subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split() |
| 504 | imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix', True) or d.expand("${IMAGE_NAME_SUFFIX}.") |
| 505 | os.chdir(deploy_dir) |
| 506 | |
| 507 | if not link_name: |
| 508 | return |
| 509 | for type in subimages: |
| 510 | if os.path.exists(img_name + imgsuffix + type): |
| 511 | dst = deploy_dir + "/" + link_name + "." + type |
| 512 | src = img_name + imgsuffix + type |
| 513 | bb.note("Creating symlink: %s -> %s" % (dst, src)) |
| 514 | if os.path.islink(dst): |
| 515 | if d.getVar('RM_OLD_IMAGE', True) == "1" and \ |
| 516 | os.path.exists(os.path.realpath(dst)): |
| 517 | os.remove(os.path.realpath(dst)) |
| 518 | os.remove(dst) |
| 519 | os.symlink(src, dst) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 520 | } |
| 521 | |
| 522 | MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|" |
| 523 | MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py" |
| 524 | MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib" |
| 525 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 526 | do_fetch[noexec] = "1" |
| 527 | do_unpack[noexec] = "1" |
| 528 | do_patch[noexec] = "1" |
| 529 | do_configure[noexec] = "1" |
| 530 | do_compile[noexec] = "1" |
| 531 | do_install[noexec] = "1" |
| 532 | do_populate_sysroot[noexec] = "1" |
| 533 | do_package[noexec] = "1" |
| 534 | do_package_qa[noexec] = "1" |
| 535 | do_packagedata[noexec] = "1" |
| 536 | do_package_write_ipk[noexec] = "1" |
| 537 | do_package_write_deb[noexec] = "1" |
| 538 | do_package_write_rpm[noexec] = "1" |
| 539 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 540 | # Allow the kernel to be repacked with the initramfs and boot image file as a single file |
| 541 | do_bundle_initramfs[depends] += "virtual/kernel:do_bundle_initramfs" |
| 542 | do_bundle_initramfs[nostamp] = "1" |
| 543 | do_bundle_initramfs[noexec] = "1" |
| 544 | do_bundle_initramfs () { |
| 545 | : |
| 546 | } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 547 | addtask bundle_initramfs after do_image_complete |