@@ -18,7 +18,6 @@ usage()
18
18
19
19
__CodeName=xenial
20
20
__CrossDir=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
21
- __InitialDir=$PWD
22
21
__BuildArch=arm
23
22
__AlpineArch=armv7
24
23
__FreeBSDArch=arm
@@ -43,7 +42,7 @@ __AlpinePackages+=" libedit"
43
42
# symlinks fixer
44
43
__UbuntuPackages+=" symlinks"
45
44
46
- # CoreCLR and CoreFX dependencies
45
+ # runtime dependencies
47
46
__UbuntuPackages+=" libicu-dev"
48
47
__UbuntuPackages+=" liblttng-ust-dev"
49
48
__UbuntuPackages+=" libunwind8-dev"
@@ -54,7 +53,7 @@ __AlpinePackages+=" libunwind-dev"
54
53
__AlpinePackages+=" lttng-ust-dev"
55
54
__AlpinePackages+=" compiler-rt-static"
56
55
57
- # CoreFX dependencies
56
+ # runtime libraries' dependencies
58
57
__UbuntuPackages+=" libcurl4-openssl-dev"
59
58
__UbuntuPackages+=" libkrb5-dev"
60
59
__UbuntuPackages+=" libssl-dev"
@@ -84,17 +83,18 @@ __IllumosPackages+=" zlib-1.2.11"
84
83
__UbuntuPackages+=" libomp5"
85
84
__UbuntuPackages+=" libomp-dev"
86
85
86
+ __Keyring=
87
87
__UseMirror=0
88
88
89
89
__UnprocessedBuildArgs=
90
90
while : ; do
91
- if [ $# -le 0 ]; then
91
+ if [[ " $# " -le 0 ] ]; then
92
92
break
93
93
fi
94
94
95
- lowerI=" $( echo $1 | tr " [:upper:]" " [:lower:]" ) "
95
+ lowerI=" $( echo " $1 " | tr " [:upper:]" " [:lower:]" ) "
96
96
case $lowerI in
97
- -? |-h|--help)
97
+ -\ ? |-h|--help)
98
98
usage
99
99
exit 1
100
100
;;
@@ -111,7 +111,7 @@ while :; do
111
111
__UbuntuRepo=" http://raspbian.raspberrypi.org/raspbian/"
112
112
__CodeName=buster
113
113
__LLDB_Package=" liblldb-6.0-dev"
114
- __Keyring=" /usr/share/keyrings/raspbian-archive-keyring.gpg"
114
+ __Keyring=" --keyring /usr/share/keyrings/raspbian-archive-keyring.gpg"
115
115
;;
116
116
arm64)
117
117
__BuildArch=arm64
@@ -189,17 +189,17 @@ while :; do
189
189
fi
190
190
;;
191
191
xenial) # Ubuntu 16.04
192
- if [ " $__CodeName " != " jessie" ]; then
192
+ if [[ " $__CodeName " != " jessie" ] ]; then
193
193
__CodeName=xenial
194
194
fi
195
195
;;
196
196
zesty) # Ubuntu 17.04
197
- if [ " $__CodeName " != " jessie" ]; then
197
+ if [[ " $__CodeName " != " jessie" ] ]; then
198
198
__CodeName=zesty
199
199
fi
200
200
;;
201
201
bionic) # Ubuntu 18.04
202
- if [ " $__CodeName " != " jessie" ]; then
202
+ if [[ " $__CodeName " != " jessie" ] ]; then
203
203
__CodeName=bionic
204
204
fi
205
205
;;
@@ -253,7 +253,7 @@ while :; do
253
253
;;
254
254
--rootfsdir|-rootfsdir)
255
255
shift
256
- __RootfsDir=$1
256
+ __RootfsDir=" $1 "
257
257
;;
258
258
--use-mirror)
259
259
__UseMirror=1
@@ -266,71 +266,66 @@ while :; do
266
266
shift
267
267
done
268
268
269
- if [ -e " $__Keyring " ]; then
270
- __Keyring=" --keyring=$__Keyring "
271
- else
272
- __Keyring=" "
273
- fi
274
-
275
- if [ " $__BuildArch " == " armel" ]; then
269
+ if [[ " $__BuildArch " == " armel" ]]; then
276
270
__LLDB_Package=" lldb-3.5-dev"
277
271
fi
272
+
278
273
__UbuntuPackages+=" ${__LLDB_Package:- } "
279
274
280
- if [ ! -z " $__LLVM_MajorVersion " ]; then
275
+ if [[ -n " $__LLVM_MajorVersion " ] ]; then
281
276
__UbuntuPackages+=" libclang-common-${__LLVM_MajorVersion}${__LLVM_MinorVersion: +.$__LLVM_MinorVersion } -dev"
282
277
fi
283
278
284
- if [ -z " $__RootfsDir " ] && [ ! -z " $ROOTFS_DIR " ]; then
285
- __RootfsDir=$ROOTFS_DIR
279
+ if [[ -z " $__RootfsDir " && -n " $ROOTFS_DIR " ] ]; then
280
+ __RootfsDir=" $ROOTFS_DIR "
286
281
fi
287
282
288
- if [ -z " $__RootfsDir " ]; then
283
+ if [[ -z " $__RootfsDir " ] ]; then
289
284
__RootfsDir=" $__CrossDir /../../../.tools/rootfs/$__BuildArch "
290
285
fi
291
286
292
- if [ -d " $__RootfsDir " ]; then
293
- if [ $__SkipUnmount == 0 ]; then
294
- umount $__RootfsDir /* || true
287
+ if [[ -d " $__RootfsDir " ] ]; then
288
+ if [[ " $__SkipUnmount " == " 0 " ] ]; then
289
+ umount " $__RootfsDir " /* || true
295
290
fi
296
- rm -rf $__RootfsDir
291
+ rm -rf " $__RootfsDir "
297
292
fi
298
293
299
- mkdir -p $__RootfsDir
294
+ mkdir -p " $__RootfsDir "
300
295
__RootfsDir=" $( cd " $__RootfsDir " && pwd ) "
301
296
302
297
if [[ " $__CodeName " == " alpine" ]]; then
303
298
__ApkToolsVersion=2.9.1
304
- __ApkToolsDir=$( mktemp -d)
305
- wget https://github.com/alpinelinux/apk-tools/releases/download/v$__ApkToolsVersion /apk-tools-$__ApkToolsVersion -x86_64-linux.tar.gz -P $__ApkToolsDir
306
- tar -xf $__ApkToolsDir /apk-tools-$__ApkToolsVersion -x86_64-linux.tar.gz -C $__ApkToolsDir
307
- mkdir -p $__RootfsDir /usr/bin
308
- cp -v /usr/bin/qemu-$__QEMUArch -static $__RootfsDir /usr/bin
299
+ __ApkToolsDir=" $( mktemp -d) "
300
+ wget " https://github.com/alpinelinux/apk-tools/releases/download/v$__ApkToolsVersion /apk-tools-$__ApkToolsVersion -x86_64-linux.tar.gz" -P " $__ApkToolsDir "
301
+ tar -xf " $__ApkToolsDir /apk-tools-$__ApkToolsVersion -x86_64-linux.tar.gz" -C " $__ApkToolsDir "
302
+ mkdir -p " $__RootfsDir " /usr/bin
303
+ cp -v " /usr/bin/qemu-$__QEMUArch -static" " $__RootfsDir /usr/bin"
309
304
310
- $__ApkToolsDir /apk-tools-$__ApkToolsVersion /apk \
311
- -X http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion /main \
312
- -X http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion /community \
313
- -U --allow-untrusted --root $__RootfsDir --arch $__AlpineArch --initdb \
305
+ " $__ApkToolsDir /apk-tools-$__ApkToolsVersion /apk" \
306
+ -X " http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion /main" \
307
+ -X " http://dl-cdn.alpinelinux.org/alpine/v$__AlpineVersion /community" \
308
+ -U --allow-untrusted --root " $__RootfsDir " --arch " $__AlpineArch " --initdb \
314
309
add $__AlpinePackages
315
310
316
- rm -r $__ApkToolsDir
311
+ rm -r " $__ApkToolsDir "
317
312
elif [[ " $__CodeName " == " freebsd" ]]; then
318
- mkdir -p $__RootfsDir /usr/local/etc
313
+ mkdir -p " $__RootfsDir " /usr/local/etc
319
314
JOBS=" $( getconf _NPROCESSORS_ONLN) "
320
- wget -O - https://download.freebsd.org/ftp/releases/${__FreeBSDArch} /${__FreeBSDMachineArch} /${__FreeBSDBase} /base.txz | tar -C $__RootfsDir -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version
321
- echo " ABI = \" FreeBSD:${__FreeBSDABI} :${__FreeBSDMachineArch} \" ; FINGERPRINTS = \" ${__RootfsDir} /usr/share/keys\" ; REPOS_DIR = [\" ${__RootfsDir} /etc/pkg\" ]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > ${__RootfsDir} /usr/local/etc/pkg.conf
322
- 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
323
- mkdir -p $__RootfsDir /tmp
315
+ wget -O - " https://download.freebsd.org/ftp/releases/${__FreeBSDArch} /${__FreeBSDMachineArch} /${__FreeBSDBase} /base.txz" | tar -C " $__RootfsDir " -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version
316
+ echo " ABI = \" FreeBSD:${__FreeBSDABI} :${__FreeBSDMachineArch} \" ; FINGERPRINTS = \" ${__RootfsDir} /usr/share/keys\" ; REPOS_DIR = [\" ${__RootfsDir} /etc/pkg\" ]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > " ${__RootfsDir} " /usr/local/etc/pkg.conf
317
+ 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
318
+ mkdir -p " $__RootfsDir " /tmp
324
319
# get and build package manager
325
- wget -O - https://github.com/freebsd/pkg/archive/${__FreeBSDPkg} .tar.gz | tar -C $__RootfsDir /tmp -zxf -
326
- cd $__RootfsDir /tmp/pkg-${__FreeBSDPkg}
320
+ wget -O - " https://github.com/freebsd/pkg/archive/${__FreeBSDPkg} .tar.gz" | tar -C " $__RootfsDir " /tmp -zxf -
321
+ cd " $__RootfsDir /tmp/pkg-${__FreeBSDPkg} "
327
322
# needed for install to succeed
328
- mkdir -p $__RootfsDir /host/etc
329
- ./autogen.sh && ./configure --prefix=$__RootfsDir /host && make -j " $JOBS " && make install
330
- rm -rf $__RootfsDir /tmp/pkg-${__FreeBSDPkg}
323
+ mkdir -p " $__RootfsDir " /host/etc
324
+ ./autogen.sh && ./configure --prefix=" $__RootfsDir " /host && make -j " $JOBS " && make install
325
+ rm -rf " $__RootfsDir /tmp/pkg-${__FreeBSDPkg} "
331
326
# install packages we need.
332
- INSTALL_AS_USER=$( whoami) $__RootfsDir /host/sbin/pkg -r $__RootfsDir -C $__RootfsDir /usr/local/etc/pkg.conf update
333
- INSTALL_AS_USER=$( whoami) $__RootfsDir /host/sbin/pkg -r $__RootfsDir -C $__RootfsDir /usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
327
+ INSTALL_AS_USER=$( whoami) " $__RootfsDir " /host/sbin/pkg -r " $__RootfsDir " -C " $__RootfsDir " /usr/local/etc/pkg.conf update
328
+ INSTALL_AS_USER=$( whoami) " $__RootfsDir " /host/sbin/pkg -r " $__RootfsDir " -C " $__RootfsDir " /usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
334
329
elif [[ " $__CodeName " == " illumos" ]]; then
335
330
mkdir " $__RootfsDir /tmp"
336
331
pushd " $__RootfsDir /tmp"
@@ -358,7 +353,7 @@ elif [[ "$__CodeName" == "illumos" ]]; then
358
353
if [[ " $__UseMirror " == 1 ]]; then
359
354
BaseUrl=http://pkgsrc.smartos.skylime.net
360
355
fi
361
- BaseUrl=" $BaseUrl " /packages/SmartOS/2020Q1/${__illumosArch} /All
356
+ BaseUrl=" $BaseUrl /packages/SmartOS/2020Q1/${__illumosArch} /All"
362
357
echo " Downloading dependencies."
363
358
read -ra array <<< " $__IllumosPackages"
364
359
for package in " ${array[@]} " ; do
@@ -376,26 +371,26 @@ elif [[ "$__CodeName" == "illumos" ]]; then
376
371
wget -P " $__RootfsDir " /usr/include/net https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/io/bpf/net/dlt.h
377
372
wget -P " $__RootfsDir " /usr/include/netpacket https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/inet/sockmods/netpacket/packet.h
378
373
wget -P " $__RootfsDir " /usr/include/sys https://raw.githubusercontent.com/illumos/illumos-gate/master/usr/src/uts/common/sys/sdt.h
379
- elif [[ -n $__CodeName ]]; then
380
- qemu-debootstrap $__Keyring --arch $__UbuntuArch $__CodeName $__RootfsDir $__UbuntuRepo
381
- cp $__CrossDir /$__BuildArch /sources.list.$__CodeName $__RootfsDir /etc/apt/sources.list
382
- chroot $__RootfsDir apt-get update
383
- chroot $__RootfsDir apt-get -f -y install
384
- chroot $__RootfsDir apt-get -y install $__UbuntuPackages
385
- chroot $__RootfsDir symlinks -cr /usr
386
- chroot $__RootfsDir apt-get clean
374
+ elif [[ -n " $__CodeName " ]]; then
375
+ qemu-debootstrap $__Keyring --arch " $__UbuntuArch " " $__CodeName " " $__RootfsDir " " $__UbuntuRepo "
376
+ cp " $__CrossDir /$__BuildArch /sources.list.$__CodeName " " $__RootfsDir /etc/apt/sources.list"
377
+ chroot " $__RootfsDir " apt-get update
378
+ chroot " $__RootfsDir " apt-get -f -y install
379
+ chroot " $__RootfsDir " apt-get -y install $__UbuntuPackages
380
+ chroot " $__RootfsDir " symlinks -cr /usr
381
+ chroot " $__RootfsDir " apt-get clean
387
382
388
- if [ $__SkipUnmount == 0 ]; then
389
- umount $__RootfsDir /* || true
383
+ if [[ " $__SkipUnmount " == " 0 " ] ]; then
384
+ umount " $__RootfsDir " /* || true
390
385
fi
391
386
392
387
if [[ " $__BuildArch " == " armel" && " $__CodeName " == " jessie" ]]; then
393
- pushd $__RootfsDir
394
- patch -p1 < $__CrossDir /$__BuildArch /armel.jessie.patch
388
+ pushd " $__RootfsDir "
389
+ patch -p1 < " $__CrossDir /$__BuildArch /armel.jessie.patch"
395
390
popd
396
391
fi
397
392
elif [[ " $__Tizen " == " tizen" ]]; then
398
- ROOTFS_DIR=$__RootfsDir $__CrossDir /$__BuildArch /tizen-build-rootfs.sh
393
+ ROOTFS_DIR=" $__RootfsDir $__CrossDir /$__BuildArch /tizen-build-rootfs.sh"
399
394
else
400
395
echo " Unsupported target platform."
401
396
usage;
0 commit comments