blob: c2f32320278ca2d5b2ef9fe70cf9b6926c5e622c [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08002IMAGE_CLASSES ??= ""
3
4# rootfs bootstrap install
5# warning - image-container resets this
6ROOTFS_BOOTSTRAP_INSTALL = "run-postinsts"
7
8# Handle inherits of any of the image classes we need
9IMGCLASSES = "rootfs_${IMAGE_PKGTYPE} image_types ${IMAGE_CLASSES}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010# Only Linux SDKs support populate_sdk_ext, fall back to populate_sdk_base
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050011# in the non-Linux SDK_OS case, such as mingw32
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012IMGCLASSES += "${@['populate_sdk_base', 'populate_sdk_ext']['linux' in d.getVar("SDK_OS")]}"
13IMGCLASSES += "${@bb.utils.contains_any('IMAGE_FSTYPES', 'live iso hddimg', 'image-live', '', d)}"
14IMGCLASSES += "${@bb.utils.contains('IMAGE_FSTYPES', 'container', 'image-container', '', d)}"
15IMGCLASSES += "image_types_wic"
16IMGCLASSES += "rootfs-postcommands"
17IMGCLASSES += "image-postinst-intercepts"
18inherit ${IMGCLASSES}
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019
20TOOLCHAIN_TARGET_TASK += "${PACKAGE_INSTALL}"
21TOOLCHAIN_TARGET_TASK_ATTEMPTONLY += "${PACKAGE_INSTALL_ATTEMPTONLY}"
22POPULATE_SDK_POST_TARGET_COMMAND += "rootfs_sysroot_relativelinks; "
23
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024LICENSE ?= "MIT"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025PACKAGES = ""
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080026DEPENDS += "${@' '.join(["%s-qemuwrapper-cross" % m for m in d.getVar("MULTILIB_VARIANTS").split()])} qemuwrapper-cross depmodwrapper-cross cross-localedef-native"
Brad Bishop19323692019-04-05 15:28:33 -040027RDEPENDS += "${PACKAGE_INSTALL} ${LINGUAS_INSTALL} ${IMAGE_INSTALL_DEBUGFS}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028RRECOMMENDS += "${PACKAGE_INSTALL_ATTEMPTONLY}"
Patrick Williams213cb262021-08-07 19:21:33 -050029PATH:prepend = "${@":".join(all_multilib_tune_values(d, 'STAGING_BINDIR_CROSS').split())}:"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030
31INHIBIT_DEFAULT_DEPS = "1"
32
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033# IMAGE_FEATURES may contain any available package group
34IMAGE_FEATURES ?= ""
35IMAGE_FEATURES[type] = "list"
Andrew Geisslerd1e89492021-02-12 15:35:20 -060036IMAGE_FEATURES[validitems] += "debug-tweaks read-only-rootfs read-only-rootfs-delayed-postinsts stateless-rootfs empty-root-password allow-empty-password allow-root-login post-install-logging"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037
38# Generate companion debugfs?
39IMAGE_GEN_DEBUGFS ?= "0"
40
William A. Kennington IIIac69b482021-06-02 12:28:27 -070041# These packages will be installed as additional into debug rootfs
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042IMAGE_INSTALL_DEBUGFS ?= ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044# These packages will be removed from a read-only rootfs after all other
45# packages have been installed
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046ROOTFS_RO_UNNEEDED ??= "update-rc.d base-passwd shadow ${VIRTUAL-RUNTIME_update-alternatives} ${ROOTFS_BOOTSTRAP_INSTALL}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048# packages to install from features
49FEATURE_INSTALL = "${@' '.join(oe.packagegroup.required_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
50FEATURE_INSTALL[vardepvalue] = "${FEATURE_INSTALL}"
51FEATURE_INSTALL_OPTIONAL = "${@' '.join(oe.packagegroup.optional_packages(oe.data.typed_value('IMAGE_FEATURES', d), d))}"
52FEATURE_INSTALL_OPTIONAL[vardepvalue] = "${FEATURE_INSTALL_OPTIONAL}"
53
54# Define some very basic feature package groups
55FEATURE_PACKAGES_package-management = "${ROOTFS_PKGMANAGE}"
56SPLASH ?= "psplash"
57FEATURE_PACKAGES_splash = "${SPLASH}"
58
59IMAGE_INSTALL_COMPLEMENTARY = '${@complementary_globs("IMAGE_FEATURES", d)}'
60
61def check_image_features(d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 valid_features = (d.getVarFlag('IMAGE_FEATURES', 'validitems') or "").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 valid_features += d.getVarFlags('COMPLEMENTARY_GLOB').keys()
64 for var in d:
Andrew Geissler82c905d2020-04-13 13:39:40 -050065 if var.startswith("FEATURE_PACKAGES_"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066 valid_features.append(var[17:])
67 valid_features.sort()
68
69 features = set(oe.data.typed_value('IMAGE_FEATURES', d))
70 for feature in features:
71 if feature not in valid_features:
72 if bb.utils.contains('EXTRA_IMAGE_FEATURES', feature, True, False, d):
73 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)))
74 else:
75 raise bb.parse.SkipRecipe("'%s' in IMAGE_FEATURES is not a valid image feature. Valid features: %s" % (feature, ' '.join(valid_features)))
76
77IMAGE_INSTALL ?= ""
78IMAGE_INSTALL[type] = "list"
79export PACKAGE_INSTALL ?= "${IMAGE_INSTALL} ${ROOTFS_BOOTSTRAP_INSTALL} ${FEATURE_INSTALL}"
80PACKAGE_INSTALL_ATTEMPTONLY ?= "${FEATURE_INSTALL_OPTIONAL}"
81
Patrick Williamsc0f7c042017-02-23 20:41:17 -060082IMGDEPLOYDIR = "${WORKDIR}/deploy-${PN}-image-complete"
83
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084# Images are generally built explicitly, do not need to be part of world.
85EXCLUDE_FROM_WORLD = "1"
86
87USE_DEVFS ?= "1"
88USE_DEPMOD ?= "1"
89
90PID = "${@os.getpid()}"
91
92PACKAGE_ARCH = "${MACHINE_ARCH}"
93
94LDCONFIGDEPEND ?= "ldconfig-native:do_populate_sysroot"
Patrick Williams213cb262021-08-07 19:21:33 -050095LDCONFIGDEPEND:libc-musl = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050096
97# This is needed to have depmod data in PKGDATA_DIR,
98# but if you're building small initramfs image
99# e.g. to include it in your kernel, you probably
100# don't want this dependency, which is causing dependency loop
101KERNELDEPMODDEPEND ?= "virtual/kernel:do_packagedata"
102
103do_rootfs[depends] += " \
104 makedevs-native:do_populate_sysroot virtual/fakeroot-native:do_populate_sysroot ${LDCONFIGDEPEND} \
105 virtual/update-alternatives-native:do_populate_sysroot update-rc.d-native:do_populate_sysroot \
106 ${KERNELDEPMODDEPEND} \
107"
108do_rootfs[recrdeptask] += "do_packagedata"
109
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500110def rootfs_command_variables(d):
111 return ['ROOTFS_POSTPROCESS_COMMAND','ROOTFS_PREPROCESS_COMMAND','ROOTFS_POSTINSTALL_COMMAND','ROOTFS_POSTUNINSTALL_COMMAND','OPKG_PREPROCESS_COMMANDS','OPKG_POSTPROCESS_COMMANDS','IMAGE_POSTPROCESS_COMMAND',
112 'IMAGE_PREPROCESS_COMMAND','RPM_PREPROCESS_COMMANDS','RPM_POSTPROCESS_COMMANDS','DEB_PREPROCESS_COMMANDS','DEB_POSTPROCESS_COMMANDS']
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113
114python () {
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500115 variables = rootfs_command_variables(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116 for var in variables:
117 if d.getVar(var, False):
118 d.setVarFlag(var, 'func', '1')
119}
120
121def rootfs_variables(d):
122 from oe.rootfs import variable_depends
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600123 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',
Andrew Geisslerf0343792020-11-18 10:42:21 -0600124 'IMAGE_ROOTFS_MAXSIZE','IMAGE_NAME','IMAGE_LINK_NAME','IMAGE_MANIFEST','DEPLOY_DIR_IMAGE','IMAGE_FSTYPES','IMAGE_INSTALL_COMPLEMENTARY','IMAGE_LINGUAS', 'IMAGE_LINGUAS_COMPLEMENTARY', 'IMAGE_LOCALES_ARCHIVE',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500125 'MULTILIBRE_ALLOW_REP','MULTILIB_TEMP_ROOTFS','MULTILIB_VARIANTS','MULTILIBS','ALL_MULTILIB_PACKAGE_ARCHS','MULTILIB_GLOBAL_VARIANTS','BAD_RECOMMENDATIONS','NO_RECOMMENDATIONS',
126 'PACKAGE_ARCHS','PACKAGE_CLASSES','TARGET_VENDOR','TARGET_ARCH','TARGET_OS','OVERRIDES','BBEXTENDVARIANT','FEED_DEPLOYDIR_BASE_URI','INTERCEPT_DIR','USE_DEVFS',
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800127 'CONVERSIONTYPES', 'IMAGE_GEN_DEBUGFS', 'ROOTFS_RO_UNNEEDED', 'IMGDEPLOYDIR', 'PACKAGE_EXCLUDE_COMPLEMENTARY', 'REPRODUCIBLE_TIMESTAMP_ROOTFS', 'IMAGE_INSTALL_DEBUGFS']
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500128 variables.extend(rootfs_command_variables(d))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129 variables.extend(variable_depends(d))
130 return " ".join(variables)
131
132do_rootfs[vardeps] += "${@rootfs_variables(d)}"
133
134do_build[depends] += "virtual/kernel:do_deploy"
135
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500136
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500137python () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500138 def extraimage_getdepends(task):
139 deps = ""
140 for dep in (d.getVar('EXTRA_IMAGEDEPENDS') or "").split():
Andrew Geissler5199d832021-09-24 16:47:35 -0500141 if ":" in dep:
142 deps += " %s " % (dep)
143 else:
144 deps += " %s:%s" % (dep, task)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500145 return deps
146
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500147 d.appendVarFlag('do_image_complete', 'depends', extraimage_getdepends('do_populate_sysroot'))
148
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500149 deps = " " + imagetypes_getdepends(d)
150 d.appendVarFlag('do_rootfs', 'depends', deps)
151
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500152 #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 Bishop6e60e8b2018-02-01 10:27:11 -0500157 replaces = set((d.getVar("IMAGE_FEATURES_REPLACES_%s" % feature) or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158 remain_features -= replaces
159
160 #Check for conflict image features
161 for feature in remain_features:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500162 conflicts = set((d.getVar("IMAGE_FEATURES_CONFLICTS_%s" % feature) or "").split())
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500163 temp = conflicts & remain_features
164 if temp:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500165 bb.fatal("%s contains conflicting IMAGE_FEATURES %s %s" % (d.getVar('PN'), feature, ' '.join(list(temp))))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600167 d.setVar('IMAGE_FEATURES', ' '.join(sorted(list(remain_features))))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168
169 check_image_features(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170}
171
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172IMAGE_POSTPROCESS_COMMAND ?= ""
173
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174# some default locales
175IMAGE_LINGUAS ?= "de-de fr-fr en-gb"
176
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500177LINGUAS_INSTALL ?= "${@" ".join(map(lambda s: "locale-base-%s" % s, d.getVar('IMAGE_LINGUAS').split()))}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178
Andrew Geisslerf0343792020-11-18 10:42:21 -0600179# per default create a locale archive
180IMAGE_LOCALES_ARCHIVE ?= '1'
181
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182# Prefer image, but use the fallback files for lookups if the image ones
183# aren't yet available.
184PSEUDO_PASSWD = "${IMAGE_ROOTFS}:${STAGING_DIR_NATIVE}"
185
Andrew Geissler90fd73c2021-03-05 15:25:55 -0600186PSEUDO_IGNORE_PATHS .= ",${WORKDIR}/intercept_scripts,${WORKDIR}/oe-rootfs-repo,${WORKDIR}/sstate-build-image_complete"
187
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188PACKAGE_EXCLUDE ??= ""
189PACKAGE_EXCLUDE[type] = "list"
190
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500191fakeroot python do_rootfs () {
192 from oe.rootfs import create_rootfs
193 from oe.manifest import create_manifest
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500194 import logging
195
196 logger = d.getVar('BB_TASK_LOGGER', False)
197 if logger:
198 logcatcher = bb.utils.LogCatcher()
199 logger.addHandler(logcatcher)
200 else:
201 logcatcher = None
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500202
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600203 # NOTE: if you add, remove or significantly refactor the stages of this
204 # process then you should recalculate the weightings here. This is quite
205 # easy to do - just change the MultiStageProgressReporter line temporarily
206 # to pass debug=True as the last parameter and you'll get a printout of
207 # the weightings as well as a map to the lines where next_stage() was
208 # called. Of course this isn't critical, but it helps to keep the progress
209 # reporting accurate.
210 stage_weights = [1, 203, 354, 186, 65, 4228, 1, 353, 49, 330, 382, 23, 1]
211 progress_reporter = bb.progress.MultiStageProgressReporter(d, stage_weights)
212 progress_reporter.next_stage()
213
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500214 # Handle package exclusions
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500215 excl_pkgs = d.getVar("PACKAGE_EXCLUDE").split()
216 inst_pkgs = d.getVar("PACKAGE_INSTALL").split()
217 inst_attempt_pkgs = d.getVar("PACKAGE_INSTALL_ATTEMPTONLY").split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218
219 d.setVar('PACKAGE_INSTALL_ORIG', ' '.join(inst_pkgs))
220 d.setVar('PACKAGE_INSTALL_ATTEMPTONLY', ' '.join(inst_attempt_pkgs))
221
222 for pkg in excl_pkgs:
223 if pkg in inst_pkgs:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500224 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 Williamsc124f4f2015-09-15 14:41:29 -0500225 inst_pkgs.remove(pkg)
226
227 if pkg in inst_attempt_pkgs:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500228 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 Williamsc124f4f2015-09-15 14:41:29 -0500229 inst_attempt_pkgs.remove(pkg)
230
231 d.setVar("PACKAGE_INSTALL", ' '.join(inst_pkgs))
232 d.setVar("PACKAGE_INSTALL_ATTEMPTONLY", ' '.join(inst_attempt_pkgs))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500233
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500234 # Ensure we handle package name remapping
235 # We have to delay the runtime_mapping_rename until just before rootfs runs
236 # otherwise, the multilib renaming could step in and squash any fixups that
237 # may have occurred.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500238 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500239 runtime_mapping_rename("PACKAGE_INSTALL", pn, d)
240 runtime_mapping_rename("PACKAGE_INSTALL_ATTEMPTONLY", pn, d)
241 runtime_mapping_rename("BAD_RECOMMENDATIONS", pn, d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500242
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500243 # Generate the initial manifest
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500244 create_manifest(d)
245
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600246 progress_reporter.next_stage()
247
248 # generate rootfs
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500249 d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500250 create_rootfs(d, progress_reporter=progress_reporter, logcatcher=logcatcher)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600251
252 progress_reporter.finish()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500253}
254do_rootfs[dirs] = "${TOPDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600255do_rootfs[cleandirs] += "${S} ${IMGDEPLOYDIR}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800256do_rootfs[file-checksums] += "${POSTINST_INTERCEPT_CHECKSUMS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500257addtask rootfs after do_prepare_recipe_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500258
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500259fakeroot python do_image () {
260 from oe.utils import execute_pre_post_process
261
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500262 d.setVarFlag('REPRODUCIBLE_TIMESTAMP_ROOTFS', 'export', '1')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500263 pre_process_cmds = d.getVar("IMAGE_PREPROCESS_COMMAND")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500264
265 execute_pre_post_process(d, pre_process_cmds)
266}
267do_image[dirs] = "${TOPDIR}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500268addtask do_image after do_rootfs
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500269
270fakeroot python do_image_complete () {
271 from oe.utils import execute_pre_post_process
272
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500273 post_process_cmds = d.getVar("IMAGE_POSTPROCESS_COMMAND")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500274
275 execute_pre_post_process(d, post_process_cmds)
276}
277do_image_complete[dirs] = "${TOPDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600278SSTATETASKS += "do_image_complete"
Patrick Williams213cb262021-08-07 19:21:33 -0500279SSTATE_SKIP_CREATION:task-image-complete = '1'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600280do_image_complete[sstate-inputdirs] = "${IMGDEPLOYDIR}"
281do_image_complete[sstate-outputdirs] = "${DEPLOY_DIR_IMAGE}"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400282do_image_complete[stamp-extra-info] = "${MACHINE_ARCH}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500283addtask do_image_complete after do_image before do_build
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500284python do_image_complete_setscene () {
285 sstate_setscene(d)
286}
287addtask do_image_complete_setscene
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500288
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600289# Add image-level QA/sanity checks to IMAGE_QA_COMMANDS
290#
291# IMAGE_QA_COMMANDS += " \
292# image_check_everything_ok \
293# "
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500294# This task runs all functions in IMAGE_QA_COMMANDS after the rootfs
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600295# construction has completed in order to validate the resulting image.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500296#
297# The functions should use ${IMAGE_ROOTFS} to find the unpacked rootfs
298# directory, which if QA passes will be the basis for the images.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600299fakeroot python do_image_qa () {
300 from oe.utils import ImageQAFailed
301
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500302 qa_cmds = (d.getVar('IMAGE_QA_COMMANDS') or '').split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600303 qamsg = ""
304
305 for cmd in qa_cmds:
306 try:
307 bb.build.exec_func(cmd, d)
308 except oe.utils.ImageQAFailed as e:
309 qamsg = qamsg + '\tImage QA function %s failed: %s\n' % (e.name, e.description)
Brad Bishop08902b02019-08-20 09:16:51 -0400310 except Exception as e:
311 qamsg = qamsg + '\tImage QA function %s failed\n' % cmd
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600312
313 if qamsg:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500314 imgname = d.getVar('IMAGE_NAME')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600315 bb.fatal("QA errors found whilst validating image: %s\n%s" % (imgname, qamsg))
316}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500317addtask do_image_qa after do_rootfs before do_image
318
319SSTATETASKS += "do_image_qa"
Patrick Williams213cb262021-08-07 19:21:33 -0500320SSTATE_SKIP_CREATION:task-image-qa = '1'
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500321do_image_qa[sstate-inputdirs] = ""
322do_image_qa[sstate-outputdirs] = ""
323python do_image_qa_setscene () {
324 sstate_setscene(d)
325}
326addtask do_image_qa_setscene
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600327
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500328def setup_debugfs_variables(d):
329 d.appendVar('IMAGE_ROOTFS', '-dbg')
Brad Bishop96ff1982019-08-19 13:50:42 -0400330 if d.getVar('IMAGE_LINK_NAME'):
331 d.appendVar('IMAGE_LINK_NAME', '-dbg')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500332 d.appendVar('IMAGE_NAME','-dbg')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600333 d.setVar('IMAGE_BUILDING_DEBUGFS', 'true')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500334 debugfs_image_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500335 if debugfs_image_fstypes:
336 d.setVar('IMAGE_FSTYPES', debugfs_image_fstypes)
337
338python setup_debugfs () {
339 setup_debugfs_variables(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500340}
341
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500342python () {
343 vardeps = set()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600344 # 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 Bishop6e60e8b2018-02-01 10:27:11 -0500352 ctypes = set(d.getVar('CONVERSIONTYPES').split())
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600353 old_overrides = d.getVar('OVERRIDES', False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500355 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 Bishop6e60e8b2018-02-01 10:27:11 -0500369 alltypes = d.getVar('IMAGE_FSTYPES').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500370 typedeps = {}
371
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500372 if d.getVar('IMAGE_GEN_DEBUGFS') == "1":
373 debugfs_fstypes = d.getVar('IMAGE_FSTYPES_DEBUGFS').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500374 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_"
Patrick Williams213cb262021-08-07 19:21:33 -0500388 deps = (d.getVar('IMAGE_TYPEDEP:' + t) or "").split()
389 vardeps.add('IMAGE_TYPEDEP:' + t)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500390 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 Bishop6e60e8b2018-02-01 10:27:11 -0500408 maskedtypes = (d.getVar('IMAGE_TYPES_MASKED') or "").split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600409 maskedtypes = [dbg + t for t in maskedtypes for dbg in ("", "debugfs_")]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500410
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 Williamsd8c66bc2016-06-20 12:57:21 -0500427 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 Bishop6e60e8b2018-02-01 10:27:11 -0500432 # 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 Williamsd8c66bc2016-06-20 12:57:21 -0500434 localdata.delVar('DATETIME')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500435 localdata.delVar('DATE')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500436 localdata.delVar('TMPDIR')
Patrick Williams93c203f2021-10-06 16:15:23 -0500437 localdata.delVar('IMAGE_VERSION_SUFFIX')
Patrick Williams213cb262021-08-07 19:21:33 -0500438 vardepsexclude = (d.getVarFlag('IMAGE_CMD:' + realt, 'vardepsexclude', True) or '').split()
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500439 for dep in vardepsexclude:
440 localdata.delVar(dep)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500441
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500442 image_cmd = localdata.getVar("IMAGE_CMD")
Patrick Williams213cb262021-08-07 19:21:33 -0500443 vardeps.add('IMAGE_CMD:' + realt)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500444 if image_cmd:
445 cmds.append("\t" + image_cmd)
446 else:
447 bb.fatal("No IMAGE_CMD defined for IMAGE_FSTYPES entry '%s' - possibly invalid type name or missing support class" % t)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600448 cmds.append(localdata.expand("\tcd ${IMGDEPLOYDIR}"))
449
Patrick Williams213cb262021-08-07 19:21:33 -0500450 # Since a copy of IMAGE_CMD:xxx will be inlined within do_image_xxx,
451 # prevent a redundant copy of IMAGE_CMD:xxx being emitted as a function.
452 d.delVarFlag('IMAGE_CMD:' + realt, 'func')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500453
454 rm_tmp_images = set()
455 def gen_conversion_cmds(bt):
Gerson Fernando Budke3c4c45d2017-09-19 14:15:36 -0300456 for ctype in sorted(ctypes):
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500457 if bt.endswith("." + ctype):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500458 type = bt[0:-len(ctype) - 1]
459 if type.startswith("debugfs_"):
460 type = type[8:]
461 # Create input image first.
462 gen_conversion_cmds(type)
463 localdata.setVar('type', type)
Patrick Williams213cb262021-08-07 19:21:33 -0500464 cmd = "\t" + localdata.getVar("CONVERSION_CMD:" + ctype)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600465 if cmd not in cmds:
466 cmds.append(cmd)
Patrick Williams213cb262021-08-07 19:21:33 -0500467 vardeps.add('CONVERSION_CMD:' + ctype)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600468 subimage = type + "." + ctype
469 if subimage not in subimages:
470 subimages.append(subimage)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500471 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 Bishop37a0e4d2017-12-04 01:01:44 -0500486 for image in sorted(rm_tmp_images):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500487 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 Bishopd7bf8c12018-02-25 22:55:05 -0500493 task = "do_image_%s" % t.replace("-", "_").replace(".", "_")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500494
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500495 d.setVar(task, '\n'.join(cmds))
496 d.setVarFlag(task, 'func', '1')
497 d.setVarFlag(task, 'fakeroot', '1')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500498
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500499 d.appendVarFlag(task, 'prefuncs', ' ' + debug + ' set_image_size')
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300500 d.prependVarFlag(task, 'postfuncs', 'create_symlinks ')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500501 d.appendVarFlag(task, 'subimages', ' ' + ' '.join(subimages))
502 d.appendVarFlag(task, 'vardeps', ' ' + ' '.join(vardeps))
Brad Bishop19323692019-04-05 15:28:33 -0400503 d.appendVarFlag(task, 'vardepsexclude', ' DATETIME DATE ' + ' '.join(vardepsexclude))
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500504
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 Williamsd8c66bc2016-06-20 12:57:21 -0500507}
508
509#
510# Compute the rootfs size
511#
512def get_rootfs_size(d):
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500513 import subprocess, oe.utils
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500514
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500515 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 Williamsd8c66bc2016-06-20 12:57:21 -0500523
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500524 size_kb = oe.utils.directory_size(d.getVar("IMAGE_ROOTFS")) / 1024
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500525
Brad Bishop316dfdd2018-06-25 12:45:53 -0400526 base_size = size_kb * overhead_factor
527 bb.debug(1, '%f = %d * %f' % (base_size, size_kb, overhead_factor))
528 base_size2 = max(base_size, rootfs_req_size) + rootfs_extra_space
Brad Bishop79641f22019-09-10 07:20:22 -0400529 bb.debug(1, '%f = max(%f, %d)[%f] + %d' % (base_size2, base_size, rootfs_req_size, max(base_size, rootfs_req_size), rootfs_extra_space))
Brad Bishop316dfdd2018-06-25 12:45:53 -0400530
531 base_size = base_size2
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500532 if base_size != int(base_size):
533 base_size = int(base_size + 1)
534 else:
535 base_size = int(base_size)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400536 bb.debug(1, '%f = int(%f)' % (base_size, base_size2))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500537
Brad Bishop316dfdd2018-06-25 12:45:53 -0400538 base_size_saved = base_size
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500539 base_size += rootfs_alignment - 1
540 base_size -= base_size % rootfs_alignment
Brad Bishop316dfdd2018-06-25 12:45:53 -0400541 bb.debug(1, '%d = aligned(%d)' % (base_size, base_size_saved))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500542
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600543 # Do not check image size of the debugfs image. This is not supposed
544 # to be deployed, etc. so it doesn't make sense to limit the size
545 # of the debug.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500546 if (d.getVar('IMAGE_BUILDING_DEBUGFS') or "") == "true":
Brad Bishop316dfdd2018-06-25 12:45:53 -0400547 bb.debug(1, 'returning debugfs size %d' % (base_size))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600548 return base_size
549
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500550 # Check the rootfs size against IMAGE_ROOTFS_MAXSIZE (if set)
551 if rootfs_maxsize:
552 rootfs_maxsize_int = int(rootfs_maxsize)
553 if base_size > rootfs_maxsize_int:
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500554 bb.fatal("The rootfs size %d(K) exceeds IMAGE_ROOTFS_MAXSIZE: %d(K)" % \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500555 (base_size, rootfs_maxsize_int))
556
557 # Check the initramfs size against INITRAMFS_MAXSIZE (if set)
558 if image_fstypes == initramfs_fstypes != '' and initramfs_maxsize:
559 initramfs_maxsize_int = int(initramfs_maxsize)
560 if base_size > initramfs_maxsize_int:
Andrew Geisslerb7d28612020-07-24 16:15:54 -0500561 bb.error("The initramfs size %d(K) exceeds INITRAMFS_MAXSIZE: %d(K)" % \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500562 (base_size, initramfs_maxsize_int))
563 bb.error("You can set INITRAMFS_MAXSIZE a larger value. Usually, it should")
564 bb.fatal("be less than 1/2 of ram size, or you may fail to boot it.\n")
Brad Bishop316dfdd2018-06-25 12:45:53 -0400565
566 bb.debug(1, 'returning %d' % (base_size))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500567 return base_size
568
569python set_image_size () {
570 rootfs_size = get_rootfs_size(d)
571 d.setVar('ROOTFS_SIZE', str(rootfs_size))
572 d.setVarFlag('ROOTFS_SIZE', 'export', '1')
573}
574
575#
576# Create symlinks to the newly created image
577#
578python create_symlinks() {
579
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500580 deploy_dir = d.getVar('IMGDEPLOYDIR')
581 img_name = d.getVar('IMAGE_NAME')
582 link_name = d.getVar('IMAGE_LINK_NAME')
583 manifest_name = d.getVar('IMAGE_MANIFEST')
584 taskname = d.getVar("BB_CURRENTTASK")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500585 subimages = (d.getVarFlag("do_" + taskname, 'subimages', False) or "").split()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500586 imgsuffix = d.getVarFlag("do_" + taskname, 'imgsuffix') or d.expand("${IMAGE_NAME_SUFFIX}.")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500587
588 if not link_name:
589 return
590 for type in subimages:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600591 dst = os.path.join(deploy_dir, link_name + "." + type)
592 src = img_name + imgsuffix + type
593 if os.path.exists(os.path.join(deploy_dir, src)):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500594 bb.note("Creating symlink: %s -> %s" % (dst, src))
595 if os.path.islink(dst):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500596 os.remove(dst)
597 os.symlink(src, dst)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600598 else:
599 bb.note("Skipping symlink, source does not exist: %s -> %s" % (dst, src))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500600}
601
602MULTILIBRE_ALLOW_REP =. "${base_bindir}|${base_sbindir}|${bindir}|${sbindir}|${libexecdir}|${sysconfdir}|${nonarch_base_libdir}/udev|/lib/modules/[^/]*/modules.*|"
603MULTILIB_CHECK_FILE = "${WORKDIR}/multilib_check.py"
604MULTILIB_TEMP_ROOTFS = "${WORKDIR}/multilib"
605
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500606do_fetch[noexec] = "1"
607do_unpack[noexec] = "1"
608do_patch[noexec] = "1"
609do_configure[noexec] = "1"
610do_compile[noexec] = "1"
611do_install[noexec] = "1"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500612deltask do_populate_lic
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500613deltask do_populate_sysroot
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500614do_package[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500615deltask do_package_qa
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500616deltask do_packagedata
Brad Bishop316dfdd2018-06-25 12:45:53 -0400617deltask do_package_write_ipk
618deltask do_package_write_deb
619deltask do_package_write_rpm
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500620
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500621# Prepare the root links to point to the /usr counterparts.
622create_merged_usr_symlinks() {
623 root="$1"
624 install -d $root${base_bindir} $root${base_sbindir} $root${base_libdir}
625 lnr $root${base_bindir} $root/bin
626 lnr $root${base_sbindir} $root/sbin
627 lnr $root${base_libdir} $root/${baselib}
628
629 if [ "${nonarch_base_libdir}" != "${base_libdir}" ]; then
630 install -d $root${nonarch_base_libdir}
631 lnr $root${nonarch_base_libdir} $root/lib
632 fi
633
634 # create base links for multilibs
635 multi_libdirs="${@d.getVar('MULTILIB_VARIANTS')}"
636 for d in $multi_libdirs; do
637 install -d $root${exec_prefix}/$d
638 lnr $root${exec_prefix}/$d $root/$d
639 done
640}
641
642create_merged_usr_symlinks_rootfs() {
643 create_merged_usr_symlinks ${IMAGE_ROOTFS}
644}
645
646create_merged_usr_symlinks_sdk() {
647 create_merged_usr_symlinks ${SDK_OUTPUT}${SDKTARGETSYSROOT}
648}
649
650ROOTFS_PREPROCESS_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_rootfs; ', '',d)}"
651POPULATE_SDK_PRE_TARGET_COMMAND += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', 'create_merged_usr_symlinks_sdk; ', '',d)}"
652
653reproducible_final_image_task () {
Brad Bishop316dfdd2018-06-25 12:45:53 -0400654 if [ "${BUILD_REPRODUCIBLE_BINARIES}" = "1" ]; then
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500655 if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800656 REPRODUCIBLE_TIMESTAMP_ROOTFS=`git -C "${COREBASE}" log -1 --pretty=%ct 2>/dev/null` || true
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500657 if [ "$REPRODUCIBLE_TIMESTAMP_ROOTFS" = "" ]; then
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800658 REPRODUCIBLE_TIMESTAMP_ROOTFS=`stat -c%Y ${@bb.utils.which(d.getVar("BBPATH"), "conf/bitbake.conf")}`
659 fi
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500660 fi
661 # Set mtime of all files to a reproducible value
662 bbnote "reproducible_final_image_task: mtime set to $REPRODUCIBLE_TIMESTAMP_ROOTFS"
Andrew Geisslerc926e172021-05-07 16:11:35 -0500663 find ${IMAGE_ROOTFS} -print0 | xargs -0 touch -h --date=@$REPRODUCIBLE_TIMESTAMP_ROOTFS
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500664 fi
665}
Brad Bishopc342db32019-05-15 21:57:59 -0400666
667systemd_preset_all () {
Brad Bishop96ff1982019-08-19 13:50:42 -0400668 if [ -e ${IMAGE_ROOTFS}${root_prefix}/lib/systemd/systemd ]; then
669 systemctl --root="${IMAGE_ROOTFS}" --preset-mode=enable-only preset-all
670 fi
Brad Bishopc342db32019-05-15 21:57:59 -0400671}
672
Patrick Williams213cb262021-08-07 19:21:33 -0500673IMAGE_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 Bishop316dfdd2018-06-25 12:45:53 -0400674
675CVE_PRODUCT = ""