[LEDE-DEV] [PATCH v2] build: reintroduce md5 checksums for generated firmware images

Stefan Lippers-Hollmann s.l-h at gmx.de
Wed Aug 17 19:16:53 PDT 2016


Commit 83175687c81bee594885d0738cfd488673f5a3fb "build: remove image
specific checksum code" dropped the generation of md5 checksums in
favour of only shipping sha256 ones.

A default Lede installation however doesn't enable busybox' sha256sum
applet, which makes confirming the checksum on the device itself (e.g.
for transmission errors to the device) more difficult than necessary,
this patch reintroduces the generation of MD5 checksums for all
firmware images.

Signed-off-by: Stefan Lippers-Hollmann <s.l-h at gmx.de>
---

It would be simpler to call md5sum rather than openssl to generate the
MD5 checksums, but in order to keep the prereqs small, I re-used
openssl for this task as well, given that it's needed for the SHA256
checksums already.

This adds roughly 3.6 seconds to the build times for ar71xx (589 files)

v2: make sure to exclude {md5,sha256}sums from checksum files

 Makefile                           | 1 +
 rules.mk                           | 9 ++++++++-
 target/imagebuilder/files/Makefile | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 59320d4..51a2e38 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,7 @@ prereq: $(target/stamp-prereq) tmp/.prereq_packages
 	fi
 
 checksum: FORCE
+	$(call md5sums,$(BIN_DIR))
 	$(call sha256sums,$(BIN_DIR))
 
 prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
diff --git a/rules.mk b/rules.mk
index de24778..a3d296b 100644
--- a/rules.mk
+++ b/rules.mk
@@ -371,10 +371,17 @@ define file_copy
 	$(CP) $(1) $(2)
 endef
 
+# Calculate md5sum of any plain file within a given directory
+# $(1) => Input directory
+define md5sums
+	(cd $(1); find . -maxdepth 1 -type f -not -name 'md5sums' -not -name 'sha256sums' -printf "%P\n" | sort | \
+		xargs openssl dgst -md5 | sed -ne 's!^MD5(\(.*\))= \(.*\)$$!\2 *\1!p' > md5sums)
+endef
+
 # Calculate sha256sum of any plain file within a given directory
 # $(1) => Input directory
 define sha256sums
-	(cd $(1); find . -maxdepth 1 -type f -not -name 'sha256sums' -printf "%P\n" | sort | \
+	(cd $(1); find . -maxdepth 1 -type f -not -name 'md5sums' -not -name 'sha256sums' -printf "%P\n" | sort | \
 		xargs openssl dgst -sha256 | sed -ne 's!^SHA256(\(.*\))= \(.*\)$$!\2 *\1!p' > sha256sums)
 endef
 
diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile
index 493012f..15c34ed 100644
--- a/target/imagebuilder/files/Makefile
+++ b/target/imagebuilder/files/Makefile
@@ -174,6 +174,7 @@ build_image: FORCE
 checksum: FORCE
 	@echo
 	@echo Calculating checksums...
+	@$(call md5sums,$(BIN_DIR))
 	@$(call sha256sums,$(BIN_DIR))
 
 clean:
-- 
2.9.3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: Digitale Signatur von OpenPGP
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20160818/5c5ca7c8/attachment.sig>


More information about the Lede-dev mailing list