From 7e434a10790544d067acf092802a92593cd76c83 Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Thu, 28 Aug 2025 18:42:08 +1000 Subject: [PATCH] change fetchruntime script to download to appropriate os-arch folder under bin/runtime --- bin/fetchruntime.cmd | 44 +++++++++++++++++++++++++------- src/scriptapps/fetchruntime.bash | 33 ++++++++++++++++++------ src/scriptapps/fetchruntime.ps1 | 11 +++++++- 3 files changed, 70 insertions(+), 18 deletions(-) diff --git a/bin/fetchruntime.cmd b/bin/fetchruntime.cmd index ec7e579f..f496014c 100644 --- a/bin/fetchruntime.cmd +++ b/bin/fetchruntime.cmd @@ -675,16 +675,31 @@ fi # 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" - output="../src/runtime/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-x86_64/tclkit-902-Linux64-arm-dyn" - output="../src/runtime/tclkit-902-Linux64-arm-dyn" + 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 @@ -696,7 +711,8 @@ 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" - output="../src/runtime/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" @@ -707,9 +723,9 @@ elif [[ "$OSTYPE" == "netbsd"* ]]; then 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 - #scriptdir? - output="../src/runtime/tclsh902z.exe" elif [[ "$OSTYPE" == "msys" ]]; then echo MSYS os="win32" @@ -721,8 +737,8 @@ elif [[ "$OSTYPE" == "msys" ]]; then #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" - #scriptdir? - output="../src/runtime/tclsh902z.exe" + outdir="${scriptdir}/runtime/win32-x86_64/tclsh902z.exe"; mkdir -p $outdir + output="${outdir}/tclsh902z.exe" runtime_available=1 else #os="$OSTYPE" @@ -736,6 +752,7 @@ if [[ "$runtime_available" -eq 1 ]]; then 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 @@ -950,7 +967,16 @@ if ($matches.count) { # $url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh902z.exe" -$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" + +$outbase = $PSScriptRoot +$outbase = Resolve-Path -Path $outbase +#expected script location is the bin folder of a punk project +$rtfolder = Join-Path -Path $outbase -ChildPath "runtime" +#$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" +$output = "$(join-path $rtfolder "win32-x86_64\tclsh902z.exe")" + +$container = split-path -Path $output -Parent +new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present if (-not(Test-Path -Path $output -PathType Leaf)) { Write-Host "Downloading from $url ..." diff --git a/src/scriptapps/fetchruntime.bash b/src/scriptapps/fetchruntime.bash index d40312a0..9e59d9d2 100644 --- a/src/scriptapps/fetchruntime.bash +++ b/src/scriptapps/fetchruntime.bash @@ -1,15 +1,30 @@ 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" - output="../src/runtime/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-x86_64/tclkit-902-Linux64-arm-dyn" - output="../src/runtime/tclkit-902-Linux64-arm-dyn" + 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 @@ -21,7 +36,8 @@ 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" - output="../src/runtime/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" @@ -32,9 +48,9 @@ elif [[ "$OSTYPE" == "netbsd"* ]]; then 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 - #scriptdir? - output="../src/runtime/tclsh902z.exe" elif [[ "$OSTYPE" == "msys" ]]; then echo MSYS os="win32" @@ -46,8 +62,8 @@ elif [[ "$OSTYPE" == "msys" ]]; then #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" - #scriptdir? - output="../src/runtime/tclsh902z.exe" + outdir="${scriptdir}/runtime/win32-x86_64/tclsh902z.exe"; mkdir -p $outdir + output="${outdir}/tclsh902z.exe" runtime_available=1 else #os="$OSTYPE" @@ -61,6 +77,7 @@ if [[ "$runtime_available" -eq 1 ]]; then 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 diff --git a/src/scriptapps/fetchruntime.ps1 b/src/scriptapps/fetchruntime.ps1 index adbfbdf3..323ae8d1 100644 --- a/src/scriptapps/fetchruntime.ps1 +++ b/src/scriptapps/fetchruntime.ps1 @@ -1,6 +1,15 @@ $url = "https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh902z.exe" -$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" + +$outbase = $PSScriptRoot +$outbase = Resolve-Path -Path $outbase +#expected script location is the bin folder of a punk project +$rtfolder = Join-Path -Path $outbase -ChildPath "runtime" +#$output = "$(join-path $PSScriptRoot "..\src\runtime\tclsh902z.exe")" +$output = "$(join-path $rtfolder "win32-x86_64\tclsh902z.exe")" + +$container = split-path -Path $output -Parent +new-item -Path $container -ItemType Directory -force #create with intermediary folders if not already present if (-not(Test-Path -Path $output -PathType Leaf)) { Write-Host "Downloading from $url ..."