@@ -142,7 +142,6 @@ while :; do
142142 case $lowerI in
143143 -\? |-h|--help)
144144 usage
145- exit 1
146145 ;;
147146 arm)
148147 __BuildArch=arm
@@ -229,12 +228,19 @@ while :; do
229228 __UbuntuRepo=" http://archive.ubuntu.com/ubuntu/"
230229 ;;
231230 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
234238
235239 # 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 "
238244 fi
239245
240246 __LLDB_Package=" liblldb-${version} -dev"
@@ -243,15 +249,19 @@ while :; do
243249 unset __LLDB_Package
244250 ;;
245251 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
254258 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+
255265 ;;
256266 xenial) # Ubuntu 16.04
257267 if [[ " $__CodeName " != " jessie" ]]; then
@@ -323,15 +333,14 @@ while :; do
323333 alpine* )
324334 __CodeName=alpine
325335 __UbuntuRepo=
326- version=" ${lowerI/ alpine/ } "
327336
328- if [[ " $version " == " edge " ]]; then
337+ if [[ " $lowerI " == " alpineedge " ]]; then
329338 __AlpineVersion=edge
330339 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 "
335344 fi
336345 ;;
337346 freebsd13)
@@ -444,11 +453,18 @@ __RootfsDir="$( cd "$__RootfsDir" && pwd )"
444453
445454if [[ " $__CodeName " == " alpine" ]]; then
446455 __ApkToolsVersion=2.12.11
447- __ApkToolsSHA512SUM=53e57b49230da07ef44ee0765b9592580308c407a8d4da7125550957bb72cb59638e04f8892a18b584451c8d841d1c7cb0f0ab680cc323a3015776affaa3be33
448456 __ApkToolsDir=" $( mktemp -d) "
449457 __ApkKeysDir=" $( mktemp -d) "
450458
451- wget " https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic//v$__ApkToolsVersion /x86_64/apk.static" -P " $__ApkToolsDir "
459+ arch=" $( uname -m) "
460+ wget " https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v$__ApkToolsVersion /$arch /apk.static" -P " $__ApkToolsDir "
461+ if [[ " $arch " == " x86_64" ]]; then
462+ __ApkToolsSHA512SUM=" 53e57b49230da07ef44ee0765b9592580308c407a8d4da7125550957bb72cb59638e04f8892a18b584451c8d841d1c7cb0f0ab680cc323a3015776affaa3be33"
463+ elif [[ " $arch " == " aarch64" ]]; then
464+ __ApkToolsSHA512SUM=" 9e2b37ecb2b56c05dad23d379be84fd494c14bd730b620d0d576bda760588e1f2f59a7fcb2f2080577e0085f23a0ca8eadd993b4e61c2ab29549fdb71969afd0"
465+ else
466+ echo " WARNING: add missing hash for your host architecture. To find the value, use: 'find /tmp -name apk.static -exec sha512sum {} \;'"
467+ fi
452468 echo " $__ApkToolsSHA512SUM $__ApkToolsDir /apk.static" | sha512sum -c
453469 chmod +x " $__ApkToolsDir /apk.static"
454470
@@ -477,12 +493,14 @@ if [[ "$__CodeName" == "alpine" ]]; then
477493 fi
478494
479495 # initialize DB
496+ # shellcheck disable=SC2086
480497 " $__ApkToolsDir /apk.static" \
481498 -X " http://dl-cdn.alpinelinux.org/alpine/$version /main" \
482499 -X " http://dl-cdn.alpinelinux.org/alpine/$version /community" \
483500 -U $__ApkSignatureArg --root " $__RootfsDir " --arch " $__AlpineArch " --initdb add
484501
485502 if [[ " $__AlpineLlvmLibsLookup " == 1 ]]; then
503+ # shellcheck disable=SC2086
486504 __AlpinePackages+=" $( " $__ApkToolsDir /apk.static" \
487505 -X " http://dl-cdn.alpinelinux.org/alpine/$version /main" \
488506 -X " http://dl-cdn.alpinelinux.org/alpine/$version /community" \
@@ -491,6 +509,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
491509 fi
492510
493511 # install all packages in one go
512+ # shellcheck disable=SC2086
494513 " $__ApkToolsDir /apk.static" \
495514 -X " http://dl-cdn.alpinelinux.org/alpine/$version /main" \
496515 -X " http://dl-cdn.alpinelinux.org/alpine/$version /community" \
@@ -514,6 +533,7 @@ elif [[ "$__CodeName" == "freebsd" ]]; then
514533 rm -rf " $__RootfsDir /tmp/pkg-${__FreeBSDPkg} "
515534 # install packages we need.
516535 INSTALL_AS_USER=$( whoami) " $__RootfsDir " /host/sbin/pkg -r " $__RootfsDir " -C " $__RootfsDir " /usr/local/etc/pkg.conf update
536+ # shellcheck disable=SC2086
517537 INSTALL_AS_USER=$( whoami) " $__RootfsDir " /host/sbin/pkg -r " $__RootfsDir " -C " $__RootfsDir " /usr/local/etc/pkg.conf install --yes $__FreeBSDPackages
518538elif [[ " $__CodeName " == " illumos" ]]; then
519539 mkdir " $__RootfsDir /tmp"
@@ -575,8 +595,8 @@ elif [[ "$__CodeName" == "haiku" ]]; then
575595 mkdir " $__RootfsDir /tmp/download"
576596
577597 echo " Downloading Haiku package tool"
578- git clone https://github.com/haiku/haiku-toolchains-ubuntu --depth 1 $__RootfsDir /tmp/script
579- 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) "
580600 unzip -o " $__RootfsDir /tmp/download/hosttools.zip" -d " $__RootfsDir /tmp/bin"
581601
582602 DepotBaseUrl=" https://depot.haiku-os.org/__api/v2/pkg/get-pkg"
@@ -609,7 +629,7 @@ elif [[ "$__CodeName" == "haiku" ]]; then
609629
610630 # Download buildtools
611631 echo " Downloading Haiku buildtools"
612- 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 ) "
613633 unzip -o " $__RootfsDir /tmp/download/buildtools.zip" -d " $__RootfsDir "
614634
615635 # Cleaning up temporary files
@@ -622,10 +642,12 @@ elif [[ -n "$__CodeName" ]]; then
622642 __Keyring=" $__Keyring --force-check-gpg"
623643 fi
624644
645+ # shellcheck disable=SC2086
625646 debootstrap " --variant=minbase" $__Keyring --arch " $__UbuntuArch " " $__CodeName " " $__RootfsDir " " $__UbuntuRepo "
626647 cp " $__CrossDir /$__BuildArch /sources.list.$__CodeName " " $__RootfsDir /etc/apt/sources.list"
627648 chroot " $__RootfsDir " apt-get update
628649 chroot " $__RootfsDir " apt-get -f -y install
650+ # shellcheck disable=SC2086
629651 chroot " $__RootfsDir " apt-get -y install $__UbuntuPackages
630652 chroot " $__RootfsDir " symlinks -cr /usr
631653 chroot " $__RootfsDir " apt-get clean
@@ -643,6 +665,5 @@ elif [[ "$__Tizen" == "tizen" ]]; then
643665 ROOTFS_DIR=" $__RootfsDir " " $__CrossDir /tizen-build-rootfs.sh" " $__BuildArch "
644666else
645667 echo " Unsupported target platform."
646- usage;
647- exit 1
668+ usage
648669fi
0 commit comments