2024-01-24 00:03:34 +01:00
|
|
|
#!/bin/busybox ash
|
|
|
|
set -exuo pipefail
|
|
|
|
|
|
|
|
forgejo_url=$1
|
|
|
|
forgejo_token=$2
|
|
|
|
|
|
|
|
# initialize abuild
|
|
|
|
apk update
|
2024-08-07 09:17:29 +02:00
|
|
|
apk add --no-cache alpine-sdk sudo util-linux curl
|
2024-01-24 00:03:34 +01:00
|
|
|
adduser -D user -h /home/user
|
|
|
|
addgroup user abuild
|
|
|
|
echo "root ALL=(ALL) ALL" >/etc/sudoers
|
|
|
|
echo "%abuild ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
|
|
|
|
mkdir -p /var/cache/distfiles
|
|
|
|
chgrp abuild /var/cache/distfiles
|
|
|
|
chmod 775 /var/cache/distfiles
|
|
|
|
mkdir -p "/home/user/.abuild"
|
|
|
|
echo "/home/user/.abuild/user.rsa" | abuild-keygen -i -b 4096
|
|
|
|
echo 'PACKAGER_PRIVKEY=/home/user/.abuild/user.rsa' >/home/user/.abuild/abuild.conf
|
|
|
|
chown -R "user:user" /home/user/
|
|
|
|
|
|
|
|
# make sure we own the relevant directory
|
|
|
|
cp -r package-source /srv/alpine
|
|
|
|
cd /srv
|
|
|
|
mkdir packages
|
|
|
|
echo "REPODEST=/srv/packages" >>/home/user/.abuild/abuild.conf
|
|
|
|
cat /home/user/.abuild/abuild.conf
|
|
|
|
chown -R user:user alpine packages
|
|
|
|
|
|
|
|
# build the package
|
2024-03-17 19:55:01 +01:00
|
|
|
sudo -u user APKBUILD=alpine/forgejo-2174/APKBUILD abuild -r
|
|
|
|
|
|
|
|
# build the package
|
|
|
|
sudo -u user APKBUILD=alpine/forgejo-2173/APKBUILD abuild -r
|
2024-01-24 00:03:34 +01:00
|
|
|
|
|
|
|
# upload new package
|
2024-03-17 19:55:01 +01:00
|
|
|
cd packages/alpine/x86_64/
|
2024-01-24 00:03:34 +01:00
|
|
|
for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do
|
2024-08-07 08:31:33 +02:00
|
|
|
# remove old package
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
-H "Authorization: token $forgejo_token" \
|
|
|
|
-X DELETE \
|
2025-01-13 05:34:29 +01:00
|
|
|
"$forgejo_url/api/packages/root/alpine/3.21/e2e-tests/$file" ||
|
2024-08-07 08:31:33 +02:00
|
|
|
true
|
|
|
|
|
|
|
|
# upload new package
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
-H "Authorization: token $forgejo_token" \
|
|
|
|
-T "$file" \
|
2025-01-13 05:34:29 +01:00
|
|
|
"$forgejo_url/api/packages/root/alpine/3.21/e2e-tests"
|
2024-01-24 00:03:34 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# ensure that the install-if condition works as expected
|
|
|
|
apk add openrc
|
|
|
|
(cd /etc/apk/keys && curl -JO $forgejo_url/api/packages/root/alpine/key)
|
2025-01-13 05:34:29 +01:00
|
|
|
echo "$forgejo_url/api/packages/root/alpine/3.21/e2e-tests" >>/etc/apk/repositories
|
2024-03-17 19:55:01 +01:00
|
|
|
apk add forgejo-2174 forgejo-2173
|
2024-08-07 08:31:33 +02:00
|
|
|
[ -e /usr/bin/forgejo_2174 ] # from the installed package
|
|
|
|
[ -e /usr/bin/forgejo_2173 ] # from the installed package
|
2024-01-24 00:03:34 +01:00
|
|
|
[ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition
|
2024-03-17 19:55:01 +01:00
|
|
|
[ -e /etc/init.d/forgejo_2173 ] # from the -openrc package installed because of the install-if condition
|