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