From da01b7271a4a9048ae8e8ae18753edc5da785a44 Mon Sep 17 00:00:00 2001 From: Titouan Christophe Date: Sat, 30 May 2026 00:02:18 +0200 Subject: [PATCH] utils/bump-stable-kernel-versions: update for split hash file Since Buildroot commit 0e3ddc9dc85e29cd00338cc79ea4be1d634a75ba, linux hash files are split between pre- and post-6.17. Since that commit, the script that automatically updates kernel versions in Buildroot was broken, as it assumed only a single linux hash file at a static location. Update the script to find all relevant files, even if a new split occurs in the future. In addition, this patch carries additional minor changes: - Fix some minor shellcheck issues found with a newer shellcheck version than in the container (quoting, test -a -> -e) - Move from wget to curl, as I had some issue on my home connection with the former (possibly ipv6 related or something) Signed-off-by: Titouan Christophe Signed-off-by: Arnout Vandecappelle --- utils/bump-stable-kernel-versions | 121 ++++++++++++++++-------------- 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/utils/bump-stable-kernel-versions b/utils/bump-stable-kernel-versions index 577a6841c8..6303bf4010 100755 --- a/utils/bump-stable-kernel-versions +++ b/utils/bump-stable-kernel-versions @@ -16,7 +16,7 @@ # OTHER DEALINGS IN THE SOFTWARE. # Check for updates to Linux stable releases. The script uses the versions found in -# linux/linux.hash. For each of the versions it downloads the related hash list and tries +# linux/*/linux.hash. For each of the versions it downloads the related hash list and tries # to find an updated stable release. If found it updates all related files and hashes. set -euo pipefail @@ -26,70 +26,79 @@ latest_release_version=$(echo "${latest_version}" | cut -f 1-2 -d .) echo "${latest_version} -> ${latest_release_version}" updated_releases_list='' +updated_versions='Update the latest kernel releases to:' -hash_list= -while read -r line; do - # e.g.: # From https://www.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc - url=$(echo "${line}" | sed -n 's|^# From \(https://www\.kernel\.org/pub/linux/kernel/.*/sha256sums.asc\)|\1|p') - # e.g.: sha256 f905f1238ea7a8e85314bacf283302e8097006010d25fcea726d0de0ea5bc9b6 linux-6.8.9.tar.xz - old_hash=$(echo "${line}" | sed -rn 's|^sha256 +([0-9a-f]+) +linux-.*$|\1|p') - old_version=$(echo "${line}" | sed -rn 's|^sha256 +[0-9a-f]+ +linux-(.+)\.tar\.xz$|\1|p') - if [ -n "${url}" ]; then - # Line contained a URL: Download hash list and use it. - if [ -a "${hash_list}" ]; then - rm "${hash_list}" - fi +update_linux_hash() { + HASHFILE="$1" + hash_list= + while read -r line; do + # e.g.: # From https://www.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc + url=$(echo "${line}" | sed -n 's|^# From \(https://www\.kernel\.org/pub/linux/kernel/.*/sha256sums.asc\)|\1|p') + # e.g.: sha256 f905f1238ea7a8e85314bacf283302e8097006010d25fcea726d0de0ea5bc9b6 linux-6.8.9.tar.xz + old_hash=$(echo "${line}" | sed -rn 's|^sha256 +([0-9a-f]+) +linux-.*$|\1|p') + old_version=$(echo "${line}" | sed -rn 's|^sha256 +[0-9a-f]+ +linux-(.+)\.tar\.xz$|\1|p') + if [ -n "${url}" ]; then + # Line contained a URL: Download hash list and use it. + if [ -e "${hash_list}" ]; then + rm "${hash_list}" + fi - hash_list=$(basename "${url}") - echo ">>> Downloading hash list from ${url}" - wget --no-verbose "${url}" - gpg --verify "${hash_list}" + hash_list=$(basename "${url}") + echo ">>> Downloading hash list from ${url}" + curl -q "${url}" > "${hash_list}" + gpg --verify "${hash_list}" - echo "${line}" >> linux/linux.hash.new - elif [ -n "${old_version}" ]; then - # Line contained a hash entry: Search for newer versions. - release_version=$(echo "${old_version}" | cut -f 1-2 -d .) # e.g.: 6.8 instead of 6.8.9 - # e.g.: 19b31956d229b5b9ca5671fa1c74320179682a3d8d00fc86794114b21da86039 linux-6.8.12.tar.xz - new_hash_entry=$(grep "^[0-9a-f]\+ \+linux-${release_version//./\\.}\.[0-9]\+\.tar\.xz$" "${hash_list}" | sort -V --key '2' | tail -1) - new_hash=$(echo "${new_hash_entry}" | cut -f 1 -d ' ') - new_version=$(echo "${new_hash_entry}" | cut -f 3 -d ' ' | sed -rn 's|linux-(.+)\.tar\.xz|\1|p') + echo "${line}" >> "$HASHFILE.new" + elif [ -n "${old_version}" ]; then + # Line contained a hash entry: Search for newer versions. + release_version=$(echo "${old_version}" | cut -f 1-2 -d .) # e.g.: 6.8 instead of 6.8.9 + # e.g.: 19b31956d229b5b9ca5671fa1c74320179682a3d8d00fc86794114b21da86039 linux-6.8.12.tar.xz + new_hash_entry=$(grep "^[0-9a-f]\+ \+linux-${release_version//./\\.}\.[0-9]\+\.tar\.xz$" "${hash_list}" | sort -V --key '2' | tail -1) + new_hash=$(echo "${new_hash_entry}" | cut -f 1 -d ' ') + new_version=$(echo "${new_hash_entry}" | cut -f 3 -d ' ' | sed -rn 's|linux-(.+)\.tar\.xz|\1|p') - if [ "$new_version" == "$old_version" ]; then - # Same version as before - echo ">>> Release ${release_version}.x already on newest version ${new_version}." - echo "${line}" >> linux/linux.hash.new + if [ "$new_version" == "$old_version" ]; then + # Same version as before + echo ">>> Release ${release_version}.x already on newest version ${new_version}." + echo "${line}" >> "$HASHFILE.new" - if [ "${old_hash}" != "${new_hash}" ]; then - # Hash changed! This should never happen! - echo ">>> Version hash changed for ${release_version}.x!" - echo ">>> It was: ${old_hash}" - echo ">>> It is: ${new_hash}" - exit 1 + if [ "${old_hash}" != "${new_hash}" ]; then + # Hash changed! This should never happen! + echo ">>> Version hash changed for ${release_version}.x!" + echo ">>> It was: ${old_hash}" + echo ">>> It is: ${new_hash}" + exit 1 + fi + else + # Different version: update hash list, default headers, and possibly latest + # version. + echo ">>> Updating hash for ${release_version}.x in $HASHFILE" + echo "sha256 ${new_hash} linux-${new_version}.tar.xz" >> "$HASHFILE.new" + + echo ">>> Updating version from ${old_version} to ${new_version} in Config.in files" + sed -Ei "s/\tdefault \"${old_version}\"([\t ]+)if /\tdefault \"${new_version}\"\1if /" \ + package/linux-headers/Config.in.host linux/Config.in + + updated_releases_list="${updated_releases_list} ${release_version}.x" + updated_versions="${updated_versions}\n - ${old_version} -> ${new_version}" fi else - # Different version: update hash list, default headers, and possibly latest - # version. - echo ">>> Updating hash for ${release_version}.x in linux/linux.hash" - echo "sha256 ${new_hash} linux-${new_version}.tar.xz" >> linux/linux.hash.new - - echo ">>> Updating version from ${old_version} to ${new_version} in Config.in files" - sed -Ei "s/\tdefault \"${old_version}\"([\t ]+)if /\tdefault \"${new_version}\"\1if /" \ - package/linux-headers/Config.in.host linux/Config.in - - updated_releases_list="${updated_releases_list} ${release_version}.x" + # Different line: Reset hash list and just copy this line over as is. + if [ -e "${hash_list}" ]; then + rm "${hash_list}" + hash_list= + fi + echo "${line}" >> "$HASHFILE.new" fi - else - # Different line: Reset hash list and just copy this line over as is. - if [ -a "${hash_list}" ]; then - rm "${hash_list}" - hash_list= - fi - echo "${line}" >> linux/linux.hash.new - fi -done < linux/linux.hash + done < "$HASHFILE" -# We were iterating over this file so we could not edit in-place. -mv linux/linux.hash.new linux/linux.hash + # We were iterating over this file so we could not edit in-place. + mv "$HASHFILE.new" "$HASHFILE" +} + +while IFS= read -r -d '' hashfile; do + update_linux_hash "$hashfile" +done < <(find linux/ -name '*.hash' -type f -print0) if [ -n "${updated_releases_list}" ]; then echo ">>> Suggested subject: {linux, linux-headers}: bump${updated_releases_list//.x /.x, } series"