From 424288fedd0e8460ab9baf51a4fbe8f7b7734604 Mon Sep 17 00:00:00 2001 From: Doridian Date: Sat, 14 Dec 2024 08:57:48 -0800 Subject: [PATCH 1/5] Add basic structure for kernel failover --- build-container/entrypoint.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build-container/entrypoint.sh b/build-container/entrypoint.sh index 1766e00..233e6f1 100755 --- a/build-container/entrypoint.sh +++ b/build-container/entrypoint.sh @@ -24,14 +24,20 @@ build() { sudo bash build.sh -d "$1" make } -build utils +failover() { + +} -build std -build lts -build hardened -build zen +# These packages must always build +build utils build dkms +# These are kernel dependant, so they might fail +build std || failover std +build lts || failover lts +build hardened || failover hardened +build zen || failover zen + # Not implemented, yet, as documented in archzfs-ci # sudo bash test.sh ... From aff11406c4423551a2cc0b596841bd9a3ae098f5 Mon Sep 17 00:00:00 2001 From: Doridian Date: Sat, 14 Dec 2024 09:39:52 -0800 Subject: [PATCH 2/5] Download previous if we fail --- .github/workflows/release.yml | 11 ++++--- build-container/entrypoint.sh | 55 +++++++++++++++++++++++++++++++---- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f50105..f4d680b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,9 @@ concurrency: permissions: contents: write +env: + RELEASE_NAME: experimental + jobs: release: name: Release @@ -33,12 +36,12 @@ jobs: env: GPG_KEY_DATA: "${{ secrets.GPG_KEY_DATA }}" GPG_KEY_ID: "${{ vars.GPG_KEY_ID }}" - run: docker run -e GPG_KEY_DATA -e GPG_KEY_ID --privileged --rm -v "$(pwd):/src" archzfs-builder + run: docker run -e GPG_KEY_DATA -e GPG_KEY_ID -e RELEASE_NAME --privileged --rm -v "$(pwd):/src" archzfs-builder - name: Release mainline uses: ncipollo/release-action@v1.14.0 with: - name: experimental - tag: experimental + name: ${{ env.RELEASE_NAME }} + tag: ${{ env.RELEASE_NAME }} commit: ${{ github.sha }} artifacts: ./repo/* allowUpdates: true @@ -48,5 +51,5 @@ jobs: removeArtifacts: true - uses: rickstaa/action-create-tag@v1.7.2 with: - tag: experimental + tag: ${{ env.RELEASE_NAME }} force_push_tag: true diff --git a/build-container/entrypoint.sh b/build-container/entrypoint.sh index 233e6f1..ed939b8 100755 --- a/build-container/entrypoint.sh +++ b/build-container/entrypoint.sh @@ -12,31 +12,74 @@ fi # Only set -x here so we can't accidently print the GPG key up there set -x +FAILOVER_REPO_DIR="" +FAILOVER_BASE_URL="" +if [ ! -z "${RELEASE_TYPE}" ]; then + FAILOVER_REPO_DIR="$(mktemp -d)" + cd "${FAILOVER_REPO_DIR}" + FAILOVER_BASE_URL="https://github.com/archzfs/archzfs/releases/download/${RELEASE_TYPE}" + curl -sL "${FAILOVER_BASE_URL}/archzfs.db.tar.xz" | tar xvJ +fi + sudo chown -R buildbot:buildbot /src cd /src sed -i "/^THREADS=/s/9/$(nproc)/" ~/.config/clean-chroot-manager.conf sudo ccm64 d || true -sudo bash build.sh -d -u all update +sudo bash build.sh -s -d -u all update build() { - sudo bash build.sh -d "$1" make + sudo bash build.sh -s -d "$1" make } failover() { + if [ -z "${FAILOVER_REPO_DIR}" ]; then + echo "No failover repo available, failing because of: $1" + exit 1 + fi + failed_pkg="$1" + + set +x # This gets way to verbose + for desc in "${FAILOVER_REPO_DIR}"/*/desc; do + + # Iterate lines + pkgbase="" + pkgfile="" + while read -r line; do + case "$line" in + %FILENAME%) + read -r pkgfile + ;; + %BASE%) + read -r pkgbase + ;; + esac + done < "$desc" + + # If BASE is us, that means we should have built this package + # so copy it from releases + if [[ "${pkgbase}" == "${failed_pkg}" ]]; then + tmp_file="$(mktemp)" + curl -o "${tmp_file}" -L "${FAILOVER_BASE_URL}/${pkgfile}" + sudo mv "${tmp_file}" "/scratch/.buildroot/root/repo/${pkgfile}" + fi + done + set -x } +sudo mkdir -p /scratch/.buildroot/root/repo + # These packages must always build build utils build dkms # These are kernel dependant, so they might fail -build std || failover std -build lts || failover lts -build hardened || failover hardened -build zen || failover zen +build std || failover zfs-linux +build lts || failover zfs-linux-lts +build hardened || failover zfs-linux-hardened +build zen || failover zfs-linux-zen # Not implemented, yet, as documented in archzfs-ci # sudo bash test.sh ... From b8ee6c8787cc2b05c9a7df1ff67101f286de9994 Mon Sep 17 00:00:00 2001 From: Doridian Date: Sat, 14 Dec 2024 09:45:29 -0800 Subject: [PATCH 3/5] log these cmds --- build-container/entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-container/entrypoint.sh b/build-container/entrypoint.sh index ed939b8..6201340 100755 --- a/build-container/entrypoint.sh +++ b/build-container/entrypoint.sh @@ -61,9 +61,11 @@ failover() { # If BASE is us, that means we should have built this package # so copy it from releases if [[ "${pkgbase}" == "${failed_pkg}" ]]; then + set -x tmp_file="$(mktemp)" curl -o "${tmp_file}" -L "${FAILOVER_BASE_URL}/${pkgfile}" sudo mv "${tmp_file}" "/scratch/.buildroot/root/repo/${pkgfile}" + set +x fi done set -x From b4cc5b38a446bd3421ba3b5d7309dd3cd84dc6a0 Mon Sep 17 00:00:00 2001 From: Doridian Date: Tue, 17 Dec 2024 13:32:46 -0800 Subject: [PATCH 4/5] Only mkdir it after required pkgs --- build-container/entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-container/entrypoint.sh b/build-container/entrypoint.sh index 6201340..eeee0b5 100755 --- a/build-container/entrypoint.sh +++ b/build-container/entrypoint.sh @@ -71,12 +71,12 @@ failover() { set -x } -sudo mkdir -p /scratch/.buildroot/root/repo - # These packages must always build build utils build dkms +sudo mkdir -p /scratch/.buildroot/root/repo + # These are kernel dependant, so they might fail build std || failover zfs-linux build lts || failover zfs-linux-lts From 10cd352862666faa72de0faef47cf975877f5bd2 Mon Sep 17 00:00:00 2001 From: Doridian Date: Tue, 17 Dec 2024 13:42:36 -0800 Subject: [PATCH 5/5] Build LTS first, never mkdir by hand --- build-container/entrypoint.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build-container/entrypoint.sh b/build-container/entrypoint.sh index eeee0b5..c8c1df0 100755 --- a/build-container/entrypoint.sh +++ b/build-container/entrypoint.sh @@ -75,11 +75,9 @@ failover() { build utils build dkms -sudo mkdir -p /scratch/.buildroot/root/repo - # These are kernel dependant, so they might fail -build std || failover zfs-linux build lts || failover zfs-linux-lts +build std || failover zfs-linux build hardened || failover zfs-linux-hardened build zen || failover zfs-linux-zen