Skip to content

Commit 0cebfe9

Browse files
committed
Use setup/ubuntu action for cross-compiling
1 parent a142602 commit 0cebfe9

2 files changed

Lines changed: 27 additions & 18 deletions

File tree

.github/actions/setup/ubuntu/action.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,42 @@ runs:
2424
using: composite
2525

2626
steps:
27+
- id: uname
28+
name: uname
29+
shell: bash
30+
env:
31+
arch: ${{ inputs.arch }}
32+
run: |
33+
setarch="${arch:+setarch $arch --}"
34+
# normalize `uname`
35+
if uname=$(${setarch} uname -m 2> /dev/null); then
36+
echo "setarch=${setarch}" >> "$GITHUB_OUTPUT"
37+
else
38+
# if `setarch` failed, take the given `arch` as-is.
39+
uname="${arch}"
40+
setarch=""
41+
fi
42+
echo "uname=$uname" >> "$GITHUB_OUTPUT"
43+
echo "dpkg=${uname/686/386}" >> "$GITHUB_OUTPUT"
44+
2745
- name: set SETARCH
2846
shell: bash
2947
run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
3048
env:
31-
setarch: ${{ inputs.arch && format('setarch {0} --', inputs.arch) }}
49+
setarch: ${{ steps.uname.outputs.setarch }}
3250

33-
- id: uname
34-
name: uname
51+
- name: dpkg setup
3552
shell: bash
3653
run: |
37-
echo uname=`${SETARCH} uname -m` >> "$GITHUB_OUTPUT"
38-
echo dpkg=`${SETARCH} uname -m | sed s/686/386/` >> "$GITHUB_OUTPUT"
54+
sudo dpkg --add-architecture ${{ steps.uname.outputs.dpkg }}
55+
if: ${{ inputs.arch }}
3956

4057
- name: apt-get
4158
shell: bash
4259
env:
4360
arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }}
4461
run: |
4562
set -x
46-
${arch:+sudo dpkg --add-architecture ${arch#:}}
4763
sudo apt-get update -qq || :
4864
sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \
4965
${arch:+cross}build-essential${arch/:/-} \

.github/workflows/crosscompile.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ jobs:
6464
builddir: build
6565
makeup: true
6666

67-
- name: Install cross-compilation toolchain
67+
- name: Setup cross-compilation toolchain sources
6868
run: |
69-
sudo dpkg --add-architecture ${{ matrix.arch }}
7069
native_arch=$(dpkg --print-architecture)
7170
# Restrict existing sources to native arch
7271
sudo sed -i '/^Architectures:/d' /etc/apt/sources.list.d/ubuntu.sources
@@ -84,16 +83,10 @@ jobs:
8483
"Components: main universe" \
8584
"Architectures: ${{ matrix.arch }}" \
8685
| sudo tee /etc/apt/sources.list.d/cross-${{ matrix.arch }}.sources
87-
sudo apt-get update -qq
88-
sudo apt-get install --no-install-recommends -qq -y \
89-
crossbuild-essential-${{ matrix.arch }} \
90-
libssl-dev:${{ matrix.arch }} \
91-
libyaml-dev:${{ matrix.arch }} \
92-
zlib1g-dev:${{ matrix.arch }} \
93-
libffi-dev:${{ matrix.arch }} \
94-
libreadline-dev:${{ matrix.arch }} \
95-
libncurses-dev:${{ matrix.arch }} \
96-
autoconf ruby
86+
87+
- uses: ./.github/actions/setup/ubuntu
88+
with:
89+
arch: ${{ matrix.arch }}
9790

9891
- uses: ./.github/actions/setup/baseruby
9992
id: baseruby

0 commit comments

Comments
 (0)