> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-
> c...@lists.openembedded.org> On Behalf Of Richard Purdie
> Sent: den 3 oktober 2021 00:18
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 3/5] image-artifact-names: Use SOURCE_DATE_EPOCH
> when making reproducible builds
> 
> Using DATETIME means the deploy output is not deterministic. Use SDE
> when using reproducible builds since it is consistent for given input
> data.
> 
> Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org>
> ---
>  meta/classes/image-artifact-names.bbclass | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/image-artifact-names.bbclass
> b/meta/classes/image-artifact-names.bbclass
> index 3ac8dd731a6..df9e17c6b0f 100644
> --- a/meta/classes/image-artifact-names.bbclass
> +++ b/meta/classes/image-artifact-names.bbclass
> @@ -4,7 +4,7 @@
> 
>  IMAGE_BASENAME ?= "${PN}"
>  IMAGE_VERSION_SUFFIX ?= "-${DATETIME}"
> -IMAGE_VERSION_SUFFIX[vardepsexclude] += "DATETIME"
> +IMAGE_VERSION_SUFFIX[vardepsexclude] += "DATETIME SOURCE_DATE_EPOCH"
>  IMAGE_NAME ?= "${IMAGE_BASENAME}-${MACHINE}${IMAGE_VERSION_SUFFIX}"
>  IMAGE_LINK_NAME ?= "${IMAGE_BASENAME}-${MACHINE}"
> 
> @@ -13,3 +13,10 @@ IMAGE_LINK_NAME ?= "${IMAGE_BASENAME}-${MACHINE}"
>  # by default) followed by additional suffices which describe the format 
> (.ext4,
>  # .ext4.xz, etc.).
>  IMAGE_NAME_SUFFIX ??= ".rootfs"
> +
> +python () {
> +    if bb.data.inherits_class('reproducible_build', d):

This needs to be something like:

    if bb.data.inherits_class('reproducible_build', d) and 
d.getVar("IMAGE_VERSION_SUFFIX", False) == "-${DATETIME}":

otherwise it will be impossible to change IMAGE_VERSION_SUFFIX if one also
has reproducible builds enabled.

//Peter

> +        import datetime
> +        d.setVar("IMAGE_VERSION_SUFFIX", "-" + 
> datetime.datetime.fromtimestamp(int(d.getVar("SOURCE_DATE_EPOCH")), 
> datetime.timezone.utc).strftime('%Y%m%d%H%M%S'))
> +        d.setVarFlag("IMAGE_VERSION_SUFFIX", "vardepvalue", "")
> +}
> --
> 2.32.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#156544): 
https://lists.openembedded.org/g/openembedded-core/message/156544
Mute This Topic: https://lists.openembedded.org/mt/86032666/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to