Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | inherit rootfs_${IMAGE_PKGTYPE} |
| 2 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3 | # Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 4 | # in the non-Linux SDK_OS case, such as mingw32 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | SDKEXTCLASS ?= "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 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 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | LICENSE ?= "MIT" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | PACKAGES = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 14 | DEPENDS += "${MLPREFIX}qemuwrapper-cross depmodwrapper-cross" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 15 | RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL}" |
| 16 | RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}" |
| 17 | |
| 18 | INHIBIT_DEFAULT_DEPS = "1" |
| 19 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | TESTIMAGECLASS = "${@oe.utils.conditional('TEST_IMAGE', '1', 'testimage-auto', '', d)}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | inherit ${TESTIMAGECLASS} |
| 22 | |
| 23 | # IMAGE_FEATURES may contain any available package group |
| 24 | IMAGE_FEATURES ?= "" |
| 25 | IMAGE_FEATURES[type] = "list" |
| 26 | IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs empty-root-password allow-empty-password post-install-logging" |
| 27 | |
| 28 | # Generate companion debugfs? |
| 29 | IMAGE_GEN_DEBUGFS ?= "0" |
| 30 | |
| 31 | # rootfs bootstrap install |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 33 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 34 | # These packages will be removed from a read-only rootfs after all other |
| 35 | # packages have been installed |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | ROOTFS_RO_UNNEEDED ??= "update-rc.d base-passwd shadow ${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}" |
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 | # packages to install from features |
| 39 | FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}" |
| 40 | FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}" |
| 41 | FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}" |
| 42 | FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}" |
| 43 | |
| 44 | # Define some very basic feature package groups |
| 45 | FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}" |
| 46 | SPLASH ?= "psplash" |
| 47 | FEATURE_PACKAGES_splash = "${SPLASH}" |
| 48 | |
| 49 | IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}' |
| 50 | |
| 51 | def check_image_features(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 52 | valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems') or "").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys() |
| 54 | for var in d: |
| 55 | if var.startswith("PACKAGE_GROUP_"): |
| 56 | bb.warn("PACKAGE_GROUP is deprecated, please use FEATURE_PACKAGES instead") |
| 57 | valid_features.append(var[14:]) |
| 58 | elif var.startswith("FEATURE_PACKAGES_"): |
| 59 | valid_features.append(var[17:]) |
| 60 | valid_features.sort() |
| 61 | |
| 62 | features = set(oe.data.typed_value('IMAGE_FEATURES', d)) |
| 63 | for feature in features: |
| 64 | if feature not in valid_features: |
| 65 | if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d): |
| 66 | 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))) |
| 67 | else: |
| 68 | raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features))) |
| 69 | |
| 70 | IMAGE_INSTALL ?= "" |
| 71 | IMAGE_INSTALL[type] = "list" |
| 72 | export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}" |
| 73 | PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}" |
| 74 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 75 | IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete" |
| 76 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 88 | LDCONFIGDEPEND_libc-musl = "" |
| 89 | |
| 90 | # This is needed to have depmod data in PKGDATA_DIR, |
| 91 | # but if you're building small initramfs image |
| 92 | # e.g. to include it in your kernel, you probably |
| 93 | # don't want this dependency, which is causing dependency loop |
| 94 | KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata" |
| 95 | |
| 96 | do_rootfs[depends] += " \ |
| 97 | makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \ |
| 98 | virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \ |
| 99 | ${KERNELDEPMODDEPEND} \ |
| 100 | " |
| 101 | do_rootfs[recrdeptask] += "do_packagedata" |
| 102 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 103 | def rootfs_command_variables(d): |
| 104 | return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','ROOTFS_POSTUNINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND', |
| 105 | '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] | 106 | |
| 107 | python () { |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 108 | variables = rootfs_command_variables(d) + sdk_command_variables(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | for var in variables: |
| 110 | if d.getVar(var, False): |
| 111 | d.setVarFlag(var, 'func', '1') |
| 112 | } |
| 113 | |
| 114 | def rootfs_variables(d): |
| 115 | from oe.rootfs import variable_depends |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 116 | variables = ['IMAGE_DEVICE_TABLE','IMAGE_DEVICE_TABLES','BUILD_IMAGES_FROM_FEEDS','IMAGE_TYPES_MASKED','IMAGE_ROOTFS_ALIGNMENT','IMAGE_OVERHEAD_FACTOR','IMAGE_ROOTFS_SIZE','IMAGE_ROOTFS_EXTRA_SPACE', |
| 117 | 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 118 | 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS', |
| 119 | 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS', |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 120 | 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS'] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 121 | variables.extend(rootfs_command_variables(d)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 122 | variables.extend(variable_depends(d)) |
| 123 | return " ".join(variables) |
| 124 | |
| 125 | do_rootfs[vardeps] += "${@rootfs_variables(d)}" |
| 126 | |
| 127 | do_build[depends] += "virtual/kernel:do_deploy" |
| 128 | |
| 129 | def build_live(d): |
| 130 | if bb.utils.contains("IMAGE_FSTYPES", "live", "live", "0", d) == "0": # live is not set but hob might set iso or hddimg |
| 131 | d.setVar('NOISO', bb.utils.contains('IMAGE_FSTYPES', "iso", "0", "1", d)) |
| 132 | d.setVar('NOHDD', bb.utils.contains('IMAGE_FSTYPES', "hddimg", "0", "1", d)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 133 | if d.getVar('NOISO') == "0" or d.getVar('NOHDD') == "0": |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 134 | return "image-live" |
| 135 | return "" |
| 136 | return "image-live" |
| 137 | |
| 138 | IMAGE_TYPE_live = "${@build_live(d)}" |
| 139 | inherit ${IMAGE_TYPE_live} |
| 140 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 141 | IMAGE_TYPE_container = '${@bb.utils.contains("IMAGE_FSTYPES", "container", "image-container", "", d)}' |
| 142 | inherit ${IMAGE_TYPE_container} |
| 143 | |
| 144 | IMAGE_TYPE_wic = "image_types_wic" |
| 145 | inherit ${IMAGE_TYPE_wic} |
| 146 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 147 | python () { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 148 | def extraimage_getdepends(task): |
| 149 | deps = "" |
| 150 | for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split(): |
| 151 | deps += " %s:%s" % (dep, task) |
| 152 | return deps |
| 153 | |
| 154 | d.appendVarFlag('do_image', 'depends', extraimage_getdepends('do_populate_lic')) |
| 155 | d.appendVarFlag('do_image_complete', 'depends', extraimage_getdepends('do_populate_sysroot')) |
| 156 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 157 | deps = " " + imagetypes_getdepends(d) |
| 158 | d.appendVarFlag('do_rootfs', 'depends', deps) |
| 159 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 160 | #process IMAGE_FEATURES, we must do this before runtime_mapping_rename |
| 161 | #Check for replaces image features |
| 162 | features = set(oe.data.typed_value('IMAGE_FEATURES', d)) |
| 163 | remain_features = features.copy() |
| 164 | for feature in features: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 165 | replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature) or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 166 | remain_features -= replaces |
| 167 | |
| 168 | #Check for conflict image features |
| 169 | for feature in remain_features: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 170 | conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature) or "").split()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | temp = conflicts & remain_features |
| 172 | if temp: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 173 | bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN'), feature, ' '.join(list(temp)))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 174 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 175 | d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features)))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 176 | |
| 177 | check_image_features(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | IMAGE_CLASSES += "image_types" |
| 181 | inherit ${IMAGE_CLASSES} |
| 182 | |
| 183 | IMAGE_POSTPROCESS_COMMAND ?= "" |
| 184 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 185 | # some default locales |
| 186 | IMAGE_LINGUAS ?= "de-de fr-fr en-gb" |
| 187 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 188 | LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS').split()))}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 189 | |
| 190 | # Prefer image, but use the fallback files for lookups if the image ones |
| 191 | # aren't yet available. |
| 192 | PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}" |
| 193 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 194 | inherit rootfs-postcommands |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | |
| 196 | PACKAGE_EXCLUDE ??= "" |
| 197 | PACKAGE_EXCLUDE[type] = "list" |
| 198 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 199 | fakeroot python do_rootfs () { |
| 200 | from oe.rootfs import create_rootfs |
| 201 | from oe.manifest import create_manifest |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 202 | import logging |
| 203 | |
| 204 | logger = d.getVar('BB_TASK_LOGGER', False) |
| 205 | if logger: |
| 206 | logcatcher = bb.utils.LogCatcher() |
| 207 | logger.addHandler(logcatcher) |
| 208 | else: |
| 209 | logcatcher = None |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 210 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 211 | # NOTE: if you add, remove or significantly refactor the stages of this |
| 212 | # process then you should recalculate the weightings here. This is quite |
| 213 | # easy to do - just change the MultiStageProgressReporter line temporarily |
| 214 | # to pass debug=True as the last parameter and you'll get a printout of |
| 215 | # the weightings as well as a map to the lines where next_stage() was |
| 216 | # called. Of course this isn't critical, but it helps to keep the progress |
| 217 | # reporting accurate. |
| 218 | stage_weights = [1, 203, 354, 186, 65, 4228, 1, 353, 49, 330, 382, 23, 1] |
| 219 | progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights) |
| 220 | progress_reporter.next_stage() |
| 221 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 222 | # Handle package exclusions |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 223 | excl_pkgs = d.getVar("PACKAGE_EXCLUDE").split() |
| 224 | inst_pkgs = d.getVar("PACKAGE_INSTALL").split() |
| 225 | inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY").split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 226 | |
| 227 | d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs)) |
| 228 | d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs)) |
| 229 | |
| 230 | for pkg in excl_pkgs: |
| 231 | if pkg in inst_pkgs: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 232 | bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 233 | inst_pkgs.remove(pkg) |
| 234 | |
| 235 | if pkg in inst_attempt_pkgs: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 236 | bb.warn("Package %s, set to be excluded, is in %s PACKAGE_INSTALL_ATTEMPTONLY (%s). It will be removed from the list." % (pkg, d.getVar('PN'), inst_pkgs)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 237 | inst_attempt_pkgs.remove(pkg) |
| 238 | |
| 239 | d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs)) |
| 240 | d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 242 | # Ensure we handle package name remapping |
| 243 | # We have to delay the runtime_mapping_rename until just before rootfs runs |
| 244 | # otherwise, the multilib renaming could step in and squash any fixups that |
| 245 | # may have occurred. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 246 | pn = d.getVar('PN') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 247 | runtime_mapping_rename("PACKAGE_INSTALL", pn, d) |
| 248 | runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d) |
| 249 | runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 250 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 251 | # Generate the initial manifest |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 252 | create_manifest(d) |
| 253 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 254 | progress_reporter.next_stage() |
| 255 | |
| 256 | # generate rootfs |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 257 | d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 258 | create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 259 | |
| 260 | progress_reporter.finish() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 261 | } |
| 262 | do_rootfs[dirs] = "${TOPDIR}" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 263 | do_rootfs[cleandirs] += "${S} ${IMGDEPLOYDIR}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 264 | do_rootfs[umask] = "022" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 265 | addtask rootfs after do_prepare_recipe_sysroot |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 266 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 267 | fakeroot python do_image () { |
| 268 | from oe.utils import execute_pre_post_process |
| 269 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 270 | d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 271 | pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 272 | |
| 273 | execute_pre_post_process(d, pre_process_cmds) |
| 274 | } |
| 275 | do_image[dirs] = "${TOPDIR}" |
| 276 | do_image[umask] = "022" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 277 | addtask do_image after do_rootfs |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 278 | |
| 279 | fakeroot python do_image_complete () { |
| 280 | from oe.utils import execute_pre_post_process |
| 281 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 282 | post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 283 | |
| 284 | execute_pre_post_process(d, post_process_cmds) |
| 285 | } |
| 286 | do_image_complete[dirs] = "${TOPDIR}" |
| 287 | do_image_complete[umask] = "022" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 288 | SSTATETASKS += "do_image_complete" |
| 289 | SSTATE_SKIP_CREATION_task-image-complete = '1' |
| 290 | do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}" |
| 291 | do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 292 | do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 293 | addtask do_image_complete after do_image before do_build |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 294 | python do_image_complete_setscene () { |
| 295 | sstate_setscene(d) |
| 296 | } |
| 297 | addtask do_image_complete_setscene |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 298 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 299 | # Add image-level QA/sanity checks to IMAGE_QA_COMMANDS |
| 300 | # |
| 301 | # IMAGE_QA_COMMANDS += " \ |
| 302 | # image_check_everything_ok \ |
| 303 | # " |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 304 | # This task runs all functions in IMAGE_QA_COMMANDS after the rootfs |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 305 | # construction has completed in order to validate the resulting image. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 306 | # |
| 307 | # The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs |
| 308 | # directory, which if QA passes will be the basis for the images. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 309 | fakeroot python do_image_qa () { |
| 310 | from oe.utils import ImageQAFailed |
| 311 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 312 | qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 313 | qamsg = "" |
| 314 | |
| 315 | for cmd in qa_cmds: |
| 316 | try: |
| 317 | bb.build.exec_func(cmd, d) |
| 318 | except oe.utils.ImageQAFailed as e: |
| 319 | qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description) |
| 320 | except bb.build.FuncFailed as e: |
| 321 | qamsg = qamsg + '\tImage QA function %s failed' % e.name |
| 322 | if e.logfile: |
| 323 | qamsg = qamsg + ' (log file is located at %s)' % e.logfile |
| 324 | qamsg = qamsg + '\n' |
| 325 | |
| 326 | if qamsg: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 327 | imgname = d.getVar('IMAGE_NAME') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 328 | bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg)) |
| 329 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 330 | addtask do_image_qa after do_rootfs before do_image |
| 331 | |
| 332 | SSTATETASKS += "do_image_qa" |
| 333 | SSTATE_SKIP_CREATION_task-image-qa = '1' |
| 334 | do_image_qa[sstate-inputdirs] = "" |
| 335 | do_image_qa[sstate-outputdirs] = "" |
| 336 | python do_image_qa_setscene () { |
| 337 | sstate_setscene(d) |
| 338 | } |
| 339 | addtask do_image_qa_setscene |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 340 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 341 | def setup_debugfs_variables(d): |
| 342 | d.appendVar('IMAGE_ROOTFS', '-dbg') |
| 343 | d.appendVar('IMAGE_LINK_NAME', '-dbg') |
| 344 | d.appendVar('IMAGE_NAME','-dbg') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 345 | d.setVar('IMAGE_BUILDING_DEBUGFS', 'true') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 346 | debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 347 | if debugfs_image_fstypes: |
| 348 | d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes) |
| 349 | |
| 350 | python setup_debugfs () { |
| 351 | setup_debugfs_variables(d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 352 | } |
| 353 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 354 | python () { |
| 355 | vardeps = set() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 356 | # We allow CONVERSIONTYPES to have duplicates. That avoids breaking |
| 357 | # derived distros when OE-core or some other layer independently adds |
| 358 | # the same type. There is still only one command for each type, but |
| 359 | # presumably the commands will do the same when the type is the same, |
| 360 | # even when added in different places. |
| 361 | # |
| 362 | # Without de-duplication, gen_conversion_cmds() below |
| 363 | # would create the same compression command multiple times. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 364 | ctypes = set(d.getVar('CONVERSIONTYPES').split()) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 365 | old_overrides = d.getVar('OVERRIDES', False) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 366 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 367 | def _image_base_type(type): |
| 368 | basetype = type |
| 369 | for ctype in ctypes: |
| 370 | if type.endswith("." + ctype): |
| 371 | basetype = type[:-len("." + ctype)] |
| 372 | break |
| 373 | |
| 374 | if basetype != type: |
| 375 | # New base type itself might be generated by a conversion command. |
| 376 | basetype = _image_base_type(basetype) |
| 377 | |
| 378 | return basetype |
| 379 | |
| 380 | basetypes = {} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 381 | alltypes = d.getVar('IMAGE_FSTYPES').split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 382 | typedeps = {} |
| 383 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 384 | if d.getVar('IMAGE_GEN_DEBUGFS') == "1": |
| 385 | debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 386 | for t in debugfs_fstypes: |
| 387 | alltypes.append("debugfs_" + t) |
| 388 | |
| 389 | def _add_type(t): |
| 390 | baset = _image_base_type(t) |
| 391 | input_t = t |
| 392 | if baset not in basetypes: |
| 393 | basetypes[baset]= [] |
| 394 | if t not in basetypes[baset]: |
| 395 | basetypes[baset].append(t) |
| 396 | debug = "" |
| 397 | if t.startswith("debugfs_"): |
| 398 | t = t[8:] |
| 399 | debug = "debugfs_" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 400 | deps = (d.getVar('IMAGE_TYPEDEP_' + t) or "").split() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 401 | vardeps.add('IMAGE_TYPEDEP_' + t) |
| 402 | if baset not in typedeps: |
| 403 | typedeps[baset] = set() |
| 404 | deps = [debug + dep for dep in deps] |
| 405 | for dep in deps: |
| 406 | if dep not in alltypes: |
| 407 | alltypes.append(dep) |
| 408 | _add_type(dep) |
| 409 | basedep = _image_base_type(dep) |
| 410 | typedeps[baset].add(basedep) |
| 411 | |
| 412 | if baset != input_t: |
| 413 | _add_type(baset) |
| 414 | |
| 415 | for t in alltypes[:]: |
| 416 | _add_type(t) |
| 417 | |
| 418 | d.appendVarFlag('do_image', 'vardeps', ' '.join(vardeps)) |
| 419 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 420 | maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 421 | maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 422 | |
| 423 | for t in basetypes: |
| 424 | vardeps = set() |
| 425 | cmds = [] |
| 426 | subimages = [] |
| 427 | realt = t |
| 428 | |
| 429 | if t in maskedtypes: |
| 430 | continue |
| 431 | |
| 432 | localdata = bb.data.createCopy(d) |
| 433 | debug = "" |
| 434 | if t.startswith("debugfs_"): |
| 435 | setup_debugfs_variables(localdata) |
| 436 | debug = "setup_debugfs " |
| 437 | realt = t[8:] |
| 438 | localdata.setVar('OVERRIDES', '%s:%s' % (realt, old_overrides)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 439 | localdata.setVar('type', realt) |
| 440 | # Delete DATETIME so we don't expand any references to it now |
| 441 | # This means the task's hash can be stable rather than having hardcoded |
| 442 | # date/time values. It will get expanded at execution time. |
| 443 | # Similarly TMPDIR since otherwise we see QA stamp comparision problems |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 444 | # Expand PV else it can trigger get_srcrev which can fail due to these variables being unset |
| 445 | localdata.setVar('PV', d.getVar('PV')) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 446 | localdata.delVar('DATETIME') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 447 | localdata.delVar('DATE') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 448 | localdata.delVar('TMPDIR') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 449 | vardepsexclude = (d.getVarFlag('IMAGE_CMD_' + realt, 'vardepsexclude', True) or '').split() |
| 450 | for dep in vardepsexclude: |
| 451 | localdata.delVar(dep) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 452 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 453 | image_cmd = localdata.getVar("IMAGE_CMD") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 454 | vardeps.add('IMAGE_CMD_' + realt) |
| 455 | if image_cmd: |
| 456 | cmds.append("\t" + image_cmd) |
| 457 | else: |
| 458 | bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 459 | cmds.append(localdata.expand("\tcd ${IMGDEPLOYDIR}")) |
| 460 | |
| 461 | # Since a copy of IMAGE_CMD_xxx will be inlined within do_image_xxx, |
| 462 | # prevent a redundant copy of IMAGE_CMD_xxx being emitted as a function. |
| 463 | d.delVarFlag('IMAGE_CMD_' + realt, 'func') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 464 | |
| 465 | rm_tmp_images = set() |
| 466 | def gen_conversion_cmds(bt): |
Gerson Fernando Budke | 3c4c45d | 2017-09-19 14:15:36 -0300 | [diff] [blame] | 467 | for ctype in sorted(ctypes): |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 468 | if bt.endswith("." + ctype): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 469 | type = bt[0:-len(ctype) - 1] |
| 470 | if type.startswith("debugfs_"): |
| 471 | type = type[8:] |
| 472 | # Create input image first. |
| 473 | gen_conversion_cmds(type) |
| 474 | localdata.setVar('type', type) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 475 | cmd = "\t" + (localdata.getVar("CONVERSION_CMD_" + ctype) or localdata.getVar("COMPRESS_CMD_" + ctype)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 476 | if cmd not in cmds: |
| 477 | cmds.append(cmd) |
| 478 | vardeps.add('CONVERSION_CMD_' + ctype) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 479 | vardeps.add('COMPRESS_CMD_' + ctype) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 480 | subimage = type + "." + ctype |
| 481 | if subimage not in subimages: |
| 482 | subimages.append(subimage) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 483 | if type not in alltypes: |
| 484 | rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}")) |
| 485 | |
| 486 | for bt in basetypes[t]: |
| 487 | gen_conversion_cmds(bt) |
| 488 | |
| 489 | localdata.setVar('type', realt) |
| 490 | if t not in alltypes: |
| 491 | rm_tmp_images.add(localdata.expand("${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.${type}")) |
| 492 | else: |
| 493 | subimages.append(realt) |
| 494 | |
| 495 | # Clean up after applying all conversion commands. Some of them might |
| 496 | # use the same input, therefore we cannot delete sooner without applying |
| 497 | # some complex dependency analysis. |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 498 | for image in sorted(rm_tmp_images): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 499 | cmds.append("\trm " + image) |
| 500 | |
| 501 | after = 'do_image' |
| 502 | for dep in typedeps[t]: |
| 503 | after += ' do_image_%s' % dep.replace("-", "_").replace(".", "_") |
| 504 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 505 | task = "do_image_%s" % t.replace("-", "_").replace(".", "_") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 506 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 507 | d.setVar(task, '\n'.join(cmds)) |
| 508 | d.setVarFlag(task, 'func', '1') |
| 509 | d.setVarFlag(task, 'fakeroot', '1') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 510 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 511 | d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size') |
| 512 | d.prependVarFlag(task, 'postfuncs', ' create_symlinks') |
| 513 | d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages)) |
| 514 | d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps)) |
| 515 | d.appendVarFlag(task, 'vardepsexclude', 'DATETIME DATE ' + ' '.join(vardepsexclude)) |
| 516 | |
| 517 | bb.debug(2, "Adding task %s before %s, after %s" % (task, 'do_image_complete', after)) |
| 518 | bb.build.addtask(task, 'do_image_complete', after, d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | # |
| 522 | # Compute the rootfs size |
| 523 | # |
| 524 | def get_rootfs_size(d): |
| 525 | import subprocess |
| 526 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 527 | rootfs_alignment = int(d.getVar('IMAGE_ROOTFS_ALIGNMENT')) |
| 528 | overhead_factor = float(d.getVar('IMAGE_OVERHEAD_FACTOR')) |
| 529 | rootfs_req_size = int(d.getVar('IMAGE_ROOTFS_SIZE')) |
| 530 | rootfs_extra_space = eval(d.getVar('IMAGE_ROOTFS_EXTRA_SPACE')) |
| 531 | rootfs_maxsize = d.getVar('IMAGE_ROOTFS_MAXSIZE') |
| 532 | image_fstypes = d.getVar('IMAGE_FSTYPES') or '' |
| 533 | initramfs_fstypes = d.getVar('INITRAMFS_FSTYPES') or '' |
| 534 | initramfs_maxsize = d.getVar('INITRAMFS_MAXSIZE') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 535 | |
| 536 | output = subprocess.check_output(['du', '-ks', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 537 | d.getVar('IMAGE_ROOTFS')]) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 538 | size_kb = int(output.split()[0]) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 539 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 540 | base_size = size_kb * overhead_factor |
| 541 | bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor)) |
| 542 | base_size2 = max(base_size, rootfs_req_size) + rootfs_extra_space |
| 543 | bb.debug(1, '%f = max(%f, %d)[%f] + %d' % (base_size2, base_size, rootfs_req_size, max(base_size, rootfs_req_size), overhead_factor)) |
| 544 | |
| 545 | base_size = base_size2 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 546 | if base_size != int(base_size): |
| 547 | base_size = int(base_size + 1) |
| 548 | else: |
| 549 | base_size = int(base_size) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 550 | bb.debug(1, '%f = int(%f)' % (base_size, base_size2)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 551 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 552 | base_size_saved = base_size |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 553 | base_size += rootfs_alignment - 1 |
| 554 | base_size -= base_size % rootfs_alignment |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 555 | bb.debug(1, '%d = aligned(%d)' % (base_size, base_size_saved)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 556 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 557 | # Do not check image size of the debugfs image. This is not supposed |
| 558 | # to be deployed, etc. so it doesn't make sense to limit the size |
| 559 | # of the debug. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 560 | if (d.getVar('IMAGE_BUILDING_DEBUGFS') or "") == "true": |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 561 | bb.debug(1, 'returning debugfs size %d' % (base_size)) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 562 | return base_size |
| 563 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 564 | # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set) |
| 565 | if rootfs_maxsize: |
| 566 | rootfs_maxsize_int = int(rootfs_maxsize) |
| 567 | if base_size > rootfs_maxsize_int: |
| 568 | bb.fatal("The rootfs size %d(K) overrides IMAGE_ROOTFS_MAXSIZE: %d(K)" % \ |
| 569 | (base_size, rootfs_maxsize_int)) |
| 570 | |
| 571 | # Check the initramfs size against INITRAMFS_MAXSIZE (if set) |
| 572 | if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize: |
| 573 | initramfs_maxsize_int = int(initramfs_maxsize) |
| 574 | if base_size > initramfs_maxsize_int: |
| 575 | bb.error("The initramfs size %d(K) overrides INITRAMFS_MAXSIZE: %d(K)" % \ |
| 576 | (base_size, initramfs_maxsize_int)) |
| 577 | bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should") |
| 578 | bb.fatal("be less than 1/2 of ram size, or you may fail to boot it.\n") |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 579 | |
| 580 | bb.debug(1, 'returning %d' % (base_size)) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 581 | return base_size |
| 582 | |
| 583 | python set_image_size () { |
| 584 | rootfs_size = get_rootfs_size(d) |
| 585 | d.setVar('ROOTFS_SIZE', str(rootfs_size)) |
| 586 | d.setVarFlag('ROOTFS_SIZE', 'export', '1') |
| 587 | } |
| 588 | |
| 589 | # |
| 590 | # Create symlinks to the newly created image |
| 591 | # |
| 592 | python create_symlinks() { |
| 593 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 594 | deploy_dir = d.getVar('IMGDEPLOYDIR') |
| 595 | img_name = d.getVar('IMAGE_NAME') |
| 596 | link_name = d.getVar('IMAGE_LINK_NAME') |
| 597 | manifest_name = d.getVar('IMAGE_MANIFEST') |
| 598 | taskname = d.getVar("BB_CURRENTTASK") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 599 | subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 600 | imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix') or d.expand("${IMAGE_NAME_SUFFIX}.") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 601 | |
| 602 | if not link_name: |
| 603 | return |
| 604 | for type in subimages: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 605 | dst = os.path.join(deploy_dir, link_name + "." + type) |
| 606 | src = img_name + imgsuffix + type |
| 607 | if os.path.exists(os.path.join(deploy_dir, src)): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 608 | bb.note("Creating symlink: %s -> %s" % (dst, src)) |
| 609 | if os.path.islink(dst): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 610 | os.remove(dst) |
| 611 | os.symlink(src, dst) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 612 | else: |
| 613 | bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|" |
| 617 | MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py" |
| 618 | MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib" |
| 619 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 620 | do_fetch[noexec] = "1" |
| 621 | do_unpack[noexec] = "1" |
| 622 | do_patch[noexec] = "1" |
| 623 | do_configure[noexec] = "1" |
| 624 | do_compile[noexec] = "1" |
| 625 | do_install[noexec] = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 626 | deltask do_populate_sysroot |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 627 | do_package[noexec] = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 628 | deltask do_package_qa |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 629 | do_packagedata[noexec] = "1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 630 | deltask do_package_write_ipk |
| 631 | deltask do_package_write_deb |
| 632 | deltask do_package_write_rpm |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 633 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 634 | # Prepare the root links to point to the /usr counterparts. |
| 635 | create_merged_usr_symlinks() { |
| 636 | root="$1" |
| 637 | install -d $root${base_bindir} $root${base_sbindir} $root${base_libdir} |
| 638 | lnr $root${base_bindir} $root/bin |
| 639 | lnr $root${base_sbindir} $root/sbin |
| 640 | lnr $root${base_libdir} $root/${baselib} |
| 641 | |
| 642 | if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then |
| 643 | install -d $root${nonarch_base_libdir} |
| 644 | lnr $root${nonarch_base_libdir} $root/lib |
| 645 | fi |
| 646 | |
| 647 | # create base links for multilibs |
| 648 | multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}" |
| 649 | for d in $multi_libdirs; do |
| 650 | install -d $root${exec_prefix}/$d |
| 651 | lnr $root${exec_prefix}/$d $root/$d |
| 652 | done |
| 653 | } |
| 654 | |
| 655 | create_merged_usr_symlinks_rootfs() { |
| 656 | create_merged_usr_symlinks ${IMAGE_ROOTFS} |
| 657 | } |
| 658 | |
| 659 | create_merged_usr_symlinks_sdk() { |
| 660 | create_merged_usr_symlinks ${SDK_OUTPUT}${SDKTARGETSYSROOT} |
| 661 | } |
| 662 | |
| 663 | ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_rootfs; ', '',d)}" |
| 664 | POPULATE_SDK_PRE_TARGET_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_sdk; ', '',d)}" |
| 665 | |
| 666 | reproducible_final_image_task () { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 667 | if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 668 | if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then |
| 669 | REPRODUCIBLE_TIMESTAMP_ROOTFS=`git log -1 --pretty=%ct` |
| 670 | fi |
| 671 | # Set mtime of all files to a reproducible value |
| 672 | bbnote "reproducible_final_image_task: mtime set to $REPRODUCIBLE_TIMESTAMP_ROOTFS" |
| 673 | find ${IMAGE_ROOTFS} -exec touch -h --date=@$REPRODUCIBLE_TIMESTAMP_ROOTFS {} \; |
| 674 | fi |
| 675 | } |
| 676 | IMAGE_PREPROCESS_COMMAND_append = " reproducible_final_image_task; " |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 677 | |
| 678 | CVE_PRODUCT = "" |