diff --git a/.forgejo/bin/deploy.sh b/.forgejo/bin/deploy.sh deleted file mode 100755 index e8e811c..0000000 --- a/.forgejo/bin/deploy.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# shellcheck disable=SC3040 -set -eu -o pipefail - -readonly REPOS="backports ilot" -readonly BASEBRANCH=$GITHUB_BASE_REF -readonly TARGET_REPO=$CI_ALPINE_REPO - -apkgs=$(find package -type f -name "*.apk") - -for apk in $apkgs; do - branch=$(echo $apk | awk -F '/' '{print $2}') - arch=$(echo $apk | awk -F '/' '{print $3}') - name=$(echo $apk | awk -F '/' '{print $4}') - - if [ "$(curl -s $GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/pulls/$GITHUB_EVENT_NUMBER | jq .draft)" == "true" ]; then - # if draft, send to -testing branch - branch="$branch-testing" - else - # if not draft, assume that this was sent to $branch-testing and nuke it - curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN -X DELETE $TARGET_REPO/$BASEBRANCH/$branch-testing/$arch/$name - fi - - echo "Sending $name of arch $arch to $TARGET_REPO/$BASEBRANCH/$branch" - return=$(curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/$branch 2>&1) - echo $return - if [ "$return" == "package file already exists" ]; then - echo "Package already exists, refreshing..." - curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN -X DELETE $TARGET_REPO/$BASEBRANCH/$branch/$arch/$name - curl -s --user $FORGE_REPO_USER:$FORGE_REPO_TOKEN --upload-file $apk $TARGET_REPO/$BASEBRANCH/$branch - fi -done - diff --git a/.forgejo/workflows/build-aarch64.yaml b/.forgejo/workflows/build-aarch64.yaml deleted file mode 100644 index 8e19c74..0000000 --- a/.forgejo/workflows/build-aarch64.yaml +++ /dev/null @@ -1,55 +0,0 @@ -on: - pull_request: - types: [ assigned, opened, synchronize, reopened ] - -concurrency: - group: ${{ github.head_ref || github.ref_name }} - cancel-in-progress: true - -jobs: - build-aarch64: - runs-on: aarch64 - container: - image: alpinelinux/alpine-gitlab-ci:latest - env: - CI_PROJECT_DIR: ${{ github.workspace }} - CI_DEBUG_BUILD: ${{ runner.debug }} - CI_MERGE_REQUEST_PROJECT_URL: ${{ github.server_url }}/${{ github.repository }} - CI_MERGE_REQUEST_TARGET_BRANCH_NAME: ${{ github.base_ref }} - steps: - - name: Environment setup - run: | - doas apk add nodejs git patch curl - cd /etc/apk/keys - doas curl -JO https://forge.ilot.io/api/packages/ilot/alpine/key - - name: Repo pull - uses: actions/checkout@v4 - with: - fetch-depth: 500 - - name: Package build - run: ${{ github.workspace }}/.forgejo/bin/build.sh - - name: Package upload - uses: forgejo/upload-artifact@v3 - with: - name: package - path: packages - - deploy-aarch64: - needs: [build-aarch64] - runs-on: aarch64 - container: - image: alpine:latest - env: - CI_ALPINE_REPO: 'https://forge.ilot.io/api/packages/ilot/alpine' - FORGE_REPO_TOKEN: ${{ secrets.FORGE_REPO_TOKEN }} - FORGE_REPO_USER: ${{ vars.FORGE_REPO_USER }} - GITHUB_EVENT_NUMBER: ${{ github.event.number }} - steps: - - name: Setting up environment - run: apk add nodejs curl findutils git gawk jq - - name: Repo pull - uses: actions/checkout@v4 - - name: Package download - uses: forgejo/download-artifact@v3 - - name: Package deployment - run: ${{ github.workspace }}/.forgejo/bin/deploy.sh diff --git a/.forgejo/workflows/build-x86_64.yaml b/.forgejo/workflows/build-x86_64.yaml deleted file mode 100644 index 9a7dac2..0000000 --- a/.forgejo/workflows/build-x86_64.yaml +++ /dev/null @@ -1,55 +0,0 @@ -on: - pull_request: - types: [ assigned, opened, synchronize, reopened ] - -concurrency: - group: ${{ github.head_ref || github.ref_name }} - cancel-in-progress: true - -jobs: - build-x86_64: - runs-on: x86_64 - container: - image: alpinelinux/alpine-gitlab-ci:latest - env: - CI_PROJECT_DIR: ${{ github.workspace }} - CI_DEBUG_BUILD: ${{ runner.debug }} - CI_MERGE_REQUEST_PROJECT_URL: ${{ github.server_url }}/${{ github.repository }} - CI_MERGE_REQUEST_TARGET_BRANCH_NAME: ${{ github.base_ref }} - steps: - - name: Environment setup - run: | - doas apk add nodejs git patch curl - cd /etc/apk/keys - doas curl -JO https://forge.ilot.io/api/packages/ilot/alpine/key - - name: Repo pull - uses: actions/checkout@v4 - with: - fetch-depth: 500 - - name: Package build - run: ${{ github.workspace }}/.forgejo/bin/build.sh - - name: Package upload - uses: forgejo/upload-artifact@v3 - with: - name: package - path: packages - - deploy-x86_64: - needs: [build-x86_64] - runs-on: x86_64 - container: - image: alpine:latest - env: - CI_ALPINE_REPO: 'https://forge.ilot.io/api/packages/ilot/alpine' - FORGE_REPO_TOKEN: ${{ secrets.FORGE_REPO_TOKEN }} - FORGE_REPO_USER: ${{ vars.FORGE_REPO_USER }} - GITHUB_EVENT_NUMBER: ${{ github.event.number }} - steps: - - name: Setting up environment - run: apk add nodejs curl findutils git gawk jq - - name: Repo pull - uses: actions/checkout@v4 - - name: Package download - uses: forgejo/download-artifact@v3 - - name: Package deployment - run: ${{ github.workspace }}/.forgejo/bin/deploy.sh diff --git a/.forgejo/workflows/lint.yaml b/.forgejo/workflows/lint.yaml deleted file mode 100644 index 3614deb..0000000 --- a/.forgejo/workflows/lint.yaml +++ /dev/null @@ -1,21 +0,0 @@ -on: - pull_request: - types: [ assigned, opened, synchronize, reopened ] - -jobs: - lint: - run-name: lint - runs-on: x86_64 - container: - image: alpinelinux/apkbuild-lint-tools:latest - env: - CI_PROJECT_DIR: ${{ github.workspace }} - CI_DEBUG_BUILD: ${{ runner.debug }} - CI_MERGE_REQUEST_PROJECT_URL: ${{ github.server_url }}/${{ github.repository }} - CI_MERGE_REQUEST_TARGET_BRANCH_NAME: ${{ github.base_ref }} - steps: - - run: doas apk add nodejs git - - uses: actions/checkout@v4 - with: - fetch-depth: 500 - - run: lint diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..dd8afae --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,109 @@ +stages: + - verify + - build + - deploy + +variables: + GIT_STRATEGY: clone + GIT_DEPTH: "500" + +lint: + stage: verify + interruptible: true + script: + - | + sudo apk add shellcheck atools sudo abuild + export PATH="$PATH:$CI_PROJECT_DIR/.gitlab/bin" + lint + allow_failure: true + only: + - merge_requests + tags: + - apk-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-x86_64 + +.build: + stage: build + interruptible: true + script: + - | + sudo apk add alpine-sdk lua-aports sudo + sudo addgroup $USER abuild + export PATH="$PATH:$CI_PROJECT_DIR/.gitlab/bin" + sudo -Eu $USER build.sh + artifacts: + paths: + - packages/ + - keys/ + - logs/ + expire_in: 7 days + when: always + only: + - merge_requests + +.cross: + stage: build + interruptible: true + script: + - | + sudo apk add alpine-sdk lua-aports sudo gzip xz qemu-$CI_QEMU_TARGET_ARCH + sudo addgroup $USER abuild + export PATH="$PATH:$CI_PROJECT_DIR/.gitlab/bin" + build-rootfs.sh alpine${CI_MERGE_REQUEST_TARGET_BRANCH_NAME/v} $CI_ALPINE_TARGET_ARCH --rootfsdir $HOME/sysroot-$CI_ALPINE_TARGET_ARCH + cp /etc/apk/repositories $HOME/sysroot-$CI_ALPINE_TARGET_ARCH/etc/apk/. + sudo -Eu $USER CHOST=$CI_TARGET_ALPINE_ARCH build.sh + artifacts: + paths: + - packages/ + - keys/ + - logs/ + expire_in: 7 days + when: always + only: + - merge_requests + +build-x86_64: + extends: .build + when: always + tags: + - apk-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-x86_64 + +build-aarch64: + extends: .build + when: always + tags: + - apk-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-aarch64 + +build-ppc64le: + extends: .build + when: manual + tags: + - apk-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-ppc64le + +build-s390x: + extends: .build + when: manual + tags: + - apk-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-s390x + +build-armv7: + extends: .cross + when: manual + tags: + - apk-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-x86_64 + variables: + CI_ALPINE_TARGET_ARCH: armv7 + CI_QEMU_TARGET_ARCH: arm + +push: + interruptible: true + stage: deploy + script: + - | + sudo apk add abuild git-lfs findutils + export PATH="$PATH:$CI_PROJECT_DIR/.gitlab/bin" + push.sh + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + when: manual + tags: + - repo diff --git a/.gitlab/bin/APKBUILD_SHIM b/.gitlab/bin/APKBUILD_SHIM new file mode 100755 index 0000000..76577ff --- /dev/null +++ b/.gitlab/bin/APKBUILD_SHIM @@ -0,0 +1,111 @@ +#!/bin/sh + +set -e + +arch= +builddir= +checkdepends= +depends= +depends_dev= +depends_doc= +depends_libs= +depends_openrc= +depends_static= +install= +install_if= +langdir= +ldpath= +license= +makedepends= +makedepends_build= +makedepends_host= +md5sums= +options= +patch_args= +pkgbasedir= +pkgdesc= +pkgdir= +pkgname= +pkgrel= +pkgver= +pkggroups= +pkgusers= +provides= +provider_priority= +replaces= +sha256sums= +sha512sums= +sonameprefix= +source= +srcdir= +startdir= +subpackages= +subpkgdir= +subpkgname= +triggers= +url= + +# abuild.conf + +CFLAGS= +CXXFLAGS= +CPPFLAGS= +LDFLAGS= +JOBS= +MAKEFLAGS= +CMAKE_CROSSOPTS= + +. ./APKBUILD + +: "$arch" +: "$builddir" +: "$checkdepends" +: "$depends" +: "$depends_dev" +: "$depends_doc" +: "$depends_libs" +: "$depends_openrc" +: "$depends_static" +: "$install" +: "$install_if" +: "$langdir" +: "$ldpath" +: "$license" +: "$makedepends" +: "$makedepends_build" +: "$makedepends_host" +: "$md5sums" +: "$options" +: "$patch_args" +: "$pkgbasedir" +: "$pkgdesc" +: "$pkgdir" +: "$pkgname" +: "$pkgrel" +: "$pkgver" +: "$pkggroups" +: "$pkgusers" +: "$provides" +: "$provider_priority" +: "$replaces" +: "$sha256sums" +: "$sha512sums" +: "$sonameprefix" +: "$source" +: "$srcdir" +: "$startdir" +: "$subpackages" +: "$subpkgdir" +: "$subpkgname" +: "$triggers" +: "$url" + +# abuild.conf + +: "$CFLAGS" +: "$CXXFLAGS" +: "$CPPFLAGS" +: "$LDFLAGS" +: "$JOBS" +: "$MAKEFLAGS" +: "$CMAKE_CROSSOPTS" diff --git a/.gitlab/bin/apkbuild-shellcheck b/.gitlab/bin/apkbuild-shellcheck new file mode 100755 index 0000000..3126684 --- /dev/null +++ b/.gitlab/bin/apkbuild-shellcheck @@ -0,0 +1,16 @@ +#!/bin/sh + +shellcheck -s ash \ + -e SC3043 \ + -e SC3057 \ + -e SC3060 \ + -e SC2016 \ + -e SC2086 \ + -e SC2169 \ + -e SC2155 \ + -e SC2100 \ + -e SC2209 \ + -e SC2030 \ + -e SC2031 \ + -e SC1090 \ + -xa $CI_PROJECT_DIR/.gitlab/bin/APKBUILD_SHIM diff --git a/.gitlab/bin/build-rootfs.sh b/.gitlab/bin/build-rootfs.sh new file mode 100755 index 0000000..44c4372 --- /dev/null +++ b/.gitlab/bin/build-rootfs.sh @@ -0,0 +1,556 @@ +#!/usr/bin/env bash +# Availabl here: https://lab.ilot.io/dotnet/arcade/-/blob/7f6d9796cc7f594772f798358dbdd8c69b6a97af/eng/common/cross/build-rootfs.sh +# Only modification: qemu-$arch-static becomes qemu-$arch + +set -e + +usage() +{ + echo "Usage: $0 [BuildArch] [CodeName] [lldbx.y] [llvmx[.y]] [--skipunmount] --rootfsdir ]" + echo "BuildArch can be: arm(default), arm64, armel, armv6, ppc64le, riscv64, s390x, x64, x86" + echo "CodeName - optional, Code name for Linux, can be: xenial(default), zesty, bionic, alpine" + echo " for alpine can be specified with version: alpineX.YY or alpineedge" + echo " for FreeBSD can be: freebsd12, freebsd13" + echo " for illumos can be: illumos" + echo " for Haiku can be: haiku." + echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FreeBSD" + echo "llvmx[.y] - optional, LLVM version for LLVM related packages." + echo "--skipunmount - optional, will skip the unmount of rootfs folder." + echo "--use-mirror - optional, use mirror URL to fetch resources, when available." + echo "--jobs N - optional, restrict to N jobs." + exit 1 +} + +__CodeName=xenial +__CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +__BuildArch=arm +__AlpineArch=armv7 +__FreeBSDArch=arm +__FreeBSDMachineArch=armv7 +__IllumosArch=arm7 +__QEMUArch=arm +__UbuntuArch=armhf +__UbuntuRepo="http://ports.ubuntu.com/" +__LLDB_Package="liblldb-3.9-dev" +__SkipUnmount=0 + +# base development support +__UbuntuPackages="build-essential" + +__AlpinePackages="alpine-base" +__AlpinePackages+=" build-base" + +# symlinks fixer +__UbuntuPackages+=" symlinks" + +# runtime dependencies +__UbuntuPackages+=" libicu-dev" +__UbuntuPackages+=" liblttng-ust-dev" +__UbuntuPackages+=" libunwind8-dev" +__UbuntuPackages+=" libnuma-dev" + +# runtime libraries' dependencies +__UbuntuPackages+=" libcurl4-openssl-dev" +__UbuntuPackages+=" libkrb5-dev" +__UbuntuPackages+=" libssl-dev" +__UbuntuPackages+=" zlib1g-dev" + +__FreeBSDBase="12.3-RELEASE" +__FreeBSDPkg="1.17.0" +__FreeBSDABI="12" +__FreeBSDPackages="libunwind" +__FreeBSDPackages+=" icu" +__FreeBSDPackages+=" libinotify" +__FreeBSDPackages+=" openssl" +__FreeBSDPackages+=" krb5" +__FreeBSDPackages+=" terminfo-db" + +__IllumosPackages="icu" +__IllumosPackages+=" mit-krb5" +__IllumosPackages+=" openssl" +__IllumosPackages+=" zlib" + +__HaikuPackages="gmp" +__HaikuPackages+=" gmp_devel" +__HaikuPackages+=" krb5" +__HaikuPackages+=" krb5_devel" +__HaikuPackages+=" libiconv" +__HaikuPackages+=" libiconv_devel" +__HaikuPackages+=" llvm12_libunwind" +__HaikuPackages+=" llvm12_libunwind_devel" +__HaikuPackages+=" mpfr" +__HaikuPackages+=" mpfr_devel" + +# ML.NET dependencies +__UbuntuPackages+=" libomp5" +__UbuntuPackages+=" libomp-dev" + +__Keyring= +__UseMirror=0 + +__UnprocessedBuildArgs= +while :; do + if [[ "$#" -le 0 ]]; then + break + fi + + lowerI="$(echo "$1" | tr "[:upper:]" "[:lower:]")" + case $lowerI in + -\?|-h|--help) + usage + exit 1 + ;; + arm) + __BuildArch=arm + __UbuntuArch=armhf + __AlpineArch=armv7 + __QEMUArch=arm + ;; + arm64) + __BuildArch=arm64 + __UbuntuArch=arm64 + __AlpineArch=aarch64 + __QEMUArch=aarch64 + __FreeBSDArch=arm64 + __FreeBSDMachineArch=aarch64 + ;; + armel) + __BuildArch=armel + __UbuntuArch=armel + __UbuntuRepo="http://ftp.debian.org/debian/" + __CodeName=jessie + ;; + armv6) + __BuildArch=armv6 + __UbuntuArch=armhf + __QEMUArch=arm + __UbuntuRepo="http://raspbian.raspberrypi.org/raspbian/" + __CodeName=buster + __LLDB_Package="liblldb-6.0-dev" + + if [[ -e "/usr/share/keyrings/raspbian-archive-keyring.gpg" ]]; then + __Keyring="--keyring /usr/share/keyrings/raspbian-archive-keyring.gpg" + fi + ;; + riscv64) + __BuildArch=riscv64 + __AlpineArch=riscv64 + __QEMUArch=riscv64 + __UbuntuArch=riscv64 + __UbuntuRepo="http://deb.debian.org/debian-ports" + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + unset __LLDB_Package + + if [[ -e "/usr/share/keyrings/debian-ports-archive-keyring.gpg" ]]; then + __Keyring="--keyring /usr/share/keyrings/debian-ports-archive-keyring.gpg --include=debian-ports-archive-keyring" + fi + ;; + ppc64le) + __BuildArch=ppc64le + __AlpineArch=ppc64le + __QEMUArch=ppc64le + __UbuntuArch=ppc64el + __UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/" + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp5/}" + unset __LLDB_Package + ;; + s390x) + __BuildArch=s390x + __AlpineArch=s390x + __QEMUArch=s390x + __UbuntuArch=s390x + __UbuntuRepo="http://ports.ubuntu.com/ubuntu-ports/" + __UbuntuPackages="${__UbuntuPackages// libunwind8-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp-dev/}" + __UbuntuPackages="${__UbuntuPackages// libomp5/}" + unset __LLDB_Package + ;; + x64) + __BuildArch=x64 + __AlpineArch=x86_64 + __QEMUArch=x86_64 + __UbuntuArch=amd64 + __FreeBSDArch=amd64 + __FreeBSDMachineArch=amd64 + __illumosArch=x86_64 + __UbuntuRepo= + ;; + x86) + __BuildArch=x86 + __AlpineArch=i386 + __QEMUArch=i386 + __UbuntuArch=i386 + __AlpineArch=x86 + __UbuntuRepo="http://archive.ubuntu.com/ubuntu/" + ;; + lldb*) + version="${lowerI/lldb/}" + parts=(${version//./ }) + + # for versions > 6.0, lldb has dropped the minor version + if [[ "${parts[0]}" -gt 6 ]]; then + version="${parts[0]}" + fi + + __LLDB_Package="liblldb-${version}-dev" + ;; + no-lldb) + unset __LLDB_Package + ;; + llvm*) + version="${lowerI/llvm/}" + parts=(${version//./ }) + __LLVM_MajorVersion="${parts[0]}" + __LLVM_MinorVersion="${parts[1]}" + + # for versions > 6.0, llvm has dropped the minor version + if [[ -z "$__LLVM_MinorVersion" && "$__LLVM_MajorVersion" -le 6 ]]; then + __LLVM_MinorVersion=0; + fi + ;; + xenial) # Ubuntu 16.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=xenial + fi + ;; + zesty) # Ubuntu 17.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=zesty + fi + ;; + bionic) # Ubuntu 18.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=bionic + fi + ;; + focal) # Ubuntu 20.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=focal + fi + ;; + jammy) # Ubuntu 22.04 + if [[ "$__CodeName" != "jessie" ]]; then + __CodeName=jammy + fi + ;; + jessie) # Debian 8 + __CodeName=jessie + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + stretch) # Debian 9 + __CodeName=stretch + __LLDB_Package="liblldb-6.0-dev" + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + buster) # Debian 10 + __CodeName=buster + __LLDB_Package="liblldb-6.0-dev" + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + bullseye) # Debian 11 + __CodeName=bullseye + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + sid) # Debian sid + __CodeName=sid + + if [[ -z "$__UbuntuRepo" ]]; then + __UbuntuRepo="http://ftp.debian.org/debian/" + fi + ;; + tizen) + __CodeName= + __UbuntuRepo= + __Tizen=tizen + ;; + alpine*) + __CodeName=alpine + __UbuntuRepo= + version="${lowerI/alpine/}" + + if [[ "$version" == "edge" ]]; then + __AlpineVersion=edge + else + parts=(${version//./ }) + __AlpineMajorVersion="${parts[0]}" + __AlpineMinoVersion="${parts[1]}" + __AlpineVersion="$__AlpineMajorVersion.$__AlpineMinoVersion" + fi + ;; + freebsd12) + __CodeName=freebsd + __SkipUnmount=1 + ;; + freebsd13) + __CodeName=freebsd + __FreeBSDBase="13.0-RELEASE" + __FreeBSDABI="13" + __SkipUnmount=1 + ;; + illumos) + __CodeName=illumos + __SkipUnmount=1 + ;; + haiku) + __CodeName=haiku + __BuildArch=x64 + __SkipUnmount=1 + ;; + --skipunmount) + __SkipUnmount=1 + ;; + --rootfsdir|-rootfsdir) + shift + __RootfsDir="$1" + ;; + --use-mirror) + __UseMirror=1 + ;; + --use-jobs) + shift + MAXJOBS=$1 + ;; + *) + __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" + ;; + esac + + shift +done + +if [[ "$__BuildArch" == "armel" ]]; then + __LLDB_Package="lldb-3.5-dev" +fi + +__UbuntuPackages+=" ${__LLDB_Package:-}" + +if [[ -n "$__LLVM_MajorVersion" ]]; then + __UbuntuPackages+=" libclang-common-${__LLVM_MajorVersion}${__LLVM_MinorVersion:+.$__LLVM_MinorVersion}-dev" +fi + +if [[ -z "$__RootfsDir" && -n "$ROOTFS_DIR" ]]; then + __RootfsDir="$ROOTFS_DIR" +fi + +if [[ -z "$__RootfsDir" ]]; then + __RootfsDir="$__CrossDir/../../../.tools/rootfs/$__BuildArch" +fi + +if [[ -d "$__RootfsDir" ]]; then + if [[ "$__SkipUnmount" == "0" ]]; then + umount "$__RootfsDir"/* || true + fi + rm -rf "$__RootfsDir" +fi + +mkdir -p "$__RootfsDir" +__RootfsDir="$( cd "$__RootfsDir" && pwd )" + +if [[ "$__CodeName" == "alpine" ]]; then + __ApkToolsVersion=2.12.11 + __ApkToolsDir="$(mktemp -d)" + + wget "https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic//v$__ApkToolsVersion/x86_64/apk.static" -P "$__ApkToolsDir" + chmod +x "$__ApkToolsDir/apk.static" + + mkdir -p "$__RootfsDir"/usr/bin + cp -v "/usr/bin/qemu-$__QEMUArch" "$__RootfsDir/usr/bin" + + if [[ "$__AlpineVersion" == "edge" ]]; then + version=edge + else + version="v$__AlpineVersion" + fi + + # initialize DB + "$__ApkToolsDir/apk.static" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -U --allow-untrusted --root "$__RootfsDir" --arch "$__AlpineArch" --initdb add + + if [[ "$__AlpineLlvmLibsLookup" == 1 ]]; then + __AlpinePackages+=" $("$__ApkToolsDir/apk.static" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -U --allow-untrusted --root "$__RootfsDir" --arch "$__AlpineArch" \ + search 'llvm*-libs' | sort | tail -1 | sed 's/-[^-]*//2g')" + fi + + # install all packages in one go + "$__ApkToolsDir/apk.static" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \ + -X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \ + -U --allow-untrusted --no-scripts --root "$__RootfsDir" --arch "$__AlpineArch" \ + add $__AlpinePackages + + rm -r "$__ApkToolsDir" +elif [[ "$__CodeName" == "freebsd" ]]; then + mkdir -p "$__RootfsDir"/usr/local/etc + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + wget -O - "https://download.freebsd.org/ftp/releases/${__FreeBSDArch}/${__FreeBSDMachineArch}/${__FreeBSDBase}/base.txz" | tar -C "$__RootfsDir" -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version + echo "ABI = \"FreeBSD:${__FreeBSDABI}:${__FreeBSDMachineArch}\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > "${__RootfsDir}"/usr/local/etc/pkg.conf + echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf + mkdir -p "$__RootfsDir"/tmp + # get and build package manager + wget -O - "https://github.com/freebsd/pkg/archive/${__FreeBSDPkg}.tar.gz" | tar -C "$__RootfsDir"/tmp -zxf - + cd "$__RootfsDir/tmp/pkg-${__FreeBSDPkg}" + # needed for install to succeed + mkdir -p "$__RootfsDir"/host/etc + ./autogen.sh && ./configure --prefix="$__RootfsDir"/host && make -j "$JOBS" && make install + rm -rf "$__RootfsDir/tmp/pkg-${__FreeBSDPkg}" + # install packages we need. + INSTALL_AS_USER=$(whoami) "$__RootfsDir"/host/sbin/pkg -r "$__RootfsDir" -C "$__RootfsDir"/usr/local/etc/pkg.conf update + INSTALL_AS_USER=$(whoami) "$__RootfsDir"/host/sbin/pkg -r "$__RootfsDir" -C "$__RootfsDir"/usr/local/etc/pkg.conf install --yes $__FreeBSDPackages +elif [[ "$__CodeName" == "illumos" ]]; then + mkdir "$__RootfsDir/tmp" + pushd "$__RootfsDir/tmp" + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + echo "Downloading sysroot." + wget -O - https://github.com/illumos/sysroot/releases/download/20181213-de6af22ae73b-v1/illumos-sysroot-i386-20181213-de6af22ae73b-v1.tar.gz | tar -C "$__RootfsDir" -xzf - + echo "Building binutils. Please wait.." + wget -O - https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf - + mkdir build-binutils && cd build-binutils + ../binutils-2.33.1/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" + make -j "$JOBS" && make install && cd .. + echo "Building gcc. Please wait.." + wget -O - https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf - + CFLAGS="-fPIC" + CXXFLAGS="-fPIC" + CXXFLAGS_FOR_TARGET="-fPIC" + CFLAGS_FOR_TARGET="-fPIC" + export CFLAGS CXXFLAGS CXXFLAGS_FOR_TARGET CFLAGS_FOR_TARGET + mkdir build-gcc && cd build-gcc + ../gcc-8.4.0/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \ + --with-gnu-ld --disable-nls --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libada --disable-libsanitizer \ + --disable-libquadmath-support --disable-shared --enable-tls + make -j "$JOBS" && make install && cd .. + BaseUrl=https://pkgsrc.smartos.org + if [[ "$__UseMirror" == 1 ]]; then + BaseUrl=https://pkgsrc.smartos.skylime.net + fi + BaseUrl="$BaseUrl/packages/SmartOS/trunk/${__illumosArch}/All" + echo "Downloading manifest" + wget "$BaseUrl" + echo "Downloading dependencies." + read -ra array <<<"$__IllumosPackages" + for package in "${array[@]}"; do + echo "Installing '$package'" + # find last occurrence of package in listing and extract its name + package="$(sed -En '/.*href="('"$package"'-[0-9].*).tgz".*/h;$!d;g;s//\1/p' All)" + echo "Resolved name '$package'" + wget "$BaseUrl"/"$package".tgz + ar -x "$package".tgz + tar --skip-old-files -xzf "$package".tmp.tg* -C "$__RootfsDir" 2>/dev/null + done + echo "Cleaning up temporary files." + popd + rm -rf "$__RootfsDir"/{tmp,+*} + mkdir -p "$__RootfsDir"/usr/include/net + mkdir -p "$__RootfsDir"/usr/include/netpacket + wget -P "$__RootfsDir"/usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/bpf.h + wget -P "$__RootfsDir"/usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h + wget -P "$__RootfsDir"/usr/include/netpacket https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h + wget -P "$__RootfsDir"/usr/include/sys https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h +elif [[ "$__CodeName" == "haiku" ]]; then + JOBS=${MAXJOBS:="$(getconf _NPROCESSORS_ONLN)"} + + echo "Building Haiku sysroot for x86_64" + mkdir -p "$__RootfsDir/tmp" + cd "$__RootfsDir/tmp" + git clone -b hrev56235 https://review.haiku-os.org/haiku + git clone -b btrev43195 https://review.haiku-os.org/buildtools + cd "$__RootfsDir/tmp/buildtools" && git checkout 7487388f5110021d400b9f3b88e1a7f310dc066d + + # Fetch some unmerged patches + cd "$__RootfsDir/tmp/haiku" + ## Add development build profile (slimmer than nightly) + git fetch origin refs/changes/64/4164/1 && git -c commit.gpgsign=false cherry-pick FETCH_HEAD + + # Build jam + cd "$__RootfsDir/tmp/buildtools/jam" + make + + # Configure cross tools + echo "Building cross-compiler" + mkdir -p "$__RootfsDir/generated" + cd "$__RootfsDir/generated" + "$__RootfsDir/tmp/haiku/configure" -j"$JOBS" --sysroot "$__RootfsDir" --cross-tools-source "$__RootfsDir/tmp/buildtools" --build-cross-tools x86_64 + + # Build Haiku packages + echo "Building Haiku" + echo 'HAIKU_BUILD_PROFILE = "development-raw" ;' > UserProfileConfig + "$__RootfsDir/tmp/buildtools/jam/jam0" -j"$JOBS" -q 'package' 'Haiku' + + BaseUrl="https://depot.haiku-os.org/__api/v2/pkg/get-pkg" + + # Download additional packages + echo "Downloading additional required packages" + read -ra array <<<"$__HaikuPackages" + for package in "${array[@]}"; do + echo "Downloading $package..." + # API documented here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L60 + # The schema here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L598 + hpkgDownloadUrl="$(wget -qO- --post-data='{"name":"'"$package"'","repositorySourceCode":"haikuports_x86_64","versionType":"LATEST","naturalLanguageCode":"en"}' \ + --header='Content-Type:application/json' "$BaseUrl" | jq -r '.result.versions[].hpkgDownloadURL')" + wget -P "$__RootfsDir/generated/download" "$hpkgDownloadUrl" + done + + # Setup the sysroot + echo "Setting up sysroot and extracting needed packages" + mkdir -p "$__RootfsDir/boot/system" + for file in "$__RootfsDir/generated/objects/haiku/x86_64/packaging/packages/"*.hpkg; do + "$__RootfsDir/generated/objects/linux/x86_64/release/tools/package/package" extract -C "$__RootfsDir/boot/system" "$file" + done + for file in "$__RootfsDir/generated/download/"*.hpkg; do + "$__RootfsDir/generated/objects/linux/x86_64/release/tools/package/package" extract -C "$__RootfsDir/boot/system" "$file" + done + + # Cleaning up temporary files + echo "Cleaning up temporary files" + rm -rf "$__RootfsDir/tmp" + for name in "$__RootfsDir/generated/"*; do + if [[ "$name" =~ "cross-tools-" ]]; then + : # Keep the cross-compiler + else + rm -rf "$name" + fi + done +elif [[ -n "$__CodeName" ]]; then + qemu-debootstrap $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo" + cp "$__CrossDir/$__BuildArch/sources.list.$__CodeName" "$__RootfsDir/etc/apt/sources.list" + chroot "$__RootfsDir" apt-get update + chroot "$__RootfsDir" apt-get -f -y install + chroot "$__RootfsDir" apt-get -y install $__UbuntuPackages + chroot "$__RootfsDir" symlinks -cr /usr + chroot "$__RootfsDir" apt-get clean + + if [[ "$__SkipUnmount" == "0" ]]; then + umount "$__RootfsDir"/* || true + fi + + if [[ "$__BuildArch" == "armel" && "$__CodeName" == "jessie" ]]; then + pushd "$__RootfsDir" + patch -p1 < "$__CrossDir/$__BuildArch/armel.jessie.patch" + popd + fi +elif [[ "$__Tizen" == "tizen" ]]; then + ROOTFS_DIR="$__RootfsDir" "$__CrossDir/tizen-build-rootfs.sh" "$__BuildArch" +else + echo "Unsupported target platform." + usage; + exit 1 +fi diff --git a/.forgejo/bin/build.sh b/.gitlab/bin/build.sh similarity index 72% rename from .forgejo/bin/build.sh rename to .gitlab/bin/build.sh index b6dcbe0..286f965 100755 --- a/.forgejo/bin/build.sh +++ b/.gitlab/bin/build.sh @@ -1,26 +1,27 @@ #!/bin/sh # shellcheck disable=SC3043 -. /usr/local/lib/functions.sh +. $CI_PROJECT_DIR/.gitlab/bin/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 REPOS="cross backports user testing community" +readonly ALPINE_REPOS="main community" 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}" +: "${MIRROR:=https://lab.ilot.io/ayakael/repo-apk/-/raw}" : "${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}" +: "${CI_ALPINE_TARGET_ARCH:=$(uname -m)}" msg() { local color=${2:-green} @@ -70,7 +71,7 @@ report() { get_release() { case $BASEBRANCH in - v*) echo "$BASEBRANCH";; + v*) echo "${BASEBRANCH%-*}";; edge) echo edge;; *) die "Branch \"$BASEBRANCH\" not supported!" esac @@ -79,8 +80,9 @@ get_release() { build_aport() { local repo="$1" aport="$2" cd "$APORTSDIR/$repo/$aport" + export CHOST=$CI_ALPINE_TARGET_ARCH if abuild -r 2>&1 | report "build-$aport"; then - checkapk 2>&1 | report "checkapk-$aport" || true + checkapk | report "checkapk-$aport" || true aport_ok="$aport_ok $repo/$aport" else aport_ng="$aport_ng $repo/$aport" @@ -90,6 +92,12 @@ build_aport() { 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 if ! abuild check_arch 2>/dev/null; then aport_na="$aport_na $repo/$aport" return 1 @@ -102,13 +110,16 @@ set_repositories_for() { 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 + 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() { @@ -128,10 +139,22 @@ setup_system() { [ "$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 + 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 + echo "PACKAGER_PRIVKEY=$HOME/.abuild/$ABUILD_KEY_NAME.rsa" >> $HOME/.abuild/abuild.conf + sudo cp $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub /etc/apk/keys/$ABUILD_KEY_NAME.rsa.pub + + # patch abuild for crosscompiling + sudo patch -p1 -d / -i $CI_PROJECT_DIR/.gitlab/patches/abuild-cross.patch + + sudo 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 @@ -180,7 +203,7 @@ 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: . +sudo chown -R $USER: . fetch_flags="-qn" debugging && fetch_flags="-v" @@ -203,6 +226,7 @@ build_start=$CI_ALPINE_BUILD_OFFSET build_limit=$CI_ALPINE_BUILD_LIMIT for repo in $(changed_repos); do + mkdir -p "$APORTSDIR"/logs "$APORTSDIR"/packages "$APORTSDIR"/keys set_repositories_for "$repo" built_aports=0 changed_aports_in_repo=$(changed_aports "$repo") @@ -243,7 +267,7 @@ for ok in $aport_ok; do done for na in $aport_na; do - msg "$na: disabled for $ARCH" yellow + msg "$na: disabled for $CI_ALPINE_TARGET_ARCH" yellow done for ng in $aport_ng; do @@ -257,4 +281,3 @@ if [ "$failed" = true ]; then elif [ -z "$aport_ok" ]; then msg "No packages found to be built." yellow fi - diff --git a/.gitlab/bin/changed-aports b/.gitlab/bin/changed-aports new file mode 100755 index 0000000..4541230 --- /dev/null +++ b/.gitlab/bin/changed-aports @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ $# -lt 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + echo "Fatal: not inside a git repository" + exit 2 +fi + +basebranch=$1 + +if ! git rev-parse --verify --quiet $basebranch >/dev/null; then + # The base branch does not eixst, probably due to a shallow clone + git fetch -v $CI_MERGE_REQUEST_PROJECT_URL.git +refs/heads/$basebranch:refs/heads/$basebranch +fi + +git --no-pager diff --diff-filter=ACMR --name-only $basebranch...HEAD -- "*/APKBUILD" | xargs -r -n1 dirname diff --git a/.gitlab/bin/functions.sh b/.gitlab/bin/functions.sh new file mode 100755 index 0000000..44de1fe --- /dev/null +++ b/.gitlab/bin/functions.sh @@ -0,0 +1,74 @@ +# shellcheck disable=SC3043 + +: + +# 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}" + + cd "$APORTSDIR" + local repo="$1" + local aports + + aports=$(git diff --name-only --diff-filter=ACMR --relative="$repo" \ + "$BASEBRANCH"...HEAD -- "*/APKBUILD" | xargs -rn1 dirname) + + # shellcheck disable=2086 + ap builddirs -d "$APORTSDIR/$repo" $aports 2>/dev/null | xargs -rn1 basename +} + +section_start() { + name=${1?arg 1 name missing} + header=${2?arg 2 header missing} + collapsed=$2 + timestamp=$(date +%s) + + options="" + case $collapsed in + yes|on|collapsed|true) options="[collapsed=true]";; + esac + + printf "\e[0Ksection_start:%d:%s%s\r\e[0K%s\n" "$timestamp" "$name" "$options" "$header" +} + +section_end() { + name=$1 + timestamp=$(date +%s) + + printf "\e[0Ksection_end:%d:%s\r\e[0K" "$timestamp" "$name" +} + +gitlab_key_to_rsa() { + KEY=$1 + TYPE=$2 + TGT=$3 + TGT_DIR=${TGT%/*} + if [ "$TGT" == "$TGT_DIR" ]; then + TGT_DIR="./" + fi + if [ ! -d "$TGT_DIR" ]; then + mkdir -p "$TGT_DIR" + fi + case $TYPE in + rsa-public) local type="PUBLIC";; + rsa-private) local type="RSA PRIVATE";; + esac + echo "-----BEGIN $type KEY-----" > "$TGT" + echo $1 | sed 's/.\{64\}/&\ +/g' >> "$TGT" + echo "-----END $type KEY-----" >> "$TGT" +} diff --git a/.gitlab/bin/lint b/.gitlab/bin/lint new file mode 100755 index 0000000..c1edcfb --- /dev/null +++ b/.gitlab/bin/lint @@ -0,0 +1,96 @@ +#!/bin/sh + +BLUE="\e[34m" +MAGENTA="\e[35m" +RESET="\e[0m" + +readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME + +verbose() { + echo "> " "$@" + # shellcheck disable=SC2068 + $@ +} + +debugging() { + [ -n "$CI_DEBUG_BUILD" ] +} + +debug() { + if debugging; then + verbose "$@" + fi +} + +# git no longer allows to execute in repositories owned by different users +sudo chown -R gitlab-runner: . + +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 "$merge_base" + git --version + git config -l + git tag merge-base "$merge_base" || { echo "Could not determine merge-base"; exit 50; } + git log --oneline --graph --decorate --all +fi + +has_problems=0 + +for PKG in $(changed-aports "$BASEBRANCH"); do + printf "$BLUE==>$RESET Linting $PKG\n" + + ( + cd "$PKG" + + repo=$(basename $(dirname $PKG)); + + if [ "$repo" == "backports" ]; then + echo "Skipping $PKG as backports (we don't care)" + continue + fi + + printf "\n\n" + printf "$BLUE" + printf '======================================================\n' + printf " parse APKBUILD:\n" + printf '======================================================' + printf "$RESET\n\n" + ( . ./APKBUILD ) || has_problems=1 + + printf "\n\n" + printf "$BLUE" + printf '======================================================\n' + printf " abuild sanitycheck:\n" + printf '======================================================' + printf "$RESET\n\n" + abuild sanitycheck || has_problems=1 + + printf "\n\n" + printf "$BLUE" + printf '======================================================\n' + printf " apkbuild-shellcheck:\n" + printf '======================================================' + printf "$RESET\n" + apkbuild-shellcheck || has_problems=1 + + printf "\n\n" + printf "$BLUE" + printf '======================================================\n' + printf " apkbuild-lint:\n" + printf '======================================================' + printf "$RESET\n\n" + apkbuild-lint APKBUILD || has_problems=1 + + return $has_problems + ) || has_problems=1 + + echo +done + +exit $has_problems diff --git a/.gitlab/bin/push.sh b/.gitlab/bin/push.sh new file mode 100755 index 0000000..e93101a --- /dev/null +++ b/.gitlab/bin/push.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# shellcheck disable=SC3043 + +. $CI_PROJECT_DIR/.gitlab/bin/functions.sh + +# shellcheck disable=SC3040 +set -eu -o pipefail + +readonly APORTSDIR=$CI_PROJECT_DIR +readonly REPOS="backports user" +readonly BASEBRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME + +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_PUB rsa-public $HOME/.abuild/$ABUILD_KEY_NAME.rsa.pub +gitlab_key_to_rsa $SSH_KEY rsa-private $HOME/.ssh/id_rsa +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 +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 pull --rebase +else + git clone git@lab.ilot.io:ayakael/repo-apk -b $BASEBRANCH $HOME/repo-apk +fi + +for i in $(find packages -type f -name "*.apk"); do + install -vDm644 $i ${i/packages/$HOME\/repo-apk} +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 + cd "$CI_PROJECT_DIR" + rm -R $repo/DUMMY +done + +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 diff --git a/.gitlab/patches/abuild-cross.patch b/.gitlab/patches/abuild-cross.patch new file mode 100644 index 0000000..50afd23 --- /dev/null +++ b/.gitlab/patches/abuild-cross.patch @@ -0,0 +1,17 @@ +diff --git a/usr/bin/abuild.orig b/usr/bin/abuild +index 71e0681..d4ae3dd 100755 +--- a/usr/bin/abuild.orig ++++ b/usr/bin/abuild +@@ -2231,7 +2231,11 @@ calcdeps() { + list_has $i $builddeps && continue + subpackages_has ${i%%[<>=]*} || builddeps="$builddeps $i" + done +- hostdeps="$EXTRADEPENDS_TARGET" ++ for i in $EXTRADEPENDS_HOST $EXTRADEPENDS_TARGET $depends $makedepends; do ++ [ "$pkgname" = "${i%%[<>=]*}" ] && continue ++ list_has $i $hostdeps && continue ++ subpackages_has ${i%%[<>=]*} || hostdeps="$hostdeps $i" ++ done + fi + } + diff --git a/ilot/authentik/APKBUILD b/ilot/authentik/APKBUILD index 72e65ad..d10a575 100644 --- a/ilot/authentik/APKBUILD +++ b/ilot/authentik/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=authentik pkgver=2024.4.3 -pkgrel=2 +pkgrel=1 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 d083ae2..1fd520c 100644 --- a/ilot/freescout/APKBUILD +++ b/ilot/freescout/APKBUILD @@ -2,7 +2,7 @@ # Contributor: Antoine Martin (ayakael) pkgname=freescout pkgver=1.8.139 -pkgrel=1 +pkgrel=0 pkgdesc="Free self-hosted help desk & shared mailbox" arch="noarch" url="freescout.net" diff --git a/ilot/listmonk/APKBUILD b/ilot/listmonk/APKBUILD index 0ad6acd..00951f0 100644 --- a/ilot/listmonk/APKBUILD +++ b/ilot/listmonk/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=listmonk pkgver=3.0.0 -pkgrel=1 +pkgrel=0 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 1381afd..38eb631 100644 --- a/ilot/loomio/APKBUILD +++ b/ilot/loomio/APKBUILD @@ -4,11 +4,10 @@ pkgname=loomio pkgver=2.21.4 _gittag=v$pkgver -pkgrel=1 +pkgrel=0 pkgdesc="A collaborative decision making tool" url="https://github.com/loomio/loomio" -# failing build -#arch="x86_64" +arch="x86_64" license="MIT" depends=" postgresql diff --git a/ilot/peertube/APKBUILD b/ilot/peertube/APKBUILD index 809936b..f50d1c1 100644 --- a/ilot/peertube/APKBUILD +++ b/ilot/peertube/APKBUILD @@ -2,10 +2,9 @@ # Contributor: Antoine Martin (ayakael) pkgname=peertube pkgver=6.0.2 -pkgrel=1 +pkgrel=0 pkgdesc="ActivityPub-federated video streaming platform using P2P directly in your web browser" -# failing build -# arch="x86_64" +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 d2bb518..44903a1 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=1 +pkgrel=0 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 48f2bbf..771466f 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=1 +pkgrel=0 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 82a1497..4a82cb3 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=1 +pkgrel=0 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 0183781..f12eac2 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=1 +pkgrel=0 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 15d12e5..784a660 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=1 +pkgrel=0 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 c5f9029..4398eae 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=1 +pkgrel=0 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 f0acb67..cea07d0 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=1 +pkgrel=0 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 43d8189..aeaad93 100644 --- a/ilot/wikijs/APKBUILD +++ b/ilot/wikijs/APKBUILD @@ -1,8 +1,9 @@ # Maintainer: Antoine Martin (ayakael) # Contributor: Antoine Martin (ayakael) + pkgname=wikijs pkgver=2.5.303 -pkgrel=1 +pkgrel=0 pkgdesc="Wiki.js | A modern, lightweight and powerful wiki app built on Node.js" license="AGPL-3.0" arch="!armv7 x86_64"