5050
5151setup () {
5252 export DEBIAN_FRONTEND=" noninteractive"
53+ export APT_ARCH=" $( dpkg --print-architecture) "
5354
5455 setup_cross_compilation_apt_sources
5556
@@ -61,18 +62,22 @@ setup() {
6162}
6263
6364setup_cross_compilation_apt_sources () {
64- if [[ " ${TARGET_ARCH} " == amd64 ]]; then
65+ if [[ " ${TARGET_ARCH} " == " ${APT_ARCH} " ]]; then
6566 return
6667 fi
68+ echo " Building on ${APT_ARCH} for ${TARGET_ARCH} . Thus modifying apt..."
6769 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
70+
71+ if [[ " ${APT_ARCH} " == " amd64" ]]; then
72+ # Duplicate the original Ubuntu sources and modify them to refer to the TARGET_ARCH:
73+ 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
74+ # Now take the original Ubuntu sources and limit those to the build host (i.e. non-TARGET_ARCH) architectures:
75+ sudo sed -re ' s/^deb /deb [arch=amd64,i386] /' -i /etc/apt/sources.list
76+ fi
7277}
7378
7479setup_cross_compiler () {
75- if [[ " ${TARGET_ARCH} " == amd64 ]]; then
80+ if [[ " ${TARGET_ARCH} " == " ${APT_ARCH} " ]]; then
7681 return
7782 fi
7883 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