-
Notifications
You must be signed in to change notification settings - Fork 0
/
linux-a3700-lts.sh
executable file
·64 lines (49 loc) · 1.75 KB
/
linux-a3700-lts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -e
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" || exit; cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo .)")" || exit; pwd)
readonly script_dir
pkgname=linux-a3700-lts
readonly pkgname
# get latest stable release version
latest=$(curl -s https://www.kernel.org/releases.json | jq -r '[.releases[] | select(.moniker=="longterm").version][0]')
readonly latest
# get latest package version
cd "${script_dir}/repos" || exit
if [ -d "${pkgname}" ]; then
cd "${pkgname}" || exit
git pull --quiet
else
git clone [email protected]:bschnei/${pkgname}.git
cd "${pkgname}" || exit
fi
current=$(sed -n -e 's/^pkgver=//p' PKGBUILD)
readonly current
# quit if the two versions are the same
if [ "${latest}" = "${current}" ]; then
echo "${pkgname} is up-to-date (${current})"
exit 0
fi
# get the new hash from upstream
new_sha256sum=$(curl -L "https://www.kernel.org/pub/linux/kernel/v${latest%%.*}.x/sha256sums.asc" | sed -n -e "s/ linux-${latest}.tar.xz$//p")
readonly new_sha256sum
# modify the PKGBUILD
sed -i "s|^pkgver=.*$|pkgver=${latest}|g" PKGBUILD
sed -i "s|^pkgrel=.*$|pkgrel=1|g" PKGBUILD
sed -i "s|^sha256sums=(.*$|sha256sums=('${new_sha256sum}'|g" PKGBUILD
# clean build the new package
makepkg --force --cleanbuild
# add updated config to the package
cp "src/linux-${latest}/.config" config
# update the SHA256 sums
updpkgsums
# version control changes
git commit --all --message="${latest}-1"
git tag "${latest}-1"
git push
git push --tags
# move package to repo server and clean unversioned files
mv "${pkgname}-${latest}-1-aarch64.pkg.tar.xz" "${script_dir}/pkg"
git clean -d --force
# update package repository database
cd "${script_dir}/pkg" || exit
repo-add rocky.db.tar.xz "${pkgname}-${latest}-1-aarch64.pkg.tar.xz"