Skip to content

Commit

Permalink
fix packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Mar 3, 2025
1 parent 422b54d commit 7a7d32f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .buildkite/metricbeat/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ steps:

- label: ":ubuntu: Metricbeat: Crosscompile"
key: "mandatory-cross-compile"
command: "make -C metricbeat crosscompile"
command: |
source .buildkite/scripts/qemu.sh
make -C metricbeat crosscompile
retry:
automatic:
- limit: 1
Expand Down
16 changes: 2 additions & 14 deletions .buildkite/scripts/packaging/packaging.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
#!/usr/bin/env bash
#
# Centralise the mage package for a given beat in Buildkite.
# It enables multi-arch builds to avoid the exec format errors when
# attempting to build arm64 inside arm64 workers.
#
# For further details, see https://github.com/elastic/elastic-agent/pull/6948
# and https://github.com/elastic/golang-crossbuild/pull/507
#

set -ueo pipefail

BEAT_DIR=${1:?-"Error: Beat directory must be specified."}

if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then
echo "Skipping qemu installation on arm64 worker"
else
BINFMT_IMAGE="tonistiigi/binfmt:qemu-v9.2.2"

# Make sure to uninstall first to avoid conflicts
docker run --privileged --rm "$BINFMT_IMAGE" --uninstall qemu-*
docker run --privileged --rm "$BINFMT_IMAGE" --install all
fi
# shellcheck source=/dev/null
source .buildkite/scripts/qemu.sh

cd $BEAT_DIR
mage package
19 changes: 19 additions & 0 deletions .buildkite/scripts/qemu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
#
# It enables multi-arch builds to avoid the exec format errors when
# attempting to build arm64 inside arm64 workers.
#
# For further details, see https://github.com/elastic/elastic-agent/pull/6948
# and https://github.com/elastic/golang-crossbuild/pull/507
#
set -euo pipefail

if [[ "$(uname -m)" == "aarch64" || "$(uname -m)" == "arm64" ]]; then
echo "Skipping qemu installation on arm64 worker"
else
BINFMT_IMAGE="tonistiigi/binfmt:qemu-v9.2.2"

# Make sure to uninstall first to avoid conflicts
docker run --privileged --rm "$BINFMT_IMAGE" --uninstall qemu-*
docker run --privileged --rm "$BINFMT_IMAGE" --install all
fi
1 change: 1 addition & 0 deletions .buildkite/x-pack/pipeline.xpack.dockerlogbeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ steps:
- label: ":ubuntu: x-pack/dockerlogbeat: Ubuntu x86_64 Unit Tests"
key: "mandatory-linux-unit-test"
command: |
source .buildkite/scripts/qemu.sh
cd x-pack/dockerlogbeat
mage build unitTest
retry:
Expand Down

0 comments on commit 7a7d32f

Please sign in to comment.