@@ -142,7 +142,6 @@ while :; do
142
142
case $lowerI in
143
143
-\? |-h|--help)
144
144
usage
145
- exit 1
146
145
;;
147
146
arm)
148
147
__BuildArch=arm
@@ -229,12 +228,19 @@ while :; do
229
228
__UbuntuRepo=" http://archive.ubuntu.com/ubuntu/"
230
229
;;
231
230
lldb* )
232
- version=" ${lowerI/ lldb/ } "
233
- parts=(${version// ./ } )
231
+ version=" $( echo " $lowerI " | tr -d ' [:alpha:]-=' ) "
232
+ majorVersion=" ${version%% .* } "
233
+
234
+ [ -z " ${version##* .* } " ] && minorVersion=" ${version#* .} "
235
+ if [ -z " $minorVersion " ]; then
236
+ minorVersion=0
237
+ fi
234
238
235
239
# for versions > 6.0, lldb has dropped the minor version
236
- if [[ " ${parts[0]} " -gt 6 ]]; then
237
- version=" ${parts[0]} "
240
+ if [ " $majorVersion " -le 6 ]; then
241
+ version=" $majorVersion .$minorVersion "
242
+ else
243
+ version=" $majorVersion "
238
244
fi
239
245
240
246
__LLDB_Package=" liblldb-${version} -dev"
@@ -243,15 +249,19 @@ while :; do
243
249
unset __LLDB_Package
244
250
;;
245
251
llvm* )
246
- version=" ${lowerI/ llvm/ } "
247
- parts=(${version// ./ } )
248
- __LLVM_MajorVersion=" ${parts[0]} "
249
- __LLVM_MinorVersion=" ${parts[1]} "
250
-
251
- # for versions > 6.0, llvm has dropped the minor version
252
- if [[ -z " $__LLVM_MinorVersion " && " $__LLVM_MajorVersion " -le 6 ]]; then
253
- __LLVM_MinorVersion=0;
252
+ version=" $( echo " $lowerI " | tr -d ' [:alpha:]-=' ) "
253
+ __LLVM_MajorVersion=" ${version%% .* } "
254
+
255
+ [ -z " ${version##* .* } " ] && __LLVM_MinorVersion=" ${version#* .} "
256
+ if [ -z " $__LLVM_MinorVersion " ]; then
257
+ __LLVM_MinorVersion=0
254
258
fi
259
+
260
+ # for versions > 6.0, lldb has dropped the minor version
261
+ if [ " $__LLVM_MajorVersion " -gt 6 ]; then
262
+ __LLVM_MinorVersion=
263
+ fi
264
+
255
265
;;
256
266
xenial) # Ubuntu 16.04
257
267
if [[ " $__CodeName " != " jessie" ]]; then
@@ -323,15 +333,14 @@ while :; do
323
333
alpine* )
324
334
__CodeName=alpine
325
335
__UbuntuRepo=
326
- version=" ${lowerI/ alpine/ } "
327
336
328
- if [[ " $version " == " edge " ]]; then
337
+ if [[ " $lowerI " == " alpineedge " ]]; then
329
338
__AlpineVersion=edge
330
339
else
331
- parts=( ${version // . / } )
332
- __AlpineMajorVersion=" ${parts[0] } "
333
- __AlpineMinoVersion =" ${parts[1] } "
334
- __AlpineVersion=" $__AlpineMajorVersion .$__AlpineMinoVersion "
340
+ version= " $( echo " $lowerI " | tr -d ' [:alpha:]-= ' ) "
341
+ __AlpineMajorVersion=" ${version %% . * } "
342
+ __AlpineMinorVersion =" ${version #* . } "
343
+ __AlpineVersion=" $__AlpineMajorVersion .$__AlpineMinorVersion "
335
344
fi
336
345
;;
337
346
freebsd13)
@@ -454,7 +463,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
454
463
elif [[ " $arch " == " aarch64" ]]; then
455
464
__ApkToolsSHA512SUM=" 9e2b37ecb2b56c05dad23d379be84fd494c14bd730b620d0d576bda760588e1f2f59a7fcb2f2080577e0085f23a0ca8eadd993b4e61c2ab29549fdb71969afd0"
456
465
else
457
- echo " WARNING: add missing hash for your host architecture. To find the value, use: ` find /tmp -name apk.static -exec sha512sum {} \; ` "
466
+ echo " WARNING: add missing hash for your host architecture. To find the value, use: ' find /tmp -name apk.static -exec sha512sum {} \;' "
458
467
fi
459
468
echo " $__ApkToolsSHA512SUM $__ApkToolsDir /apk.static" | sha512sum -c
460
469
chmod +x " $__ApkToolsDir /apk.static"
@@ -484,12 +493,14 @@ if [[ "$__CodeName" == "alpine" ]]; then
484
493
fi
485
494
486
495
# initialize DB
496
+ # shellcheck disable=SC2086
487
497
" $__ApkToolsDir /apk.static" \
488
498
-X " http://dl-cdn.alpinelinux.org/alpine/$version /main" \
489
499
-X " http://dl-cdn.alpinelinux.org/alpine/$version /community" \
490
500
-U $__ApkSignatureArg --root " $__RootfsDir " --arch " $__AlpineArch " --initdb add
491
501
492
502
if [[ " $__AlpineLlvmLibsLookup " == 1 ]]; then
503
+ # shellcheck disable=SC2086
493
504
__AlpinePackages+=" $( " $__ApkToolsDir /apk.static" \
494
505
-X " http://dl-cdn.alpinelinux.org/alpine/$version /main" \
495
506
-X " http://dl-cdn.alpinelinux.org/alpine/$version /community" \
@@ -498,6 +509,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
498
509
fi
499
510
500
511
# install all packages in one go
512
+ # shellcheck disable=SC2086
501
513
" $__ApkToolsDir /apk.static" \
502
514
-X " http://dl-cdn.alpinelinux.org/alpine/$version /main" \
503
515
-X " http://dl-cdn.alpinelinux.org/alpine/$version /community" \
@@ -521,6 +533,7 @@ elif [[ "$__CodeName" == "freebsd" ]]; then
521
533
rm -rf " $__RootfsDir /tmp/pkg-${__FreeBSDPkg} "
522
534
# install packages we need.
523
535
INSTALL_AS_USER=$( whoami) " $__RootfsDir " /host/sbin/pkg -r " $__RootfsDir " -C " $__RootfsDir " /usr/local/etc/pkg.conf update
536
+ # shellcheck disable=SC2086
524
537
INSTALL_AS_USER=$( whoami) " $__RootfsDir " /host/sbin/pkg -r " $__RootfsDir " -C " $__RootfsDir " /usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
525
538
elif [[ " $__CodeName " == " illumos" ]]; then
526
539
mkdir " $__RootfsDir /tmp"
@@ -582,8 +595,8 @@ elif [[ "$__CodeName" == "haiku" ]]; then
582
595
mkdir " $__RootfsDir /tmp/download"
583
596
584
597
echo " Downloading Haiku package tool"
585
- git clone https://github.com/haiku/haiku-toolchains-ubuntu --depth 1 $__RootfsDir /tmp/script
586
- wget -O " $__RootfsDir /tmp/download/hosttools.zip" $( $__RootfsDir /tmp/script/fetch.sh --hosttools)
598
+ git clone https://github.com/haiku/haiku-toolchains-ubuntu --depth 1 " $__RootfsDir /tmp/script"
599
+ wget -O " $__RootfsDir /tmp/download/hosttools.zip" " $( " $__RootfsDir /tmp/script/fetch.sh" --hosttools) "
587
600
unzip -o " $__RootfsDir /tmp/download/hosttools.zip" -d " $__RootfsDir /tmp/bin"
588
601
589
602
DepotBaseUrl=" https://depot.haiku-os.org/__api/v2/pkg/get-pkg"
@@ -616,7 +629,7 @@ elif [[ "$__CodeName" == "haiku" ]]; then
616
629
617
630
# Download buildtools
618
631
echo " Downloading Haiku buildtools"
619
- wget -O " $__RootfsDir /tmp/download/buildtools.zip" $( $__RootfsDir /tmp/script/fetch.sh --buildtools --arch=$__HaikuArch )
632
+ wget -O " $__RootfsDir /tmp/download/buildtools.zip" " $( " $__RootfsDir /tmp/script/fetch.sh" --buildtools --arch=$__HaikuArch ) "
620
633
unzip -o " $__RootfsDir /tmp/download/buildtools.zip" -d " $__RootfsDir "
621
634
622
635
# Cleaning up temporary files
@@ -629,10 +642,12 @@ elif [[ -n "$__CodeName" ]]; then
629
642
__Keyring=" $__Keyring --force-check-gpg"
630
643
fi
631
644
645
+ # shellcheck disable=SC2086
632
646
debootstrap " --variant=minbase" $__Keyring --arch " $__UbuntuArch " " $__CodeName " " $__RootfsDir " " $__UbuntuRepo "
633
647
cp " $__CrossDir /$__BuildArch /sources.list.$__CodeName " " $__RootfsDir /etc/apt/sources.list"
634
648
chroot " $__RootfsDir " apt-get update
635
649
chroot " $__RootfsDir " apt-get -f -y install
650
+ # shellcheck disable=SC2086
636
651
chroot " $__RootfsDir " apt-get -y install $__UbuntuPackages
637
652
chroot " $__RootfsDir " symlinks -cr /usr
638
653
chroot " $__RootfsDir " apt-get clean
@@ -650,6 +665,5 @@ elif [[ "$__Tizen" == "tizen" ]]; then
650
665
ROOTFS_DIR=" $__RootfsDir " " $__CrossDir /tizen-build-rootfs.sh" " $__BuildArch "
651
666
else
652
667
echo " Unsupported target platform."
653
- usage;
654
- exit 1
668
+ usage
655
669
fi
0 commit comments