2024-01-22 14:41:38 +00:00
|
|
|
#!/bin/busybox ash
|
|
|
|
set -exuo pipefail
|
|
|
|
|
|
|
|
# initialize abuild
|
|
|
|
apk update
|
|
|
|
apk add --no-cache alpine-sdk sudo util-linux
|
|
|
|
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
|
|
|
|
mkdir /home/user/packages
|
2024-01-22 14:43:14 +00:00
|
|
|
echo 'REPODEST="/home/user/packages-arm"' >/home/user/.abuild/abuild.conf
|
|
|
|
echo 'PACKAGER_PRIVKEY="/home/user/.abuild/user.rsa\"' >>/home/user/.abuild/abuild.conf
|
2024-01-22 14:41:38 +00:00
|
|
|
chown -R "user:user" /home/user/
|
|
|
|
|
|
|
|
# make sure we own the relevant directory
|
|
|
|
sudo chown -R user:user alpine packages
|
|
|
|
|
|
|
|
# build the package
|
|
|
|
sudo -u user -- APKBUILD=alpine/APKBUILD abuild -r
|
|
|
|
|
|
|
|
# upload new package
|
|
|
|
cd packages/forgejo-2174/x86_64/
|
|
|
|
for file in $(find . -name '*.apk' -type f | sed -e 's,./,,'); do
|
|
|
|
# remove old package
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
-H "Authorization: token ${{secrets.PACKAGE_TOKEN}}" \
|
|
|
|
-X DELETE \
|
|
|
|
"https://msrd0.dev/api/packages/msrd0/alpine/3.19/forgejo-2174/$file" \
|
|
|
|
|| true
|
|
|
|
|
|
|
|
# upload new package
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
-H "Authorization: token ${{secrets.PACKAGE_TOKEN}}" \
|
|
|
|
-T "$file" \
|
|
|
|
"https://msrd0.dev/api/packages/msrd0/alpine/3.19/forgejo-2174"
|
|
|
|
done
|
|
|
|
|
|
|
|
# ensure that the install-if condition works as expected
|
|
|
|
apk add openrc
|
|
|
|
echo "https://msrd0.dev/api/packages/msrd0/alpine/3.19/forgejo-2174" >>/etc/apk/repositories
|
|
|
|
apk add forgejo_2174
|
|
|
|
[ -e /usr/bin/forgejo_2174 ] # from the installed package
|
|
|
|
[ -e /etc/init.d/forgejo_2174 ] # from the -openrc package installed because of the install-if condition
|