From 0795847f42eb60eb60816a946657a532dbeea278 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Fri, 23 Aug 2024 18:14:01 +0200 Subject: [PATCH] Implement config driven BSP package modification to set last good kernel for a single device This will prevent upgrading to higher kernels which are known to be broken. --- tools/repository/repo | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/repository/repo b/tools/repository/repo index bd991083aff7..c7800131185a 100755 --- a/tools/repository/repo +++ b/tools/repository/repo @@ -56,6 +56,24 @@ adding_packages() { return 0 fi for f in "${4}${2}"/*.deb; do + # If we have a list of last known working kernels, repack BSP files to prevent upgrade to kernel that breaks + if [[ -f userpatches/last-known-good.map ]]; then + PACKAGE_NAME=$(dpkg-deb -W $f | awk '{ print $1 }') + for g in $(cat userpatches/last-known-good-kernel-pkg.map); do + # Read values from file + BOARD=$(echo $g | cut -d"|" -f1); + BRANCH=$(echo $g | cut -d"|" -f2); + LINUXFAMILY=$(echo $g | cut -d"|" -f3) + LASTKERNEL=$(echo $g | cut -d"|" -f4); + if [[ ${PACKAGE_NAME} == "armbian-bsp-cli-${BOARD}-${BRANCH}" ]]; then + echo "Setting last kernel upgrade for $BOARD to linux-image-$BRANCH-$BOARD=${LASTKERNEL}" + tempdir=$(mktemp -d) + dpkg-deb -R $f $tempdir + sed -i '/^Replaces:/ s/$/, linux-image-'$BRANCH'-'$LINUXFAMILY' (>> '$LASTKERNEL'), linux-dtb-'$BRANCH'-'$LINUXFAMILY' (>> '$LASTKERNEL')/' $tempdir/DEBIAN/control + dpkg-deb -b $tempdir ${f} >/dev/null + fi + done + fi aptly repo add -remove-files -force-replace -config="${CONFIG}" "${1}" "${f}" done }