5151setup () {
5252 export DEBIAN_FRONTEND=" noninteractive"
5353
54+ APT_ARCH=" $( dpkg --print-architecture) "
55+ export APT_ARCH
56+
5457 setup_cross_compilation_apt_sources
5558
5659 echo " Installing dependencies..."
@@ -61,18 +64,22 @@ setup() {
6164}
6265
6366setup_cross_compilation_apt_sources () {
64- if [[ " ${TARGET_ARCH} " == amd64 ]]; then
67+ if [[ " ${TARGET_ARCH} " == " ${APT_ARCH} " ]]; then
6568 return
6669 fi
70+ echo " Building on ${APT_ARCH} for ${TARGET_ARCH} . Thus modifying apt..."
6771 sudo dpkg --add-architecture " ${TARGET_ARCH} "
68- # Duplicate the original Ubuntu sources and modify them to refer to the TARGET_ARCH:
69- sed -rne " s|^deb.*/ ([^ -]+(-updates)?) main.*|deb [arch=${TARGET_ARCH} ] http://ports.ubuntu.com/ubuntu-ports \1 main universe multiverse restricted|p" /etc/apt/sources.list | sudo dd of=/etc/apt/sources.list.d/" ${TARGET_ARCH} " .list
70- # Now take the original Ubuntu sources and limit those to the build host (i.e. non-TARGET_ARCH) architectures:
71- sudo sed -re ' s/^deb /deb [arch=amd64,i386] /' -i /etc/apt/sources.list
72+
73+ if [[ " ${APT_ARCH} " == " amd64" ]]; then
74+ # Duplicate the original Ubuntu sources and modify them to refer to the TARGET_ARCH:
75+ sed -rne " s|^deb.*/ ([^ -]+(-updates)?) main.*|deb [arch=${TARGET_ARCH} ] http://ports.ubuntu.com/ubuntu-ports \1 main universe multiverse restricted|p" /etc/apt/sources.list | sudo dd of=/etc/apt/sources.list.d/" ${TARGET_ARCH} " .list
76+ # Now take the original Ubuntu sources and limit those to the build host (i.e. non-TARGET_ARCH) architectures:
77+ sudo sed -re ' s/^deb /deb [arch=amd64,i386] /' -i /etc/apt/sources.list
78+ fi
7279}
7380
7481setup_cross_compiler () {
75- if [[ " ${TARGET_ARCH} " == amd64 ]]; then
82+ if [[ " ${TARGET_ARCH} " == " ${APT_ARCH} " ]]; then
7683 return
7784 fi
7885 local GCC_VERSION=9 # 9 is the default on 20.04, there is no reason not to update once 20.04 is out of support
0 commit comments