From 85e296833a81c344012b52d046a70b7d7f45b6ea Mon Sep 17 00:00:00 2001 From: xdavidwu Date: Fri, 12 Nov 2021 23:07:36 +0800 Subject: [PATCH] add auto update script --- checknupdate.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 checknupdate.sh diff --git a/checknupdate.sh b/checknupdate.sh new file mode 100755 index 0000000..86220ca --- /dev/null +++ b/checknupdate.sh @@ -0,0 +1,40 @@ +#!/bin/bash +git pull --no-edit + +VER=$(grep '^_pkgver=' PKGBUILD | cut -d '=' -f 2) +CURR_VERSION=$(echo $VER | cut -d '.' -f 1) +CURR_PATCHLEVEL=$(echo $VER | cut -d '.' -f 2) +CURR_SUBLEVEL=$(echo $VER | cut -d '.' -f 3) +CURR_BRANCH=$CURR_VERSION.$CURR_PATCHLEVEL + +VERSION=$(rsstail -1pNu https://www.kernel.org/feeds/kdist.xml | grep "^ $CURR_VERSION\.$CURR_PATCHLEVEL[:\.]") + +if [ ! -n "$VERSION" ];then + echo "Error: $CURR_BRANCH may be EOLed" + exit 1 +fi + +NEW_SUBLEVEL=$(echo "$VERSION" | tail -n 1 | cut -d ':' -f 1 | cut -d '.' -f 3) + +if [ ! -n "$NEW_SUBLEVEL" ];then + exit 0 +fi + +if [ "$NEW_SUBLEVEL" -gt "$CURR_SUBLEVEL" ];then + echo "Update: $CURR_BRANCH.$CURR_SUBLEVEL -> $CURR_BRANCH.$NEW_SUBLEVEL" + #https://cdn.kernel.org/pub/linux/kernel/v4.x/incr/patch-4.17.5-6.xz + if [ "$NEW_SUBLEVEL" -eq 1 ];then + echo "Manual work required for first patch" + exit 1 + fi + sed "s/pkgver=$VER/pkgver=$CURR_BRANCH.$NEW_SUBLEVEL/" -i APKBUILD + podman run -itu builder -w /home/builder -v .:/home/builder --userns keep-id registry.xdavidwu.link/ci-modulize/abuild:edge sh -c 'abuild checksum && apkgrel -z APKBUILD' + SED_ERRNO=$? + git add APKBUILD + if [ "$SED_ERRNO" -eq 0 ];then + git commit -m "Auto Update: $CURR_BRANCH.$CURR_SUBLEVEL -> $CURR_BRANCH.$NEW_SUBLEVEL" + else + git commit -m "[FAILED] Auto Update: $CURR_BRANCH.$CURR_SUBLEVEL -> $CURR_BRANCH.$NEW_SUBLEVEL" + fi + git push +fi -- 2.45.2