22
33usage ()
44{
5- echo " Usage: $0 [BuildArch] [LinuxCodeName ] [lldbx.y] [--skipunmount] --rootfsdir <directory>]"
5+ echo " Usage: $0 [BuildArch] [CodeName ] [lldbx.y] [--skipunmount] --rootfsdir <directory>]"
66 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"
7+ echo " CodeName - 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 " for FreeBSD can be: freebsd11 or freebsd12."
9+ echo " lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FReeBSD"
910 echo " --skipunmount - optional, will skip the unmount of rootfs folder."
1011 exit 1
1112}
1213
13- __LinuxCodeName =xenial
14+ __CodeName =xenial
1415__CrossDir=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
1516__InitialDir=$PWD
1617__BuildArch=arm
@@ -53,6 +54,15 @@ __AlpinePackages+=" krb5-dev"
5354__AlpinePackages+=" openssl-dev"
5455__AlpinePackages+=" zlib-dev"
5556
57+ __FreeBSDBase=" 12.1-RELEASE"
58+ __FreeBSDPkg=" 1.10.5"
59+ __FreeBSDPackages=" libunwind"
60+ __FreeBSDPackages+=" icu"
61+ __FreeBSDPackages+=" libinotify"
62+ __FreeBSDPackages+=" lttng-ust"
63+ __FreeBSDPackages+=" llvm-90"
64+ __FreeBSDPackages+=" krb5"
65+
5666__UnprocessedBuildArgs=
5767while : ; do
5868 if [ $# -le 0 ]; then
@@ -81,7 +91,7 @@ while :; do
8191 __BuildArch=armel
8292 __UbuntuArch=armel
8393 __UbuntuRepo=" http://ftp.debian.org/debian/"
84- __LinuxCodeName =jessie
94+ __CodeName =jessie
8595 ;;
8696 x86)
8797 __BuildArch=x86
@@ -110,36 +120,36 @@ while :; do
110120 unset __LLDB_Package
111121 ;;
112122 trusty) # Ubuntu 14.04
113- if [ " $__LinuxCodeName " != " jessie" ]; then
114- __LinuxCodeName =trusty
123+ if [ " $__CodeName " != " jessie" ]; then
124+ __CodeName =trusty
115125 fi
116126 ;;
117127 xenial) # Ubuntu 16.04
118- if [ " $__LinuxCodeName " != " jessie" ]; then
119- __LinuxCodeName =xenial
128+ if [ " $__CodeName " != " jessie" ]; then
129+ __CodeName =xenial
120130 fi
121131 ;;
122132 zesty) # Ubuntu 17.04
123- if [ " $__LinuxCodeName " != " jessie" ]; then
124- __LinuxCodeName =zesty
133+ if [ " $__CodeName " != " jessie" ]; then
134+ __CodeName =zesty
125135 fi
126136 ;;
127137 bionic) # Ubuntu 18.04
128- if [ " $__LinuxCodeName " != " jessie" ]; then
129- __LinuxCodeName =bionic
138+ if [ " $__CodeName " != " jessie" ]; then
139+ __CodeName =bionic
130140 fi
131141 ;;
132142 jessie) # Debian 8
133- __LinuxCodeName =jessie
143+ __CodeName =jessie
134144 __UbuntuRepo=" http://ftp.debian.org/debian/"
135145 ;;
136146 stretch) # Debian 9
137- __LinuxCodeName =stretch
147+ __CodeName =stretch
138148 __UbuntuRepo=" http://ftp.debian.org/debian/"
139149 __LLDB_Package=" liblldb-6.0-dev"
140150 ;;
141151 buster) # Debian 10
142- __LinuxCodeName =buster
152+ __CodeName =buster
143153 __UbuntuRepo=" http://ftp.debian.org/debian/"
144154 __LLDB_Package=" liblldb-6.0-dev"
145155 ;;
@@ -149,14 +159,22 @@ while :; do
149159 usage;
150160 exit 1;
151161 fi
152- __LinuxCodeName =
162+ __CodeName =
153163 __UbuntuRepo=
154164 __Tizen=tizen
155165 ;;
156166 alpine)
157- __LinuxCodeName =alpine
167+ __CodeName =alpine
158168 __UbuntuRepo=
159169 ;;
170+ freebsd11)
171+ __FreeBSDBase=" 11.3-RELEASE"
172+ ;&
173+ freebsd12)
174+ __CodeName=freebsd
175+ __BuildArch=x64
176+ __SkipUnmount=1
177+ ;;
160178 --skipunmount)
161179 __SkipUnmount=1
162180 ;;
@@ -192,7 +210,7 @@ if [ -d "$__RootfsDir" ]; then
192210 rm -rf $__RootfsDir
193211fi
194212
195- if [[ " $__LinuxCodeName " == " alpine" ]]; then
213+ if [[ " $__CodeName " == " alpine" ]]; then
196214 __ApkToolsVersion=2.9.1
197215 __AlpineVersion=3.9
198216 __ApkToolsDir=$( mktemp -d)
@@ -218,9 +236,24 @@ if [[ "$__LinuxCodeName" == "alpine" ]]; then
218236 add $__AlpinePackagesEdgeTesting
219237
220238 rm -r $__ApkToolsDir
221- elif [[ -n $__LinuxCodeName ]]; then
222- qemu-debootstrap --arch $__UbuntuArch $__LinuxCodeName $__RootfsDir $__UbuntuRepo
223- cp $__CrossDir /$__BuildArch /sources.list.$__LinuxCodeName $__RootfsDir /etc/apt/sources.list
239+ elif [[ " $__CodeName " == " freebsd" ]]; then
240+ mkdir -p $__RootfsDir /usr/local/etc
241+ wget -O - https://download.freebsd.org/ftp/releases/amd64/${__FreeBSDBase} /base.txz | tar -C $__RootfsDir -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version
242+ # For now, ask for 11 ABI even on 12. This can be revisited later.
243+ echo " ABI = \" FreeBSD:11:amd64\" ; FINGERPRINTS = \" ${__RootfsDir} /usr/share/keys\" ; REPOS_DIR = [\" ${__RootfsDir} /etc/pkg\" ]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${__RootfsDir} /usr/local/etc/pkg.conf
244+ echo " FreeBSD: { url: " pkg+http://pkg.FreeBSD.org/\$ {ABI}/quarterly" , mirror_type: \" srv\" , signature_type: \" fingerprints\" , fingerprints: \" ${__RootfsDir} /usr/share/keys/pkg\" , enabled: yes }" > ${__RootfsDir} /etc/pkg/FreeBSD.conf
245+ mkdir -p $__RootfsDir /tmp
246+ # get and build package manager
247+ wget -O - https://github.com/freebsd/pkg/archive/${__FreeBSDPkg} .tar.gz | tar -C $__RootfsDir /tmp -zxf -
248+ cd $__RootfsDir /tmp/pkg-${__FreeBSDPkg}
249+ ./autogen.sh && ./configure --prefix=$__RootfsDir /host && make install
250+ rm -rf $__RootfsDir /tmp/pkg-${__FreeBSDPkg}
251+ # install packages we need.
252+ $__RootfsDir /host/sbin/pkg -r $__RootfsDir -C $__RootfsDir /usr/local/etc/pkg.conf update
253+ $__RootfsDir /host/sbin/pkg -r $__RootfsDir -C $__RootfsDir /usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
254+ elif [[ -n $__CodeName ]]; then
255+ qemu-debootstrap --arch $__UbuntuArch $__CodeName $__RootfsDir $__UbuntuRepo
256+ cp $__CrossDir /$__BuildArch /sources.list.$__CodeName $__RootfsDir /etc/apt/sources.list
224257 chroot $__RootfsDir apt-get update
225258 chroot $__RootfsDir apt-get -f -y install
226259 chroot $__RootfsDir apt-get -y install $__UbuntuPackages
@@ -230,7 +263,7 @@ elif [[ -n $__LinuxCodeName ]]; then
230263 umount $__RootfsDir /*
231264 fi
232265
233- if [[ " $__BuildArch " == " arm" && " $__LinuxCodeName " == " trusty" ]]; then
266+ if [[ " $__BuildArch " == " arm" && " $__CodeName " == " trusty" ]]; then
234267 pushd $__RootfsDir
235268 patch -p1 < $__CrossDir /$__BuildArch /trusty.patch
236269 patch -p1 < $__CrossDir /$__BuildArch /trusty-lttng-2.4.patch
0 commit comments