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
|
|
|
|
|
2019-11-07 00:25:42 +08:00
|
|
|
#URL='https://cdn.kernel.org/pub/linux/kernel/v5.x/'
|
|
|
|
URL='https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git'
|
2019-09-19 17:23:22 +08:00
|
|
|
VER=$pkgver
|
2019-11-07 00:25:42 +08:00
|
|
|
#CHANGELOG_FORMAT="patch-"
|
|
|
|
CHANGELOG_FORMAT="Linux "
|
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-11-07 00:25:42 +08:00
|
|
|
#[ $next == 0 ] && next=1
|
|
|
|
((next=next+1))
|
2019-09-19 17:23:22 +08:00
|
|
|
while true; do
|
2019-11-07 00:25:42 +08:00
|
|
|
if grep -Fq "${CHANGELOG_FORMAT}${MAJOR_MINOR}.${next}" <<< "$html"; then
|
2019-09-19 17:23:22 +08:00
|
|
|
((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
|