2019-09-19 17:23:22 +08:00
|
|
|
#!/bin/bash
|
2019-10-23 21:26:45 +08:00
|
|
|
# buildbot update hook for kernel packages
|
2019-09-19 17:23:22 +08:00
|
|
|
set -e -o pipefail
|
|
|
|
|
2019-10-23 21:26:45 +08:00
|
|
|
assertPkgname() {
|
|
|
|
if [[ "$(basename $(pwd))" != "$PKGNAME" ]]; then
|
|
|
|
echo "Please run this script inside the $PKGNAME dir."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-09-19 17:23:22 +08:00
|
|
|
## This section does essential preparations
|
2019-10-23 21:26:45 +08:00
|
|
|
PKGNAME='linux-phicomm-n1' && assertPkgname
|
2019-09-19 17:23:22 +08:00
|
|
|
PKGBUILD='PKGBUILD'
|
|
|
|
git pull --ff-only
|
|
|
|
git checkout $PKGBUILD
|
|
|
|
pkgver=$(source $PKGBUILD; echo $pkgver)
|
|
|
|
|
|
|
|
# This section does actual jobs
|
|
|
|
newPkgVer() {
|
|
|
|
# do not print anything to stdout other than new pkgver here
|
|
|
|
|
|
|
|
URL='https://cdn.kernel.org/pub/linux/kernel/v5.x/'
|
|
|
|
VER=$pkgver
|
2019-11-06 14:14:57 +08:00
|
|
|
CHANGELOG_FORMAT="patch-"
|
2019-09-19 17:23:22 +08:00
|
|
|
|
|
|
|
PATCH=${VER##*.}
|
|
|
|
MAJOR_MINOR=${VER%.*}
|
|
|
|
|
|
|
|
if ! grep -Eq '[0-9].[0-9]' <<< "$MAJOR_MINOR"; then echo "Bad MAJOR_MINOR: ${MAJOR_MINOR}" >&2; return 1; fi
|
|
|
|
if ! grep -Eq '[0-9]' <<< "$PATCH"; then echo "Bad PATCH: ${PATCH}" >&2; return 1; fi
|
|
|
|
|
|
|
|
html="$(curl -s ${URL})"
|
|
|
|
|
|
|
|
next=$PATCH
|
2019-09-21 17:01:22 +08:00
|
|
|
[ $next == 0 ] && next=1
|
2019-09-19 17:23:22 +08:00
|
|
|
while true; do
|
|
|
|
if grep -Fq "${MAJOR_MINOR}.${next}" <<< "$html"; then
|
|
|
|
((next=next+1))
|
|
|
|
else
|
|
|
|
((next=next-1))
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if (("$PATCH" < "$next")); then
|
|
|
|
echo "New patch level found: ${next}" >&2
|
|
|
|
echo -n "${MAJOR_MINOR}.${next}"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo "No new patch level found: ${next}" >&2
|
2019-09-19 20:42:50 +08:00
|
|
|
return 0
|
2019-09-19 17:23:22 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
newpkgver=$(newPkgVer)
|
2019-09-19 20:42:50 +08:00
|
|
|
[ -z "$newpkgver" ] && exit 0
|
2019-09-19 17:23:22 +08:00
|
|
|
sed -i "s/^pkgver=.*\$/pkgver=${newpkgver}/g" $PKGBUILD
|
|
|
|
sed -i "s/^pkgrel=.*\$/pkgrel=1/g" $PKGBUILD
|
|
|
|
pkgver=$(source $PKGBUILD; echo $pkgver)
|
|
|
|
pkgrel=$(source $PKGBUILD; echo $pkgrel)
|
|
|
|
[ "$pkgver" != "$newpkgver" ] && echo "unexpected pkgver: ${pkgver}" >&2 && exit 1
|
|
|
|
[ "$pkgrel" != '1' ] && echo "unexpected pkgrel: ${pkgrel}" >&2 && exit 1
|
2019-09-21 10:49:04 +08:00
|
|
|
updpkgsums
|
2019-09-19 17:23:22 +08:00
|
|
|
git add $PKGBUILD
|
2019-10-23 21:26:45 +08:00
|
|
|
git commit -m "autoupdate: ${PKGNAME} to ${pkgver}"
|
2019-09-19 17:23:22 +08:00
|
|
|
git push
|