Skip to content

Commit 3b232b3

Browse files
authored
fix: install arm64 system deps for aarch64 cross-compilation (#1436)
1 parent a2aa6da commit 3b232b3

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

.github/workflows/_rust-binary.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,25 @@ jobs:
208208

209209
- name: Install additional system dependencies
210210
if: runner.os == 'Linux' && inputs.system_deps != ''
211+
env:
212+
BUILD_TARGET: ${{ matrix.target }}
211213
run: |
212214
sudo apt-get update
213-
sudo apt-get install -y ${{ inputs.system_deps }}
215+
case "$BUILD_TARGET" in
216+
aarch64-unknown-linux-gnu)
217+
sudo dpkg --add-architecture arm64
218+
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
219+
echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -cs) main restricted universe" | sudo tee /etc/apt/sources.list.d/arm64.list
220+
echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -cs)-updates main restricted universe" | sudo tee -a /etc/apt/sources.list.d/arm64.list
221+
sudo apt-get update
222+
for pkg in ${{ inputs.system_deps }}; do
223+
sudo apt-get install -y "${pkg}:arm64"
224+
done
225+
;;
226+
*)
227+
sudo apt-get install -y ${{ inputs.system_deps }}
228+
;;
229+
esac
214230
215231
- name: Install cross-compilation tools
216232
if: runner.os == 'Linux'

engine/install.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,60 @@ if [ -n "$init_target" ]; then
473473
fi
474474
fi
475475

476+
# ---------------------------------------------------------------------------
477+
# Install iii-worker (VM-based isolated worker runtime)
478+
# The worker needs glibc on Linux (for KVM/msb_krun) and is not available
479+
# for x86_64-apple-darwin (no firmware).
480+
# ---------------------------------------------------------------------------
481+
worker_target=""
482+
case "$uname_s" in
483+
Linux)
484+
case "$arch" in
485+
x86_64) worker_target="x86_64-unknown-linux-gnu" ;;
486+
aarch64) worker_target="aarch64-unknown-linux-gnu" ;;
487+
esac
488+
;;
489+
Darwin)
490+
case "$arch" in
491+
aarch64) worker_target="aarch64-apple-darwin" ;;
492+
esac
493+
;;
494+
esac
495+
496+
if [ -n "$worker_target" ]; then
497+
worker_asset_name="iii-worker-${worker_target}.tar.gz"
498+
499+
if command -v jq >/dev/null 2>&1; then
500+
worker_asset_url=$(printf '%s' "$json" \
501+
| jq -r --arg name "$worker_asset_name" \
502+
'.assets[] | select(.name == $name) | .browser_download_url' \
503+
| head -n 1)
504+
else
505+
worker_asset_url=$(printf '%s' "$json" \
506+
| grep -oE '"browser_download_url"[[:space:]]*:[[:space:]]*"[^"]+"' \
507+
| sed -E 's/.*"([^"]+)".*/\1/' \
508+
| grep -F "$worker_asset_name" \
509+
| head -n 1)
510+
fi
511+
512+
if [ -n "$worker_asset_url" ]; then
513+
curl -fsSL -L "$worker_asset_url" -o "$tmpdir/$worker_asset_name" 2>/dev/null
514+
if [ $? -eq 0 ]; then
515+
tar -xzf "$tmpdir/$worker_asset_name" -C "$tmpdir" 2>/dev/null
516+
worker_bin_file=$(find "$tmpdir" -type f -name "iii-worker" | head -n 1)
517+
if [ -n "$worker_bin_file" ] && [ -f "$worker_bin_file" ]; then
518+
if command -v install >/dev/null 2>&1; then
519+
install -m 755 "$worker_bin_file" "$bin_dir/iii-worker"
520+
else
521+
cp "$worker_bin_file" "$bin_dir/iii-worker"
522+
chmod 755 "$bin_dir/iii-worker"
523+
fi
524+
printf 'installed %s to %s\n' "iii-worker" "$bin_dir/iii-worker"
525+
fi
526+
fi
527+
fi
528+
fi
529+
476530
if [ "$install_event_prefix" = "upgrade" ]; then
477531
payload=$(printf '{"from_version":%s,"to_version":%s,"install_method":"sh","target_binary":%s}' \
478532
"$(json_str "$from_version")" "$(json_str "$installed_version")" "$(json_str "$BIN_NAME")")

0 commit comments

Comments
 (0)