xxh-shell-nushell/build.sh
2025-07-09 17:26:45 +03:00

51 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
set -o pipefail
CDIR="$(cd "$(dirname "$0")" && pwd)"
build_dir=${CDIR}/build
while getopts A:K:q option; do
case "${option}" in
q) QUIET=1 ;;
A) ARCH="${OPTARG:-x86_64}" ;;
K) ;;
*) ;;
esac
done
echo "${ARCH:=x86_64}"
rm -rf "${build_dir}"
mkdir -p "${build_dir}"
for f in entrypoint.sh; do
cp "${CDIR}/${f}" "${build_dir}/"
done
nushell_version=0.105.1
url="https://github.com/nushell/nushell/releases/download/0.105.1/nu-${nushell_version}-${ARCH}-unknown-linux-musl.tar.gz"
tarname=$(basename "${url}")
cd "${build_dir}" || exit
mkdir -p download
cd download || exit
[[ -n "${QUIET}" ]] && arg_q=('-q') || arg_q=()
[[ -n "${QUIET}" ]] && arg_s=('-s') || arg_s=()
[[ -n "${QUIET}" ]] && arg_progress=() || arg_progress=('--show-progress')
if wget --version; then
wget "${arg_q[@]}" "${arg_progress[*]}" "${url}" -O "${tarname}"
elif curl --version; then
curl "${arg_s[@]}" -L "${url}" -o "${tarname}"
else
echo Install wget or curl
fi
tar -xzf "${tarname}"
mv -t ../ ./nu-*/nu
cd .. || exit
rm -rf ./download