xref: /openbmc/openbmc/poky/meta/classes-recipe/image-artifact-names.bbclass (revision 8f840685fb701a268141f0fcebc1d34fcd9b01de)
192b42cb3SPatrick Williams#
292b42cb3SPatrick Williams# Copyright OpenEmbedded Contributors
392b42cb3SPatrick Williams#
492b42cb3SPatrick Williams# SPDX-License-Identifier: MIT
592b42cb3SPatrick Williams#
692b42cb3SPatrick Williams
792b42cb3SPatrick Williams##################################################################
892b42cb3SPatrick Williams# Specific image creation and rootfs population info.
992b42cb3SPatrick Williams##################################################################
1092b42cb3SPatrick Williams
1192b42cb3SPatrick WilliamsIMAGE_BASENAME ?= "${PN}"
1292b42cb3SPatrick WilliamsIMAGE_VERSION_SUFFIX ?= "-${DATETIME}"
1392b42cb3SPatrick WilliamsIMAGE_VERSION_SUFFIX[vardepsexclude] += "DATETIME SOURCE_DATE_EPOCH"
14fc113eadSAndrew GeisslerIMAGE_NAME ?= "${IMAGE_LINK_NAME}${IMAGE_VERSION_SUFFIX}"
15*8f840685SAndrew GeisslerIMAGE_LINK_NAME ?= "${IMAGE_BASENAME}${IMAGE_MACHINE_SUFFIX}${IMAGE_NAME_SUFFIX}"
16fc113eadSAndrew Geissler
17fc113eadSAndrew Geissler# This needs to stay in sync with IMAGE_LINK_NAME, but with INITRAMFS_IMAGE instead of IMAGE_BASENAME
18*8f840685SAndrew Geissler# and without ${IMAGE_NAME_SUFFIX} which all initramfs images should set to empty
19fc113eadSAndrew GeisslerINITRAMFS_IMAGE_NAME ?= "${@['${INITRAMFS_IMAGE}${IMAGE_MACHINE_SUFFIX}', ''][d.getVar('INITRAMFS_IMAGE') == '']}"
20fc113eadSAndrew Geissler
21fc113eadSAndrew Geissler# The default DEPLOY_DIR_IMAGE is ${MACHINE} directory:
22fc113eadSAndrew Geissler# meta/conf/bitbake.conf:DEPLOY_DIR_IMAGE ?= "${DEPLOY_DIR}/images/${MACHINE}"
23fc113eadSAndrew Geissler# so many people find it unnecessary to include this suffix to every image
24fc113eadSAndrew Geissler# stored there, but other people often fetch various images for different
25fc113eadSAndrew Geissler# MACHINEs to the same downloads directory and then the suffix is very helpful
26fc113eadSAndrew Geissler# add separate variable for projects to decide which scheme works best for them
27fc113eadSAndrew Geissler# without understanding the IMAGE_NAME/IMAGE_LINK_NAME structure.
28fc113eadSAndrew GeisslerIMAGE_MACHINE_SUFFIX ??= "-${MACHINE}"
2992b42cb3SPatrick Williams
3092b42cb3SPatrick Williams# IMAGE_NAME is the base name for everything produced when building images.
3192b42cb3SPatrick Williams# The actual image that contains the rootfs has an additional suffix (.rootfs
3292b42cb3SPatrick Williams# by default) followed by additional suffices which describe the format (.ext4,
3392b42cb3SPatrick Williams# .ext4.xz, etc.).
3492b42cb3SPatrick WilliamsIMAGE_NAME_SUFFIX ??= ".rootfs"
3592b42cb3SPatrick Williams
3692b42cb3SPatrick Williamspython () {
3792b42cb3SPatrick Williams    if bb.data.inherits_class('deploy', d) and d.getVar("IMAGE_VERSION_SUFFIX") == "-${DATETIME}":
3892b42cb3SPatrick Williams        import datetime
3992b42cb3SPatrick Williams        d.setVar("IMAGE_VERSION_SUFFIX", "-" + datetime.datetime.fromtimestamp(int(d.getVar("SOURCE_DATE_EPOCH")), datetime.timezone.utc).strftime('%Y%m%d%H%M%S'))
4092b42cb3SPatrick Williams        d.setVarFlag("IMAGE_VERSION_SUFFIX", "vardepvalue", "")
4192b42cb3SPatrick Williams}
42