Replies: 2 comments
-
|
I have a fix but it ends up me determining the machine os/arch myself to send the right --select name and/or --install-file seems not DRY since dra already knows these. I will look into making a PR. so install-file and --select can identify and fill tags |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
for those intereste here is my bash fix #!/bin/bash
# UCISMS System Discovery Module
#
# Provides standardized system information (arch, os, distro)
# and token resolution utilities.
# -----------------------------------------------------------------------------
# Architecture
# -----------------------------------------------------------------------------
uci::system::arch() {
local raw_arch
raw_arch=$(uname -m)
case "$raw_arch" in
x86_64) echo "amd64" ;;
aarch64) echo "arm64" ;;
i386|i686) echo "386" ;;
armv7l) echo "arm" ;;
*) echo "$raw_arch" ;;
esac
}
# -----------------------------------------------------------------------------
# Operating System
# -----------------------------------------------------------------------------
uci::system::os() {
local raw_os
raw_os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$raw_os" in
linux*) echo "linux" ;;
darwin*) echo "darwin" ;;
msys*|cygwin*|mingw*) echo "windows" ;;
*) echo "$raw_os" ;;
esac
}
# -----------------------------------------------------------------------------
# Distribution
# -----------------------------------------------------------------------------
uci::system::distro() {
# 1. Check for WSL
if [[ -n "${WSL_DISTRO_NAME:-}" ]] || grep -qi "microsoft" /proc/version 2>/dev/null; then
echo "wsl"
return
fi
# 2. Check for Darwin
if [[ "$(uci::system::os)" == "darwin" ]]; then
echo "darwin"
return
fi
# 3. Check /etc/os-release for Linux
if [[ -f /etc/os-release ]]; then
# shellcheck disable=SC1091
source /etc/os-release
echo "${ID:-unknown}" | tr '[:upper:]' '[:lower:]'
return
fi
echo "unknown"
}
# -----------------------------------------------------------------------------
# Token Resolution
# -----------------------------------------------------------------------------
uci::system::resolve_tokens() {
local input="$1"
local raw_arch=$(uname -m)
local goarch=$(uci::system::arch)
local os=$(uci::system::os)
local distro=$(uci::system::distro)
local output="$input"
output="${output//\{arch\}/$raw_arch}"
output="${output//\{goarch\}/$goarch}"
output="${output//\{os\}/$os}"
output="${output//\{distro\}/$distro}"
echo "$output"
}
# -----------------------------------------------------------------------------
# Coordinator
# -----------------------------------------------------------------------------
uci::system() {
local target="${1:-}"
case "$target" in
arch) uci::system::arch ;;
os) uci::system::os ;;
distro) uci::system::distro ;;
"")
echo "arch=$(uci::system::arch)"
echo "os=$(uci::system::os)"
echo "distro=$(uci::system::distro)"
echo "raw_arch=$(uname -m)"
;;
*)
echo "ERROR: Unknown system property: $target" >&2
return 1
;;
esac
}# Build dra command
local dra_opts=("--tag \"$version\"" "--output \"$UCISMS_BIN/\"")
# Selection Mode: Explicit Asset Select vs Automatic System Detection
if [[ -n "$asset" ]]; then
local pattern=$(uci::system::resolve_tokens "$asset")
dra_opts+=("--select \"$pattern\"")
uci::logger::log DEBUG "tool_download: Using select pattern '$pattern'"
else
dra_opts+=("--automatic")
uci::logger::log DEBUG "tool_download: Using automatic system detection"
fi
# Installation Mode: Extract archive contents vs Direct Download
if [[ "$no_install" != "true" ]]; then
dra_opts+=("--install")
# Targeted extraction for ambiguous archives
if [[ -n "$install_file" ]]; then
local ifile=$(uci::system::resolve_tokens "$install_file")
dra_opts+=("--install-file \"$ifile\"")
uci::logger::log DEBUG "tool_download: Using targeted install file '$ifile'"
fi
fi
local dra_cmd="dra download \"$repo\" ${dra_opts[*]}"
uci::logger::log DEBUG "tool_download: Running: $dra_cmd"
echo " Command: $dra_cmd"
# Execute dra command
if ! eval "$dra_cmd" 2>&1 | sed 's/^/ /'; then
echo " ERROR: dra download failed for $tool_name" >&2
uci::logger::log ERROR "tool_download: dra download failed for '$tool_name' from $repo@$version"
return 1
fi
.....
```
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
in these two runs you can see the issue.
BUT that probably just pics up whatever the first match is (darwin) and does then not honor target os/architecture (i.e. linux)
is there a work around? can dra be smarter about the wildcard? like if it mataches more than one then further filters on the os/architetuecte
I do need dra to work this repo based on os/arch I can't hard code linux nor amd. I mean I guess I could premake my own select string but lol that not very DRY considering dra already determines the system os/arch. What to do?
Beta Was this translation helpful? Give feedback.
All reactions