Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions lib/linux/catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ PLAN_AUTO=""
catalog_resolve() {
local requested=("$@")
local -a wanted=() queue=("$@")
local -A wanted_set=()
local id dep i

while ((${#queue[@]})); do
id="${queue[0]}"; queue=("${queue[@]:1}")
[[ " ${wanted[*]} " == *" $id "* ]] && continue
[[ -n "${wanted_set[$id]:-}" ]] && continue
i="$(catalog_index_of "$id")" || continue
if [[ "${CAT_PROVIDER[i]}" == manual ]]; then ui_err "AutoOS cannot install $id; use its vendor link for manual setup."; return 1; fi
wanted+=("$id")
wanted_set["$id"]=1
if [[ -n "${CAT_REQUIRES[i]}" ]]; then
IFS=',' read -ra deps <<<"${CAT_REQUIRES[i]}"
for dep in "${deps[@]}"; do
Expand All @@ -174,26 +176,26 @@ catalog_resolve() {
fi
done

local -a done_list=() visiting=()
local -A done_set=() visiting_set=()
local ordered=""

_visit() {
local node="$1" idx d
[[ " ${done_list[*]} " == *" $node "* ]] && return 0
if [[ " ${visiting[*]} " == *" $node "* ]]; then
[[ -n "${done_set[$node]:-}" ]] && return 0
if [[ -n "${visiting_set[$node]:-}" ]]; then
ui_err "Dependency cycle in catalog at '$node'"; return 1
fi
visiting+=("$node")
visiting_set["$node"]=1
idx="$(catalog_index_of "$node")" || return 0
if [[ -n "${CAT_REQUIRES[idx]}" ]]; then
IFS=',' read -ra ds <<<"${CAT_REQUIRES[idx]}"
for d in "${ds[@]}"; do
[[ -z "$d" ]] && continue
[[ " ${wanted[*]} " == *" $d "* ]] && { _visit "$d" || return 1; }
[[ -n "${wanted_set[$d]:-}" ]] && { _visit "$d" || return 1; }
done
fi
visiting=("${visiting[@]/$node}")
done_list+=("$node")
unset "visiting_set[$node]"
done_set["$node"]=1
ordered+="$node "
return 0
}
Expand Down
19 changes: 10 additions & 9 deletions lib/windows/AutoOS.Detect.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,21 @@ function Get-AutoOSShimDirectory {
$home_ = $env:USERPROFILE
@(
# Scoop: user-scope by default, global when SCOOP_GLOBAL is set.
(Join-Path $home_ 'scoop\shims'),
$(if ($home_) { Join-Path $home_ 'scoop\shims' }),
$(if ($env:SCOOP) { Join-Path $env:SCOOP 'shims' }),
$(if ($env:SCOOP_GLOBAL) { Join-Path $env:SCOOP_GLOBAL 'shims' }),
(Join-Path $env:ProgramData 'scoop\shims'),
$(if ($env:ProgramData) { Join-Path $env:ProgramData 'scoop\shims' }),
# Chocolatey.
(Join-Path $env:ProgramData 'chocolatey\bin'),
$(if ($env:ProgramData) { Join-Path $env:ProgramData 'chocolatey\bin' }),
"C:\ProgramData\chocolatey\bin",
# winget's own shim directory for portable packages.
(Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links'),
(Join-Path $env:ProgramFiles 'WinGet\Links'),
$(if ($env:LOCALAPPDATA) { Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Links' }),
$(if ($env:ProgramFiles) { Join-Path $env:ProgramFiles 'WinGet\Links' }),
# npm -g, pipx/uv and cargo all install here and all rely on PATH.
(Join-Path $env:APPDATA 'npm'),
(Join-Path $home_ '.local\bin'),
(Join-Path $home_ '.cargo\bin'),
(Join-Path $home_ 'bin')
$(if ($env:APPDATA) { Join-Path $env:APPDATA 'npm' }),
$(if ($home_) { Join-Path $home_ '.local\bin' }),
$(if ($home_) { Join-Path $home_ '.cargo\bin' }),
$(if ($home_) { Join-Path $home_ 'bin' })
) | Where-Object { $_ }
}

Expand Down
Loading