1
-
2
1
#! /bin/bash
3
2
if [ $# != 2 ]; then
4
3
echo " Please use: setup_build.sh [dist] [arch]"
13
12
disttype=" debian"
14
13
fi
15
14
16
- # Determine base apt repository URL based on type of distribution.
15
+ if [ " $dist " = " focal" ]; then
16
+ ubuntu_ports=" /ubuntu-ports"
17
+ fi
18
+ # Determine base apt repository URL based on type of distribution and architecture.
17
19
case " $disttype " in
18
20
ubuntu)
19
- url=http://archive.ubuntu.com/ubuntu
20
- ;;
21
+ if [ " $arch " = " arm64" ] || [ " $arch " = " armhf" ]; then
22
+ url=http://ports.ubuntu.com/ubuntu-ports
23
+ else
24
+ url=http://archive.ubuntu.com/ubuntu
25
+ fi
26
+ ;;
21
27
debian)
22
28
url=http://deb.debian.org/debian
23
29
;;
@@ -31,12 +37,34 @@ sbuild-createchroot \
31
37
${dist} ` mktemp -d` ${url}
32
38
33
39
# Ubuntu has the main and ports repositories on different URLs, so we need to
34
- # properly set up /etc/apt/sources.list to make cross compilation work.
40
+ # properly set up /etc/apt/sources.list to make cross compilation work
41
+ # and enable multi-architecture support inside a chroot environment
35
42
if [ " $disttype " = " ubuntu" ]; then
43
+ schroot -c source:${dist} -${arch} -sbuild -d / -- dpkg --add-architecture i386
44
+ schroot -c source:${dist} -${arch} -sbuild -d / -- dpkg --add-architecture armhf
45
+ schroot -c source:${dist} -${arch} -sbuild -d / -- dpkg --add-architecture arm64
46
+ # Update /etc/apt/sources.list for cross-compilation (Ubuntu)
36
47
cat << __END__ | schroot -c source:${dist} -${arch} -sbuild -d / -- tee /etc/apt/sources.list
37
48
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu ${dist} main universe
38
49
deb [arch=amd64,i386] http://archive.ubuntu.com/ubuntu ${dist} -updates main universe
39
- deb [arch=armhf,arm64] http://ports.ubuntu.com ${dist} main universe
40
- deb [arch=armhf,arm64] http://ports.ubuntu.com ${dist} -updates main universe
50
+ deb [arch=armhf,arm64] http://ports.ubuntu.com${ubuntu_ports} ${dist} main universe
51
+ deb [arch=armhf,arm64] http://ports.ubuntu.com${ubuntu_ports} ${dist} -updates main universe
52
+ __END__
53
+
54
+ elif [ " $disttype " = " debian" ]; then
55
+ # enable multi-architecture support inside a chroot environment
56
+ schroot -c source:${dist} -${arch} -sbuild -d / -- dpkg --add-architecture i386
57
+ schroot -c source:${dist} -${arch} -sbuild -d / -- dpkg --add-architecture armhf
58
+ schroot -c source:${dist} -${arch} -sbuild -d / -- dpkg --add-architecture arm64
59
+ # Update /etc/apt/sources.list for cross-compilation (Debian)
60
+ cat << __END__ | schroot -c source:${dist} -${arch} -sbuild -d / -- tee /etc/apt/sources.list
61
+ deb [arch=amd64,i386,armhf,arm64] http://deb.debian.org/debian ${dist} main contrib non-free non-free-firmware
62
+ deb [arch=amd64,i386,armhf,arm64] http://deb.debian.org/debian ${dist} -updates main contrib non-free non-free-firmware
63
+ deb [arch=amd64,i386,armhf,arm64] http://deb.debian.org/debian-security ${dist} -security main contrib non-free non-free-firmware
41
64
__END__
42
65
fi
66
+ if [ " $dist " = " focal" ]; then
67
+ # Install gcc-10 and g++-10 which are required in case of Ubuntu Focal to support Ranges library, introduced in C++20
68
+ schroot -c source:${dist} -${arch} -sbuild -d / -- bash -c " apt update && apt remove -y gcc-9 g++-9 gcc-9-base && apt upgrade -yqq && apt install -y gcc build-essential gcc-10 g++-10 clang-format clang lcov openssl"
69
+ schroot -c source:${dist} -${arch} -sbuild -d / -- bash -c " [ -f /usr/bin/gcc-10 ] && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10|| echo 'gcc-10 installation failed'"
70
+ fi
0 commit comments