mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Subject: [ptxdist] [PATCH 2/4] scripts: make checksum update hash algorithm agnostic
Date: Mon, 27 Apr 2026 16:28:46 +0200	[thread overview]
Message-ID: <20260427142848.989702-3-p.zabel@pengutronix.de> (raw)
In-Reply-To: <20260427142848.989702-1-p.zabel@pengutronix.de>

Rename ptxd_make_world_update_md5() to ptxd_make_world_update_checksum()
and pass in the checksum tool (md5sum) and the hash suffix (MD5) as
parameters.
Rename local variables md5 to checksum and PKG_MD5 to PKG_SUM.

Add back ptxd_make_world_update_md5() as a wrapper that calls
ptx_make_world_update_checksum md5sum MD5.

No functional change.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 scripts/lib/ptxd_make_world_check_src.sh | 45 ++++++++++++++----------
 1 file changed, 27 insertions(+), 18 deletions(-)

diff --git a/scripts/lib/ptxd_make_world_check_src.sh b/scripts/lib/ptxd_make_world_check_src.sh
index 8aaeb1137152..044b1872fd0c 100644
--- a/scripts/lib/ptxd_make_world_check_src.sh
+++ b/scripts/lib/ptxd_make_world_check_src.sh
@@ -8,26 +8,28 @@
 
 
 #
-# try to update the md5sum of the current package
-# this only works if the makefile contains a "<PKG>_MD5 := ..." line.
+# $1: checksum tool, e.g. md5sum
+# $2: hash type suffix appended to <PKG>_, e.g. MD5
 #
-ptxd_make_world_update_md5() {
+ptxd_make_world_update_checksum() {
+    local tool="${1}"
+    local SUFFIX="${2}"
     local config file_dotconfig
-    set -- $(md5sum "${pkg_src}")
-    local md5="${1}"
+    set -- $("${tool}" "${pkg_src}")
+    local checksum="${1}"
 
-    local PKG_MD5="PTXCONF_${pkg_PKG}_MD5"
+    local PKG_SUM="PTXCONF_${pkg_PKG}_${SUFFIX}"
     for config in "${PTXDIST_PLATFORMCONFIG}" "${PTXDIST_PTXCONFIG}"; do
 	file_dotconfig="${config}"
 	ptxd_normalize_config
-	if grep -q "^${PKG_MD5}=\"" "${file_dotconfig}"; then
-	    sed -i "s/^${PKG_MD5}=\".*$/${PKG_MD5}=\"${md5}\"/" "${file_dotconfig}"
-	    ptxd_warning "New checksum for ${pkg_PKG}: ${md5} in $(ptxd_print_path "${file_dotconfig}")"
+	if grep -q "^${PKG_SUM}=\"" "${file_dotconfig}"; then
+	    sed -i "s/^${PKG_SUM}=\".*$/${PKG_SUM}=\"${checksum}\"/" "${file_dotconfig}"
+	    ptxd_warning "New checksum for ${pkg_PKG}: ${checksum} in $(ptxd_print_path "${file_dotconfig}")"
 	    if [ -e "${file_dotconfig}.diff" ]; then
-		if grep -q "^${PKG_MD5}=\"" "${file_dotconfig}.diff"; then
-		    sed -i "s/^${PKG_MD5}=\".*$/${PKG_MD5}=\"${md5}\"/" "${file_dotconfig}.diff"
+		if grep -q "^${PKG_SUM}=\"" "${file_dotconfig}.diff"; then
+		    sed -i "s/^${PKG_SUM}=\".*$/${PKG_SUM}=\"${checksum}\"/" "${file_dotconfig}.diff"
 		else
-		    echo "${PKG_MD5}=\"${md5}\"" >> "${file_dotconfig}.diff"
+		    echo "${PKG_SUM}=\"${checksum}\"" >> "${file_dotconfig}.diff"
 		    if [ "${config}" == "${PTXDIST_PLATFORMCONFIG}" ]; then
 			arg=" platform"
 		    fi
@@ -40,14 +42,21 @@ ptxd_make_world_update_md5() {
     if [ -z "${pkg_makefile}" ]; then
 	ptxd_bailout "Could not update checksum for '${pkg_label}': makefile not found"
     fi
-    local count=$(grep "^${pkg_PKG}_MD5[ 	]*:=" "${pkg_makefile}" 2> /dev/null | wc -l)
+    local count=$(grep "^${pkg_PKG}_${SUFFIX}[ 	]*:=" "${pkg_makefile}" 2> /dev/null | wc -l)
     if [ "${count}" -gt 1 ]; then
-	ptxd_bailout "Could not update checksum for '${pkg_label}': ${pkg_PKG}_MD5 found ${count} times in '$(ptxd_print_path ${pkg_makefile})'."
+	ptxd_bailout "Could not update checksum for '${pkg_label}': ${pkg_PKG}_${SUFFIX} found ${count} times in '$(ptxd_print_path ${pkg_makefile})'."
     fi
-    sed -i "s/^\(\<${pkg_PKG}_MD5[ 	]*:=\) *[a-f0-9]*\$/\1 ${md5}/" "${pkg_makefile}"
-    if ! grep -q "${md5}\$" "${pkg_makefile}"; then
-	ptxd_bailout "Could not update checksum for '${pkg_label}': ${pkg_PKG}_MD5 not found"
+    sed -i "s/^\(\<${pkg_PKG}_${SUFFIX}[ 	]*:=\) *[a-f0-9]*\$/\1 ${checksum}/" "${pkg_makefile}"
+    if ! grep -q "${checksum}\$" "${pkg_makefile}"; then
+	ptxd_bailout "Could not update checksum for '${pkg_label}': ${pkg_PKG}_${SUFFIX} not found"
     fi
-    ptxd_warning "New checksum for ${pkg_PKG}: ${md5} in $(ptxd_print_path "${pkg_makefile}")"
+    ptxd_warning "New checksum for ${pkg_PKG}: ${checksum} in $(ptxd_print_path "${pkg_makefile}")"
+}
+export -f ptxd_make_world_update_checksum
+
+# try to update the md5sum of the current package
+# this only works if the makefile contains a "<PKG>_MD5 := ..." line.
+ptxd_make_world_update_md5() {
+    ptxd_make_world_update_checksum md5sum MD5
 }
 export -f ptxd_make_world_update_md5
-- 
2.47.3




  parent reply	other threads:[~2026-04-27 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 14:28 [ptxdist] [PATCH 0/4] Add SHA256 package checksum support Philipp Zabel
2026-04-27 14:28 ` [ptxdist] [PATCH 1/4] scripts: make checksum messages hash algorithm agnostic Philipp Zabel
2026-04-27 14:28 ` Philipp Zabel [this message]
2026-04-27 14:28 ` [ptxdist] [PATCH 3/4] scripts: add package sha256sum support Philipp Zabel
2026-04-27 14:28 ` [ptxdist] [PATCH 4/4] ptxdist: add --update-checksum option Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260427142848.989702-3-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox