Skip to content

Commit de2cc4f

Browse files
committed
make Expand-LSUpdate accept multiple packages (#109)
1 parent 698b964 commit de2cc4f

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

public/Expand-LSUpdate.ps1

+26-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
function Expand-LSUpdate {
22
<#
33
.SYNOPSIS
4-
Extracts a packages installer.
4+
Extracts package installers.
55
66
.DESCRIPTION
7-
Extracts a packages installer.
7+
Extracts package installers.
88
99
.PARAMETER Package
10-
The Lenovo package object to extract
10+
The Lenovo package or packages whose installer to extract
1111
1212
.PARAMETER Path
13-
The directory containing the package files to extract.
13+
The directory containing the previously downloaded packages.
14+
Use `Save-LSUpdate` to download packages.
1415
#>
1516
[CmdletBinding()]
1617
Param (
@@ -20,16 +21,27 @@
2021
[System.IO.DirectoryInfo]$Path = "$env:TEMP\LSUPackages"
2122
)
2223

23-
if ($Package.Installer.ExtractCommand) {
24-
Write-Verbose "Extracting package $($Package.ID) ..."
25-
$PackageDirectory = Join-Path -Path $Path -ChildPath $Package.ID
26-
$extractionProcess = Invoke-PackageCommand -Path $PackageDirectory -Command $Package.Installer.ExtractCommand -RuntimeLimit $script:LSUClientConfiguration.MaxExtractRuntime
27-
if ($extractionProcess.Err) {
28-
Write-Warning "Extraction of package $($Package.ID) has failed!"
29-
} elseif ($extractionProcess.Info.ExitCode -ne 0) {
30-
Write-Warning "Extraction of package $($Package.ID) may have failed!"
24+
begin {
25+
if ($PSBoundParameters['Debug'] -and $DebugPreference -eq 'Inquire') {
26+
Write-Verbose "Adjusting the DebugPreference to 'Continue'."
27+
$DebugPreference = 'Continue'
28+
}
29+
}
30+
31+
process {
32+
foreach ($PackageToExtract in $Package) {
33+
if ($PackageToExtract.Installer.ExtractCommand) {
34+
Write-Verbose "Extracting package $($PackageToExtract.ID) ..."
35+
$PackageDirectory = Join-Path -Path $Path -ChildPath $PackageToExtract.ID
36+
$extractionProcess = Invoke-PackageCommand -Path $PackageDirectory -Command $PackageToExtract.Installer.ExtractCommand -RuntimeLimit $script:LSUClientConfiguration.MaxExtractRuntime
37+
if ($extractionProcess.Err) {
38+
Write-Warning "Extraction of package $($PackageToExtract.ID) has failed!"
39+
} elseif ($extractionProcess.Info.ExitCode -ne 0) {
40+
Write-Warning "Extraction of package $($PackageToExtract.ID) may have failed!"
41+
}
42+
} else {
43+
Write-Verbose "The package '$($PackageToExtract.ID)' does not require extraction."
44+
}
3145
}
32-
} else {
33-
Write-Verbose "The package '$($Package.ID)' does not require extraction."
3446
}
3547
}

0 commit comments

Comments
 (0)