From 0fdf4ea4178144fb8814a02751d69625706b45aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Gryta?= Date: Fri, 3 Mar 2023 20:10:00 +0100 Subject: [PATCH] Added version override for automated install (#7) --- README.md | 4 ++-- WSLTools/Public/WSL-Ubuntu-Install.ps1 | 6 +++++- WSLTools/WSLTools.psd1 | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7284e41..11703d4 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,9 @@ WSL-Alpine-Install [-Interactive] [-DistroAlias ] [-InstallPath ] ### WSL-Ubuntu-Install -Deploys clean Ubuntu Linux distro into WSL. Usage is the same to WSL-Alpine-Install. Currently takes lunar as default. +Deploys clean Ubuntu Linux distro into WSL. Usage is the same to WSL-Alpine-Install. Currently takes lunar as default. If you want to override default version, then specify -Version with lowercase release, e.g. `-Version kinetic`. ```powershell -WSL-Ubuntu-Install [-Interactive] [-DistroAlias ] [-InstallPath ] +WSL-Ubuntu-Install [-Interactive] [-DistroAlias ] [-InstallPath ] [-Version ] ``` ### WSL-Debian-Install diff --git a/WSLTools/Public/WSL-Ubuntu-Install.ps1 b/WSLTools/Public/WSL-Ubuntu-Install.ps1 index 96a1e97..4195bb2 100644 --- a/WSLTools/Public/WSL-Ubuntu-Install.ps1 +++ b/WSLTools/Public/WSL-Ubuntu-Install.ps1 @@ -3,6 +3,7 @@ function WSL-Ubuntu-Install Param( [switch]$Interactive = $false, [Parameter(Mandatory = $true)] [String]$DistroAlias, + [String]$Version, [String]$InstallPath ) try { @@ -72,7 +73,10 @@ function WSL-Ubuntu-Install } # Get latest if (-not $Interactive) { - $selected = $parsed_versions | Select-String -Pattern 'dist-lunar.*' | Select-Object -Index 0 + if (-not($PSBoundParameters.ContainsKey('Version'))) { + $Version = "lunar" + } + $selected = $parsed_versions | Select-String -Pattern "dist-$Version.*" | Select-Object -Index 0 } $selected = "?h=$selected" Do { diff --git a/WSLTools/WSLTools.psd1 b/WSLTools/WSLTools.psd1 index 7d1485a..ebe074b 100644 --- a/WSLTools/WSLTools.psd1 +++ b/WSLTools/WSLTools.psd1 @@ -12,7 +12,7 @@ RootModule = 'WSLTools.psm1' # Version number of this module. -ModuleVersion = '1.3.1' +ModuleVersion = '1.3.2' # Supported PSEditions CompatiblePSEditions = 'Desktop', 'Core'