Skip to content

Commit 698b964

Browse files
committed
return the status of packages and ignore hidden ones (fix #113)
this is an enhancement for users managing private repositories with Update Retriever, which can mark packages as 'Active' (default), 'Hidden' or some other statuses. This status was previously ignored. Packages sourced from Model-XML repositories, including Lenovos public repository, do not store Status information for packages.
1 parent 7fc7c85 commit 698b964

3 files changed

Lines changed: 29 additions & 14 deletions

File tree

LSUClient.psm1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class PackageFilePointer {
113113
# Internal
114114
class PackageXmlPointer : PackageFilePointer {
115115
[string] $Category
116+
[string] $Status
116117

117118
# Constructor with file name
118119
PackageXmlPointer (
@@ -122,7 +123,8 @@ class PackageXmlPointer : PackageFilePointer {
122123
[string] $Kind,
123124
[string] $Checksum,
124125
[Int64] $Size,
125-
[string] $Category
126+
[string] $Category,
127+
[string] $Status
126128
) : base (
127129
$Name,
128130
$AbsoluteLocation,
@@ -132,6 +134,7 @@ class PackageXmlPointer : PackageFilePointer {
132134
$Size
133135
) {
134136
$this.Category = $Category
137+
$this.Status = $Status
135138
}
136139

137140
# Constructor without explicit file name
@@ -141,7 +144,8 @@ class PackageXmlPointer : PackageFilePointer {
141144
[string] $Kind,
142145
[string] $Checksum,
143146
[Int64] $Size,
144-
[string] $Category
147+
[string] $Category,
148+
[string] $Status
145149
) : base (
146150
$AbsoluteLocation,
147151
$LocationType,
@@ -150,6 +154,7 @@ class PackageXmlPointer : PackageFilePointer {
150154
$Size
151155
) {
152156
$this.Category = $Category
157+
$this.Status = $Status
153158
}
154159
}
155160

@@ -172,6 +177,7 @@ class LenovoPackage {
172177
[Severity] $Severity
173178
[DateTime] $ReleaseDate
174179
[int] $RebootType
180+
[string] $Status
175181
[string] $Vendor
176182
[Int64] $Size
177183
[string] $URL

private/Get-PackagesInRepository.ps1

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
'XmlDefinition',
6666
$Package.checksum.'#text',
6767
0,
68-
$Package.category
68+
$Package.category,
69+
'Active' # Model-XML files do not store a status for packages, so I've decided to default them all to 'Active' for usability
6970
)
7071
} else {
7172
Write-Error "The package definition at $($Package.location) could not be found or accessed"
@@ -99,18 +100,25 @@
99100
:NextPackage foreach ($Package in $PARSEDXML.Database.package) {
100101
foreach ($CompatibleSystem in $Package.SystemCompatibility.System) {
101102
if ($CompatibleSystem.mtm -eq $Model -and $CompatibleSystem.os -eq "Windows $($CachedHardwareTable._OS)") {
102-
$PathInfo = Get-PackagePathInfo -Path $Package.LocalPath -BasePath $Repository
103-
if ($PathInfo.Valid) {
104-
[PackageXmlPointer]::new(
105-
$PathInfo.AbsoluteLocation,
106-
$PathInfo.Type,
107-
'XmlDefinition',
108-
$Package.checksum.'#text',
109-
0,
110-
$Package.category
111-
)
103+
# Updates in a database.xml repository have a 'Status' that can be set to 'Active', 'Hidden' and a few others.
104+
# Get-LSUpdate should not show updates that have been hidden, so we skip them. See issue #113.
105+
if ($Package.Status -ne 'Hidden') {
106+
$PathInfo = Get-PackagePathInfo -Path $Package.LocalPath -BasePath $Repository
107+
if ($PathInfo.Valid) {
108+
[PackageXmlPointer]::new(
109+
$PathInfo.AbsoluteLocation,
110+
$PathInfo.Type,
111+
'XmlDefinition',
112+
$Package.checksum.'#text',
113+
0,
114+
$Package.category,
115+
$Package.Status
116+
)
117+
} else {
118+
Write-Error "The package definition at $($Package.LocalPath) could not be found or accessed"
119+
}
112120
} else {
113-
Write-Error "The package definition at $($Package.LocalPath) could not be found or accessed"
121+
Write-Verbose "Discovered package $($Package.LocalPath) is hidden and will be ignored"
114122
}
115123
continue NextPackage
116124
}

public/Get-LSUpdate.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
'Severity' = $PackageSeverity
295295
'ReleaseDate' = [DateTime]::ParseExact($packageXML.Package.ReleaseDate, 'yyyy-MM-dd', [CultureInfo]::InvariantCulture, 'None')
296296
'RebootType' = $packageXML.Package.Reboot.type
297+
'Status' = $Package.Status
297298
'Vendor' = $packageXML.Package.Vendor
298299
'Size' = $PackageSize
299300
'URL' = $Package.AbsoluteLocation

0 commit comments

Comments
 (0)