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 ALPINE_REPOS="main community testing"
|
||||||
readonly ARCH=$(apk --print-arch)
|
readonly ARCH=$(apk --print-arch)
|
||||||
# gitlab variables
|
# gitlab variables
|
||||||
readonly BASEBRANCH=$(echo ${CI_RUNNER_TAGS%%-*} | sed 's|apk||')
|
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
||||||
|
|
||||||
: "${REPODEST:=$HOME/packages}"
|
: "${REPODEST:=$HOME/packages}"
|
||||||
: "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}"
|
: "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}"
|
||||||
|
@ -70,36 +70,30 @@ report() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_release() {
|
get_release() {
|
||||||
case $BASEBRANCH in
|
local RELEASE=$(echo $CI_RUNNER_TAGS | awk -F '-' '{print $2}')
|
||||||
v*) echo "${BASEBRANCH%-*}";;
|
case $RELEASE in
|
||||||
|
v*) echo "${RELEASE%-*}";;
|
||||||
edge) echo edge;;
|
edge) echo edge;;
|
||||||
*) die "Branch \"$BASEBRANCH\" not supported!"
|
*) die "Branch \"$RELEASE\" not supported!"
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
build_aport() {
|
build_aport() {
|
||||||
local repo="$1" aport="$2"
|
local repo="$1" aport="$2"
|
||||||
cd "$APORTSDIR/$repo/$aport"
|
cd "$APORTSDIR/$aport"
|
||||||
export CHOST=$CI_ALPINE_TARGET_ARCH
|
|
||||||
if abuild -r 2>&1 | report "build-$aport"; then
|
if abuild -r 2>&1 | report "build-$aport"; then
|
||||||
checkapk | report "checkapk-$aport" || true
|
checkapk | report "checkapk-$aport" || true
|
||||||
aport_ok="$aport_ok $repo/$aport"
|
aport_ok="$aport_ok $aport"
|
||||||
else
|
else
|
||||||
aport_ng="$aport_ng $repo/$aport"
|
aport_ng="$aport_ng $aport"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_aport() {
|
check_aport() {
|
||||||
local repo="$1" aport="$2"
|
local repo="$1" aport="$2"
|
||||||
cd "$APORTSDIR/$repo/$aport"
|
cd "$APORTSDIR/$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
|
|
||||||
if ! abuild check_arch 2>/dev/null; then
|
if ! abuild check_arch 2>/dev/null; then
|
||||||
aport_na="$aport_na $repo/$aport"
|
aport_na="$aport_na $aport"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -115,11 +109,6 @@ set_repositories_for() {
|
||||||
done
|
done
|
||||||
sudo sh -c "printf '%s\n' $repos >> /etc/apk/repositories"
|
sudo sh -c "printf '%s\n' $repos >> /etc/apk/repositories"
|
||||||
sudo apk update || true
|
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() {
|
apply_offset_limit() {
|
||||||
|
@ -142,9 +131,6 @@ setup_system() {
|
||||||
repos="$repos $MIRROR/$release/cross"
|
repos="$repos $MIRROR/$release/cross"
|
||||||
sudo sh -c "printf '%s\n' $repos > /etc/apk/repositories"
|
sudo sh -c "printf '%s\n' $repos > /etc/apk/repositories"
|
||||||
sudo apk -U upgrade -a || sudo apk fix || die "Failed to up/downgrade system"
|
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 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 $ABUILD_KEY_PUB rsa-public $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub
|
||||||
chmod 700 $HOME/.abuild/$ABUILD_KEY_NAME.rsa
|
chmod 700 $HOME/.abuild/$ABUILD_KEY_NAME.rsa
|
||||||
|
@ -222,11 +208,11 @@ section_end setup
|
||||||
build_start=$CI_ALPINE_BUILD_OFFSET
|
build_start=$CI_ALPINE_BUILD_OFFSET
|
||||||
build_limit=$CI_ALPINE_BUILD_LIMIT
|
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
|
mkdir -p "$APORTSDIR"/logs "$APORTSDIR"/packages "$APORTSDIR"/keys
|
||||||
set_repositories_for "$repo"
|
set_repositories_for "$repo"
|
||||||
built_aports=0
|
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_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")
|
changed_aports_to_build=$(echo "$changed_aports_in_repo" | apply_offset_limit "$build_start" "$build_limit")
|
||||||
|
|
||||||
|
|
|
@ -5,17 +5,6 @@
|
||||||
# shellcheck disable=SC3040
|
# shellcheck disable=SC3040
|
||||||
set -eu -o pipefail
|
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() {
|
changed_aports() {
|
||||||
: "${APORTSDIR?APORTSDIR missing}"
|
: "${APORTSDIR?APORTSDIR missing}"
|
||||||
: "${BASEBRANCH?BASEBRANCH missing}"
|
: "${BASEBRANCH?BASEBRANCH missing}"
|
||||||
|
@ -24,11 +13,11 @@ changed_aports() {
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
local aports
|
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)
|
"$BASEBRANCH"...HEAD -- "*/APKBUILD" | xargs -rn1 dirname)
|
||||||
|
|
||||||
# shellcheck disable=2086
|
# 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() {
|
section_start() {
|
||||||
|
|
|
@ -11,6 +11,8 @@ readonly APORTSDIR=$CI_PROJECT_DIR
|
||||||
readonly REPOS="backports user"
|
readonly REPOS="backports user"
|
||||||
readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
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"
|
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
|
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
|
chmod 700 "$HOME"/.abuild/$ABUILD_KEY_NAME.rsa
|
||||||
|
|
||||||
echo "PACKAGER_PRIVKEY=$HOME/.abuild/$ABUILD_KEY_NAME.rsa" > $HOME/.abuild/abuild.conf
|
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/.
|
sudo cp $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub /etc/apk/keys/.
|
||||||
|
|
||||||
if [ -d $HOME/repo-apk ]; then
|
if [ -d $HOME/repo-apk ]; then
|
||||||
git -C $HOME/repo-apk fetch
|
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
|
git -C $HOME/repo-apk pull --rebase
|
||||||
else
|
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
|
fi
|
||||||
|
|
||||||
|
# TODO: Detect qubes release
|
||||||
|
QUBES_REL=r41
|
||||||
|
|
||||||
for i in $(find packages -type f -name "*.apk"); do
|
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
|
done
|
||||||
|
|
||||||
fetch_flags="-qn"
|
fetch_flags="-qn"
|
||||||
git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \
|
git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \
|
||||||
"+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH"
|
"+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH"
|
||||||
|
|
||||||
for repo in $(changed_repos); do
|
rm $HOME/repo-apk/qubes/$QUBES_REL/*/APKINDEX.tar.gz || true
|
||||||
rm $HOME/repo-apk/$repo/*/APKINDEX.tar.gz | true
|
mkdir -p qubes/$QUBES_REL/DUMMY
|
||||||
mkdir -p $repo/DUMMY
|
echo "pkgname=DUMMY" > qubes/$QUBES_REL/DUMMY/APKBUILD
|
||||||
echo "pkgname=DUMMY" > $repo/DUMMY/APKBUILD
|
cd qubes/$QUBES_REL/DUMMY
|
||||||
cd $repo/DUMMY
|
abuild index
|
||||||
for i in $(find $HOME/repo-apk/$repo -maxdepth 1 -mindepth 1 -printf '%P '); do
|
cd "$CI_PROJECT_DIR"
|
||||||
CHOST=$i abuild index
|
rm -R qubes/$QUBES_REL/DUMMY
|
||||||
done
|
|
||||||
cd "$CI_PROJECT_DIR"
|
|
||||||
rm -R $repo/DUMMY
|
|
||||||
done
|
|
||||||
|
|
||||||
git -C $HOME/repo-apk add .
|
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 commit -m "Update from $CI_MERGE_REQUEST_IID - $CI_MERGE_REQUEST_TITLE"
|
||||||
|
|
Loading…
Reference in a new issue