scoop.ps1
|
function scoop_base ( [string[]] $basepkgs = @() ) { $minpkgs = @('7zip', 'git', 'aria2', 'dark', 'innounp', 'lessmsi', 'sudo', 'pwsh') foreach ($pkg in $minpkgs) { if (-not $basepkgs.contains($pkg)) { $basepkgs += $pkg } } if (-not (gcm_app scoop)) { iex "& {$(irm get.scoop.sh -useb)} -RunAsAdmin" scoop install @basepkgs scoop config aria2-warning-enabled false scoop update pwsh -c '& {Set-ExecutionPolicy -force -scope localmachine -ExecutionPolicy bypass}' pwsh -c '& {Set-ExecutionPolicy -force -scope currentuser -ExecutionPolicy bypass}' } } function scoop_buckets ( [string[]] $buckets = @() ) { # bucket add is idempotent; no need for manual check foreach ($name in $buckets) { if (-not $name) { continue } try { $tmp = $name.split(' ') scoop bucket add @tmp } catch { write-host -f y "error while adding bucket: $name" } } scoop update } function scoop_apps ( [string[]] $apps ) { # you can loop over these, try/catching each one; it may be much slower, though # the tradeoff is that one install failure will cascade into (unpredictable?) other install failures # scoop may also throw an incorrect error when an app in apps has a dependency, and they are both already installed try { scoop install @apps } catch { write-host -f y "error while installing packages: $apps" } } function scoop_shim ( [parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $pair ) { # adding shims using `scoop add` is NOT idempotent, so this check is necessary $split = $pair.split(' ') if (-not ($split[0] -and $split[1])) { write-host -f y "scoop shim: malformed shim: $pair" return } if (scoop shim info $split[0]) { write-host -f green "scoop shim: already exists for: $pair" } else { scoop shim add $split[0] $(scoop which $split[1]) } } function scoop_shims ( [string[]] $shims = @() ) { # adding a shim is NOT idempotent; manual check is needed foreach ($pair in $shims) { if (-not $pair) { continue } try { scoop_shim $pair } catch { write-host -f y "error while adding shim: $pair" } } } |