Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
- name: "Install QEMU"
run: |
set -x
if [[ "${{ inputs.platform }}" == "arm64" && "$(uname -m)" != "aarch64" ]]; then
if [[ "${{ inputs.platform }}" != "$(dpkg --print-architecture)" ]]; then
echo "Installing QEMU"
sudo apt-get update -qq && sudo apt-get install -y qemu-user-static
else
Expand Down
14 changes: 11 additions & 3 deletions mkimage
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ cp -a "${ROOT}/debootstrap/"* "${DEBOOTSTRAP_DIR}/scripts"
KEYRING=$DEBOOTSTRAP_DIR/debian-archive-keyring.gpg

use_qemu_static() {
[[ "$PLATFORM" == "arm64" && ! ( "$(uname -m)" == *arm* || "$(uname -m)" == *aarch64* ) ]]
[[ "$PLATFORM" != "$(dpkg --print-architecture)" ]]
}

qemu_static_arch() {
case "$PLATFORM" in
amd64) echo x86_64 ;;
arm64) echo aarch64 ;;
*) echo "$PLATFORM" ;;
esac
}

export DEBIAN_FRONTEND=noninteractive
Expand Down Expand Up @@ -60,10 +68,10 @@ rootfs_chroot() {
if use_qemu_static ; then
echo "Setting up qemu static in chroot"
usr_bin_modification_time=$(stat -c %y "$rootfsDir"/usr/bin)
if [ -f "/usr/bin/qemu-aarch64-static" ]; then
if [ -f "/usr/bin/qemu-$(qemu_static_arch)-static" ]; then
find /usr/bin/ -type f -name 'qemu-*-static' -exec cp {} "$rootfsDir"/usr/bin/. \;
else
echo "Cannot find aarch64 qemu static. Aborting..." >&2
echo "Cannot find $(qemu_static_arch) qemu static. Aborting..." >&2
exit 1
fi
touch -d "$usr_bin_modification_time" "$rootfsDir"/usr/bin
Expand Down
16 changes: 6 additions & 10 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@ function test() {

bind_mounts=( )
docker_platform_args=( )
if [[ "$PLATFORM" == "arm64" ]]; then
if [[ "$(uname -m)" == *arm* || "$(uname -m)" == *aarch64* ]]; then
echo "Running in arm host. QEMU is not needed"
else
echo "Setting up qemu static"
for qemu_static_file in /usr/bin/qemu-*-static; do
bind_mounts+=( -v="$qemu_static_file:$qemu_static_file" )
done
docker_platform_args+=( --platform "linux/arm64" )
fi
if [[ "$PLATFORM" != "$(dpkg --print-architecture)" ]]; then
echo "Setting up qemu static"
for qemu_static_file in /usr/bin/qemu-*-static; do
bind_mounts+=( -v="$qemu_static_file:$qemu_static_file" )
done
docker_platform_args+=( --platform "linux/$PLATFORM" )
fi

function test_extra_args() {
Expand Down
Loading