From a735032a6c722ea5e2e90f1f429d4dee523c1848 Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Tue, 20 Jun 2023 17:48:52 +0400 Subject: [PATCH 1/4] fix: use host architecture to determine FreeBSD ABI This allows to get working FreeBSD agent packages on both x86 and arm64 hosts/runners. --- scripts/packages/packager/local-entrypoint.sh | 35 ++++++++++++------- .../packages/packager/signed-entrypoint.sh | 11 ++++-- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/scripts/packages/packager/local-entrypoint.sh b/scripts/packages/packager/local-entrypoint.sh index 792cf342d8..19a8446b36 100644 --- a/scripts/packages/packager/local-entrypoint.sh +++ b/scripts/packages/packager/local-entrypoint.sh @@ -4,6 +4,13 @@ set -e set -x set -euxo pipefail +case "$(uname -m)" in + amd64|x86_64) ABIARCH=amd64 ;; + arm64|aarch64) ABIARCH=aarch64 ;; +esac + +FREEBSD_DISTROS="FreeBSD:12:${ABIARCH} FreeBSD:13:${ABIARCH}" + cd /nginx-agent/ mkdir -p /staging/usr/local/bin @@ -24,17 +31,21 @@ chmod +x /staging/usr/local/etc/rc.d/nginx-agent git config --global --add safe.directory /nginx-agent VERSION="$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')-SNAPSHOT-$(git rev-parse --short HEAD)" envsubst < scripts/packages/manifest > /staging/+MANIFEST -pkg -o ABI="FreeBSD:13:amd64" create --format txz \ - -m /staging \ - -r /staging \ - -p /staging/plist \ - -o ./build/; \ - -# Creating symbolic link from txz to pkg. In older versions of pkg the extension would represent the format of the file -# but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. -# See 1.17.0 release notes for more info: https://cgit.freebsd.org/ports/commit/?id=e497a16a286972bfcab908209b11ee6a13d99dc9 -cd build/ -ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".txz -cd .. +for freebsd_abi in $FREEBSD_DISTROS; do + mkdir -p ./build/packages/txz/"$freebsd_abi" + + pkg -o ABI="$freebsd_abi" create --format txz \ + -m /staging \ + -r /staging \ + -p /staging/plist \ + -o ./build/packages/txz/"$freebsd_abi" + + # Creating symbolic link from txz to pkg. In older versions of pkg the extension would represent the format of the file + # but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. + # See 1.17.0 release notes for more info: https://cgit.freebsd.org/ports/commit/?id=e497a16a286972bfcab908209b11ee6a13d99dc9 + cd build/packages/txz/"$freebsd_abi" + ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".txz + cd ../../../../ +done rm -rf /staging diff --git a/scripts/packages/packager/signed-entrypoint.sh b/scripts/packages/packager/signed-entrypoint.sh index f4529b6fbe..0e7713c80d 100644 --- a/scripts/packages/packager/signed-entrypoint.sh +++ b/scripts/packages/packager/signed-entrypoint.sh @@ -4,7 +4,12 @@ set -e set -x set -euxo pipefail -FREEBSD_DISTROS="FreeBSD:12:amd64 FreeBSD:13:amd64" +case "$(uname -m)" in + amd64|x86_64) ABIARCH=amd64 ;; + arm64|aarch64) ABIARCH=aarch64 ;; +esac + +FREEBSD_DISTROS="FreeBSD:12:${ABIARCH} FreeBSD:13:${ABIARCH}" cd /nginx-agent/ @@ -39,8 +44,8 @@ for freebsd_abi in $FREEBSD_DISTROS; do \ -o ./build/packages/txz/"$freebsd_abi"; \ # create freebsd pkg repo layout pkg repo ./build/packages/txz/"$freebsd_abi" .key.rsa; \ - # Creating symbolic link from txz to pkg. In older versions of pkg the extension would represent the format of the file - # but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. + # Creating symbolic link from txz to pkg. In older versions of pkg the extension would represent the format of the file + # but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. # See 1.17.0 release notes for more info: https://cgit.freebsd.org/ports/commit/?id=e497a16a286972bfcab908209b11ee6a13d99dc9 cd build/packages/txz/"$freebsd_abi"; \ ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')".pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')".txz; \ From 72ba74c47948f198728c60e6851f99ab48d0a9d8 Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Tue, 20 Jun 2023 18:05:06 +0400 Subject: [PATCH 2/4] CI: pick FreeBSD 13 package for unsigned snapshot --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f42b99a33..0ba6c9daec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -230,6 +230,7 @@ jobs: - name: Build Packages run: | make clean local-deb-package local-rpm-package local-txz-package local-apk-package + cp ./build/packages/txz/FreeBSD:13:*/*.pkg ./build/ tar -cf ./build/nginx-agent-snapshots.tar.gz ./build/*.deb ./build/*.rpm ./build/*.pkg ./build/*.apk - name: Upload Artifacts uses: actions/upload-artifact@v3 From b3110f1ded15f9253ad2d63371d8af86f83af105 Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Mon, 26 Jun 2023 18:43:02 +0400 Subject: [PATCH 3/4] Build FreeBSD 13 only version with local-txz-package --- .github/workflows/ci.yml | 1 - scripts/packages/packager/local-entrypoint.sh | 32 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ba6c9daec..4f42b99a33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -230,7 +230,6 @@ jobs: - name: Build Packages run: | make clean local-deb-package local-rpm-package local-txz-package local-apk-package - cp ./build/packages/txz/FreeBSD:13:*/*.pkg ./build/ tar -cf ./build/nginx-agent-snapshots.tar.gz ./build/*.deb ./build/*.rpm ./build/*.pkg ./build/*.apk - name: Upload Artifacts uses: actions/upload-artifact@v3 diff --git a/scripts/packages/packager/local-entrypoint.sh b/scripts/packages/packager/local-entrypoint.sh index 19a8446b36..d4e628f8c5 100644 --- a/scripts/packages/packager/local-entrypoint.sh +++ b/scripts/packages/packager/local-entrypoint.sh @@ -9,8 +9,6 @@ case "$(uname -m)" in arm64|aarch64) ABIARCH=aarch64 ;; esac -FREEBSD_DISTROS="FreeBSD:12:${ABIARCH} FreeBSD:13:${ABIARCH}" - cd /nginx-agent/ mkdir -p /staging/usr/local/bin @@ -31,21 +29,19 @@ chmod +x /staging/usr/local/etc/rc.d/nginx-agent git config --global --add safe.directory /nginx-agent VERSION="$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')-SNAPSHOT-$(git rev-parse --short HEAD)" envsubst < scripts/packages/manifest > /staging/+MANIFEST -for freebsd_abi in $FREEBSD_DISTROS; do - mkdir -p ./build/packages/txz/"$freebsd_abi" - - pkg -o ABI="$freebsd_abi" create --format txz \ - -m /staging \ - -r /staging \ - -p /staging/plist \ - -o ./build/packages/txz/"$freebsd_abi" - - # Creating symbolic link from txz to pkg. In older versions of pkg the extension would represent the format of the file - # but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. - # See 1.17.0 release notes for more info: https://cgit.freebsd.org/ports/commit/?id=e497a16a286972bfcab908209b11ee6a13d99dc9 - cd build/packages/txz/"$freebsd_abi" - ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".txz - cd ../../../../ -done +mkdir -p ./build + +pkg -o ABI="FreeBSD:13:${ABIARCH}" create --format txz \ + -m /staging \ + -r /staging \ + -p /staging/plist \ + -o ./build + +# Creating symbolic link from txz to pkg. In older versions of pkg the extension would represent the format of the file +# but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. +# See 1.17.0 release notes for more info: https://cgit.freebsd.org/ports/commit/?id=e497a16a286972bfcab908209b11ee6a13d99dc9 +cd build +ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".txz +cd ../ rm -rf /staging From 5e8c0917af5d27bf2b6b4b7f0bfc994b02e9cc41 Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Fri, 30 Jun 2023 15:44:01 +0400 Subject: [PATCH 4/4] Revert functional changes in signed txz builder entrypoint --- scripts/packages/packager/signed-entrypoint.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/packages/packager/signed-entrypoint.sh b/scripts/packages/packager/signed-entrypoint.sh index 0e7713c80d..cb899ccb3d 100644 --- a/scripts/packages/packager/signed-entrypoint.sh +++ b/scripts/packages/packager/signed-entrypoint.sh @@ -4,12 +4,7 @@ set -e set -x set -euxo pipefail -case "$(uname -m)" in - amd64|x86_64) ABIARCH=amd64 ;; - arm64|aarch64) ABIARCH=aarch64 ;; -esac - -FREEBSD_DISTROS="FreeBSD:12:${ABIARCH} FreeBSD:13:${ABIARCH}" +FREEBSD_DISTROS="FreeBSD:12:amd64 FreeBSD:13:amd64" cd /nginx-agent/