[OpenWrt-Devel,1/2] build: image: add common and reproducible IMG_PART_SIGNATURE variable
diff mbox series

Message ID 20191107140903.21731-1-ynezz@true.cz
State Accepted
Delegated to: Petr Štetiar
Headers show
Series
  • [OpenWrt-Devel,1/2] build: image: add common and reproducible IMG_PART_SIGNATURE variable
Related show

Commit Message

Petr Štetiar Nov. 7, 2019, 2:09 p.m. UTC
From: Paul Spooren <mail@aparcar.org>

x86, mvebu and tegra targets are currently using more or less same
SIGNATURE variable which provides unique partition ID/signature, so it
makes sense to refactor it out into common variable which could be
reused by all targets.  While at it, make the content of the variable
reproducible.

Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-March/016148.html
Signed-off-by: Paul Spooren <mail@aparcar.org>
Suggested-by: Jo-Philipp Wich <jo@mein.io>
[renamed to IMG_PARTSIGNATURE, reworked with epoch+vermagic hash]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 include/image.mk | 1 +
 1 file changed, 1 insertion(+)

Comments

Paul Spooren Nov. 7, 2019, 6:28 p.m. UTC | #1
Thank you for reworking this! Daniel already told me that a fallback is 
required if SOURCE_DATE_EPOCH is unset, this looks like a clean solution.

On 11/7/19 4:09 AM, Petr Štetiar wrote:
> From: Paul Spooren <mail@aparcar.org>
>
> x86, mvebu and tegra targets are currently using more or less same
> SIGNATURE variable which provides unique partition ID/signature, so it
> makes sense to refactor it out into common variable which could be
> reused by all targets.  While at it, make the content of the variable
> reproducible.
>
> Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-March/016148.html
> Signed-off-by: Paul Spooren <mail@aparcar.org>
> Suggested-by: Jo-Philipp Wich <jo@mein.io>
> [renamed to IMG_PARTSIGNATURE, reworked with epoch+vermagic hash]
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>   include/image.mk | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/include/image.mk b/include/image.mk
> index 77d456719711..8755c4832abd 100644
> --- a/include/image.mk
> +++ b/include/image.mk
> @@ -44,6 +44,7 @@ IMG_PREFIX_VERCODE:=$(if $(CONFIG_VERSION_CODE_FILENAMES),$(call sanitize,$(VERS
>   IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(IMG_PREFIX_VERNUM)$(IMG_PREFIX_VERCODE)$(IMG_PREFIX_EXTRA)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
>   IMG_ROOTFS:=$(IMG_PREFIX)-rootfs
>   IMG_COMBINED:=$(IMG_PREFIX)-combined
> +IMG_PART_SIGNATURE:=$(shell echo $(SOURCE_DATE_EPOCH)$(LINUX_VERMAGIC) | mkhash md5 | head --bytes 8)
>   
>   MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt
>

Patch
diff mbox series

diff --git a/include/image.mk b/include/image.mk
index 77d456719711..8755c4832abd 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -44,6 +44,7 @@  IMG_PREFIX_VERCODE:=$(if $(CONFIG_VERSION_CODE_FILENAMES),$(call sanitize,$(VERS
 IMG_PREFIX:=$(VERSION_DIST_SANITIZED)-$(IMG_PREFIX_VERNUM)$(IMG_PREFIX_VERCODE)$(IMG_PREFIX_EXTRA)$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
 IMG_ROOTFS:=$(IMG_PREFIX)-rootfs
 IMG_COMBINED:=$(IMG_PREFIX)-combined
+IMG_PART_SIGNATURE:=$(shell echo $(SOURCE_DATE_EPOCH)$(LINUX_VERMAGIC) | mkhash md5 | head --bytes 8)
 
 MKFS_DEVTABLE_OPT := -D $(INCLUDE_DIR)/device_table.txt