utils/bump-stable-kernel-versions: update for split hash file

Since Buildroot commit 0e3ddc9dc8,
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 <titouan.christophe@mind.be>
Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
Titouan Christophe
2026-05-30 00:02:18 +02:00
committed by Arnout Vandecappelle
parent 758e5cdbdd
commit da01b7271a

View File

@@ -16,7 +16,7 @@
# OTHER DEALINGS IN THE SOFTWARE. # OTHER DEALINGS IN THE SOFTWARE.
# Check for updates to Linux stable releases. The script uses the versions found in # 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. # to find an updated stable release. If found it updates all related files and hashes.
set -euo pipefail set -euo pipefail
@@ -26,70 +26,79 @@ latest_release_version=$(echo "${latest_version}" | cut -f 1-2 -d .)
echo "${latest_version} -> ${latest_release_version}" echo "${latest_version} -> ${latest_release_version}"
updated_releases_list='' updated_releases_list=''
updated_versions='Update the latest kernel releases to:'
hash_list= update_linux_hash() {
while read -r line; do HASHFILE="$1"
# e.g.: # From https://www.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc hash_list=
url=$(echo "${line}" | sed -n 's|^# From \(https://www\.kernel\.org/pub/linux/kernel/.*/sha256sums.asc\)|\1|p') while read -r line; do
# e.g.: sha256 f905f1238ea7a8e85314bacf283302e8097006010d25fcea726d0de0ea5bc9b6 linux-6.8.9.tar.xz # e.g.: # From https://www.kernel.org/pub/linux/kernel/v6.x/sha256sums.asc
old_hash=$(echo "${line}" | sed -rn 's|^sha256 +([0-9a-f]+) +linux-.*$|\1|p') url=$(echo "${line}" | sed -n 's|^# From \(https://www\.kernel\.org/pub/linux/kernel/.*/sha256sums.asc\)|\1|p')
old_version=$(echo "${line}" | sed -rn 's|^sha256 +[0-9a-f]+ +linux-(.+)\.tar\.xz$|\1|p') # e.g.: sha256 f905f1238ea7a8e85314bacf283302e8097006010d25fcea726d0de0ea5bc9b6 linux-6.8.9.tar.xz
if [ -n "${url}" ]; then old_hash=$(echo "${line}" | sed -rn 's|^sha256 +([0-9a-f]+) +linux-.*$|\1|p')
# Line contained a URL: Download hash list and use it. old_version=$(echo "${line}" | sed -rn 's|^sha256 +[0-9a-f]+ +linux-(.+)\.tar\.xz$|\1|p')
if [ -a "${hash_list}" ]; then if [ -n "${url}" ]; then
rm "${hash_list}" # Line contained a URL: Download hash list and use it.
fi if [ -e "${hash_list}" ]; then
rm "${hash_list}"
fi
hash_list=$(basename "${url}") hash_list=$(basename "${url}")
echo ">>> Downloading hash list from ${url}" echo ">>> Downloading hash list from ${url}"
wget --no-verbose "${url}" curl -q "${url}" > "${hash_list}"
gpg --verify "${hash_list}" gpg --verify "${hash_list}"
echo "${line}" >> linux/linux.hash.new echo "${line}" >> "$HASHFILE.new"
elif [ -n "${old_version}" ]; then elif [ -n "${old_version}" ]; then
# Line contained a hash entry: Search for newer versions. # 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 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 # 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_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_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') new_version=$(echo "${new_hash_entry}" | cut -f 3 -d ' ' | sed -rn 's|linux-(.+)\.tar\.xz|\1|p')
if [ "$new_version" == "$old_version" ]; then if [ "$new_version" == "$old_version" ]; then
# Same version as before # Same version as before
echo ">>> Release ${release_version}.x already on newest version ${new_version}." echo ">>> Release ${release_version}.x already on newest version ${new_version}."
echo "${line}" >> linux/linux.hash.new echo "${line}" >> "$HASHFILE.new"
if [ "${old_hash}" != "${new_hash}" ]; then if [ "${old_hash}" != "${new_hash}" ]; then
# Hash changed! This should never happen! # Hash changed! This should never happen!
echo ">>> Version hash changed for ${release_version}.x!" echo ">>> Version hash changed for ${release_version}.x!"
echo ">>> It was: ${old_hash}" echo ">>> It was: ${old_hash}"
echo ">>> It is: ${new_hash}" echo ">>> It is: ${new_hash}"
exit 1 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 fi
else else
# Different version: update hash list, default headers, and possibly latest # Different line: Reset hash list and just copy this line over as is.
# version. if [ -e "${hash_list}" ]; then
echo ">>> Updating hash for ${release_version}.x in linux/linux.hash" rm "${hash_list}"
echo "sha256 ${new_hash} linux-${new_version}.tar.xz" >> linux/linux.hash.new hash_list=
fi
echo ">>> Updating version from ${old_version} to ${new_version} in Config.in files" echo "${line}" >> "$HASHFILE.new"
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"
fi fi
else done < "$HASHFILE"
# 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
# We were iterating over this file so we could not edit in-place. # We were iterating over this file so we could not edit in-place.
mv linux/linux.hash.new linux/linux.hash 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 if [ -n "${updated_releases_list}" ]; then
echo ">>> Suggested subject: {linux, linux-headers}: bump${updated_releases_list//.x /.x, } series" echo ">>> Suggested subject: {linux, linux-headers}: bump${updated_releases_list//.x /.x, } series"