2023-02-09 22:56:28 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# shellcheck disable=SC3043
|
|
|
|
|
|
|
|
. $CI_PROJECT_DIR/.gitlab/bin/functions.sh
|
|
|
|
|
|
|
|
# shellcheck disable=SC3040
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
readonly APORTSDIR=$CI_PROJECT_DIR
|
2023-02-10 05:37:40 +00:00
|
|
|
readonly REPOS="backports user"
|
2023-02-09 22:56:28 +00:00
|
|
|
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
|
|
|
|
|
|
|
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
|
|
|
|
2023-03-03 06:39:38 +00:00
|
|
|
gitlab_key_to_rsa $ABUILD_KEY rsa-private $HOME/.abuild/$ABUILD_KEY_NAME.rsa
|
|
|
|
gitlab_key_to_rsa $ABUILD_KEY_PUB rsa-public $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub
|
|
|
|
gitlab_key_to_rsa $SSH_KEY rsa-private $HOME/.ssh/id_rsa
|
2023-02-09 22:56:28 +00:00
|
|
|
chmod 700 "$HOME"/.ssh/id_rsa
|
2023-02-22 03:04:09 +00:00
|
|
|
chmod 700 "$HOME"/.abuild/$ABUILD_KEY_NAME.rsa
|
2023-02-09 22:56:28 +00:00
|
|
|
|
2023-04-26 04:02:11 +00:00
|
|
|
echo "PACKAGER_PRIVKEY=$HOME/.abuild/$ABUILD_KEY_NAME.rsa" > $HOME/.abuild/abuild.conf
|
|
|
|
echo "REPODEST=$HOME/repo-apk" >> $HOME/.abuild/abuild.conf
|
2023-02-22 03:04:09 +00:00
|
|
|
doas cp $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub /etc/apk/keys/.
|
2023-02-09 22:56:28 +00:00
|
|
|
|
2023-04-26 04:02:11 +00:00
|
|
|
if [ -d $HOME/repo-apk ]; then
|
2023-05-07 23:39:05 +00:00
|
|
|
git -C $HOME/repo-apk fetch
|
2023-04-26 04:02:11 +00:00
|
|
|
git -C $HOME/repo-apk checkout $BASEBRANCH
|
|
|
|
git -C $HOME/repo-apk pull --rebase
|
|
|
|
else
|
|
|
|
git clone git@lab.ilot.io:ayakael/repo-apk -b $BASEBRANCH $HOME/repo-apk
|
|
|
|
fi
|
|
|
|
|
2023-02-09 22:56:28 +00:00
|
|
|
for i in $(find packages -type f -name "*.apk"); do
|
2023-04-26 04:02:11 +00:00
|
|
|
install -vDm644 $i ${i/packages/$HOME\/repo-apk}
|
2023-02-09 22:56:28 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
fetch_flags="-qn"
|
|
|
|
git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \
|
|
|
|
"+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH"
|
|
|
|
|
|
|
|
for repo in $(changed_repos); do
|
2023-04-26 04:02:11 +00:00
|
|
|
rm $HOME/repo-apk/$repo/*/APKINDEX.tar.gz | true
|
2023-02-09 22:56:28 +00:00
|
|
|
mkdir -p $repo/DUMMY
|
|
|
|
echo "pkgname=DUMMY" > $repo/DUMMY/APKBUILD
|
|
|
|
cd $repo/DUMMY
|
2023-04-26 04:02:11 +00:00
|
|
|
for i in $(find $HOME/repo-apk/$repo -maxdepth 1 -mindepth 1 -printf '%P '); do
|
2023-04-23 20:14:13 +00:00
|
|
|
CHOST=$i abuild index
|
|
|
|
done
|
2023-02-09 22:56:28 +00:00
|
|
|
cd "$CI_PROJECT_DIR"
|
|
|
|
rm -R $repo/DUMMY
|
|
|
|
done
|
|
|
|
|
2023-04-26 04:02:11 +00:00
|
|
|
git -C $HOME/repo-apk add .
|
|
|
|
git -C $HOME/repo-apk commit -m "Update from $CI_MERGE_REQUEST_IID - $CI_MERGE_REQUEST_TITLE"
|
|
|
|
git -C $HOME/repo-apk push
|