diff --git a/.forgejo/bin/build.sh b/.forgejo/bin/build.sh new file mode 100755 index 0000000..b6dcbe0 --- /dev/null +++ b/.forgejo/bin/build.sh @@ -0,0 +1,260 @@ +#!/bin/sh +# shellcheck disable=SC3043 + +. /usr/local/lib/functions.sh + +# shellcheck disable=SC3040 +set -eu -o pipefail + +readonly APORTSDIR=$CI_PROJECT_DIR +readonly REPOS="ilot backports" +readonly ALPINE_REPOS="main community testing" +readonly ARCH=$(apk --print-arch) +# gitlab variables +readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME + +: "${REPODEST:=$HOME/packages}" +: "${MIRROR:=https://forge.ilot.io/api/packages/ilot/alpine}" +: "${ALPINE_MIRROR:=http://dl-cdn.alpinelinux.org/alpine}" +: "${MAX_ARTIFACT_SIZE:=300000000}" #300M +: "${CI_DEBUG_BUILD:=}" + +: "${CI_ALPINE_BUILD_OFFSET:=0}" +: "${CI_ALPINE_BUILD_LIMIT:=9999}" + +msg() { + local color=${2:-green} + case "$color" in + red) color="31";; + green) color="32";; + yellow) color="33";; + blue) color="34";; + *) color="32";; + esac + printf "\033[1;%sm>>>\033[1;0m %s\n" "$color" "$1" | xargs >&2 +} + +verbose() { + echo "> " "$@" + # shellcheck disable=SC2068 + $@ +} + +debugging() { + [ -n "$CI_DEBUG_BUILD" ] +} + +debug() { + if debugging; then + verbose "$@" + fi +} + +die() { + msg "$1" red + exit 1 +} + +capture_stderr() { + "$@" 2>&1 +} + +report() { + report=$1 + + reportsdir=$APORTSDIR/logs/ + mkdir -p "$reportsdir" + + tee -a "$reportsdir/$report.log" +} + +get_release() { + case $BASEBRANCH in + v*) echo "$BASEBRANCH";; + edge) echo edge;; + *) die "Branch \"$BASEBRANCH\" not supported!" + esac +} + +build_aport() { + local repo="$1" aport="$2" + cd "$APORTSDIR/$repo/$aport" + if abuild -r 2>&1 | report "build-$aport"; then + checkapk 2>&1 | report "checkapk-$aport" || true + aport_ok="$aport_ok $repo/$aport" + else + aport_ng="$aport_ng $repo/$aport" + fi +} + +check_aport() { + local repo="$1" aport="$2" + cd "$APORTSDIR/$repo/$aport" + if ! abuild check_arch 2>/dev/null; then + aport_na="$aport_na $repo/$aport" + return 1 + fi +} + +set_repositories_for() { + local target_repo="$1" repos='' repo='' + local release + + release=$(get_release) + for repo in $REPOS; do + [ "$repo" = "non-free" ] && continue + [ "$release" == "edge" ] && [ "$repo" == "backports" ] && continue + repos="$repos $MIRROR/$release/$repo $REPODEST/$repo" + [ "$repo" = "$target_repo" ] && break + done + doas sh -c "printf '%s\n' $repos >> /etc/apk/repositories" + doas apk update || true +} + +apply_offset_limit() { + start=$1 + limit=$2 + end=$((start+limit)) + + sed -n "$((start+1)),${end}p" +} + +setup_system() { + local repos='' repo='' + local release + + release=$(get_release) + for repo in $ALPINE_REPOS; do + [ "$release" != "edge" ] && [ "$repo" == "testing" ] && continue + repos="$repos $ALPINE_MIRROR/$release/$repo" + done + doas sh -c "printf '%s\n' $repos > /etc/apk/repositories" + doas apk -U upgrade -a || apk fix || die "Failed to up/downgrade system" + abuild-keygen -ain + doas sed -i -E 's/export JOBS=[0-9]+$/export JOBS=$(nproc)/' /etc/abuild.conf + ( . /etc/abuild.conf && echo "Building with $JOBS jobs" ) + mkdir -p "$REPODEST" + git config --global init.defaultBranch master +} + +sysinfo() { + printf ">>> Host system information (arch: %s, release: %s) <<<\n" "$ARCH" "$(get_release)" + printf "- Number of Cores: %s\n" "$(nproc)" + printf "- Memory: %s Gb\n" "$(awk '/^MemTotal/ {print ($2/1024/1024)}' /proc/meminfo)" + printf "- Free space: %s\n" "$(df -hP / | awk '/\/$/ {print $4}')" +} + +copy_artifacts() { + cd "$APORTSDIR" + + packages_size="$(du -sk "$REPODEST" | awk '{print $1 * 1024}')" + if [ -z "$packages_size" ]; then + return + fi + + echo "Artifact size: $packages_size bytes" + + mkdir -p keys/ packages/ + + if [ "$packages_size" -lt $MAX_ARTIFACT_SIZE ]; then + msg "Copying packages for artifact upload" + cp -ar "$REPODEST"/* packages/ 2>/dev/null + cp ~/.abuild/*.rsa.pub keys/ + else + msg "Artifact size $packages_size larger than max ($MAX_ARTIFACT_SIZE), skipping uploading them" yellow + fi +} + +section_start setup "Setting up the system" collapse + +if debugging; then + set -x +fi + +aport_ok= +aport_na= +aport_ng= +failed= + +sysinfo || true +setup_system || die "Failed to setup system" + +# git no longer allows to execute in repositories owned by different users +doas chown -R buildozer: . + +fetch_flags="-qn" +debugging && fetch_flags="-v" + +git fetch $fetch_flags "$CI_MERGE_REQUEST_PROJECT_URL" \ + "+refs/heads/$BASEBRANCH:refs/heads/$BASEBRANCH" + +if debugging; then + merge_base=$(git merge-base "$BASEBRANCH" HEAD) || echo "Could not determine merge-base" + echo "Merge base: $merge_base" + git --version + git config -l + [ -n "$merge_base" ] && git tag -f merge-base "$merge_base" + git --no-pager log -200 --oneline --graph --decorate --all +fi + +section_end setup + +build_start=$CI_ALPINE_BUILD_OFFSET +build_limit=$CI_ALPINE_BUILD_LIMIT + +for repo in $(changed_repos); do + set_repositories_for "$repo" + built_aports=0 + changed_aports_in_repo=$(changed_aports "$repo") + 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") + + msg "Changed aports in $repo:" + # shellcheck disable=SC2086 # Splitting is expected here + printf " - %s\n" $changed_aports_to_build + for pkgname in $changed_aports_to_build; do + section_start "build_$pkgname" "Building package $pkgname" + built_aports=$((built_aports+1)) + if check_aport "$repo" "$pkgname"; then + build_aport "$repo" "$pkgname" + fi + section_end "build_$pkgname" + done + + build_start=$((build_start-(changed_aports_in_repo_count-built_aports))) + build_limit=$((build_limit-built_aports)) + + if [ $build_limit -le 0 ]; then + msg "Limit reached, breaking" + break + fi +done + +section_start artifacts "Handeling artifacts" collapse +copy_artifacts || true +section_end artifacts + +section_start summary "Build summary" + +echo "### Build summary ###" + +for ok in $aport_ok; do + msg "$ok: build succesfully" +done + +for na in $aport_na; do + msg "$na: disabled for $ARCH" yellow +done + +for ng in $aport_ng; do + msg "$ng: build failed" red + failed=true +done +section_end summary + +if [ "$failed" = true ]; then + exit 1 +elif [ -z "$aport_ok" ]; then + msg "No packages found to be built." yellow +fi + diff --git a/.forgejo/patches/build.patch b/.forgejo/patches/build.patch deleted file mode 100644 index 6de7c04..0000000 --- a/.forgejo/patches/build.patch +++ /dev/null @@ -1,66 +0,0 @@ -diff --git a/usr/local/bin/build.sh.orig b/usr/local/bin/build.sh -old mode 100644 -new mode 100755 -index c3b8f7a..f609018 ---- a/usr/local/bin/build.sh.orig -+++ b/usr/local/bin/build.sh -@@ -7,13 +7,15 @@ - set -eu -o pipefail - - readonly APORTSDIR=$CI_PROJECT_DIR --readonly REPOS="main community testing non-free" -+readonly REPOS="ilot backports" -+readonly ALPINE_REPOS="main community testing" - readonly ARCH=$(apk --print-arch) - # gitlab variables - readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - : "${REPODEST:=$HOME/packages}" --: "${MIRROR:=https://dl-cdn.alpinelinux.org/alpine}" -+: "${MIRROR:=https://forge.ilot.io/api/packages/ilot/alpine}" -+: "${ALPINE_MIRROR:=http://dl-cdn.alpinelinux.org/alpine}" - : "${MAX_ARTIFACT_SIZE:=300000000}" #300M - : "${CI_DEBUG_BUILD:=}" - -@@ -68,8 +70,8 @@ report() { - - get_release() { - case $BASEBRANCH in -- *-stable) echo v"${BASEBRANCH%-*}";; -- master) echo edge;; -+ v*) echo "$BASEBRANCH";; -+ edge) echo edge;; - *) die "Branch \"$BASEBRANCH\" not supported!" - esac - } -@@ -101,11 +103,11 @@ set_repositories_for() { - release=$(get_release) - for repo in $REPOS; do - [ "$repo" = "non-free" ] && continue -- [ "$release" != "edge" ] && [ "$repo" == "testing" ] && continue -+ [ "$release" == "edge" ] && [ "$repo" == "backports" ] && continue - repos="$repos $MIRROR/$release/$repo $REPODEST/$repo" - [ "$repo" = "$target_repo" ] && break - done -- doas sh -c "printf '%s\n' $repos > /etc/apk/repositories" -+ doas sh -c "printf '%s\n' $repos >> /etc/apk/repositories" - doas apk update - } - -@@ -118,7 +120,15 @@ apply_offset_limit() { - } - - setup_system() { -- doas sh -c "echo $MIRROR/$(get_release)/main > /etc/apk/repositories" -+ local repos='' repo='' -+ local release -+ -+ release=$(get_release) -+ for repo in $ALPINE_REPOS; do -+ [ "$release" != "edge" ] && [ "$repo" == "testing" ] && continue -+ repos="$repos $ALPINE_MIRROR/$release/$repo" -+ done -+ doas sh -c "printf '%s\n' $repos > /etc/apk/repositories" - doas apk -U upgrade -a || apk fix || die "Failed to up/downgrade system" - abuild-keygen -ain - doas sed -i -E 's/export JOBS=[0-9]+$/export JOBS=$(nproc)/' /etc/abuild.conf diff --git a/.forgejo/workflows/build-aarch64.yaml b/.forgejo/workflows/build-aarch64.yaml index b1fe4fe..8e19c74 100644 --- a/.forgejo/workflows/build-aarch64.yaml +++ b/.forgejo/workflows/build-aarch64.yaml @@ -27,9 +27,7 @@ jobs: with: fetch-depth: 500 - name: Package build - run: | - doas patch -d / -p1 -i ${{ github.workspace }}/.forgejo/patches/build.patch - build.sh + run: ${{ github.workspace }}/.forgejo/bin/build.sh - name: Package upload uses: forgejo/upload-artifact@v3 with: diff --git a/.forgejo/workflows/build-x86_64.yaml b/.forgejo/workflows/build-x86_64.yaml index 2725613..9a7dac2 100644 --- a/.forgejo/workflows/build-x86_64.yaml +++ b/.forgejo/workflows/build-x86_64.yaml @@ -27,9 +27,7 @@ jobs: with: fetch-depth: 500 - name: Package build - run: | - doas patch -d / -p1 -i ${{ github.workspace }}/.forgejo/patches/build.patch - build.sh + run: ${{ github.workspace }}/.forgejo/bin/build.sh - name: Package upload uses: forgejo/upload-artifact@v3 with: diff --git a/ilot/authentik/APKBUILD b/ilot/authentik/APKBUILD index d10a575..72e65ad 100644 --- a/ilot/authentik/APKBUILD +++ b/ilot/authentik/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=authentik pkgver=2024.4.3 -pkgrel=1 +pkgrel=2 pkgdesc="An open-source Identity Provider focused on flexibility and versatility" url="https://github.com/goauthentik/authentik" # s390x: missing py3-celery py3-flower and py3-kombu diff --git a/ilot/freescout/APKBUILD b/ilot/freescout/APKBUILD index 1fd520c..d083ae2 100644 --- a/ilot/freescout/APKBUILD +++ b/ilot/freescout/APKBUILD @@ -2,7 +2,7 @@ # Contributor: Antoine Martin (ayakael) pkgname=freescout pkgver=1.8.139 -pkgrel=0 +pkgrel=1 pkgdesc="Free self-hosted help desk & shared mailbox" arch="noarch" url="freescout.net" diff --git a/ilot/listmonk/APKBUILD b/ilot/listmonk/APKBUILD index 00951f0..0ad6acd 100644 --- a/ilot/listmonk/APKBUILD +++ b/ilot/listmonk/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=listmonk pkgver=3.0.0 -pkgrel=0 +pkgrel=1 pkgdesc='Self-hosted newsletter and mailing list manager with a modern dashboard' arch="all" url=https://listmonk.app diff --git a/ilot/loomio/APKBUILD b/ilot/loomio/APKBUILD index 38eb631..1381afd 100644 --- a/ilot/loomio/APKBUILD +++ b/ilot/loomio/APKBUILD @@ -4,10 +4,11 @@ pkgname=loomio pkgver=2.21.4 _gittag=v$pkgver -pkgrel=0 +pkgrel=1 pkgdesc="A collaborative decision making tool" url="https://github.com/loomio/loomio" -arch="x86_64" +# failing build +#arch="x86_64" license="MIT" depends=" postgresql diff --git a/ilot/peertube/APKBUILD b/ilot/peertube/APKBUILD index f50d1c1..809936b 100644 --- a/ilot/peertube/APKBUILD +++ b/ilot/peertube/APKBUILD @@ -2,9 +2,10 @@ # Contributor: Antoine Martin (ayakael) pkgname=peertube pkgver=6.0.2 -pkgrel=0 +pkgrel=1 pkgdesc="ActivityPub-federated video streaming platform using P2P directly in your web browser" -arch="x86_64" +# failing build +# arch="x86_64" url="https://joinpeertube.org/" license="AGPL" depends=" diff --git a/ilot/php82-pecl-inotify/APKBUILD b/ilot/php82-pecl-inotify/APKBUILD index 44903a1..d2bb518 100644 --- a/ilot/php82-pecl-inotify/APKBUILD +++ b/ilot/php82-pecl-inotify/APKBUILD @@ -3,7 +3,7 @@ pkgname=php82-pecl-inotify _extname=inotify pkgver=3.0.0 -pkgrel=0 +pkgrel=1 pkgdesc="Inotify bindings for PHP 8.3" url="https://pecl.php.net/package/inotify" arch="all" diff --git a/ilot/php83-pecl-inotify/APKBUILD b/ilot/php83-pecl-inotify/APKBUILD index 771466f..48f2bbf 100644 --- a/ilot/php83-pecl-inotify/APKBUILD +++ b/ilot/php83-pecl-inotify/APKBUILD @@ -3,7 +3,7 @@ pkgname=php83-pecl-inotify _extname=inotify pkgver=3.0.0 -pkgrel=0 +pkgrel=1 pkgdesc="Inotify bindings for PHP 8.3" url="https://pecl.php.net/package/inotify" arch="all" diff --git a/ilot/py3-django-rest-framework/APKBUILD b/ilot/py3-django-rest-framework/APKBUILD index 4a82cb3..82a1497 100644 --- a/ilot/py3-django-rest-framework/APKBUILD +++ b/ilot/py3-django-rest-framework/APKBUILD @@ -4,7 +4,7 @@ pkgname=py3-django-rest-framework _pkgname=django-rest-framework pkgver=3.14.0 -pkgrel=0 +pkgrel=1 pkgdesc="Web APIs for Django" url="https://github.com/encode/django-rest-framework" arch="noarch" diff --git a/ilot/py3-django-tenants/APKBUILD b/ilot/py3-django-tenants/APKBUILD index f12eac2..0183781 100644 --- a/ilot/py3-django-tenants/APKBUILD +++ b/ilot/py3-django-tenants/APKBUILD @@ -4,7 +4,7 @@ pkgname=py3-django-tenants #_pkgreal is used by apkbuild-pypi to find modules at PyPI _pkgreal=django-tenants pkgver=3.6.1 -pkgrel=0 +pkgrel=1 pkgdesc="Tenant support for Django using PostgreSQL schemas." url="https://pypi.python.org/project/django-tenants" arch="noarch" diff --git a/ilot/py3-scim2-filter-parser/APKBUILD b/ilot/py3-scim2-filter-parser/APKBUILD index 784a660..15d12e5 100644 --- a/ilot/py3-scim2-filter-parser/APKBUILD +++ b/ilot/py3-scim2-filter-parser/APKBUILD @@ -4,7 +4,7 @@ pkgname=py3-scim2-filter-parser #_pkgreal is used by apkbuild-pypi to find modules at PyPI _pkgreal=scim2-filter-parser pkgver=0.5.0 -pkgrel=0 +pkgrel=1 pkgdesc="A customizable parser/transpiler for SCIM2.0 filters" url="https://pypi.python.org/project/scim2-filter-parser" arch="noarch" diff --git a/ilot/py3-tenant-schemas-celery/APKBUILD b/ilot/py3-tenant-schemas-celery/APKBUILD index 4398eae..c5f9029 100644 --- a/ilot/py3-tenant-schemas-celery/APKBUILD +++ b/ilot/py3-tenant-schemas-celery/APKBUILD @@ -4,7 +4,7 @@ pkgname=py3-tenant-schemas-celery #_pkgreal is used by apkbuild-pypi to find modules at PyPI _pkgreal=tenant-schemas-celery pkgver=2.2.0 -pkgrel=0 +pkgrel=1 pkgdesc="Celery integration for django-tenant-schemas and django-tenants" url="https://pypi.python.org/project/tenant-schemas-celery" arch="noarch" diff --git a/ilot/uptime-kuma/APKBUILD b/ilot/uptime-kuma/APKBUILD index cea07d0..f0acb67 100644 --- a/ilot/uptime-kuma/APKBUILD +++ b/ilot/uptime-kuma/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=uptime-kuma pkgver=1.23.13 -pkgrel=0 +pkgrel=1 pkgdesc='A fancy self-hosted monitoring tool' arch="all" url="https://github.com/louislam/uptime-kuma" diff --git a/ilot/wikijs/APKBUILD b/ilot/wikijs/APKBUILD index aeaad93..43d8189 100644 --- a/ilot/wikijs/APKBUILD +++ b/ilot/wikijs/APKBUILD @@ -1,9 +1,8 @@ # Maintainer: Antoine Martin (ayakael) # Contributor: Antoine Martin (ayakael) - pkgname=wikijs pkgver=2.5.303 -pkgrel=0 +pkgrel=1 pkgdesc="Wiki.js | A modern, lightweight and powerful wiki app built on Node.js" license="AGPL-3.0" arch="!armv7 x86_64"