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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# shellcheck shell=dash
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the MIT license
|
| 5 |
+
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
| 6 |
+
# option. This file may not be copied, modified, or distributed
|
| 7 |
+
# except according to those terms.
|
| 8 |
+
|
| 9 |
+
if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
|
| 10 |
+
# The version of ksh93 that ships with many illumos systems does not
|
| 11 |
+
# support the "local" extension. Print a message rather than fail in
|
| 12 |
+
# subtle ways later on:
|
| 13 |
+
echo 'this installer does not work with this ksh93 version; please try bash!' >&2
|
| 14 |
+
exit 1
|
| 15 |
+
fi
|
| 16 |
+
|
| 17 |
+
set -u
|
| 18 |
+
|
| 19 |
+
APP_NAME="uv"
|
| 20 |
+
APP_VERSION="0.5.0"
|
| 21 |
+
# Look for GitHub Enterprise-style base URL first
|
| 22 |
+
if [ -n "${UV_INSTALLER_GHE_BASE_URL:-}" ]; then
|
| 23 |
+
INSTALLER_BASE_URL="$UV_INSTALLER_GHE_BASE_URL"
|
| 24 |
+
else
|
| 25 |
+
INSTALLER_BASE_URL="${UV_INSTALLER_GITHUB_BASE_URL:-https://github.com}"
|
| 26 |
+
fi
|
| 27 |
+
if [ -n "${INSTALLER_DOWNLOAD_URL:-}" ]; then
|
| 28 |
+
ARTIFACT_DOWNLOAD_URL="$INSTALLER_DOWNLOAD_URL"
|
| 29 |
+
else
|
| 30 |
+
ARTIFACT_DOWNLOAD_URL="${INSTALLER_BASE_URL}/astral-sh/uv/releases/download/0.5.0"
|
| 31 |
+
fi
|
| 32 |
+
PRINT_VERBOSE=${INSTALLER_PRINT_VERBOSE:-0}
|
| 33 |
+
PRINT_QUIET=${INSTALLER_PRINT_QUIET:-0}
|
| 34 |
+
if [ -n "${UV_NO_MODIFY_PATH:-}" ]; then
|
| 35 |
+
NO_MODIFY_PATH="$UV_NO_MODIFY_PATH"
|
| 36 |
+
else
|
| 37 |
+
NO_MODIFY_PATH=${INSTALLER_NO_MODIFY_PATH:-0}
|
| 38 |
+
fi
|
| 39 |
+
if [ "${UV_DISABLE_UPDATE:-0}" = "1" ]; then
|
| 40 |
+
INSTALL_UPDATER=0
|
| 41 |
+
else
|
| 42 |
+
INSTALL_UPDATER=1
|
| 43 |
+
fi
|
| 44 |
+
UNMANAGED_INSTALL="${UV_UNMANAGED_INSTALL:-}"
|
| 45 |
+
if [ -n "${UNMANAGED_INSTALL}" ]; then
|
| 46 |
+
NO_MODIFY_PATH=1
|
| 47 |
+
INSTALL_UPDATER=0
|
| 48 |
+
fi
|
| 49 |
+
|
| 50 |
+
read -r RECEIPT <<EORECEIPT
|
| 51 |
+
{"binaries":["CARGO_DIST_BINS"],"binary_aliases":{},"cdylibs":["CARGO_DIST_DYLIBS"],"cstaticlibs":["CARGO_DIST_STATICLIBS"],"install_layout":"unspecified","install_prefix":"AXO_INSTALL_PREFIX","modify_path":true,"provider":{"source":"cargo-dist","version":"0.25.1"},"source":{"app_name":"uv","name":"uv","owner":"astral-sh","release_type":"github"},"version":"0.5.0"}
|
| 52 |
+
EORECEIPT
|
| 53 |
+
RECEIPT_HOME="${HOME}/.config/uv"
|
| 54 |
+
|
| 55 |
+
usage() {
|
| 56 |
+
# print help (this cat/EOF stuff is a "heredoc" string)
|
| 57 |
+
cat <<EOF
|
| 58 |
+
uv-installer.sh
|
| 59 |
+
|
| 60 |
+
The installer for uv 0.5.0
|
| 61 |
+
|
| 62 |
+
This script detects what platform you're on and fetches an appropriate archive from
|
| 63 |
+
https://github.com/astral-sh/uv/releases/download/0.5.0
|
| 64 |
+
then unpacks the binaries and installs them to the first of the following locations
|
| 65 |
+
|
| 66 |
+
\$XDG_BIN_HOME
|
| 67 |
+
\$XDG_DATA_HOME/../bin
|
| 68 |
+
\$HOME/.local/bin
|
| 69 |
+
|
| 70 |
+
It will then add that dir to PATH by adding the appropriate line to your shell profiles.
|
| 71 |
+
|
| 72 |
+
USAGE:
|
| 73 |
+
uv-installer.sh [OPTIONS]
|
| 74 |
+
|
| 75 |
+
OPTIONS:
|
| 76 |
+
-v, --verbose
|
| 77 |
+
Enable verbose output
|
| 78 |
+
|
| 79 |
+
-q, --quiet
|
| 80 |
+
Disable progress output
|
| 81 |
+
|
| 82 |
+
--no-modify-path
|
| 83 |
+
Don't configure the PATH environment variable
|
| 84 |
+
|
| 85 |
+
-h, --help
|
| 86 |
+
Print help information
|
| 87 |
+
EOF
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
download_binary_and_run_installer() {
|
| 91 |
+
downloader --check
|
| 92 |
+
need_cmd uname
|
| 93 |
+
need_cmd mktemp
|
| 94 |
+
need_cmd chmod
|
| 95 |
+
need_cmd mkdir
|
| 96 |
+
need_cmd rm
|
| 97 |
+
need_cmd tar
|
| 98 |
+
need_cmd grep
|
| 99 |
+
need_cmd cat
|
| 100 |
+
|
| 101 |
+
for arg in "$@"; do
|
| 102 |
+
case "$arg" in
|
| 103 |
+
--help)
|
| 104 |
+
usage
|
| 105 |
+
exit 0
|
| 106 |
+
;;
|
| 107 |
+
--quiet)
|
| 108 |
+
PRINT_QUIET=1
|
| 109 |
+
;;
|
| 110 |
+
--verbose)
|
| 111 |
+
PRINT_VERBOSE=1
|
| 112 |
+
;;
|
| 113 |
+
--no-modify-path)
|
| 114 |
+
say "--no-modify-path has been deprecated; please set UV_NO_MODIFY_PATH=1 in the environment"
|
| 115 |
+
NO_MODIFY_PATH=1
|
| 116 |
+
;;
|
| 117 |
+
*)
|
| 118 |
+
OPTIND=1
|
| 119 |
+
if [ "${arg%%--*}" = "" ]; then
|
| 120 |
+
err "unknown option $arg"
|
| 121 |
+
fi
|
| 122 |
+
while getopts :hvq sub_arg "$arg"; do
|
| 123 |
+
case "$sub_arg" in
|
| 124 |
+
h)
|
| 125 |
+
usage
|
| 126 |
+
exit 0
|
| 127 |
+
;;
|
| 128 |
+
v)
|
| 129 |
+
# user wants to skip the prompt --
|
| 130 |
+
# we don't need /dev/tty
|
| 131 |
+
PRINT_VERBOSE=1
|
| 132 |
+
;;
|
| 133 |
+
q)
|
| 134 |
+
# user wants to skip the prompt --
|
| 135 |
+
# we don't need /dev/tty
|
| 136 |
+
PRINT_QUIET=1
|
| 137 |
+
;;
|
| 138 |
+
*)
|
| 139 |
+
err "unknown option -$OPTARG"
|
| 140 |
+
;;
|
| 141 |
+
esac
|
| 142 |
+
done
|
| 143 |
+
;;
|
| 144 |
+
esac
|
| 145 |
+
done
|
| 146 |
+
|
| 147 |
+
get_architecture || return 1
|
| 148 |
+
local _true_arch="$RETVAL"
|
| 149 |
+
assert_nz "$_true_arch" "arch"
|
| 150 |
+
local _cur_arch="$_true_arch"
|
| 151 |
+
|
| 152 |
+
# Lookup what archives support this platform
|
| 153 |
+
local _artifact_name
|
| 154 |
+
_artifact_name="$(select_archive_for_arch "$_true_arch")" || return 1
|
| 155 |
+
local _bins
|
| 156 |
+
local _zip_ext
|
| 157 |
+
local _arch
|
| 158 |
+
|
| 159 |
+
# try each archive, checking runtime conditions like libc versions
|
| 160 |
+
# accepting the first one that matches, as it's the best match
|
| 161 |
+
case "$_artifact_name" in
|
| 162 |
+
"uv-aarch64-apple-darwin.tar.gz")
|
| 163 |
+
_arch="aarch64-apple-darwin"
|
| 164 |
+
_zip_ext=".tar.gz"
|
| 165 |
+
_bins="uv uvx"
|
| 166 |
+
_bins_js_array='"uv","uvx"'
|
| 167 |
+
_libs=""
|
| 168 |
+
_libs_js_array=""
|
| 169 |
+
_staticlibs=""
|
| 170 |
+
_staticlibs_js_array=""
|
| 171 |
+
_updater_name=""
|
| 172 |
+
_updater_bin=""
|
| 173 |
+
;;
|
| 174 |
+
"uv-aarch64-unknown-linux-gnu.tar.gz")
|
| 175 |
+
_arch="aarch64-unknown-linux-gnu"
|
| 176 |
+
_zip_ext=".tar.gz"
|
| 177 |
+
_bins="uv uvx"
|
| 178 |
+
_bins_js_array='"uv","uvx"'
|
| 179 |
+
_libs=""
|
| 180 |
+
_libs_js_array=""
|
| 181 |
+
_staticlibs=""
|
| 182 |
+
_staticlibs_js_array=""
|
| 183 |
+
_updater_name=""
|
| 184 |
+
_updater_bin=""
|
| 185 |
+
;;
|
| 186 |
+
"uv-aarch64-unknown-linux-musl.tar.gz")
|
| 187 |
+
_arch="aarch64-unknown-linux-musl-static"
|
| 188 |
+
_zip_ext=".tar.gz"
|
| 189 |
+
_bins="uv uvx"
|
| 190 |
+
_bins_js_array='"uv","uvx"'
|
| 191 |
+
_libs=""
|
| 192 |
+
_libs_js_array=""
|
| 193 |
+
_staticlibs=""
|
| 194 |
+
_staticlibs_js_array=""
|
| 195 |
+
_updater_name=""
|
| 196 |
+
_updater_bin=""
|
| 197 |
+
;;
|
| 198 |
+
"uv-arm-unknown-linux-musleabihf.tar.gz")
|
| 199 |
+
_arch="arm-unknown-linux-musl-staticeabihf"
|
| 200 |
+
_zip_ext=".tar.gz"
|
| 201 |
+
_bins="uv uvx"
|
| 202 |
+
_bins_js_array='"uv","uvx"'
|
| 203 |
+
_libs=""
|
| 204 |
+
_libs_js_array=""
|
| 205 |
+
_staticlibs=""
|
| 206 |
+
_staticlibs_js_array=""
|
| 207 |
+
_updater_name=""
|
| 208 |
+
_updater_bin=""
|
| 209 |
+
;;
|
| 210 |
+
"uv-armv7-unknown-linux-gnueabihf.tar.gz")
|
| 211 |
+
_arch="armv7-unknown-linux-gnueabihf"
|
| 212 |
+
_zip_ext=".tar.gz"
|
| 213 |
+
_bins="uv uvx"
|
| 214 |
+
_bins_js_array='"uv","uvx"'
|
| 215 |
+
_libs=""
|
| 216 |
+
_libs_js_array=""
|
| 217 |
+
_staticlibs=""
|
| 218 |
+
_staticlibs_js_array=""
|
| 219 |
+
_updater_name=""
|
| 220 |
+
_updater_bin=""
|
| 221 |
+
;;
|
| 222 |
+
"uv-armv7-unknown-linux-musleabihf.tar.gz")
|
| 223 |
+
_arch="armv7-unknown-linux-musl-staticeabihf"
|
| 224 |
+
_zip_ext=".tar.gz"
|
| 225 |
+
_bins="uv uvx"
|
| 226 |
+
_bins_js_array='"uv","uvx"'
|
| 227 |
+
_libs=""
|
| 228 |
+
_libs_js_array=""
|
| 229 |
+
_staticlibs=""
|
| 230 |
+
_staticlibs_js_array=""
|
| 231 |
+
_updater_name=""
|
| 232 |
+
_updater_bin=""
|
| 233 |
+
;;
|
| 234 |
+
"uv-i686-pc-windows-msvc.zip")
|
| 235 |
+
_arch="i686-pc-windows-msvc"
|
| 236 |
+
_zip_ext=".zip"
|
| 237 |
+
_bins="uv.exe uvx.exe"
|
| 238 |
+
_bins_js_array='"uv.exe","uvx.exe"'
|
| 239 |
+
_libs=""
|
| 240 |
+
_libs_js_array=""
|
| 241 |
+
_staticlibs=""
|
| 242 |
+
_staticlibs_js_array=""
|
| 243 |
+
_updater_name=""
|
| 244 |
+
_updater_bin=""
|
| 245 |
+
;;
|
| 246 |
+
"uv-i686-unknown-linux-gnu.tar.gz")
|
| 247 |
+
_arch="i686-unknown-linux-gnu"
|
| 248 |
+
_zip_ext=".tar.gz"
|
| 249 |
+
_bins="uv uvx"
|
| 250 |
+
_bins_js_array='"uv","uvx"'
|
| 251 |
+
_libs=""
|
| 252 |
+
_libs_js_array=""
|
| 253 |
+
_staticlibs=""
|
| 254 |
+
_staticlibs_js_array=""
|
| 255 |
+
_updater_name=""
|
| 256 |
+
_updater_bin=""
|
| 257 |
+
;;
|
| 258 |
+
"uv-i686-unknown-linux-musl.tar.gz")
|
| 259 |
+
_arch="i686-unknown-linux-musl-static"
|
| 260 |
+
_zip_ext=".tar.gz"
|
| 261 |
+
_bins="uv uvx"
|
| 262 |
+
_bins_js_array='"uv","uvx"'
|
| 263 |
+
_libs=""
|
| 264 |
+
_libs_js_array=""
|
| 265 |
+
_staticlibs=""
|
| 266 |
+
_staticlibs_js_array=""
|
| 267 |
+
_updater_name=""
|
| 268 |
+
_updater_bin=""
|
| 269 |
+
;;
|
| 270 |
+
"uv-powerpc64-unknown-linux-gnu.tar.gz")
|
| 271 |
+
_arch="powerpc64-unknown-linux-gnu"
|
| 272 |
+
_zip_ext=".tar.gz"
|
| 273 |
+
_bins="uv uvx"
|
| 274 |
+
_bins_js_array='"uv","uvx"'
|
| 275 |
+
_libs=""
|
| 276 |
+
_libs_js_array=""
|
| 277 |
+
_staticlibs=""
|
| 278 |
+
_staticlibs_js_array=""
|
| 279 |
+
_updater_name=""
|
| 280 |
+
_updater_bin=""
|
| 281 |
+
;;
|
| 282 |
+
"uv-powerpc64le-unknown-linux-gnu.tar.gz")
|
| 283 |
+
_arch="powerpc64le-unknown-linux-gnu"
|
| 284 |
+
_zip_ext=".tar.gz"
|
| 285 |
+
_bins="uv uvx"
|
| 286 |
+
_bins_js_array='"uv","uvx"'
|
| 287 |
+
_libs=""
|
| 288 |
+
_libs_js_array=""
|
| 289 |
+
_staticlibs=""
|
| 290 |
+
_staticlibs_js_array=""
|
| 291 |
+
_updater_name=""
|
| 292 |
+
_updater_bin=""
|
| 293 |
+
;;
|
| 294 |
+
"uv-s390x-unknown-linux-gnu.tar.gz")
|
| 295 |
+
_arch="s390x-unknown-linux-gnu"
|
| 296 |
+
_zip_ext=".tar.gz"
|
| 297 |
+
_bins="uv uvx"
|
| 298 |
+
_bins_js_array='"uv","uvx"'
|
| 299 |
+
_libs=""
|
| 300 |
+
_libs_js_array=""
|
| 301 |
+
_staticlibs=""
|
| 302 |
+
_staticlibs_js_array=""
|
| 303 |
+
_updater_name=""
|
| 304 |
+
_updater_bin=""
|
| 305 |
+
;;
|
| 306 |
+
"uv-x86_64-apple-darwin.tar.gz")
|
| 307 |
+
_arch="x86_64-apple-darwin"
|
| 308 |
+
_zip_ext=".tar.gz"
|
| 309 |
+
_bins="uv uvx"
|
| 310 |
+
_bins_js_array='"uv","uvx"'
|
| 311 |
+
_libs=""
|
| 312 |
+
_libs_js_array=""
|
| 313 |
+
_staticlibs=""
|
| 314 |
+
_staticlibs_js_array=""
|
| 315 |
+
_updater_name=""
|
| 316 |
+
_updater_bin=""
|
| 317 |
+
;;
|
| 318 |
+
"uv-x86_64-pc-windows-msvc.zip")
|
| 319 |
+
_arch="x86_64-pc-windows-msvc"
|
| 320 |
+
_zip_ext=".zip"
|
| 321 |
+
_bins="uv.exe uvx.exe"
|
| 322 |
+
_bins_js_array='"uv.exe","uvx.exe"'
|
| 323 |
+
_libs=""
|
| 324 |
+
_libs_js_array=""
|
| 325 |
+
_staticlibs=""
|
| 326 |
+
_staticlibs_js_array=""
|
| 327 |
+
_updater_name=""
|
| 328 |
+
_updater_bin=""
|
| 329 |
+
;;
|
| 330 |
+
"uv-x86_64-unknown-linux-gnu.tar.gz")
|
| 331 |
+
_arch="x86_64-unknown-linux-gnu"
|
| 332 |
+
_zip_ext=".tar.gz"
|
| 333 |
+
_bins="uv uvx"
|
| 334 |
+
_bins_js_array='"uv","uvx"'
|
| 335 |
+
_libs=""
|
| 336 |
+
_libs_js_array=""
|
| 337 |
+
_staticlibs=""
|
| 338 |
+
_staticlibs_js_array=""
|
| 339 |
+
_updater_name=""
|
| 340 |
+
_updater_bin=""
|
| 341 |
+
;;
|
| 342 |
+
"uv-x86_64-unknown-linux-musl.tar.gz")
|
| 343 |
+
_arch="x86_64-unknown-linux-musl-static"
|
| 344 |
+
_zip_ext=".tar.gz"
|
| 345 |
+
_bins="uv uvx"
|
| 346 |
+
_bins_js_array='"uv","uvx"'
|
| 347 |
+
_libs=""
|
| 348 |
+
_libs_js_array=""
|
| 349 |
+
_staticlibs=""
|
| 350 |
+
_staticlibs_js_array=""
|
| 351 |
+
_updater_name=""
|
| 352 |
+
_updater_bin=""
|
| 353 |
+
;;
|
| 354 |
+
*)
|
| 355 |
+
err "internal installer error: selected download $_artifact_name doesn't exist!?"
|
| 356 |
+
;;
|
| 357 |
+
esac
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
# Replace the placeholder binaries with the calculated array from above
|
| 361 |
+
RECEIPT="$(echo "$RECEIPT" | sed s/'"CARGO_DIST_BINS"'/"$_bins_js_array"/)"
|
| 362 |
+
RECEIPT="$(echo "$RECEIPT" | sed s/'"CARGO_DIST_DYLIBS"'/"$_libs_js_array"/)"
|
| 363 |
+
RECEIPT="$(echo "$RECEIPT" | sed s/'"CARGO_DIST_STATICLIBS"'/"$_staticlibs_js_array"/)"
|
| 364 |
+
|
| 365 |
+
# download the archive
|
| 366 |
+
local _url="$ARTIFACT_DOWNLOAD_URL/$_artifact_name"
|
| 367 |
+
local _dir
|
| 368 |
+
_dir="$(ensure mktemp -d)" || return 1
|
| 369 |
+
local _file="$_dir/input$_zip_ext"
|
| 370 |
+
|
| 371 |
+
say "downloading $APP_NAME $APP_VERSION ${_arch}" 1>&2
|
| 372 |
+
say_verbose " from $_url" 1>&2
|
| 373 |
+
say_verbose " to $_file" 1>&2
|
| 374 |
+
|
| 375 |
+
ensure mkdir -p "$_dir"
|
| 376 |
+
|
| 377 |
+
if ! downloader "$_url" "$_file"; then
|
| 378 |
+
say "failed to download $_url"
|
| 379 |
+
say "this may be a standard network error, but it may also indicate"
|
| 380 |
+
say "that $APP_NAME's release process is not working. When in doubt"
|
| 381 |
+
say "please feel free to open an issue!"
|
| 382 |
+
exit 1
|
| 383 |
+
fi
|
| 384 |
+
|
| 385 |
+
# ...and then the updater, if it exists
|
| 386 |
+
if [ -n "$_updater_name" ] && [ "$INSTALL_UPDATER" = "1" ]; then
|
| 387 |
+
local _updater_url="$ARTIFACT_DOWNLOAD_URL/$_updater_name"
|
| 388 |
+
# This renames the artifact while doing the download, removing the
|
| 389 |
+
# target triple and leaving just the appname-update format
|
| 390 |
+
local _updater_file="$_dir/$APP_NAME-update"
|
| 391 |
+
|
| 392 |
+
if ! downloader "$_updater_url" "$_updater_file"; then
|
| 393 |
+
say "failed to download $_updater_url"
|
| 394 |
+
say "this may be a standard network error, but it may also indicate"
|
| 395 |
+
say "that $APP_NAME's release process is not working. When in doubt"
|
| 396 |
+
say "please feel free to open an issue!"
|
| 397 |
+
exit 1
|
| 398 |
+
fi
|
| 399 |
+
|
| 400 |
+
# Add the updater to the list of binaries to install
|
| 401 |
+
_bins="$_bins $APP_NAME-update"
|
| 402 |
+
fi
|
| 403 |
+
|
| 404 |
+
# unpack the archive
|
| 405 |
+
case "$_zip_ext" in
|
| 406 |
+
".zip")
|
| 407 |
+
ensure unzip -q "$_file" -d "$_dir"
|
| 408 |
+
;;
|
| 409 |
+
|
| 410 |
+
".tar."*)
|
| 411 |
+
ensure tar xf "$_file" --strip-components 1 -C "$_dir"
|
| 412 |
+
;;
|
| 413 |
+
*)
|
| 414 |
+
err "unknown archive format: $_zip_ext"
|
| 415 |
+
;;
|
| 416 |
+
esac
|
| 417 |
+
|
| 418 |
+
install "$_dir" "$_bins" "$_libs" "$_staticlibs" "$_arch" "$@"
|
| 419 |
+
local _retval=$?
|
| 420 |
+
if [ "$_retval" != 0 ]; then
|
| 421 |
+
return "$_retval"
|
| 422 |
+
fi
|
| 423 |
+
|
| 424 |
+
ignore rm -rf "$_dir"
|
| 425 |
+
|
| 426 |
+
# Install the install receipt
|
| 427 |
+
if [ "$INSTALL_UPDATER" = "1" ]; then
|
| 428 |
+
if ! mkdir -p "$RECEIPT_HOME"; then
|
| 429 |
+
err "unable to create receipt directory at $RECEIPT_HOME"
|
| 430 |
+
else
|
| 431 |
+
echo "$RECEIPT" > "$RECEIPT_HOME/$APP_NAME-receipt.json"
|
| 432 |
+
# shellcheck disable=SC2320
|
| 433 |
+
local _retval=$?
|
| 434 |
+
fi
|
| 435 |
+
else
|
| 436 |
+
local _retval=0
|
| 437 |
+
fi
|
| 438 |
+
|
| 439 |
+
return "$_retval"
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
# Replaces $HOME with the variable name for display to the user,
|
| 443 |
+
# only if $HOME is defined.
|
| 444 |
+
replace_home() {
|
| 445 |
+
local _str="$1"
|
| 446 |
+
|
| 447 |
+
if [ -n "${HOME:-}" ]; then
|
| 448 |
+
echo "$_str" | sed "s,$HOME,\$HOME,"
|
| 449 |
+
else
|
| 450 |
+
echo "$_str"
|
| 451 |
+
fi
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
json_binary_aliases() {
|
| 455 |
+
local _arch="$1"
|
| 456 |
+
|
| 457 |
+
case "$_arch" in
|
| 458 |
+
"aarch64-apple-darwin")
|
| 459 |
+
echo '{}'
|
| 460 |
+
;;
|
| 461 |
+
"aarch64-unknown-linux-gnu")
|
| 462 |
+
echo '{}'
|
| 463 |
+
;;
|
| 464 |
+
"aarch64-unknown-linux-musl-dynamic")
|
| 465 |
+
echo '{}'
|
| 466 |
+
;;
|
| 467 |
+
"aarch64-unknown-linux-musl-static")
|
| 468 |
+
echo '{}'
|
| 469 |
+
;;
|
| 470 |
+
"arm-unknown-linux-gnueabihf")
|
| 471 |
+
echo '{}'
|
| 472 |
+
;;
|
| 473 |
+
"arm-unknown-linux-musl-dynamiceabihf")
|
| 474 |
+
echo '{}'
|
| 475 |
+
;;
|
| 476 |
+
"arm-unknown-linux-musl-staticeabihf")
|
| 477 |
+
echo '{}'
|
| 478 |
+
;;
|
| 479 |
+
"armv7-unknown-linux-gnueabihf")
|
| 480 |
+
echo '{}'
|
| 481 |
+
;;
|
| 482 |
+
"armv7-unknown-linux-musl-dynamiceabihf")
|
| 483 |
+
echo '{}'
|
| 484 |
+
;;
|
| 485 |
+
"armv7-unknown-linux-musl-staticeabihf")
|
| 486 |
+
echo '{}'
|
| 487 |
+
;;
|
| 488 |
+
"i686-pc-windows-gnu")
|
| 489 |
+
echo '{}'
|
| 490 |
+
;;
|
| 491 |
+
"i686-unknown-linux-gnu")
|
| 492 |
+
echo '{}'
|
| 493 |
+
;;
|
| 494 |
+
"i686-unknown-linux-musl-dynamic")
|
| 495 |
+
echo '{}'
|
| 496 |
+
;;
|
| 497 |
+
"i686-unknown-linux-musl-static")
|
| 498 |
+
echo '{}'
|
| 499 |
+
;;
|
| 500 |
+
"powerpc64-unknown-linux-gnu")
|
| 501 |
+
echo '{}'
|
| 502 |
+
;;
|
| 503 |
+
"powerpc64le-unknown-linux-gnu")
|
| 504 |
+
echo '{}'
|
| 505 |
+
;;
|
| 506 |
+
"s390x-unknown-linux-gnu")
|
| 507 |
+
echo '{}'
|
| 508 |
+
;;
|
| 509 |
+
"x86_64-apple-darwin")
|
| 510 |
+
echo '{}'
|
| 511 |
+
;;
|
| 512 |
+
"x86_64-pc-windows-gnu")
|
| 513 |
+
echo '{}'
|
| 514 |
+
;;
|
| 515 |
+
"x86_64-unknown-linux-gnu")
|
| 516 |
+
echo '{}'
|
| 517 |
+
;;
|
| 518 |
+
"x86_64-unknown-linux-musl-dynamic")
|
| 519 |
+
echo '{}'
|
| 520 |
+
;;
|
| 521 |
+
"x86_64-unknown-linux-musl-static")
|
| 522 |
+
echo '{}'
|
| 523 |
+
;;
|
| 524 |
+
*)
|
| 525 |
+
echo '{}'
|
| 526 |
+
;;
|
| 527 |
+
esac
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
aliases_for_binary() {
|
| 531 |
+
local _bin="$1"
|
| 532 |
+
local _arch="$2"
|
| 533 |
+
|
| 534 |
+
case "$_arch" in
|
| 535 |
+
"aarch64-apple-darwin")
|
| 536 |
+
case "$_bin" in
|
| 537 |
+
*)
|
| 538 |
+
echo ""
|
| 539 |
+
;;
|
| 540 |
+
esac
|
| 541 |
+
;;
|
| 542 |
+
"aarch64-unknown-linux-gnu")
|
| 543 |
+
case "$_bin" in
|
| 544 |
+
*)
|
| 545 |
+
echo ""
|
| 546 |
+
;;
|
| 547 |
+
esac
|
| 548 |
+
;;
|
| 549 |
+
"aarch64-unknown-linux-musl-dynamic")
|
| 550 |
+
case "$_bin" in
|
| 551 |
+
*)
|
| 552 |
+
echo ""
|
| 553 |
+
;;
|
| 554 |
+
esac
|
| 555 |
+
;;
|
| 556 |
+
"aarch64-unknown-linux-musl-static")
|
| 557 |
+
case "$_bin" in
|
| 558 |
+
*)
|
| 559 |
+
echo ""
|
| 560 |
+
;;
|
| 561 |
+
esac
|
| 562 |
+
;;
|
| 563 |
+
"arm-unknown-linux-gnueabihf")
|
| 564 |
+
case "$_bin" in
|
| 565 |
+
*)
|
| 566 |
+
echo ""
|
| 567 |
+
;;
|
| 568 |
+
esac
|
| 569 |
+
;;
|
| 570 |
+
"arm-unknown-linux-musl-dynamiceabihf")
|
| 571 |
+
case "$_bin" in
|
| 572 |
+
*)
|
| 573 |
+
echo ""
|
| 574 |
+
;;
|
| 575 |
+
esac
|
| 576 |
+
;;
|
| 577 |
+
"arm-unknown-linux-musl-staticeabihf")
|
| 578 |
+
case "$_bin" in
|
| 579 |
+
*)
|
| 580 |
+
echo ""
|
| 581 |
+
;;
|
| 582 |
+
esac
|
| 583 |
+
;;
|
| 584 |
+
"armv7-unknown-linux-gnueabihf")
|
| 585 |
+
case "$_bin" in
|
| 586 |
+
*)
|
| 587 |
+
echo ""
|
| 588 |
+
;;
|
| 589 |
+
esac
|
| 590 |
+
;;
|
| 591 |
+
"armv7-unknown-linux-musl-dynamiceabihf")
|
| 592 |
+
case "$_bin" in
|
| 593 |
+
*)
|
| 594 |
+
echo ""
|
| 595 |
+
;;
|
| 596 |
+
esac
|
| 597 |
+
;;
|
| 598 |
+
"armv7-unknown-linux-musl-staticeabihf")
|
| 599 |
+
case "$_bin" in
|
| 600 |
+
*)
|
| 601 |
+
echo ""
|
| 602 |
+
;;
|
| 603 |
+
esac
|
| 604 |
+
;;
|
| 605 |
+
"i686-pc-windows-gnu")
|
| 606 |
+
case "$_bin" in
|
| 607 |
+
*)
|
| 608 |
+
echo ""
|
| 609 |
+
;;
|
| 610 |
+
esac
|
| 611 |
+
;;
|
| 612 |
+
"i686-unknown-linux-gnu")
|
| 613 |
+
case "$_bin" in
|
| 614 |
+
*)
|
| 615 |
+
echo ""
|
| 616 |
+
;;
|
| 617 |
+
esac
|
| 618 |
+
;;
|
| 619 |
+
"i686-unknown-linux-musl-dynamic")
|
| 620 |
+
case "$_bin" in
|
| 621 |
+
*)
|
| 622 |
+
echo ""
|
| 623 |
+
;;
|
| 624 |
+
esac
|
| 625 |
+
;;
|
| 626 |
+
"i686-unknown-linux-musl-static")
|
| 627 |
+
case "$_bin" in
|
| 628 |
+
*)
|
| 629 |
+
echo ""
|
| 630 |
+
;;
|
| 631 |
+
esac
|
| 632 |
+
;;
|
| 633 |
+
"powerpc64-unknown-linux-gnu")
|
| 634 |
+
case "$_bin" in
|
| 635 |
+
*)
|
| 636 |
+
echo ""
|
| 637 |
+
;;
|
| 638 |
+
esac
|
| 639 |
+
;;
|
| 640 |
+
"powerpc64le-unknown-linux-gnu")
|
| 641 |
+
case "$_bin" in
|
| 642 |
+
*)
|
| 643 |
+
echo ""
|
| 644 |
+
;;
|
| 645 |
+
esac
|
| 646 |
+
;;
|
| 647 |
+
"s390x-unknown-linux-gnu")
|
| 648 |
+
case "$_bin" in
|
| 649 |
+
*)
|
| 650 |
+
echo ""
|
| 651 |
+
;;
|
| 652 |
+
esac
|
| 653 |
+
;;
|
| 654 |
+
"x86_64-apple-darwin")
|
| 655 |
+
case "$_bin" in
|
| 656 |
+
*)
|
| 657 |
+
echo ""
|
| 658 |
+
;;
|
| 659 |
+
esac
|
| 660 |
+
;;
|
| 661 |
+
"x86_64-pc-windows-gnu")
|
| 662 |
+
case "$_bin" in
|
| 663 |
+
*)
|
| 664 |
+
echo ""
|
| 665 |
+
;;
|
| 666 |
+
esac
|
| 667 |
+
;;
|
| 668 |
+
"x86_64-unknown-linux-gnu")
|
| 669 |
+
case "$_bin" in
|
| 670 |
+
*)
|
| 671 |
+
echo ""
|
| 672 |
+
;;
|
| 673 |
+
esac
|
| 674 |
+
;;
|
| 675 |
+
"x86_64-unknown-linux-musl-dynamic")
|
| 676 |
+
case "$_bin" in
|
| 677 |
+
*)
|
| 678 |
+
echo ""
|
| 679 |
+
;;
|
| 680 |
+
esac
|
| 681 |
+
;;
|
| 682 |
+
"x86_64-unknown-linux-musl-static")
|
| 683 |
+
case "$_bin" in
|
| 684 |
+
*)
|
| 685 |
+
echo ""
|
| 686 |
+
;;
|
| 687 |
+
esac
|
| 688 |
+
;;
|
| 689 |
+
*)
|
| 690 |
+
echo ""
|
| 691 |
+
;;
|
| 692 |
+
esac
|
| 693 |
+
}
|
| 694 |
+
|
| 695 |
+
select_archive_for_arch() {
|
| 696 |
+
local _true_arch="$1"
|
| 697 |
+
local _archive
|
| 698 |
+
case "$_true_arch" in
|
| 699 |
+
"aarch64-apple-darwin")
|
| 700 |
+
_archive="uv-aarch64-apple-darwin.tar.gz"
|
| 701 |
+
if [ -n "$_archive" ]; then
|
| 702 |
+
echo "$_archive"
|
| 703 |
+
return 0
|
| 704 |
+
fi
|
| 705 |
+
_archive="uv-x86_64-apple-darwin.tar.gz"
|
| 706 |
+
if [ -n "$_archive" ]; then
|
| 707 |
+
echo "$_archive"
|
| 708 |
+
return 0
|
| 709 |
+
fi
|
| 710 |
+
;;
|
| 711 |
+
"aarch64-pc-windows-msvc")
|
| 712 |
+
_archive="uv-x86_64-pc-windows-msvc.zip"
|
| 713 |
+
if [ -n "$_archive" ]; then
|
| 714 |
+
echo "$_archive"
|
| 715 |
+
return 0
|
| 716 |
+
fi
|
| 717 |
+
_archive="uv-i686-pc-windows-msvc.zip"
|
| 718 |
+
if [ -n "$_archive" ]; then
|
| 719 |
+
echo "$_archive"
|
| 720 |
+
return 0
|
| 721 |
+
fi
|
| 722 |
+
;;
|
| 723 |
+
"aarch64-unknown-linux-gnu")
|
| 724 |
+
_archive="uv-aarch64-unknown-linux-gnu.tar.gz"
|
| 725 |
+
if ! check_glibc "2" "31"; then
|
| 726 |
+
_archive=""
|
| 727 |
+
fi
|
| 728 |
+
if [ -n "$_archive" ]; then
|
| 729 |
+
echo "$_archive"
|
| 730 |
+
return 0
|
| 731 |
+
fi
|
| 732 |
+
_archive="uv-aarch64-unknown-linux-musl.tar.gz"
|
| 733 |
+
if [ -n "$_archive" ]; then
|
| 734 |
+
echo "$_archive"
|
| 735 |
+
return 0
|
| 736 |
+
fi
|
| 737 |
+
;;
|
| 738 |
+
"aarch64-unknown-linux-musl-dynamic")
|
| 739 |
+
_archive="uv-aarch64-unknown-linux-musl.tar.gz"
|
| 740 |
+
if [ -n "$_archive" ]; then
|
| 741 |
+
echo "$_archive"
|
| 742 |
+
return 0
|
| 743 |
+
fi
|
| 744 |
+
;;
|
| 745 |
+
"aarch64-unknown-linux-musl-static")
|
| 746 |
+
_archive="uv-aarch64-unknown-linux-musl.tar.gz"
|
| 747 |
+
if [ -n "$_archive" ]; then
|
| 748 |
+
echo "$_archive"
|
| 749 |
+
return 0
|
| 750 |
+
fi
|
| 751 |
+
;;
|
| 752 |
+
"arm-unknown-linux-gnueabihf")
|
| 753 |
+
_archive="uv-arm-unknown-linux-musleabihf.tar.gz"
|
| 754 |
+
if [ -n "$_archive" ]; then
|
| 755 |
+
echo "$_archive"
|
| 756 |
+
return 0
|
| 757 |
+
fi
|
| 758 |
+
;;
|
| 759 |
+
"arm-unknown-linux-musl-dynamiceabihf")
|
| 760 |
+
_archive="uv-arm-unknown-linux-musleabihf.tar.gz"
|
| 761 |
+
if [ -n "$_archive" ]; then
|
| 762 |
+
echo "$_archive"
|
| 763 |
+
return 0
|
| 764 |
+
fi
|
| 765 |
+
;;
|
| 766 |
+
"arm-unknown-linux-musl-staticeabihf")
|
| 767 |
+
_archive="uv-arm-unknown-linux-musleabihf.tar.gz"
|
| 768 |
+
if [ -n "$_archive" ]; then
|
| 769 |
+
echo "$_archive"
|
| 770 |
+
return 0
|
| 771 |
+
fi
|
| 772 |
+
;;
|
| 773 |
+
"armv7-unknown-linux-gnueabihf")
|
| 774 |
+
_archive="uv-armv7-unknown-linux-gnueabihf.tar.gz"
|
| 775 |
+
if ! check_glibc "2" "31"; then
|
| 776 |
+
_archive=""
|
| 777 |
+
fi
|
| 778 |
+
if [ -n "$_archive" ]; then
|
| 779 |
+
echo "$_archive"
|
| 780 |
+
return 0
|
| 781 |
+
fi
|
| 782 |
+
_archive="uv-armv7-unknown-linux-musleabihf.tar.gz"
|
| 783 |
+
if [ -n "$_archive" ]; then
|
| 784 |
+
echo "$_archive"
|
| 785 |
+
return 0
|
| 786 |
+
fi
|
| 787 |
+
;;
|
| 788 |
+
"armv7-unknown-linux-musl-dynamiceabihf")
|
| 789 |
+
_archive="uv-armv7-unknown-linux-musleabihf.tar.gz"
|
| 790 |
+
if [ -n "$_archive" ]; then
|
| 791 |
+
echo "$_archive"
|
| 792 |
+
return 0
|
| 793 |
+
fi
|
| 794 |
+
;;
|
| 795 |
+
"armv7-unknown-linux-musl-staticeabihf")
|
| 796 |
+
_archive="uv-armv7-unknown-linux-musleabihf.tar.gz"
|
| 797 |
+
if [ -n "$_archive" ]; then
|
| 798 |
+
echo "$_archive"
|
| 799 |
+
return 0
|
| 800 |
+
fi
|
| 801 |
+
;;
|
| 802 |
+
"i686-pc-windows-gnu")
|
| 803 |
+
_archive="uv-i686-pc-windows-msvc.zip"
|
| 804 |
+
if [ -n "$_archive" ]; then
|
| 805 |
+
echo "$_archive"
|
| 806 |
+
return 0
|
| 807 |
+
fi
|
| 808 |
+
;;
|
| 809 |
+
"i686-pc-windows-msvc")
|
| 810 |
+
_archive="uv-i686-pc-windows-msvc.zip"
|
| 811 |
+
if [ -n "$_archive" ]; then
|
| 812 |
+
echo "$_archive"
|
| 813 |
+
return 0
|
| 814 |
+
fi
|
| 815 |
+
;;
|
| 816 |
+
"i686-unknown-linux-gnu")
|
| 817 |
+
_archive="uv-i686-unknown-linux-gnu.tar.gz"
|
| 818 |
+
if ! check_glibc "2" "31"; then
|
| 819 |
+
_archive=""
|
| 820 |
+
fi
|
| 821 |
+
if [ -n "$_archive" ]; then
|
| 822 |
+
echo "$_archive"
|
| 823 |
+
return 0
|
| 824 |
+
fi
|
| 825 |
+
_archive="uv-i686-unknown-linux-musl.tar.gz"
|
| 826 |
+
if [ -n "$_archive" ]; then
|
| 827 |
+
echo "$_archive"
|
| 828 |
+
return 0
|
| 829 |
+
fi
|
| 830 |
+
;;
|
| 831 |
+
"i686-unknown-linux-musl-dynamic")
|
| 832 |
+
_archive="uv-i686-unknown-linux-musl.tar.gz"
|
| 833 |
+
if [ -n "$_archive" ]; then
|
| 834 |
+
echo "$_archive"
|
| 835 |
+
return 0
|
| 836 |
+
fi
|
| 837 |
+
;;
|
| 838 |
+
"i686-unknown-linux-musl-static")
|
| 839 |
+
_archive="uv-i686-unknown-linux-musl.tar.gz"
|
| 840 |
+
if [ -n "$_archive" ]; then
|
| 841 |
+
echo "$_archive"
|
| 842 |
+
return 0
|
| 843 |
+
fi
|
| 844 |
+
;;
|
| 845 |
+
"powerpc64-unknown-linux-gnu")
|
| 846 |
+
_archive="uv-powerpc64-unknown-linux-gnu.tar.gz"
|
| 847 |
+
if ! check_glibc "2" "31"; then
|
| 848 |
+
_archive=""
|
| 849 |
+
fi
|
| 850 |
+
if [ -n "$_archive" ]; then
|
| 851 |
+
echo "$_archive"
|
| 852 |
+
return 0
|
| 853 |
+
fi
|
| 854 |
+
;;
|
| 855 |
+
"powerpc64le-unknown-linux-gnu")
|
| 856 |
+
_archive="uv-powerpc64le-unknown-linux-gnu.tar.gz"
|
| 857 |
+
if ! check_glibc "2" "31"; then
|
| 858 |
+
_archive=""
|
| 859 |
+
fi
|
| 860 |
+
if [ -n "$_archive" ]; then
|
| 861 |
+
echo "$_archive"
|
| 862 |
+
return 0
|
| 863 |
+
fi
|
| 864 |
+
;;
|
| 865 |
+
"s390x-unknown-linux-gnu")
|
| 866 |
+
_archive="uv-s390x-unknown-linux-gnu.tar.gz"
|
| 867 |
+
if ! check_glibc "2" "31"; then
|
| 868 |
+
_archive=""
|
| 869 |
+
fi
|
| 870 |
+
if [ -n "$_archive" ]; then
|
| 871 |
+
echo "$_archive"
|
| 872 |
+
return 0
|
| 873 |
+
fi
|
| 874 |
+
;;
|
| 875 |
+
"x86_64-apple-darwin")
|
| 876 |
+
_archive="uv-x86_64-apple-darwin.tar.gz"
|
| 877 |
+
if [ -n "$_archive" ]; then
|
| 878 |
+
echo "$_archive"
|
| 879 |
+
return 0
|
| 880 |
+
fi
|
| 881 |
+
;;
|
| 882 |
+
"x86_64-pc-windows-gnu")
|
| 883 |
+
_archive="uv-x86_64-pc-windows-msvc.zip"
|
| 884 |
+
if [ -n "$_archive" ]; then
|
| 885 |
+
echo "$_archive"
|
| 886 |
+
return 0
|
| 887 |
+
fi
|
| 888 |
+
;;
|
| 889 |
+
"x86_64-pc-windows-msvc")
|
| 890 |
+
_archive="uv-x86_64-pc-windows-msvc.zip"
|
| 891 |
+
if [ -n "$_archive" ]; then
|
| 892 |
+
echo "$_archive"
|
| 893 |
+
return 0
|
| 894 |
+
fi
|
| 895 |
+
_archive="uv-i686-pc-windows-msvc.zip"
|
| 896 |
+
if [ -n "$_archive" ]; then
|
| 897 |
+
echo "$_archive"
|
| 898 |
+
return 0
|
| 899 |
+
fi
|
| 900 |
+
;;
|
| 901 |
+
"x86_64-unknown-linux-gnu")
|
| 902 |
+
_archive="uv-x86_64-unknown-linux-gnu.tar.gz"
|
| 903 |
+
if ! check_glibc "2" "31"; then
|
| 904 |
+
_archive=""
|
| 905 |
+
fi
|
| 906 |
+
if [ -n "$_archive" ]; then
|
| 907 |
+
echo "$_archive"
|
| 908 |
+
return 0
|
| 909 |
+
fi
|
| 910 |
+
_archive="uv-x86_64-unknown-linux-musl.tar.gz"
|
| 911 |
+
if [ -n "$_archive" ]; then
|
| 912 |
+
echo "$_archive"
|
| 913 |
+
return 0
|
| 914 |
+
fi
|
| 915 |
+
;;
|
| 916 |
+
"x86_64-unknown-linux-musl-dynamic")
|
| 917 |
+
_archive="uv-x86_64-unknown-linux-musl.tar.gz"
|
| 918 |
+
if [ -n "$_archive" ]; then
|
| 919 |
+
echo "$_archive"
|
| 920 |
+
return 0
|
| 921 |
+
fi
|
| 922 |
+
;;
|
| 923 |
+
"x86_64-unknown-linux-musl-static")
|
| 924 |
+
_archive="uv-x86_64-unknown-linux-musl.tar.gz"
|
| 925 |
+
if [ -n "$_archive" ]; then
|
| 926 |
+
echo "$_archive"
|
| 927 |
+
return 0
|
| 928 |
+
fi
|
| 929 |
+
;;
|
| 930 |
+
*)
|
| 931 |
+
err "there isn't a download for your platform $_true_arch"
|
| 932 |
+
;;
|
| 933 |
+
esac
|
| 934 |
+
err "no compatible downloads were found for your platform $_true_arch"
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
check_glibc() {
|
| 938 |
+
local _min_glibc_major="$1"
|
| 939 |
+
local _min_glibc_series="$2"
|
| 940 |
+
|
| 941 |
+
# Parsing version out from line 1 like:
|
| 942 |
+
# ldd (Ubuntu GLIBC 2.35-0ubuntu3.1) 2.35
|
| 943 |
+
_local_glibc="$(ldd --version | awk -F' ' '{ if (FNR<=1) print $NF }')"
|
| 944 |
+
|
| 945 |
+
if [ "$(echo "${_local_glibc}" | awk -F. '{ print $1 }')" = "$_min_glibc_major" ] && [ "$(echo "${_local_glibc}" | awk -F. '{ print $2 }')" -ge "$_min_glibc_series" ]; then
|
| 946 |
+
return 0
|
| 947 |
+
else
|
| 948 |
+
say "System glibc version (\`${_local_glibc}') is too old; checking alternatives" >&2
|
| 949 |
+
return 1
|
| 950 |
+
fi
|
| 951 |
+
}
|
| 952 |
+
|
| 953 |
+
# See discussion of late-bound vs early-bound for why we use single-quotes with env vars
|
| 954 |
+
# shellcheck disable=SC2016
|
| 955 |
+
install() {
|
| 956 |
+
# This code needs to both compute certain paths for itself to write to, and
|
| 957 |
+
# also write them to shell/rc files so that they can look them up to e.g.
|
| 958 |
+
# add them to PATH. This requires an active distinction between paths
|
| 959 |
+
# and expressions that can compute them.
|
| 960 |
+
#
|
| 961 |
+
# The distinction lies in when we want env-vars to be evaluated. For instance
|
| 962 |
+
# if we determine that we want to install to $HOME/.myapp, which do we add
|
| 963 |
+
# to e.g. $HOME/.profile:
|
| 964 |
+
#
|
| 965 |
+
# * early-bound: export PATH="/home/myuser/.myapp:$PATH"
|
| 966 |
+
# * late-bound: export PATH="$HOME/.myapp:$PATH"
|
| 967 |
+
#
|
| 968 |
+
# In this case most people would prefer the late-bound version, but in other
|
| 969 |
+
# cases the early-bound version might be a better idea. In particular when using
|
| 970 |
+
# other env-vars than $HOME, they are more likely to be only set temporarily
|
| 971 |
+
# for the duration of this install script, so it's more advisable to erase their
|
| 972 |
+
# existence with early-bounding.
|
| 973 |
+
#
|
| 974 |
+
# This distinction is handled by "double-quotes" (early) vs 'single-quotes' (late).
|
| 975 |
+
#
|
| 976 |
+
# However if we detect that "$SOME_VAR/..." is a subdir of $HOME, we try to rewrite
|
| 977 |
+
# it to be '$HOME/...' to get the best of both worlds.
|
| 978 |
+
#
|
| 979 |
+
# This script has a few different variants, the most complex one being the
|
| 980 |
+
# CARGO_HOME version which attempts to install things to Cargo's bin dir,
|
| 981 |
+
# potentially setting up a minimal version if the user hasn't ever installed Cargo.
|
| 982 |
+
#
|
| 983 |
+
# In this case we need to:
|
| 984 |
+
#
|
| 985 |
+
# * Install to $HOME/.cargo/bin/
|
| 986 |
+
# * Create a shell script at $HOME/.cargo/env that:
|
| 987 |
+
# * Checks if $HOME/.cargo/bin/ is on PATH
|
| 988 |
+
# * and if not prepends it to PATH
|
| 989 |
+
# * Edits $HOME/.profile to run $HOME/.cargo/env (if the line doesn't exist)
|
| 990 |
+
#
|
| 991 |
+
# To do this we need these 4 values:
|
| 992 |
+
|
| 993 |
+
# The actual path we're going to install to
|
| 994 |
+
local _install_dir
|
| 995 |
+
# The directory C dynamic/static libraries install to
|
| 996 |
+
local _lib_install_dir
|
| 997 |
+
# The install prefix we write to the receipt.
|
| 998 |
+
# For organized install methods like CargoHome, which have
|
| 999 |
+
# subdirectories, this is the root without `/bin`. For other
|
| 1000 |
+
# methods, this is the same as `_install_dir`.
|
| 1001 |
+
local _receipt_install_dir
|
| 1002 |
+
# Path to the an shell script that adds install_dir to PATH
|
| 1003 |
+
local _env_script_path
|
| 1004 |
+
# Potentially-late-bound version of install_dir to write env_script
|
| 1005 |
+
local _install_dir_expr
|
| 1006 |
+
# Potentially-late-bound version of env_script_path to write to rcfiles like $HOME/.profile
|
| 1007 |
+
local _env_script_path_expr
|
| 1008 |
+
# Forces the install to occur at this path, not the default
|
| 1009 |
+
local _force_install_dir
|
| 1010 |
+
# Which install layout to use - "flat" or "hierarchical"
|
| 1011 |
+
local _install_layout="unspecified"
|
| 1012 |
+
|
| 1013 |
+
# Check the newer app-specific variable before falling back
|
| 1014 |
+
# to the older generic one
|
| 1015 |
+
if [ -n "${UV_INSTALL_DIR:-}" ]; then
|
| 1016 |
+
_force_install_dir="$UV_INSTALL_DIR"
|
| 1017 |
+
_install_layout="flat"
|
| 1018 |
+
elif [ -n "${CARGO_DIST_FORCE_INSTALL_DIR:-}" ]; then
|
| 1019 |
+
_force_install_dir="$CARGO_DIST_FORCE_INSTALL_DIR"
|
| 1020 |
+
_install_layout="flat"
|
| 1021 |
+
elif [ -n "$UNMANAGED_INSTALL" ]; then
|
| 1022 |
+
_force_install_dir="$UNMANAGED_INSTALL"
|
| 1023 |
+
_install_layout="flat"
|
| 1024 |
+
fi
|
| 1025 |
+
|
| 1026 |
+
# Workaround for https://github.com/axodotdev/axoupdater/issues/210
|
| 1027 |
+
# This was manually added to the installer post-release to patch the 0.4.30 -> 0.5.0 upgrade
|
| 1028 |
+
if [ -n "${_force_install_dir:-}" ]; then
|
| 1029 |
+
if [ "$_force_install_dir" = "${HOME:-}/.cargo" ] || [ "$_force_install_dir" = "${CARGO_HOME:-}" ]; then
|
| 1030 |
+
_install_layout="cargo-home"
|
| 1031 |
+
else
|
| 1032 |
+
_install_layout="flat"
|
| 1033 |
+
fi
|
| 1034 |
+
fi
|
| 1035 |
+
|
| 1036 |
+
# Before actually consulting the configured install strategy, see
|
| 1037 |
+
# if we're overriding it.
|
| 1038 |
+
if [ -n "${_force_install_dir:-}" ]; then
|
| 1039 |
+
case "$_install_layout" in
|
| 1040 |
+
"hierarchical")
|
| 1041 |
+
_install_dir="$_force_install_dir/bin"
|
| 1042 |
+
_lib_install_dir="$_force_install_dir/lib"
|
| 1043 |
+
_receipt_install_dir="$_force_install_dir"
|
| 1044 |
+
_env_script_path="$_force_install_dir/env"
|
| 1045 |
+
_install_dir_expr="$(replace_home "$_force_install_dir/bin")"
|
| 1046 |
+
_env_script_path_expr="$(replace_home "$_force_install_dir/env")"
|
| 1047 |
+
;;
|
| 1048 |
+
"cargo-home")
|
| 1049 |
+
_install_dir="$_force_install_dir/bin"
|
| 1050 |
+
_lib_install_dir="$_force_install_dir/bin"
|
| 1051 |
+
_receipt_install_dir="$_force_install_dir"
|
| 1052 |
+
_env_script_path="$_force_install_dir/env"
|
| 1053 |
+
_install_dir_expr="$(replace_home "$_force_install_dir/bin")"
|
| 1054 |
+
_env_script_path_expr="$(replace_home "$_force_install_dir/env")"
|
| 1055 |
+
;;
|
| 1056 |
+
"flat")
|
| 1057 |
+
_install_dir="$_force_install_dir"
|
| 1058 |
+
_lib_install_dir="$_force_install_dir"
|
| 1059 |
+
_receipt_install_dir="$_install_dir"
|
| 1060 |
+
_env_script_path="$_force_install_dir/env"
|
| 1061 |
+
_install_dir_expr="$(replace_home "$_force_install_dir")"
|
| 1062 |
+
_env_script_path_expr="$(replace_home "$_force_install_dir/env")"
|
| 1063 |
+
;;
|
| 1064 |
+
*)
|
| 1065 |
+
err "Unrecognized install layout: $_install_layout"
|
| 1066 |
+
;;
|
| 1067 |
+
esac
|
| 1068 |
+
fi
|
| 1069 |
+
if [ -z "${_install_dir:-}" ]; then
|
| 1070 |
+
_install_layout="flat"
|
| 1071 |
+
# Install to $XDG_BIN_HOME
|
| 1072 |
+
if [ -n "${XDG_BIN_HOME:-}" ]; then
|
| 1073 |
+
_install_dir="$XDG_BIN_HOME"
|
| 1074 |
+
_lib_install_dir="$_install_dir"
|
| 1075 |
+
_receipt_install_dir="$_install_dir"
|
| 1076 |
+
_env_script_path="$XDG_BIN_HOME/env"
|
| 1077 |
+
_install_dir_expr="$(replace_home "$_install_dir")"
|
| 1078 |
+
_env_script_path_expr="$(replace_home "$_env_script_path")"
|
| 1079 |
+
fi
|
| 1080 |
+
fi
|
| 1081 |
+
if [ -z "${_install_dir:-}" ]; then
|
| 1082 |
+
_install_layout="flat"
|
| 1083 |
+
# Install to $XDG_DATA_HOME/../bin
|
| 1084 |
+
if [ -n "${XDG_DATA_HOME:-}" ]; then
|
| 1085 |
+
_install_dir="$XDG_DATA_HOME/../bin"
|
| 1086 |
+
_lib_install_dir="$_install_dir"
|
| 1087 |
+
_receipt_install_dir="$_install_dir"
|
| 1088 |
+
_env_script_path="$XDG_DATA_HOME/../bin/env"
|
| 1089 |
+
_install_dir_expr="$(replace_home "$_install_dir")"
|
| 1090 |
+
_env_script_path_expr="$(replace_home "$_env_script_path")"
|
| 1091 |
+
fi
|
| 1092 |
+
fi
|
| 1093 |
+
if [ -z "${_install_dir:-}" ]; then
|
| 1094 |
+
_install_layout="flat"
|
| 1095 |
+
# Install to $HOME/.local/bin
|
| 1096 |
+
if [ -n "${HOME:-}" ]; then
|
| 1097 |
+
_install_dir="$HOME/.local/bin"
|
| 1098 |
+
_lib_install_dir="$HOME/.local/bin"
|
| 1099 |
+
_receipt_install_dir="$_install_dir"
|
| 1100 |
+
_env_script_path="$HOME/.local/bin/env"
|
| 1101 |
+
_install_dir_expr='$HOME/.local/bin'
|
| 1102 |
+
_env_script_path_expr='$HOME/.local/bin/env'
|
| 1103 |
+
fi
|
| 1104 |
+
fi
|
| 1105 |
+
|
| 1106 |
+
if [ -z "$_install_dir_expr" ]; then
|
| 1107 |
+
err "could not find a valid path to install to!"
|
| 1108 |
+
fi
|
| 1109 |
+
|
| 1110 |
+
# Identical to the sh version, just with a .fish file extension
|
| 1111 |
+
# We place it down here to wait until it's been assigned in every
|
| 1112 |
+
# path.
|
| 1113 |
+
_fish_env_script_path="${_env_script_path}.fish"
|
| 1114 |
+
_fish_env_script_path_expr="${_env_script_path_expr}.fish"
|
| 1115 |
+
|
| 1116 |
+
# Replace the temporary cargo home with the calculated one
|
| 1117 |
+
RECEIPT=$(echo "$RECEIPT" | sed "s,AXO_INSTALL_PREFIX,$_receipt_install_dir,")
|
| 1118 |
+
# Also replace the aliases with the arch-specific one
|
| 1119 |
+
RECEIPT=$(echo "$RECEIPT" | sed "s'\"binary_aliases\":{}'\"binary_aliases\":$(json_binary_aliases "$_arch")'")
|
| 1120 |
+
# And replace the install layout
|
| 1121 |
+
RECEIPT=$(echo "$RECEIPT" | sed "s'\"install_layout\":\"unspecified\"'\"install_layout\":\"$_install_layout\"'")
|
| 1122 |
+
if [ "$NO_MODIFY_PATH" = "1" ]; then
|
| 1123 |
+
RECEIPT=$(echo "$RECEIPT" | sed "s'\"modify_path\":true'\"modify_path\":false'")
|
| 1124 |
+
fi
|
| 1125 |
+
|
| 1126 |
+
say "installing to $_install_dir"
|
| 1127 |
+
ensure mkdir -p "$_install_dir"
|
| 1128 |
+
ensure mkdir -p "$_lib_install_dir"
|
| 1129 |
+
|
| 1130 |
+
# copy all the binaries to the install dir
|
| 1131 |
+
local _src_dir="$1"
|
| 1132 |
+
local _bins="$2"
|
| 1133 |
+
local _libs="$3"
|
| 1134 |
+
local _staticlibs="$4"
|
| 1135 |
+
local _arch="$5"
|
| 1136 |
+
for _bin_name in $_bins; do
|
| 1137 |
+
local _bin="$_src_dir/$_bin_name"
|
| 1138 |
+
ensure mv "$_bin" "$_install_dir"
|
| 1139 |
+
# unzip seems to need this chmod
|
| 1140 |
+
ensure chmod +x "$_install_dir/$_bin_name"
|
| 1141 |
+
for _dest in $(aliases_for_binary "$_bin_name" "$_arch"); do
|
| 1142 |
+
ln -sf "$_install_dir/$_bin_name" "$_install_dir/$_dest"
|
| 1143 |
+
done
|
| 1144 |
+
say " $_bin_name"
|
| 1145 |
+
done
|
| 1146 |
+
# Like the above, but no aliases
|
| 1147 |
+
for _lib_name in $_libs; do
|
| 1148 |
+
local _lib="$_src_dir/$_lib_name"
|
| 1149 |
+
ensure mv "$_lib" "$_lib_install_dir"
|
| 1150 |
+
# unzip seems to need this chmod
|
| 1151 |
+
ensure chmod +x "$_lib_install_dir/$_lib_name"
|
| 1152 |
+
say " $_lib_name"
|
| 1153 |
+
done
|
| 1154 |
+
for _lib_name in $_staticlibs; do
|
| 1155 |
+
local _lib="$_src_dir/$_lib_name"
|
| 1156 |
+
ensure mv "$_lib" "$_lib_install_dir"
|
| 1157 |
+
# unzip seems to need this chmod
|
| 1158 |
+
ensure chmod +x "$_lib_install_dir/$_lib_name"
|
| 1159 |
+
say " $_lib_name"
|
| 1160 |
+
done
|
| 1161 |
+
|
| 1162 |
+
say "everything's installed!"
|
| 1163 |
+
|
| 1164 |
+
# Avoid modifying the users PATH if they are managing their PATH manually
|
| 1165 |
+
case :$PATH:
|
| 1166 |
+
in *:$_install_dir:*) NO_MODIFY_PATH=1 ;;
|
| 1167 |
+
*) ;;
|
| 1168 |
+
esac
|
| 1169 |
+
|
| 1170 |
+
if [ "0" = "$NO_MODIFY_PATH" ]; then
|
| 1171 |
+
add_install_dir_to_ci_path "$_install_dir"
|
| 1172 |
+
add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".profile" "sh"
|
| 1173 |
+
exit1=$?
|
| 1174 |
+
shotgun_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".profile .bashrc .bash_profile .bash_login" "sh"
|
| 1175 |
+
exit2=$?
|
| 1176 |
+
add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" ".zshrc .zshenv" "sh"
|
| 1177 |
+
exit3=$?
|
| 1178 |
+
# This path may not exist by default
|
| 1179 |
+
ensure mkdir -p "$HOME/.config/fish/conf.d"
|
| 1180 |
+
exit4=$?
|
| 1181 |
+
add_install_dir_to_path "$_install_dir_expr" "$_fish_env_script_path" "$_fish_env_script_path_expr" ".config/fish/conf.d/$APP_NAME.env.fish" "fish"
|
| 1182 |
+
exit5=$?
|
| 1183 |
+
|
| 1184 |
+
if [ "${exit1:-0}" = 1 ] || [ "${exit2:-0}" = 1 ] || [ "${exit3:-0}" = 1 ] || [ "${exit4:-0}" = 1 ] || [ "${exit5:-0}" = 1 ]; then
|
| 1185 |
+
say ""
|
| 1186 |
+
say "To add $_install_dir_expr to your PATH, either restart your shell or run:"
|
| 1187 |
+
say ""
|
| 1188 |
+
say " source $_env_script_path_expr (sh, bash, zsh)"
|
| 1189 |
+
say " source $_fish_env_script_path_expr (fish)"
|
| 1190 |
+
fi
|
| 1191 |
+
fi
|
| 1192 |
+
}
|
| 1193 |
+
|
| 1194 |
+
print_home_for_script() {
|
| 1195 |
+
local script="$1"
|
| 1196 |
+
|
| 1197 |
+
local _home
|
| 1198 |
+
case "$script" in
|
| 1199 |
+
# zsh has a special ZDOTDIR directory, which if set
|
| 1200 |
+
# should be considered instead of $HOME
|
| 1201 |
+
.zsh*)
|
| 1202 |
+
if [ -n "${ZDOTDIR:-}" ]; then
|
| 1203 |
+
_home="$ZDOTDIR"
|
| 1204 |
+
else
|
| 1205 |
+
_home="$HOME"
|
| 1206 |
+
fi
|
| 1207 |
+
;;
|
| 1208 |
+
*)
|
| 1209 |
+
_home="$HOME"
|
| 1210 |
+
;;
|
| 1211 |
+
esac
|
| 1212 |
+
|
| 1213 |
+
echo "$_home"
|
| 1214 |
+
}
|
| 1215 |
+
|
| 1216 |
+
add_install_dir_to_ci_path() {
|
| 1217 |
+
# Attempt to do CI-specific rituals to get the install-dir on PATH faster
|
| 1218 |
+
local _install_dir="$1"
|
| 1219 |
+
|
| 1220 |
+
# If GITHUB_PATH is present, then write install_dir to the file it refs.
|
| 1221 |
+
# After each GitHub Action, the contents will be added to PATH.
|
| 1222 |
+
# So if you put a curl | sh for this script in its own "run" step,
|
| 1223 |
+
# the next step will have this dir on PATH.
|
| 1224 |
+
#
|
| 1225 |
+
# Note that GITHUB_PATH will not resolve any variables, so we in fact
|
| 1226 |
+
# want to write install_dir and not install_dir_expr
|
| 1227 |
+
if [ -n "${GITHUB_PATH:-}" ]; then
|
| 1228 |
+
ensure echo "$_install_dir" >> "$GITHUB_PATH"
|
| 1229 |
+
fi
|
| 1230 |
+
}
|
| 1231 |
+
|
| 1232 |
+
add_install_dir_to_path() {
|
| 1233 |
+
# Edit rcfiles ($HOME/.profile) to add install_dir to $PATH
|
| 1234 |
+
#
|
| 1235 |
+
# We do this slightly indirectly by creating an "env" shell script which checks if install_dir
|
| 1236 |
+
# is on $PATH already, and prepends it if not. The actual line we then add to rcfiles
|
| 1237 |
+
# is to just source that script. This allows us to blast it into lots of different rcfiles and
|
| 1238 |
+
# have it run multiple times without causing problems. It's also specifically compatible
|
| 1239 |
+
# with the system rustup uses, so that we don't conflict with it.
|
| 1240 |
+
local _install_dir_expr="$1"
|
| 1241 |
+
local _env_script_path="$2"
|
| 1242 |
+
local _env_script_path_expr="$3"
|
| 1243 |
+
local _rcfiles="$4"
|
| 1244 |
+
local _shell="$5"
|
| 1245 |
+
|
| 1246 |
+
if [ -n "${HOME:-}" ]; then
|
| 1247 |
+
local _target
|
| 1248 |
+
local _home
|
| 1249 |
+
|
| 1250 |
+
# Find the first file in the array that exists and choose
|
| 1251 |
+
# that as our target to write to
|
| 1252 |
+
for _rcfile_relative in $_rcfiles; do
|
| 1253 |
+
_home="$(print_home_for_script "$_rcfile_relative")"
|
| 1254 |
+
local _rcfile="$_home/$_rcfile_relative"
|
| 1255 |
+
|
| 1256 |
+
if [ -f "$_rcfile" ]; then
|
| 1257 |
+
_target="$_rcfile"
|
| 1258 |
+
break
|
| 1259 |
+
fi
|
| 1260 |
+
done
|
| 1261 |
+
|
| 1262 |
+
# If we didn't find anything, pick the first entry in the
|
| 1263 |
+
# list as the default to create and write to
|
| 1264 |
+
if [ -z "${_target:-}" ]; then
|
| 1265 |
+
local _rcfile_relative
|
| 1266 |
+
_rcfile_relative="$(echo "$_rcfiles" | awk '{ print $1 }')"
|
| 1267 |
+
_home="$(print_home_for_script "$_rcfile_relative")"
|
| 1268 |
+
_target="$_home/$_rcfile_relative"
|
| 1269 |
+
fi
|
| 1270 |
+
|
| 1271 |
+
# `source x` is an alias for `. x`, and the latter is more portable/actually-posix.
|
| 1272 |
+
# This apparently comes up a lot on freebsd. It's easy enough to always add
|
| 1273 |
+
# the more robust line to rcfiles, but when telling the user to apply the change
|
| 1274 |
+
# to their current shell ". x" is pretty easy to misread/miscopy, so we use the
|
| 1275 |
+
# prettier "source x" line there. Hopefully people with Weird Shells are aware
|
| 1276 |
+
# this is a thing and know to tweak it (or just restart their shell).
|
| 1277 |
+
local _robust_line=". \"$_env_script_path_expr\""
|
| 1278 |
+
local _pretty_line="source \"$_env_script_path_expr\""
|
| 1279 |
+
|
| 1280 |
+
# Add the env script if it doesn't already exist
|
| 1281 |
+
if [ ! -f "$_env_script_path" ]; then
|
| 1282 |
+
say_verbose "creating $_env_script_path"
|
| 1283 |
+
if [ "$_shell" = "sh" ]; then
|
| 1284 |
+
write_env_script_sh "$_install_dir_expr" "$_env_script_path"
|
| 1285 |
+
else
|
| 1286 |
+
write_env_script_fish "$_install_dir_expr" "$_env_script_path"
|
| 1287 |
+
fi
|
| 1288 |
+
else
|
| 1289 |
+
say_verbose "$_env_script_path already exists"
|
| 1290 |
+
fi
|
| 1291 |
+
|
| 1292 |
+
# Check if the line is already in the rcfile
|
| 1293 |
+
# grep: 0 if matched, 1 if no match, and 2 if an error occurred
|
| 1294 |
+
#
|
| 1295 |
+
# Ideally we could use quiet grep (-q), but that makes "match" and "error"
|
| 1296 |
+
# have the same behaviour, when we want "no match" and "error" to be the same
|
| 1297 |
+
# (on error we want to create the file, which >> conveniently does)
|
| 1298 |
+
#
|
| 1299 |
+
# We search for both kinds of line here just to do the right thing in more cases.
|
| 1300 |
+
if ! grep -F "$_robust_line" "$_target" > /dev/null 2>/dev/null && \
|
| 1301 |
+
! grep -F "$_pretty_line" "$_target" > /dev/null 2>/dev/null
|
| 1302 |
+
then
|
| 1303 |
+
# If the script now exists, add the line to source it to the rcfile
|
| 1304 |
+
# (This will also create the rcfile if it doesn't exist)
|
| 1305 |
+
if [ -f "$_env_script_path" ]; then
|
| 1306 |
+
local _line
|
| 1307 |
+
# Fish has deprecated `.` as an alias for `source` and
|
| 1308 |
+
# it will be removed in a later version.
|
| 1309 |
+
# https://fishshell.com/docs/current/cmds/source.html
|
| 1310 |
+
# By contrast, `.` is the traditional syntax in sh and
|
| 1311 |
+
# `source` isn't always supported in all circumstances.
|
| 1312 |
+
if [ "$_shell" = "fish" ]; then
|
| 1313 |
+
_line="$_pretty_line"
|
| 1314 |
+
else
|
| 1315 |
+
_line="$_robust_line"
|
| 1316 |
+
fi
|
| 1317 |
+
say_verbose "adding $_line to $_target"
|
| 1318 |
+
# prepend an extra newline in case the user's file is missing a trailing one
|
| 1319 |
+
ensure echo "" >> "$_target"
|
| 1320 |
+
ensure echo "$_line" >> "$_target"
|
| 1321 |
+
return 1
|
| 1322 |
+
fi
|
| 1323 |
+
else
|
| 1324 |
+
say_verbose "$_install_dir already on PATH"
|
| 1325 |
+
fi
|
| 1326 |
+
fi
|
| 1327 |
+
}
|
| 1328 |
+
|
| 1329 |
+
shotgun_install_dir_to_path() {
|
| 1330 |
+
# Edit rcfiles ($HOME/.profile) to add install_dir to $PATH
|
| 1331 |
+
# (Shotgun edition - write to all provided files that exist rather than just the first)
|
| 1332 |
+
local _install_dir_expr="$1"
|
| 1333 |
+
local _env_script_path="$2"
|
| 1334 |
+
local _env_script_path_expr="$3"
|
| 1335 |
+
local _rcfiles="$4"
|
| 1336 |
+
local _shell="$5"
|
| 1337 |
+
|
| 1338 |
+
if [ -n "${HOME:-}" ]; then
|
| 1339 |
+
local _found=false
|
| 1340 |
+
local _home
|
| 1341 |
+
|
| 1342 |
+
for _rcfile_relative in $_rcfiles; do
|
| 1343 |
+
_home="$(print_home_for_script "$_rcfile_relative")"
|
| 1344 |
+
local _rcfile_abs="$_home/$_rcfile_relative"
|
| 1345 |
+
|
| 1346 |
+
if [ -f "$_rcfile_abs" ]; then
|
| 1347 |
+
_found=true
|
| 1348 |
+
add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" "$_rcfile_relative" "$_shell"
|
| 1349 |
+
fi
|
| 1350 |
+
done
|
| 1351 |
+
|
| 1352 |
+
# Fall through to previous "create + write to first file in list" behavior
|
| 1353 |
+
if [ "$_found" = false ]; then
|
| 1354 |
+
add_install_dir_to_path "$_install_dir_expr" "$_env_script_path" "$_env_script_path_expr" "$_rcfiles" "$_shell"
|
| 1355 |
+
fi
|
| 1356 |
+
fi
|
| 1357 |
+
}
|
| 1358 |
+
|
| 1359 |
+
write_env_script_sh() {
|
| 1360 |
+
# write this env script to the given path (this cat/EOF stuff is a "heredoc" string)
|
| 1361 |
+
local _install_dir_expr="$1"
|
| 1362 |
+
local _env_script_path="$2"
|
| 1363 |
+
ensure cat <<EOF > "$_env_script_path"
|
| 1364 |
+
#!/bin/sh
|
| 1365 |
+
# add binaries to PATH if they aren't added yet
|
| 1366 |
+
# affix colons on either side of \$PATH to simplify matching
|
| 1367 |
+
case ":\${PATH}:" in
|
| 1368 |
+
*:"$_install_dir_expr":*)
|
| 1369 |
+
;;
|
| 1370 |
+
*)
|
| 1371 |
+
# Prepending path in case a system-installed binary needs to be overridden
|
| 1372 |
+
export PATH="$_install_dir_expr:\$PATH"
|
| 1373 |
+
;;
|
| 1374 |
+
esac
|
| 1375 |
+
EOF
|
| 1376 |
+
}
|
| 1377 |
+
|
| 1378 |
+
write_env_script_fish() {
|
| 1379 |
+
# write this env script to the given path (this cat/EOF stuff is a "heredoc" string)
|
| 1380 |
+
local _install_dir_expr="$1"
|
| 1381 |
+
local _env_script_path="$2"
|
| 1382 |
+
ensure cat <<EOF > "$_env_script_path"
|
| 1383 |
+
if not contains "$_install_dir_expr" \$PATH
|
| 1384 |
+
# Prepending path in case a system-installed binary needs to be overridden
|
| 1385 |
+
set -x PATH "$_install_dir_expr" \$PATH
|
| 1386 |
+
end
|
| 1387 |
+
EOF
|
| 1388 |
+
}
|
| 1389 |
+
|
| 1390 |
+
check_proc() {
|
| 1391 |
+
# Check for /proc by looking for the /proc/self/exe link
|
| 1392 |
+
# This is only run on Linux
|
| 1393 |
+
if ! test -L /proc/self/exe ; then
|
| 1394 |
+
err "fatal: Unable to find /proc/self/exe. Is /proc mounted? Installation cannot proceed without /proc."
|
| 1395 |
+
fi
|
| 1396 |
+
}
|
| 1397 |
+
|
| 1398 |
+
get_bitness() {
|
| 1399 |
+
need_cmd head
|
| 1400 |
+
# Architecture detection without dependencies beyond coreutils.
|
| 1401 |
+
# ELF files start out "\x7fELF", and the following byte is
|
| 1402 |
+
# 0x01 for 32-bit and
|
| 1403 |
+
# 0x02 for 64-bit.
|
| 1404 |
+
# The printf builtin on some shells like dash only supports octal
|
| 1405 |
+
# escape sequences, so we use those.
|
| 1406 |
+
local _current_exe_head
|
| 1407 |
+
_current_exe_head=$(head -c 5 /proc/self/exe )
|
| 1408 |
+
if [ "$_current_exe_head" = "$(printf '\177ELF\001')" ]; then
|
| 1409 |
+
echo 32
|
| 1410 |
+
elif [ "$_current_exe_head" = "$(printf '\177ELF\002')" ]; then
|
| 1411 |
+
echo 64
|
| 1412 |
+
else
|
| 1413 |
+
err "unknown platform bitness"
|
| 1414 |
+
fi
|
| 1415 |
+
}
|
| 1416 |
+
|
| 1417 |
+
is_host_amd64_elf() {
|
| 1418 |
+
need_cmd head
|
| 1419 |
+
need_cmd tail
|
| 1420 |
+
# ELF e_machine detection without dependencies beyond coreutils.
|
| 1421 |
+
# Two-byte field at offset 0x12 indicates the CPU,
|
| 1422 |
+
# but we're interested in it being 0x3E to indicate amd64, or not that.
|
| 1423 |
+
local _current_exe_machine
|
| 1424 |
+
_current_exe_machine=$(head -c 19 /proc/self/exe | tail -c 1)
|
| 1425 |
+
[ "$_current_exe_machine" = "$(printf '\076')" ]
|
| 1426 |
+
}
|
| 1427 |
+
|
| 1428 |
+
get_endianness() {
|
| 1429 |
+
local cputype=$1
|
| 1430 |
+
local suffix_eb=$2
|
| 1431 |
+
local suffix_el=$3
|
| 1432 |
+
|
| 1433 |
+
# detect endianness without od/hexdump, like get_bitness() does.
|
| 1434 |
+
need_cmd head
|
| 1435 |
+
need_cmd tail
|
| 1436 |
+
|
| 1437 |
+
local _current_exe_endianness
|
| 1438 |
+
_current_exe_endianness="$(head -c 6 /proc/self/exe | tail -c 1)"
|
| 1439 |
+
if [ "$_current_exe_endianness" = "$(printf '\001')" ]; then
|
| 1440 |
+
echo "${cputype}${suffix_el}"
|
| 1441 |
+
elif [ "$_current_exe_endianness" = "$(printf '\002')" ]; then
|
| 1442 |
+
echo "${cputype}${suffix_eb}"
|
| 1443 |
+
else
|
| 1444 |
+
err "unknown platform endianness"
|
| 1445 |
+
fi
|
| 1446 |
+
}
|
| 1447 |
+
|
| 1448 |
+
get_architecture() {
|
| 1449 |
+
local _ostype
|
| 1450 |
+
local _cputype
|
| 1451 |
+
_ostype="$(uname -s)"
|
| 1452 |
+
_cputype="$(uname -m)"
|
| 1453 |
+
local _clibtype="gnu"
|
| 1454 |
+
local _local_glibc
|
| 1455 |
+
|
| 1456 |
+
if [ "$_ostype" = Linux ]; then
|
| 1457 |
+
if [ "$(uname -o)" = Android ]; then
|
| 1458 |
+
_ostype=Android
|
| 1459 |
+
fi
|
| 1460 |
+
if ldd --version 2>&1 | grep -q 'musl'; then
|
| 1461 |
+
_clibtype="musl-dynamic"
|
| 1462 |
+
else
|
| 1463 |
+
# Assume all other linuxes are glibc (even if wrong, static libc fallback will apply)
|
| 1464 |
+
_clibtype="gnu"
|
| 1465 |
+
fi
|
| 1466 |
+
fi
|
| 1467 |
+
|
| 1468 |
+
if [ "$_ostype" = Darwin ] && [ "$_cputype" = i386 ]; then
|
| 1469 |
+
# Darwin `uname -m` lies
|
| 1470 |
+
if sysctl hw.optional.x86_64 | grep -q ': 1'; then
|
| 1471 |
+
_cputype=x86_64
|
| 1472 |
+
fi
|
| 1473 |
+
fi
|
| 1474 |
+
|
| 1475 |
+
if [ "$_ostype" = Darwin ] && [ "$_cputype" = x86_64 ]; then
|
| 1476 |
+
# Rosetta on aarch64
|
| 1477 |
+
if [ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ]; then
|
| 1478 |
+
_cputype=aarch64
|
| 1479 |
+
fi
|
| 1480 |
+
fi
|
| 1481 |
+
|
| 1482 |
+
if [ "$_ostype" = SunOS ]; then
|
| 1483 |
+
# Both Solaris and illumos presently announce as "SunOS" in "uname -s"
|
| 1484 |
+
# so use "uname -o" to disambiguate. We use the full path to the
|
| 1485 |
+
# system uname in case the user has coreutils uname first in PATH,
|
| 1486 |
+
# which has historically sometimes printed the wrong value here.
|
| 1487 |
+
if [ "$(/usr/bin/uname -o)" = illumos ]; then
|
| 1488 |
+
_ostype=illumos
|
| 1489 |
+
fi
|
| 1490 |
+
|
| 1491 |
+
# illumos systems have multi-arch userlands, and "uname -m" reports the
|
| 1492 |
+
# machine hardware name; e.g., "i86pc" on both 32- and 64-bit x86
|
| 1493 |
+
# systems. Check for the native (widest) instruction set on the
|
| 1494 |
+
# running kernel:
|
| 1495 |
+
if [ "$_cputype" = i86pc ]; then
|
| 1496 |
+
_cputype="$(isainfo -n)"
|
| 1497 |
+
fi
|
| 1498 |
+
fi
|
| 1499 |
+
|
| 1500 |
+
case "$_ostype" in
|
| 1501 |
+
|
| 1502 |
+
Android)
|
| 1503 |
+
_ostype=linux-android
|
| 1504 |
+
;;
|
| 1505 |
+
|
| 1506 |
+
Linux)
|
| 1507 |
+
check_proc
|
| 1508 |
+
_ostype=unknown-linux-$_clibtype
|
| 1509 |
+
_bitness=$(get_bitness)
|
| 1510 |
+
;;
|
| 1511 |
+
|
| 1512 |
+
FreeBSD)
|
| 1513 |
+
_ostype=unknown-freebsd
|
| 1514 |
+
;;
|
| 1515 |
+
|
| 1516 |
+
NetBSD)
|
| 1517 |
+
_ostype=unknown-netbsd
|
| 1518 |
+
;;
|
| 1519 |
+
|
| 1520 |
+
DragonFly)
|
| 1521 |
+
_ostype=unknown-dragonfly
|
| 1522 |
+
;;
|
| 1523 |
+
|
| 1524 |
+
Darwin)
|
| 1525 |
+
_ostype=apple-darwin
|
| 1526 |
+
;;
|
| 1527 |
+
|
| 1528 |
+
illumos)
|
| 1529 |
+
_ostype=unknown-illumos
|
| 1530 |
+
;;
|
| 1531 |
+
|
| 1532 |
+
MINGW* | MSYS* | CYGWIN* | Windows_NT)
|
| 1533 |
+
_ostype=pc-windows-gnu
|
| 1534 |
+
;;
|
| 1535 |
+
|
| 1536 |
+
*)
|
| 1537 |
+
err "unrecognized OS type: $_ostype"
|
| 1538 |
+
;;
|
| 1539 |
+
|
| 1540 |
+
esac
|
| 1541 |
+
|
| 1542 |
+
case "$_cputype" in
|
| 1543 |
+
|
| 1544 |
+
i386 | i486 | i686 | i786 | x86)
|
| 1545 |
+
_cputype=i686
|
| 1546 |
+
;;
|
| 1547 |
+
|
| 1548 |
+
xscale | arm)
|
| 1549 |
+
_cputype=arm
|
| 1550 |
+
if [ "$_ostype" = "linux-android" ]; then
|
| 1551 |
+
_ostype=linux-androideabi
|
| 1552 |
+
fi
|
| 1553 |
+
;;
|
| 1554 |
+
|
| 1555 |
+
armv6l)
|
| 1556 |
+
_cputype=arm
|
| 1557 |
+
if [ "$_ostype" = "linux-android" ]; then
|
| 1558 |
+
_ostype=linux-androideabi
|
| 1559 |
+
else
|
| 1560 |
+
_ostype="${_ostype}eabihf"
|
| 1561 |
+
fi
|
| 1562 |
+
;;
|
| 1563 |
+
|
| 1564 |
+
armv7l | armv8l)
|
| 1565 |
+
_cputype=armv7
|
| 1566 |
+
if [ "$_ostype" = "linux-android" ]; then
|
| 1567 |
+
_ostype=linux-androideabi
|
| 1568 |
+
else
|
| 1569 |
+
_ostype="${_ostype}eabihf"
|
| 1570 |
+
fi
|
| 1571 |
+
;;
|
| 1572 |
+
|
| 1573 |
+
aarch64 | arm64)
|
| 1574 |
+
_cputype=aarch64
|
| 1575 |
+
;;
|
| 1576 |
+
|
| 1577 |
+
x86_64 | x86-64 | x64 | amd64)
|
| 1578 |
+
_cputype=x86_64
|
| 1579 |
+
;;
|
| 1580 |
+
|
| 1581 |
+
mips)
|
| 1582 |
+
_cputype=$(get_endianness mips '' el)
|
| 1583 |
+
;;
|
| 1584 |
+
|
| 1585 |
+
mips64)
|
| 1586 |
+
if [ "$_bitness" -eq 64 ]; then
|
| 1587 |
+
# only n64 ABI is supported for now
|
| 1588 |
+
_ostype="${_ostype}abi64"
|
| 1589 |
+
_cputype=$(get_endianness mips64 '' el)
|
| 1590 |
+
fi
|
| 1591 |
+
;;
|
| 1592 |
+
|
| 1593 |
+
ppc)
|
| 1594 |
+
_cputype=powerpc
|
| 1595 |
+
;;
|
| 1596 |
+
|
| 1597 |
+
ppc64)
|
| 1598 |
+
_cputype=powerpc64
|
| 1599 |
+
;;
|
| 1600 |
+
|
| 1601 |
+
ppc64le)
|
| 1602 |
+
_cputype=powerpc64le
|
| 1603 |
+
;;
|
| 1604 |
+
|
| 1605 |
+
s390x)
|
| 1606 |
+
_cputype=s390x
|
| 1607 |
+
;;
|
| 1608 |
+
riscv64)
|
| 1609 |
+
_cputype=riscv64gc
|
| 1610 |
+
;;
|
| 1611 |
+
loongarch64)
|
| 1612 |
+
_cputype=loongarch64
|
| 1613 |
+
;;
|
| 1614 |
+
*)
|
| 1615 |
+
err "unknown CPU type: $_cputype"
|
| 1616 |
+
|
| 1617 |
+
esac
|
| 1618 |
+
|
| 1619 |
+
# Detect 64-bit linux with 32-bit userland
|
| 1620 |
+
if [ "${_ostype}" = unknown-linux-gnu ] && [ "${_bitness}" -eq 32 ]; then
|
| 1621 |
+
case $_cputype in
|
| 1622 |
+
x86_64)
|
| 1623 |
+
# 32-bit executable for amd64 = x32
|
| 1624 |
+
if is_host_amd64_elf; then {
|
| 1625 |
+
err "x32 linux unsupported"
|
| 1626 |
+
}; else
|
| 1627 |
+
_cputype=i686
|
| 1628 |
+
fi
|
| 1629 |
+
;;
|
| 1630 |
+
mips64)
|
| 1631 |
+
_cputype=$(get_endianness mips '' el)
|
| 1632 |
+
;;
|
| 1633 |
+
powerpc64)
|
| 1634 |
+
_cputype=powerpc
|
| 1635 |
+
;;
|
| 1636 |
+
aarch64)
|
| 1637 |
+
_cputype=armv7
|
| 1638 |
+
if [ "$_ostype" = "linux-android" ]; then
|
| 1639 |
+
_ostype=linux-androideabi
|
| 1640 |
+
else
|
| 1641 |
+
_ostype="${_ostype}eabihf"
|
| 1642 |
+
fi
|
| 1643 |
+
;;
|
| 1644 |
+
riscv64gc)
|
| 1645 |
+
err "riscv64 with 32-bit userland unsupported"
|
| 1646 |
+
;;
|
| 1647 |
+
esac
|
| 1648 |
+
fi
|
| 1649 |
+
|
| 1650 |
+
# treat armv7 systems without neon as plain arm
|
| 1651 |
+
if [ "$_ostype" = "unknown-linux-gnueabihf" ] && [ "$_cputype" = armv7 ]; then
|
| 1652 |
+
if ensure grep '^Features' /proc/cpuinfo | grep -q -v neon; then
|
| 1653 |
+
# At least one processor does not have NEON.
|
| 1654 |
+
_cputype=arm
|
| 1655 |
+
fi
|
| 1656 |
+
fi
|
| 1657 |
+
|
| 1658 |
+
_arch="${_cputype}-${_ostype}"
|
| 1659 |
+
|
| 1660 |
+
RETVAL="$_arch"
|
| 1661 |
+
}
|
| 1662 |
+
|
| 1663 |
+
say() {
|
| 1664 |
+
if [ "0" = "$PRINT_QUIET" ]; then
|
| 1665 |
+
echo "$1"
|
| 1666 |
+
fi
|
| 1667 |
+
}
|
| 1668 |
+
|
| 1669 |
+
say_verbose() {
|
| 1670 |
+
if [ "1" = "$PRINT_VERBOSE" ]; then
|
| 1671 |
+
echo "$1"
|
| 1672 |
+
fi
|
| 1673 |
+
}
|
| 1674 |
+
|
| 1675 |
+
err() {
|
| 1676 |
+
if [ "0" = "$PRINT_QUIET" ]; then
|
| 1677 |
+
local red
|
| 1678 |
+
local reset
|
| 1679 |
+
red=$(tput setaf 1 2>/dev/null || echo '')
|
| 1680 |
+
reset=$(tput sgr0 2>/dev/null || echo '')
|
| 1681 |
+
say "${red}ERROR${reset}: $1" >&2
|
| 1682 |
+
fi
|
| 1683 |
+
exit 1
|
| 1684 |
+
}
|
| 1685 |
+
|
| 1686 |
+
need_cmd() {
|
| 1687 |
+
if ! check_cmd "$1"
|
| 1688 |
+
then err "need '$1' (command not found)"
|
| 1689 |
+
fi
|
| 1690 |
+
}
|
| 1691 |
+
|
| 1692 |
+
check_cmd() {
|
| 1693 |
+
command -v "$1" > /dev/null 2>&1
|
| 1694 |
+
return $?
|
| 1695 |
+
}
|
| 1696 |
+
|
| 1697 |
+
assert_nz() {
|
| 1698 |
+
if [ -z "$1" ]; then err "assert_nz $2"; fi
|
| 1699 |
+
}
|
| 1700 |
+
|
| 1701 |
+
# Run a command that should never fail. If the command fails execution
|
| 1702 |
+
# will immediately terminate with an error showing the failing
|
| 1703 |
+
# command.
|
| 1704 |
+
ensure() {
|
| 1705 |
+
if ! "$@"; then err "command failed: $*"; fi
|
| 1706 |
+
}
|
| 1707 |
+
|
| 1708 |
+
# This is just for indicating that commands' results are being
|
| 1709 |
+
# intentionally ignored. Usually, because it's being executed
|
| 1710 |
+
# as part of error handling.
|
| 1711 |
+
ignore() {
|
| 1712 |
+
"$@"
|
| 1713 |
+
}
|
| 1714 |
+
|
| 1715 |
+
# This wraps curl or wget. Try curl first, if not installed,
|
| 1716 |
+
# use wget instead.
|
| 1717 |
+
downloader() {
|
| 1718 |
+
if check_cmd curl
|
| 1719 |
+
then _dld=curl
|
| 1720 |
+
elif check_cmd wget
|
| 1721 |
+
then _dld=wget
|
| 1722 |
+
else _dld='curl or wget' # to be used in error message of need_cmd
|
| 1723 |
+
fi
|
| 1724 |
+
|
| 1725 |
+
if [ "$1" = --check ]
|
| 1726 |
+
then need_cmd "$_dld"
|
| 1727 |
+
elif [ "$_dld" = curl ]
|
| 1728 |
+
then curl -sSfL "$1" -o "$2"
|
| 1729 |
+
elif [ "$_dld" = wget ]
|
| 1730 |
+
then wget "$1" -O "$2"
|
| 1731 |
+
else err "Unknown downloader" # should not reach here
|
| 1732 |
+
fi
|
| 1733 |
+
}
|
| 1734 |
+
|
| 1735 |
+
download_binary_and_run_installer "$@" || exit 1
|