-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yml
97 lines (97 loc) · 4.57 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: "Cross-Compile Support on Ubuntu"
description: "Adds APT package repository for Ubuntu architecture and installs cross-compile packages from it."
inputs:
arch:
description: "A valid Ubuntu [arch] like arm64, armhf or i386"
required: true
default: "arm64"
runs:
using: "composite"
steps:
- name: "Add repository and install packages"
shell: bash
env:
ARCH: ${{ inputs.arch }}
run: |
export HOSTARCH=$(dpkg --print-architecture)
export CODENAME=$(lsb_release -c -s)
export APTFILE=/etc/apt/sources.list.d/$ARCH-cross-compile-sources.list
sudo dpkg --add-architecture $ARCH
if [ $CODENAME == noble ]; then \
export DEFAULTAPTFILE=/etc/apt/sources.list.d/ubuntu.sources; \
export REPLACETHIS="Components: main universe restricted multiverse"; \
if [ $ARCH == i386 ]; then \
sudo sed -i 's/'"$REPLACETHIS"'/'"$REPLACETHIS"'\nArchitectures: amd64 i386/g' $DEFAULTAPTFILE; \
else \
sudo sed -i 's/'"$REPLACETHIS"'/'"$REPLACETHIS"'\nArchitectures: amd64/g' $DEFAULTAPTFILE; \
fi \
else \
export DEFAULTAPTFILE=/etc/apt/sources.list; \
if [ $ARCH == i386 ]; then \
sudo sed -i 's/deb http/deb [arch=amd64,i386] http/g' $DEFAULTAPTFILE; \
sudo sed -i 's/deb mirror/deb [arch=amd64,i386] mirror/g' $DEFAULTAPTFILE; \
else \
sudo sed -i 's/deb http/deb [arch=amd64] http/g' $DEFAULTAPTFILE; \
sudo sed -i 's/deb mirror/deb [arch=amd64] mirror/g' $DEFAULTAPTFILE; \
fi \
fi
if [ $ARCH != amd64 ] && [ $ARCH != i386 ]; then \
sudo bash -c "echo -e '\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME main restricted \n\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME-updates main restricted \n\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME universe \n\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME-updates universe \n\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME multiverse \n\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME-updates multiverse \n\
deb [arch=$ARCH] http://ports.ubuntu.com/ $CODENAME-backports main restricted universe multiverse \n' > $APTFILE"; \
fi
sudo apt-get update
sudo apt-get install -y \
libstdc++6-$ARCH-cross \
libc6-dev-$ARCH-cross \
libc6-dev:$ARCH \
linux-libc-dev-$ARCH-cross \
linux-libc-dev:$ARCH
if [ $ARCH != amd64 ] && [ $ARCH != i386 ]; then \
sudo apt-get install -y crossbuild-essential-$ARCH; \
fi
if [ $ARCH == amd64 ]; then export ARCHGCC=x86-64-linux-gnu; fi
if [ $ARCH == i386 ]; then export ARCHGCC=i686-linux-gnu; fi
if [ $ARCH == arm64 ]; then export ARCHGCC=aarch64-linux-gnu; fi
if [ $ARCH == armhf ]; then export ARCHGCC=arm-linux-gnueabihf; fi
if [ $ARCH == armel ]; then export ARCHGCC=arm-linux-gnueabi; fi
if [ $ARCH == mips64 ]; then export ARCHGCC=mips64-linux-gnuabi64; fi
if [ $ARCH == mips64el ]; then export ARCHGCC=mips64el-linux-gnuabi64-gcc; fi
if [ $ARCH == ppc64 ]; then export ARCHGCC=powerpc64-linux-gnu; fi
if [ $ARCH == ppc64el ]; then export ARCHGCC=powerpc64le-linux-gnu; fi
if [ $ARCH == riscv64 ]; then export ARCHGCC=riscv64-linux-gnu; fi
if [ $ARCH == s390x ]; then export ARCHGCC=s390x-linux-gnu; fi
if [ $ARCH == sparc64 ]; then export ARCHGCC=sparc64-linux-gnu; fi
if [ $CODENAME == bionic ]; then \
sudo apt-get install -y \
gcc-8-$ARCHGCC \
g++-8-$ARCHGCC \
libstdc++-8-dev-$ARCH-cross \
libstdc++-8-dev:$ARCH; \
fi
if [ $CODENAME == focal ]; then \
sudo apt-get install -y \
gcc-10-$ARCHGCC \
g++-10-$ARCHGCC \
libstdc++-10-dev-$ARCH-cross \
libstdc++-10-dev:$ARCH; \
fi
if [ $CODENAME == jammy ]; then \
sudo apt-get install -y \
gcc-11-$ARCHGCC \
g++-11-$ARCHGCC \
libstdc++-11-dev-$ARCH-cross \
libstdc++-11-dev:$ARCH; \
fi
if [ $CODENAME == noble ]; then \
sudo apt-get install -y \
gcc-13-$ARCHGCC \
g++-13-$ARCHGCC \
libstdc++-11-dev-$ARCH-cross \
libstdc++-11-dev:$ARCH; \
fi