fix golang version bad output direction
[webi-installers/.git] / webi / bootstrap.bash
index 6c379a15561a89425e3e837dd0b7afd725112224..13d34d96d13c72c5a8a5cded4fb8357099cc7323 100644 (file)
@@ -4,6 +4,7 @@
 
 #WEBI_PKG=
 #WEBI_HOST=https://webinstall.dev
+export WEBI_HOST
 
 mkdir -p "$HOME/.local/bin"
 
@@ -26,21 +27,26 @@ fi
 
 my_ext=""
 set +e
+# NOTE: the order here is least favorable to most favorable
+if [ -n "\$(command -v pkgutil)" ]; then
+       my_ext="pkg,\$my_ext"
+fi
+# disable this check for the sake of building the macOS installer on Linux
+#if [ -n "\$(command -v diskutil)" ]; then
+       # note: could also detect via hdiutil
+       my_ext="dmg,\$my_ext"
+#fi
 if [ -n "\$(command -v git)" ]; then
        my_ext="git,\$my_ext"
 fi
-if [ -n "\$(command -v tar)" ]; then
-       my_ext="tar,\$my_ext"
+if [ -n "\$(command -v unxz)" ]; then
+       my_ext="xz,\$my_ext"
 fi
 if [ -n "\$(command -v unzip)" ]; then
        my_ext="zip,\$my_ext"
 fi
-if [ -n "\$(command -v pkgutil)" ]; then
-       my_ext="pkg,\$my_ext"
-fi
-if [ -n "\$(command -v diskutil)" ]; then
-       # note: could also detect via hdiutil
-       my_ext="dmg,\$my_ext"
+if [ -n "\$(command -v tar)" ]; then
+       my_ext="tar,\$my_ext"
 fi
 my_ext="\$(echo "\$my_ext" | sed 's/,$//')" # nix trailing comma
 set -e
@@ -58,6 +64,7 @@ export WEBI_HOST="\${WEBI_HOST:-https://webinstall.dev}"
 export WEBI_UA="\$(uname -a)"
 
 my_installer_url="\$WEBI_HOST/api/installers/\$my_package.bash?formats=\$my_ext"
+set +e
 if [ -n "\$WEBI_CURL" ]; then
        curl -fsSL "\$my_installer_url" -H "User-Agent: curl \$WEBI_UA" \\
                -o "\$WEBI_BOOT/\$my_package-bootstrap.sh"
@@ -65,6 +72,11 @@ else
        wget -q "\$my_installer_url" --user-agent="wget \$WEBI_UA" \\
                -O "\$WEBI_BOOT/\$my_package-bootstrap.sh"
 fi
+if ! [ \$? -eq 0 ]; then
+  echo "error fetching '\$my_installer_url'"
+  exit 1
+fi
+set -e
 
 pushd "\$WEBI_BOOT" 2>&1 > /dev/null
        bash "\$my_package-bootstrap.sh"