gitlab-ci: adapt to qubes-aports
This commit is contained in:
parent
37a9e0289c
commit
b62162574c
3 changed files with 30 additions and 54 deletions
|
@ -11,7 +11,7 @@ readonly REPOS="qubes-aports"
|
|||
readonly ALPINE_REPOS="main community testing"
|
||||
readonly ARCH=$(apk --print-arch)
|
||||
# gitlab variables
|
||||
readonly BASEBRANCH=$(echo ${CI_RUNNER_TAGS%%-*} | sed 's|apk||')
|
||||
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
||||
|
||||
: "${REPODEST:=$HOME/packages}"
|
||||
: "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}"
|
||||
|
@ -70,36 +70,30 @@ report() {
|
|||
}
|
||||
|
||||
get_release() {
|
||||
case $BASEBRANCH in
|
||||
v*) echo "${BASEBRANCH%-*}";;
|
||||
local RELEASE=$(echo $CI_RUNNER_TAGS | awk -F '-' '{print $2}')
|
||||
case $RELEASE in
|
||||
v*) echo "${RELEASE%-*}";;
|
||||
edge) echo edge;;
|
||||
*) die "Branch \"$BASEBRANCH\" not supported!"
|
||||
*) die "Branch \"$RELEASE\" not supported!"
|
||||
esac
|
||||
}
|
||||
|
||||
build_aport() {
|
||||
local repo="$1" aport="$2"
|
||||
cd "$APORTSDIR/$repo/$aport"
|
||||
export CHOST=$CI_ALPINE_TARGET_ARCH
|
||||
cd "$APORTSDIR/$aport"
|
||||
if abuild -r 2>&1 | report "build-$aport"; then
|
||||
checkapk | report "checkapk-$aport" || true
|
||||
aport_ok="$aport_ok $repo/$aport"
|
||||
aport_ok="$aport_ok $aport"
|
||||
else
|
||||
aport_ng="$aport_ng $repo/$aport"
|
||||
aport_ng="$aport_ng $aport"
|
||||
fi
|
||||
}
|
||||
|
||||
check_aport() {
|
||||
local repo="$1" aport="$2"
|
||||
cd "$APORTSDIR/$repo/$aport"
|
||||
export CHOST=$CI_ALPINE_TARGET_ARCH
|
||||
# TODO: this enables crossbuild only on user, this should be cleaner
|
||||
if [ "$repo" != "user" ] && [ "$repo" != "backports" ] && [ "$CI_ALPINE_TARGET_ARCH" != "$ARCH" ]; then
|
||||
aport_na="$aport_na $repo/$aport"
|
||||
return 1
|
||||
fi
|
||||
cd "$APORTSDIR/$aport"
|
||||
if ! abuild check_arch 2>/dev/null; then
|
||||
aport_na="$aport_na $repo/$aport"
|
||||
aport_na="$aport_na $aport"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
@ -115,11 +109,6 @@ set_repositories_for() {
|
|||
done
|
||||
sudo sh -c "printf '%s\n' $repos >> /etc/apk/repositories"
|
||||
sudo apk update || true
|
||||
if [ "$CI_ALPINE_TARGET_ARCH" != "$ARCH" ]; then
|
||||
sudo sh -c "printf '%s\n' $repos >> $HOME/sysroot-$CI_ALPINE_TARGET_ARCH/etc/apk/repositories"
|
||||
sudo cp -R /etc/apk/keys/* $HOME/sysroot-$CI_ALPINE_TARGET_ARCH/etc/apk/keys/.
|
||||
sudo apk --root=$HOME/sysroot-$CI_ALPINE_TARGET_ARCH update || true
|
||||
fi
|
||||
}
|
||||
|
||||
apply_offset_limit() {
|
||||
|
@ -142,9 +131,6 @@ setup_system() {
|
|||
repos="$repos $MIRROR/$release/cross"
|
||||
sudo sh -c "printf '%s\n' $repos > /etc/apk/repositories"
|
||||
sudo apk -U upgrade -a || sudo apk fix || die "Failed to up/downgrade system"
|
||||
if [ "$CI_ALPINE_TARGET_ARCH" != "$ARCH" ]; then
|
||||
sudo apk add gcc-$CI_ALPINE_TARGET_ARCH
|
||||
fi
|
||||
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
|
||||
chmod 700 $HOME/.abuild/$ABUILD_KEY_NAME.rsa
|
||||
|
@ -222,11 +208,11 @@ section_end setup
|
|||
build_start=$CI_ALPINE_BUILD_OFFSET
|
||||
build_limit=$CI_ALPINE_BUILD_LIMIT
|
||||
|
||||
for repo in $(changed_repos); do
|
||||
for repo in qubes-aports; do
|
||||
mkdir -p "$APORTSDIR"/logs "$APORTSDIR"/packages "$APORTSDIR"/keys
|
||||
set_repositories_for "$repo"
|
||||
built_aports=0
|
||||
changed_aports_in_repo=$(changed_aports "$repo")
|
||||
changed_aports_in_repo=$(changed_aports $BASEBRANCH)
|
||||
changed_aports_in_repo_count=$(echo "$changed_aports_in_repo" | wc -l)
|
||||
changed_aports_to_build=$(echo "$changed_aports_in_repo" | apply_offset_limit "$build_start" "$build_limit")
|
||||
|
||||
|
|
|
@ -5,17 +5,6 @@
|
|||
# shellcheck disable=SC3040
|
||||
set -eu -o pipefail
|
||||
|
||||
changed_repos() {
|
||||
: "${APORTSDIR?APORTSDIR missing}"
|
||||
: "${BASEBRANCH?BASEBRANCH missing}"
|
||||
|
||||
cd "$APORTSDIR"
|
||||
for repo in $REPOS; do
|
||||
git diff --diff-filter=ACMR --exit-code "$BASEBRANCH"...HEAD -- "$repo" >/dev/null \
|
||||
|| echo "$repo"
|
||||
done
|
||||
}
|
||||
|
||||
changed_aports() {
|
||||
: "${APORTSDIR?APORTSDIR missing}"
|
||||
: "${BASEBRANCH?BASEBRANCH missing}"
|
||||
|
@ -24,11 +13,11 @@ changed_aports() {
|
|||
local repo="$1"
|
||||
local aports
|
||||
|
||||
aports=$(git diff --name-only --diff-filter=ACMR --relative="$repo" \
|
||||
aports=$(git diff --name-only --diff-filter=ACMR \
|
||||
"$BASEBRANCH"...HEAD -- "*/APKBUILD" | xargs -rn1 dirname)
|
||||
|
||||
# shellcheck disable=2086
|
||||
ap builddirs -d "$APORTSDIR/$repo" $aports 2>/dev/null | xargs -rn1 basename
|
||||
ap builddirs -d "$APORTSDIR" $aports 2>/dev/null | xargs -rn1 basename
|
||||
}
|
||||
|
||||
section_start() {
|
||||
|
|
|
@ -11,6 +11,8 @@ readonly APORTSDIR=$CI_PROJECT_DIR
|
|||
readonly REPOS="backports user"
|
||||
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
||||
|
||||
ALPINE_RELEASE=$(echo $CI_RUNNER_TAGS | awk -F '-' '{print $2}')
|
||||
|
||||
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
||||
|
||||
gitlab_key_to_rsa $ABUILD_KEY rsa-private $HOME/.abuild/$ABUILD_KEY_NAME.rsa
|
||||
|
@ -20,36 +22,35 @@ chmod 700 "$HOME"/.ssh/id_rsa
|
|||
chmod 700 "$HOME"/.abuild/$ABUILD_KEY_NAME.rsa
|
||||
|
||||
echo "PACKAGER_PRIVKEY=$HOME/.abuild/$ABUILD_KEY_NAME.rsa" > $HOME/.abuild/abuild.conf
|
||||
echo "REPODEST=$HOME/repo-apk" >> $HOME/.abuild/abuild.conf
|
||||
echo "REPODEST=$HOME/repo-apk/qubes" >> $HOME/.abuild/abuild.conf
|
||||
sudo cp $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub /etc/apk/keys/.
|
||||
|
||||
if [ -d $HOME/repo-apk ]; then
|
||||
git -C $HOME/repo-apk fetch
|
||||
git -C $HOME/repo-apk checkout $BASEBRANCH
|
||||
git -C $HOME/repo-apk checkout $ALPINE_RELEASE
|
||||
git -C $HOME/repo-apk pull --rebase
|
||||
else
|
||||
git clone git@lab.ilot.io:ayakael/repo-apk -b $BASEBRANCH $HOME/repo-apk
|
||||
git clone git@lab.ilot.io:ayakael/repo-apk -b $ALPINE_RELEASE $HOME/repo-apk
|
||||
fi
|
||||
|
||||
# TODO: Detect qubes release
|
||||
QUBES_REL=r41
|
||||
|
||||
for i in $(find packages -type f -name "*.apk"); do
|
||||
install -vDm644 $i ${i/packages/$HOME\/repo-apk}
|
||||
install -vDm644 $i ${i/packages\/qubes-aports/$HOME\/repo-apk\/qubes\/$QUBES_REL}
|
||||
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
|
||||
rm $HOME/repo-apk/$repo/*/APKINDEX.tar.gz | true
|
||||
mkdir -p $repo/DUMMY
|
||||
echo "pkgname=DUMMY" > $repo/DUMMY/APKBUILD
|
||||
cd $repo/DUMMY
|
||||
for i in $(find $HOME/repo-apk/$repo -maxdepth 1 -mindepth 1 -printf '%P '); do
|
||||
CHOST=$i abuild index
|
||||
done
|
||||
rm $HOME/repo-apk/qubes/$QUBES_REL/*/APKINDEX.tar.gz || true
|
||||
mkdir -p qubes/$QUBES_REL/DUMMY
|
||||
echo "pkgname=DUMMY" > qubes/$QUBES_REL/DUMMY/APKBUILD
|
||||
cd qubes/$QUBES_REL/DUMMY
|
||||
abuild index
|
||||
cd "$CI_PROJECT_DIR"
|
||||
rm -R $repo/DUMMY
|
||||
done
|
||||
rm -R qubes/$QUBES_REL/DUMMY
|
||||
|
||||
git -C $HOME/repo-apk add .
|
||||
git -C $HOME/repo-apk commit -m "Update from $CI_MERGE_REQUEST_IID - $CI_MERGE_REQUEST_TITLE"
|
||||
|
|
Loading…
Reference in a new issue