update-kernel-versions.sh: Depends more on sha256sums.asc (#522)

Prefer to take a list of kernels tags for stables and longterm branches from sha256sums.asc instead git
This commit is contained in:
Dmitry Skvortsov
2022-05-25 00:58:05 +03:00
committed by GitHub
parent 03e9f00901
commit 543aa22206

View File

@@ -8,7 +8,7 @@ escape() {
_escaped=$(printf '%s\n' "$1" | sed -e 's/[]\/$*.^[]/\\&/g')
}
kernel_tags=$(git -c 'versionsort.suffix=-' \
kernel_git_tags=$(git -c 'versionsort.suffix=-' \
ls-remote --exit-code --refs --sort='version:refname' --tags https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git '*.*' \
| cut --delimiter='/' --fields=3)
@@ -34,6 +34,7 @@ if [ ! -s gnupg/keyring.gpg ]; then
exit 3
fi
gpg --batch --homedir gnupg --export torvalds@kernel.org gregkh@kernel.org autosigner@kernel.org > gnupg/keyring.gpg
echo "----------------------"
fi
# Cleanup
@@ -41,14 +42,13 @@ rm -f v*.x.sha256sums{,.asc}
updates=""
for _key in "${_current_kernels[@]}"; do
latest_full_ver=$(echo "$kernel_tags" | grep -F "v$_key" | tail -1 | cut -c2-)
kver_major="$(echo ${_key} | cut -d. -f1)"
kver_base="$(echo ${_key} | tr -d ".")"
## Getting sha256sums by sha256sums.asc
if [ ! -s v${kver_major}.x.sha256sums ]; then
echo "Downloading the checksums file for linux-v${kver_major}.x"
curl -sL -o "v${kver_major}.x.sha256sums.asc" https://cdn.kernel.org/pub/linux/kernel/v${kver_major}.x/sha256sums.asc
curl -sL --retry 2 -o "v${kver_major}.x.sha256sums.asc" https://cdn.kernel.org/pub/linux/kernel/v${kver_major}.x/sha256sums.asc
if [[ $? != "0" ]]; then
echo "FAILED to download the v${kver_major}.x checksums file"
exit 3
@@ -61,10 +61,16 @@ for _key in "${_current_kernels[@]}"; do
exit 3
fi
rm -f "v${kver_major}.x.sha256sums.asc"
echo "----------------------"
fi
_from_rc_to_release="false"
latest_full_ver=$(cut -c 67- v${kver_major}.x.sha256sums | grep ".tar.xz" | sed 's/.tar.xz//' | grep -F "linux-$_key" | tail -1 | sed 's/linux-//')
if [[ "${_kver_subver_map[$_key]}" == rc* ]]; then
# check if latest_full_ver is non-RC
if [ ! -n "$latest_full_ver" ]; then
latest_full_ver=$(echo "$kernel_git_tags" | grep -F "v$_key-rc" | tail -1 | cut -c2-)
fi
if [[ "$latest_full_ver" == *rc* ]]; then
latest_subver="${latest_full_ver##*-rc}"
else
@@ -113,13 +119,16 @@ for _key in "${_current_kernels[@]}"; do
sed -i "/^_kver_subver_map=($/,/^)$/s|$_from|$_to|g" linux-tkg-config/prepare
old_kernel_shasum=$(grep -A$(wc -l PKGBUILD | cut -d' ' -f1) "${kver_base})" PKGBUILD | grep sha256sums -m 1 - | cut -d \' -f2)
new_kernel_shasum=$(cat v${kver_major}.x.sha256sums | grep linux-${_key}.tar.xz | cut -d' ' -f1)
new_kernel_shasum=$(grep linux-${_key}.tar.xz v${kver_major}.x.sha256sums | cut -d' ' -f1)
if [ ! -n "$new_kernel_shasum" ]; then
echo "WARNING sha256sum for linux-${_key} was not found."
fi
if [ "$latest_subver" != "0" ]; then
# we move from an rc release directly to a kernel with a subversion update
sed -i "s|#\"\$patch_site\"|\"\$patch_site\"|g" PKGBUILD
old_kernel_patch_shasum="#upcoming_kernel_patch_sha256"
new_kernel_patch_shasum="'$(cat v${kver_major}.x.sha256sums | grep patch-${_key}.${latest_subver}.xz | cut -d' ' -f1)'"
new_kernel_patch_shasum="'$(grep patch-${_key}.${latest_subver}.xz v${kver_major}.x.sha256sums | cut -d' ' -f1)'"
fi
elif (( "$current_subver" < "$latest_subver" )); then
# append kernel version update to updates
@@ -141,7 +150,7 @@ for _key in "${_current_kernels[@]}"; do
# For RC we need download the original file
echo "Downloading the GZ tarball for linux-${_key}-rc${latest_subver}"
curl -sL -o "linux-${_key}-rc${latest_subver}.tar.gz" https://git.kernel.org/torvalds/t/linux-${_key}-rc${latest_subver}.tar.gz
curl -sL --retry 2 -o "linux-${_key}-rc${latest_subver}.tar.gz" https://git.kernel.org/torvalds/t/linux-${_key}-rc${latest_subver}.tar.gz
if [[ $? != "0" ]]; then
echo "FAILED to download the linux-${_key}-rc${latest_subver}.tar.gz"
exit 3
@@ -163,10 +172,10 @@ for _key in "${_current_kernels[@]}"; do
# we move from an initial release to a kernel subversion update
sed -i "s|#\"\$patch_site\"|\"\$patch_site\"|g" PKGBUILD
old_kernel_patch_shasum="#upcoming_kernel_patch_sha256"
new_kernel_patch_shasum="'$(cat v${kver_major}.x.sha256sums | grep patch-${_key}.${latest_subver}.xz | cut -d' ' -f1)'"
new_kernel_patch_shasum="'$(grep patch-${_key}.${latest_subver}.xz v${kver_major}.x.sha256sums | cut -d' ' -f1)'"
else
old_kernel_patch_shasum="$(cat v${kver_major}.x.sha256sums | grep patch-${_key}.${current_subver}.xz | cut -d' ' -f1)"
new_kernel_patch_shasum="$(cat v${kver_major}.x.sha256sums | grep patch-${_key}.${latest_subver}.xz | cut -d' ' -f1)"
old_kernel_patch_shasum="$(grep patch-${_key}.${current_subver}.xz v${kver_major}.x.sha256sums | cut -d' ' -f1)"
new_kernel_patch_shasum="$(grep patch-${_key}.${latest_subver}.xz v${kver_major}.x.sha256sums | cut -d' ' -f1)"
fi
fi
else
@@ -175,11 +184,15 @@ for _key in "${_current_kernels[@]}"; do
if [ -n "$new_kernel_shasum" ]; then
echo "Updating kernel shasum in PKGBUILD"
echo "old kernel: $old_kernel_shasum"
echo "new kernel: $new_kernel_shasum"
sed -i "s|$old_kernel_shasum|$new_kernel_shasum|g" PKGBUILD
fi
if [ -n "$new_kernel_patch_shasum" ]; then
echo "Updating kernel patch shasum in PKGBUILD"
echo "old kernel patch: $old_kernel_patch_shasum"
echo "new kernel patch: $new_kernel_patch_shasum"
sed -i "s|$old_kernel_patch_shasum|$new_kernel_patch_shasum|g" PKGBUILD
fi