88 echo " BuildArch can be: arm(default), armel, arm64, x86"
99 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."
1010 echo " for FreeBSD can be: freebsd11 or freebsd12."
11+ echo " for illumos can be: illumos."
1112 echo " lldbx.y - optional, LLDB version, can be: lldb3.9(default), lldb4.0, lldb5.0, lldb6.0 no-lldb. Ignored for alpine and FReeBSD"
1213 echo " --skipunmount - optional, will skip the unmount of rootfs folder."
14+ echo " --use-mirror - optional, use mirror URL to fetch resources, when available."
1315 exit 1
1416}
1517
@@ -67,6 +69,13 @@ __FreeBSDPackages+=" libinotify"
6769__FreeBSDPackages+=" lttng-ust"
6870__FreeBSDPackages+=" krb5"
6971
72+ __IllumosPackages=" icu-64.2nb2"
73+ __IllumosPackages+=" mit-krb5-1.16.2nb4"
74+ __IllumosPackages+=" openssl-1.1.1e"
75+ __IllumosPackages+=" zlib-1.2.11"
76+
77+ __UseMirror=0
78+
7079__UnprocessedBuildArgs=
7180while : ; do
7281 if [ $# -le 0 ]; then
@@ -179,13 +188,21 @@ while :; do
179188 __BuildArch=x64
180189 __SkipUnmount=1
181190 ;;
191+ illumos)
192+ __CodeName=illumos
193+ __BuildArch=x64
194+ __SkipUnmount=1
195+ ;;
182196 --skipunmount)
183197 __SkipUnmount=1
184198 ;;
185199 --rootfsdir|-rootfsdir)
186200 shift
187201 __RootfsDir=$1
188202 ;;
203+ --use-mirror)
204+ __UseMirror=1
205+ ;;
189206 * )
190207 __UnprocessedBuildArgs=" $__UnprocessedBuildArgs $1 "
191208 ;;
@@ -214,6 +231,9 @@ if [ -d "$__RootfsDir" ]; then
214231 rm -rf $__RootfsDir
215232fi
216233
234+ mkdir -p $__RootfsDir
235+ __RootfsDir=" $( cd " $__RootfsDir " && pwd ) "
236+
217237if [[ " $__CodeName " == " alpine" ]]; then
218238 __ApkToolsVersion=2.9.1
219239 __AlpineVersion=3.9
@@ -257,6 +277,51 @@ elif [[ "$__CodeName" == "freebsd" ]]; then
257277 # install packages we need.
258278 INSTALL_AS_USER=$( whoami) $__RootfsDir /host/sbin/pkg -r $__RootfsDir -C $__RootfsDir /usr/local/etc/pkg.conf update
259279 INSTALL_AS_USER=$( whoami) $__RootfsDir /host/sbin/pkg -r $__RootfsDir -C $__RootfsDir /usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
280+ elif [[ " $__CodeName " == " illumos" ]]; then
281+ mkdir " $__RootfsDir /tmp"
282+ pushd " $__RootfsDir /tmp"
283+ JOBS=" $( getconf _NPROCESSORS_ONLN) "
284+ echo " Downloading sysroot."
285+ wget -O - https://github.com/illumos/sysroot/releases/download/20181213-de6af22ae73b-v1/illumos-sysroot-i386-20181213-de6af22ae73b-v1.tar.gz | tar -C " $__RootfsDir " -xzf -
286+ echo " Building binutils. Please wait.."
287+ wget -O - https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf -
288+ mkdir build-binutils && cd build-binutils
289+ ../binutils-2.33.1/configure --prefix=" $__RootfsDir " --target=" x86_64-sun-solaris2.10" --program-prefix=" x86_64-illumos-" --with-sysroot=" $__RootfsDir "
290+ make -j " $JOBS " && make install && cd ..
291+ echo " Building gcc. Please wait.."
292+ wget -O - https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf -
293+ CFLAGS=" -fPIC"
294+ CXXFLAGS=" -fPIC"
295+ CXXFLAGS_FOR_TARGET=" -fPIC"
296+ CFLAGS_FOR_TARGET=" -fPIC"
297+ export CFLAGS CXXFLAGS CXXFLAGS_FOR_TARGET CFLAGS_FOR_TARGET
298+ mkdir build-gcc && cd build-gcc
299+ ../gcc-8.4.0/configure --prefix=" $__RootfsDir " --target=" x86_64-sun-solaris2.10" --program-prefix=" x86_64-illumos-" --with-sysroot=" $__RootfsDir " --with-gnu-as \
300+ --with-gnu-ld --disable-nls --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libada --disable-libsanitizer \
301+ --disable-libquadmath-support --disable-shared --enable-tls
302+ make -j " $JOBS " && make install && cd ..
303+ BaseUrl=https://pkgsrc.joyent.com
304+ if [[ " $__UseMirror " == 1 ]]; then
305+ BaseUrl=http://pkgsrc.smartos.skylime.net
306+ fi
307+ BaseUrl=" $BaseUrl " /packages/SmartOS/2020Q1/x86_64/All
308+ echo " Downloading dependencies."
309+ read -ra array <<< " $__IllumosPackages"
310+ for package in " ${array[@]} " ; do
311+ echo " Installing $package ..."
312+ wget " $BaseUrl " /" $package " .tgz
313+ ar -x " $package " .tgz
314+ tar --skip-old-files -xzf " $package " .tmp.tgz -C " $__RootfsDir " 2> /dev/null
315+ done
316+ echo " Cleaning up temporary files."
317+ popd
318+ rm -rf " $__RootfsDir " /{tmp,+* }
319+ mkdir -p " $__RootfsDir " /usr/include/net
320+ mkdir -p " $__RootfsDir " /usr/include/netpacket
321+ wget -P " $__RootfsDir " /usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/bpf.h
322+ wget -P " $__RootfsDir " /usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h
323+ wget -P " $__RootfsDir " /usr/include/netpacket https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h
324+ wget -P " $__RootfsDir " /usr/include/sys https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h
260325elif [[ -n $__CodeName ]]; then
261326 qemu-debootstrap --arch $__UbuntuArch $__CodeName $__RootfsDir $__UbuntuRepo
262327 cp $__CrossDir /$__BuildArch /sources.list.$__CodeName $__RootfsDir /etc/apt/sources.list
@@ -275,7 +340,7 @@ elif [[ -n $__CodeName ]]; then
275340 patch -p1 < $__CrossDir /$__BuildArch /trusty-lttng-2.4.patch
276341 popd
277342 fi
278- elif [ " $__Tizen " == " tizen" ]; then
343+ elif [[ " $__Tizen " == " tizen" ] ]; then
279344 ROOTFS_DIR=$__RootfsDir $__CrossDir /$__BuildArch /tizen-build-rootfs.sh
280345else
281346 echo " Unsupported target platform."
0 commit comments