Skip to content

Commit

Permalink
Merge pull request #13 from AndreasBrostrom/Actually-have-better-erro…
Browse files Browse the repository at this point in the history
…r-handling-for-upgrade-and-bettert-upgrade

Actually have better error handling for upgrade and bettert upgrade
  • Loading branch information
AndreasBrostrom authored Oct 5, 2024
2 parents e44df75 + 1589f9a commit 95e2e61
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions upgrade.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,17 @@ function runWSLUpdate {
$i=0
wsl.exe --list | ForEach-Object -Process {
$i++
if ($i -lt 2) {return}
if ($_ -eq "") {return}
if ($_.contains("Copyright")) {break}
if ($_.contains("Distributions")) {break}
if ($_.contains("https://aka.ms/wslstore")) {break}
if ($_ -like "Copyright*") {break}
if ($i -lt 2) {return}
$dist = -split "$_"
$distName = $dist[0]
$DistrosList += $distName
}
}
Catch {
Write-Host "WSL not supported via remote connections...`nSee https://github.com/microsoft/WSL/issues/7900`n" -ForegroundColor Red
Write-Host "No WSL distributions detected skipping..." -ForegroundColor Yellow
#Write-Host "WSL not supported via remote connections...`nSee https://github.com/microsoft/WSL/issues/7900`n" -ForegroundColor Red
return
}
if ( $distrosList.contains("error") ) {
Expand Down Expand Up @@ -181,9 +180,10 @@ function runWSLUpdate {
if (-not $suMode) {
$distPackageManagers = (
"eval '" +
"type yay > /dev/null 2>&1 &&" +
" echo -e `"\033[33myay: can´t install AUR package as root use --suMode to run as your user.\033[0m`";" +
"type paru > /dev/null 2>&1 &&" +
" echo -e `"\033[1;32mparu\033[0m`" &&" +
" yes `"`" | paru -Syyu --sudoloop --noconfirm --color=always &&" +
" echo -e `"\033[33mparu: can´t install AUR package as root use --suMode to run as your user.\033[0m`";" +

"type snap > /dev/null 2>&1 &&" +
" echo -e `"\033[1;32msnap\033[0m`" &&" +
Expand All @@ -192,7 +192,6 @@ function runWSLUpdate {
" echo -e `"\033[1;32mflatpak\033[0m`" &&" +
" sudo flatpak update -y;" +

"type paru > /dev/null 2>&1 && exit;" +
" echo -e `"\033[1;32mpacman\033[0m`" &&" +
" yes `"`" | pacman -Syyuu;" +
"'"
Expand Down

0 comments on commit 95e2e61

Please sign in to comment.