5 echo "Usage: $0 [BuildArch] [LinuxCodeName] [lldbx.y] [--skipunmount] --rootfsdir <directory>]"
6 echo "BuildArch can be: arm(default), armel, arm64, x86"
7 echo "LinuxCodeName - optional, Code name for Linux, can be: trusty, xenial(default), zesty, bionic, alpine. If BuildArch is armel, LinuxCodeName is jessie(default) or tizen."
8 echo "lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine"
9 echo "--skipunmount - optional, will skip the unmount of rootfs folder."
13 __LinuxCodeName
=xenial
14 __CrossDir
=$
( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
18 __UbuntuRepo
="http://ports.ubuntu.com/"
19 __LLDB_Package
="liblldb-3.9-dev"
22 # base development support
23 __UbuntuPackages
="build-essential"
25 __AlpinePackages
="alpine-base"
26 __AlpinePackages
+=" build-base"
27 __AlpinePackages
+=" linux-headers"
28 __AlpinePackages
+=" lldb-dev"
29 __AlpinePackages
+=" llvm-dev"
32 __UbuntuPackages
+=" symlinks"
34 # CoreCLR and CoreFX dependencies
35 __UbuntuPackages
+=" libicu-dev"
36 __UbuntuPackages
+=" liblttng-ust-dev"
37 __UbuntuPackages
+=" libunwind8-dev"
39 __AlpinePackages
+=" gettext-dev"
40 __AlpinePackages
+=" icu-dev"
41 __AlpinePackages
+=" libunwind-dev"
42 __AlpinePackages
+=" lttng-ust-dev"
45 __UbuntuPackages
+=" libcurl4-openssl-dev"
46 __UbuntuPackages
+=" libkrb5-dev"
47 __UbuntuPackages
+=" libssl-dev"
48 __UbuntuPackages
+=" zlib1g-dev"
50 __AlpinePackages
+=" curl-dev"
51 __AlpinePackages
+=" krb5-dev"
52 __AlpinePackages
+=" openssl-dev"
53 __AlpinePackages
+=" zlib-dev"
55 __UnprocessedBuildArgs
=
61 lowerI
="$(echo $1 | awk '{print tolower($0)}')"
82 __UbuntuRepo
="http://ftp.debian.org/debian/"
83 __LinuxCodeName
=jessie
88 __UbuntuRepo
="http://archive.ubuntu.com/ubuntu/"
91 __LLDB_Package
="lldb-3.6-dev"
94 __LLDB_Package
="lldb-3.8-dev"
97 __LLDB_Package
="liblldb-3.9-dev"
100 __LLDB_Package
="liblldb-4.0-dev"
103 __LLDB_Package
="liblldb-5.0-dev"
106 __LLDB_Package
="liblldb-6.0-dev"
111 trusty
) # Ubuntu 14.04
112 if [ "$__LinuxCodeName" != "jessie" ]; then
113 __LinuxCodeName
=trusty
116 xenial
) # Ubuntu 16.04
117 if [ "$__LinuxCodeName" != "jessie" ]; then
118 __LinuxCodeName
=xenial
121 zesty
) # Ubuntu 17.04
122 if [ "$__LinuxCodeName" != "jessie" ]; then
123 __LinuxCodeName
=zesty
126 bionic
) # Ubuntu 18.04
127 if [ "$__LinuxCodeName" != "jessie" ]; then
128 __LinuxCodeName
=bionic
132 __LinuxCodeName
=jessie
133 __UbuntuRepo
="http://ftp.debian.org/debian/"
136 __LinuxCodeName
=stretch
137 __UbuntuRepo
="http://ftp.debian.org/debian/"
138 __LLDB_Package
="liblldb-6.0-dev"
141 __LinuxCodeName
=buster
142 __UbuntuRepo
="http://ftp.debian.org/debian/"
143 __LLDB_Package
="liblldb-6.0-dev"
146 if [ "$__BuildArch" != "armel" ]; then
147 echo "Tizen is available only for armel."
156 __LinuxCodeName
=alpine
162 --rootfsdir|
-rootfsdir)
167 __UnprocessedBuildArgs
="$__UnprocessedBuildArgs $1"
174 if [ "$__BuildArch" == "armel" ]; then
175 __LLDB_Package
="lldb-3.5-dev"
177 __UbuntuPackages
+=" ${__LLDB_Package:-}"
179 if [ -z "$__RootfsDir" ] && [ ! -z "$ROOTFS_DIR" ]; then
180 __RootfsDir
=$ROOTFS_DIR
183 if [ -z "$__RootfsDir" ]; then
184 __RootfsDir
="$__CrossDir/../../../.tools/rootfs/$__BuildArch"
187 if [ -d "$__RootfsDir" ]; then
188 if [ $__SkipUnmount == 0 ]; then
189 umount
$__RootfsDir/*
194 if [[ "$__LinuxCodeName" == "alpine" ]]; then
195 __ApkToolsVersion
=2.9.1
197 __ApkToolsDir
=$
(mktemp
-d)
198 wget https
://github.com
/alpinelinux
/apk-tools
/releases
/download
/v
$__ApkToolsVersion/apk-tools-
$__ApkToolsVersion-x86_64-linux.
tar.gz
-P $__ApkToolsDir
199 tar -xf $__ApkToolsDir/apk-tools-
$__ApkToolsVersion-x86_64-linux.
tar.gz
-C $__ApkToolsDir
200 mkdir
-p $__RootfsDir/usr
/bin
201 cp -v /usr
/bin
/qemu-
$__QEMUArch-static $__RootfsDir/usr
/bin
202 $__ApkToolsDir/apk-tools-
$__ApkToolsVersion/apk \
203 -X http
://dl-cdn.alpinelinux.org
/alpine
/v
$__AlpineVersion/main \
204 -X http
://dl-cdn.alpinelinux.org
/alpine
/v
$__AlpineVersion/community \
205 -X http
://dl-cdn.alpinelinux.org
/alpine
/edge
/testing \
206 -X http
://dl-cdn.alpinelinux.org
/alpine
/edge
/main \
207 -U --allow-untrusted --root $__RootfsDir --arch $__AlpineArch --initdb \
208 add
$__AlpinePackages
210 elif [[ -n $__LinuxCodeName ]]; then
211 qemu-debootstrap
--arch $__UbuntuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
212 cp $__CrossDir/$__BuildArch/sources.list.
$__LinuxCodeName $__RootfsDir/etc
/apt
/sources.list
213 chroot
$__RootfsDir apt-get update
214 chroot
$__RootfsDir apt-get
-f -y install
215 chroot
$__RootfsDir apt-get
-y install $__UbuntuPackages
216 chroot
$__RootfsDir symlinks
-cr /usr
218 if [ $__SkipUnmount == 0 ]; then
219 umount
$__RootfsDir/*
222 if [[ "$__BuildArch" == "arm" && "$__LinuxCodeName" == "trusty" ]]; then
224 patch -p1 < $__CrossDir/$__BuildArch/trusty.
patch
225 patch -p1 < $__CrossDir/$__BuildArch/trusty-lttng-2.4.
patch
228 elif [ "$__Tizen" == "tizen" ]; then
229 ROOTFS_DIR
=$__RootfsDir $__CrossDir/$__BuildArch/tizen-build-rootfs.sh
231 echo "Unsupported target platform."