You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

86 lines
3.0 KiB

url_kitbase="https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master"
wdir="$(pwd)"; [ "$(pwd)" = "/" ] && wdir=""
case "$0" in
/*) scriptpath="${0}";;
*) scriptpath="$wdir/${0#./}";;
esac
scriptdir="${scriptpath%/*}"
scriptdir=$(realpath $scriptdir)
scriptpath=$(realpath $scriptpath)
basename=$(basename "$scriptpath") #e.g fetchruntime.bash
scriptroot="${basename%.*}" #e.g "fetchruntime"
runtime_available=0
if [[ "$OSTYPE" == "linux"* ]]; then
arch=$(uname -i)
if [[ "$arch" == "x86_64"* ]]; then
url="${url_kitbase}/linux-x86_64/tclkit-902-Linux64-intel-dyn"
outdir="${scriptdir}/runtime/linux-x86_64"; mkdir -p $outdir
output="${outdir}/tclkit-902-Linux64-intel-dyn"
runtime_available=1
elif [[ "$arch" == "arm"* ]]; then
url="${url_kitbase}/linux-arm/tclkit-902-Linux64-arm-dyn"
outdir="${scriptdir}/runtime/linux-arm"; mkdir -p $outdir
output="${outdir}/tclkit-902-Linux64-arm-dyn"
runtime_available=1
fi
if [[ "$runtime_available" -eq 1 ]]; then
echo "Please ensure libxFt.so.2 is available"
echo "e.g on Ubuntu: sudo apt-get install libxft2"
fi
os="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
os="macosx"
#assumed to be Mach-O 'universal binaries' for both x86-64 and arm? - REVIEW
url="${url_kitbase}/macosx/tclkit-902-Darwin64-dyn"
outdir="${scriptdir}/runtime/macosx/"; mkdir -p $outdir
output="${outdir}/tclkit-902-Darwin64-dyn"
runtime_available=1
elif [[ "$OSTYPE" == "freebsd"* ]]; then
os="freebsd"
elif [[ "$OSTYPE" == "dragonflybsd"* ]]; then
os="dragonflybsd"
elif [[ "$OSTYPE" == "netbsd"* ]]; then
os="netbsd"
elif [[ "$OSTYPE" == "win32" ]]; then
os="win32"
url="${url_kitbase}/win32-x86_64/tclsh902z.exe"
outdir="${scriptdir}/runtime/win32-x86_64/"; mkdir -p $outdir
output="${outdir}/tcsh902z.exe"
runtime_available=1
elif [[ "$OSTYPE" == "msys" ]]; then
echo MSYS
os="win32"
#use 'command -v' (shell builtin preferred over external which)
interp = `ps -p $$ | awk '$1 != "PID" {print $(NF)}' | tr -d '()' | sed -E 's/^.*\/|^-//'`
shellpath=`command -v $interp`
shellfolder="${shellpath%/*}" #avoid dependency on basename or dirname
#"c:/windows/system32/" is quite likely in the path ahead of msys,git etc.
#This breaks calls to various unix utils such as sed etc (wsl related?)
export PATH="$shellfolder${PATH:+:${PATH}}"
url="${url_kitbase}/win32-x86_64/tclsh902z.exe"
outdir="${scriptdir}/runtime/win32-x86_64/tclsh902z.exe"; mkdir -p $outdir
output="${outdir}/tclsh902z.exe"
runtime_available=1
else
#os="$OSTYPE"
os="other"
fi
if [[ "$runtime_available" -eq 1 ]]; then
#test win32
echo "Attempting to download $url"
#wget $url -O $output
curl -SL --output "$output" "$url"
if [[ $? -eq 0 ]]; then
echo "File downloaded to $output"
chmod +x $output
else
echo "Error: Failed to download to $output"
fi
else
echo "No runtime currently available for $os"
fi