Skip to contentSkip to conversation

buildhistory: simplify buildhistory_list_files()

PATCH In review Jacob Kroon 1 participant 3 messages Jan 9, 2019 – Jan 12, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 buildhistory: simplify buildhistory_list_files()

Avoid duplicating shell code for the two cases, fakeroot/non-fakeroot.

---
 meta/classes/buildhistory.bbclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
meta/classes/buildhistory.bbclass +6 -4
index d1f3e6aa82..33eb1b00f6 100644
@@ -519,12 +519,14 @@ buildhistory_get_sdk_installed_target() {
 
 buildhistory_list_files() {
 	# List the files in the specified directory, but exclude date/time etc.
-	# This awk script is somewhat messy, but handles where the size is not printed for device files under pseudo
+	# This is somewhat messy, but handles where the size is not printed for device files under pseudo
+	( cd $1
+	find_cmd='find . ! -path . -printf "%M %-10u %-10g %10s %p -> %l\n"'
 	if [ "$3" = "fakeroot" ] ; then
-		( cd $1 && ${FAKEROOTENV} ${FAKEROOTCMD} find . ! -path . -printf "%M %-10u %-10g %10s %p -> %l\n" | sort -k5 | sed 's/ * -> $//' > $2 )
+		eval ${FAKEROOTENV} ${FAKEROOTCMD} $find_cmd
 	else
-		( cd $1 && find . ! -path . -printf "%M %-10u %-10g %10s %p -> %l\n" | sort -k5 | sed 's/ * -> $//' > $2 )
-	fi
+		eval $find_cmd
+	fi | sort -k5 | sed 's/ * -> $//' > $2 )
 }
 
 buildhistory_list_pkg_files() {
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 2/2 buildhistory: support generating sha256 checksums of regular files

Introduce 'sha256' in BUILDHISTORY_FEATURES and enable it by default when doing reproducible builds.

When enabled this will additionally create:

files-in-package-sha256.txt
files-in-image-sha256.txt
files-in-sdk-sha256.txt

containing the sha256 checksums of regular files.

---
 meta/classes/buildhistory.bbclass | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Changes in v2:
* Switch to sha256
* Let find only build the arguments and execute sha256sum once
* Use single quotes in inline python code

meta/classes/buildhistory.bbclass +8 -2
index 33eb1b00f6..84f85da0bd 100644
@@ -7,7 +7,8 @@
 # Copyright (C) 2007-2011 Koen Kooi <[email protected]>
 #
 
-BUILDHISTORY_FEATURES ?= "image package sdk"
+BUILDHISTORY_FEATURES ?= "image package sdk \
+  ${@ 'sha256' if bb.utils.to_boolean(d.getVar('BUILD_REPRODUCIBLE_BINARIES')) else ''}"
 BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
 BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
 BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
@@ -526,7 +527,12 @@ buildhistory_list_files() {
 		eval ${FAKEROOTENV} ${FAKEROOTCMD} $find_cmd
 	else
 		eval $find_cmd
-	fi | sort -k5 | sed 's/ * -> $//' > $2 )
+	fi | sort -k5 | sed 's/ * -> $//' > $2
+	if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'sha256', '1', '0', d)}" = "1" ] ; then
+		sha256filename=$(echo $2 | sed 's/\.txt$/-sha256.txt/')
+		find -type f -exec sha256sum {} + | sort -k2 > $sha256filename
+		[ -s $sha256filename ] || rm $sha256filename # remove result if empty
+	fi )
 }
 
 buildhistory_list_pkg_files() {
Signature · 1 line
2.11.0
#2 lore raw

Re: [PATCH v2 2/2] buildhistory: support generating sha256 checksums of regular files

Quoted 51 lines · Jacob Kroon

Introduce 'sha256' in BUILDHISTORY_FEATURES and enable it by default when doing reproducible builds.

When enabled this will additionally create:

files-in-package-sha256.txt
files-in-image-sha256.txt
files-in-sdk-sha256.txt

containing the sha256 checksums of regular files.

---
 meta/classes/buildhistory.bbclass | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Changes in v2:
* Switch to sha256
* Let find only build the arguments and execute sha256sum once
* Use single quotes in inline python code

meta/classes/buildhistory.bbclass +8 -3
index 33eb1b00f6..84f85da0bd 100644
@@ -7,7 +7,8 @@
 # Copyright (C) 2007-2011 Koen Kooi <[email protected]>
 #
 
-BUILDHISTORY_FEATURES ?= "image package sdk"
+BUILDHISTORY_FEATURES ?= "image package sdk \
+  ${@ 'sha256' if bb.utils.to_boolean(d.getVar('BUILD_REPRODUCIBLE_BINARIES')) else ''}"
 BUILDHISTORY_DIR ?= "${TOPDIR}/buildhistory"
 BUILDHISTORY_DIR_IMAGE = "${BUILDHISTORY_DIR}/images/${MACHINE_ARCH}/${TCLIBC}/${IMAGE_BASENAME}"
 BUILDHISTORY_DIR_PACKAGE = "${BUILDHISTORY_DIR}/packages/${MULTIMACH_TARGET_SYS}/${PN}"
@@ -526,7 +527,12 @@ buildhistory_list_files() {
                eval ${FAKEROOTENV} ${FAKEROOTCMD} $find_cmd
        else
                eval $find_cmd
-       fi | sort -k5 | sed 's/ * -> $//' > $2 )
+       fi | sort -k5 | sed 's/ * -> $//' > $2
+       if [ "${@bb.utils.contains('BUILDHISTORY_FEATURES', 'sha256', '1', '0', d)}" = "1" ] ; then
+               sha256filename=$(echo $2 | sed 's/\.txt$/-sha256.txt/')
+               find -type f -exec sha256sum {} + | sort -k2 > $sha256filename
+               [ -s $sha256filename ] || rm $sha256filename # remove result if empty
+       fi )
 }
 
 buildhistory_list_pkg_files() {
--
Quoted 1 line

2.11.0

Ignore this patch, I completely missed the "task" BUILDHISTORY_FEATURE, which seems to do this already.