Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions catalogscrape/CatalogScrape.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,11 @@ function Invoke-DriverScrape {
foreach ($Target in $Config.Targets) {
Write-Host "`n=> Investigating Microsoft Update Catalog for $($Target.Name)..." -ForegroundColor Cyan
$AvailablePackages = @()
# Devices whose only candidates fell below their MinVersion floor — tracked so the
# manifest can say WHY they were skipped (vs the catalog returning nothing at all).
$floorBlocked = @{}

foreach ($Device in $Target.Devices) {
$deviceKey = $Device.Key
$label = $Device.Label
$titleExclude = if ($Device.ContainsKey('TitleExclude')) { @($Device.TitleExclude) } else { @() }
# Optional per-device version floor. Drivers below it are dropped — used when the
# only catalog matches for an HWID are a stale generic legacy driver (e.g. a 2016
# driver whose INF blankets dozens of PIDs), so the device skips rather than ships
# the antique. A real per-chip driver (whose [version] major encodes the model, e.g.
# 1157.x) clears the floor automatically once Realtek publishes it.
$minVersion = if ($Device.ContainsKey('MinVersion')) { ConvertTo-CsVersion $Device.MinVersion } else { $null }
$floorDropped = 0
$seenIds = [System.Collections.Generic.HashSet[string]]::new()

# Expand each base query into its dual-query-union variants, then dedup.
Expand Down Expand Up @@ -331,12 +321,6 @@ function Invoke-DriverScrape {
continue
}

if ($minVersion -and $ver -lt $minVersion) {
$floorDropped++
Write-Verbose "Dropped $label candidate $($d.Id): version $($d.Version) below MinVersion $($Device.MinVersion)."
continue
}

$AvailablePackages += [pscustomobject]@{
Key = $deviceKey
Label = $label
Expand All @@ -350,12 +334,6 @@ function Invoke-DriverScrape {
}
}
}

# A device whose every candidate was floored out: record why, for the manifest.
if ($minVersion -and $floorDropped -gt 0 -and -not ($AvailablePackages | Where-Object { $_.Key -eq $deviceKey })) {
$floorBlocked[$deviceKey] = $Device.MinVersion
Write-Host " [!] ${label}: $floorDropped candidate(s) found but all below MinVersion $($Device.MinVersion); none selected." -ForegroundColor Yellow
}
}

if (-not $AvailablePackages) {
Expand All @@ -368,12 +346,7 @@ function Invoke-DriverScrape {
$foundKeys = @($AvailablePackages.Key | Select-Object -Unique)
foreach ($Device in $Target.Devices) {
if ($Device.Key -notin $foundKeys) {
$reason = if ($floorBlocked.ContainsKey($Device.Key)) {
"all candidates below MinVersion $($floorBlocked[$Device.Key])"
} else {
'no catalog candidates'
}
$Manifest.Add("SKIPPED: $($Device.Label) ($reason)")
$Manifest.Add("SKIPPED: $($Device.Label) (no catalog candidates)")
}
}

Expand Down
17 changes: 2 additions & 15 deletions catalogscrape/Test-CatalogScrape.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,9 @@ Assert { (Get-CsBranchRank ([version]'9.9.9.9') @('26.30')) -eq ([int]::MaxValue
$bestMt = Select-CsBestPackage -Packages @((Pkg '5.7.0.5659' '2026-03-06'), (Pkg '26.30.3.62' '2026-04-08')) -PreferredBranches @('26.30', '25.30', '5.7')
Assert { $bestMt.Version -eq [version]'26.30.3.62' } "MediaTek picks 26.30.3.62 (got $($bestMt.Version))"

# Higher version wins DESPITE older catalog date (the core date-vs-version fix). NB: these two
# stale builds are exactly what RTL8157/8159 now floor out via MinVersion (asserted below).
# Realtek RTL8159: higher version wins DESPITE older catalog date (the core date-vs-version fix)
$bestRtl = Select-CsBestPackage -Packages @((Pkg '11.19.602.2025' '2016-03-30'), (Pkg '11.19.20.602' '2018-03-30'))
Assert { $bestRtl.Version -eq [version]'11.19.602.2025' } "version beats older date: picks 11.19.602.2025 over newer-dated 11.19.20.602 (got $($bestRtl.Version))"

# MinVersion floor (RTL8157/8159): the stale 2016/2018 generic driver is below the 1157/1159
# floor, so the device skips it; a real per-chip 115x.x driver clears the floor automatically.
Assert { ([version]'11.19.602.2025') -lt (ConvertTo-CsVersion '1157') } 'MinVersion floor: legacy 11.19.x is below the 1157 floor (8157/8159 skip the stale generic)'
Assert { (ConvertTo-CsVersion '1157.22.113.2026') -ge (ConvertTo-CsVersion '1157') } 'MinVersion floor: a real 1157.x driver clears the floor'
Assert { (ConvertTo-CsVersion '1159') -gt [version]'11.19.20.602' } 'MinVersion floor: 1159 floor sits above the legacy 815A driver'
Assert { $bestRtl.Version -eq [version]'11.19.602.2025' } "Realtek picks 11.19.602.2025 over newer-dated 11.19.20.602 (got $($bestRtl.Version))"

# Intel I226-V: re-released older version has a NEWER date; highest version must still win
$bestIntel = Select-CsBestPackage -Packages @((Pkg '2.1.5.10' '2025-12-29'), (Pkg '2.1.5.7' '2026-01-19'))
Expand Down Expand Up @@ -159,12 +152,6 @@ Assert { $be.Queries[0] -eq 'VEN_8086&DEV_272B' } 'BE200 keeps correct 272B (not
$md = Import-PowerShellDataFile (Join-Path $PSScriptRoot 'mediatek.psd1')
$mt7925 = $md.Targets.Devices | Where-Object Key -eq '7925'
Assert { $mt7925.PreferredBranches[0] -eq '26.30' } 'MT7925 preferred branch refreshed to 26.30'
# Realtek RTL8157/8159 carry a MinVersion floor so the stale 2016 generic driver is skipped.
$rt = Import-PowerShellDataFile (Join-Path $PSScriptRoot 'realtek.psd1')
$rt57 = $rt.Targets.Devices | Where-Object Key -eq '1157'
$rt59 = $rt.Targets.Devices | Where-Object Key -eq '1159'
Assert { (ConvertTo-CsVersion $rt57.MinVersion) -eq (ConvertTo-CsVersion '1157') } 'realtek RTL8157 has MinVersion 1157 floor'
Assert { (ConvertTo-CsVersion $rt59.MinVersion) -eq (ConvertTo-CsVersion '1159') } 'realtek RTL8159 has MinVersion 1159 floor'

# GPU graphics tables: unified Intel device, NVIDIA consumer/pro split, AMD Radeon Pro present.
$ig = Import-PowerShellDataFile (Join-Path $PSScriptRoot 'intel-gfx.psd1')
Expand Down
15 changes: 6 additions & 9 deletions catalogscrape/realtek.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@
@{
Name = 'RTL_USB_Family'
Devices = @(
# Realtek publishes a per-PID modern USB NIC driver whose [version] major encodes
# the chip (8153->1153.x, 8156->1156.x, ...). RTL8153/8156 have current drivers
# (e.g. 1153.22.113.2026, Jan 2026).
# USB packages carry a stale 2016/2018 catalog versionDate, so selection-by-date
# used to pick the OLDER build. The engine now selects by highest [version]
# (date as tiebreak), so e.g. RTL8159 correctly picks 11.19.602.2025 over the
# 2018-dated 11.19.20.602.
@{ Key = '1153'; Label = 'RTL8153'; Queries = @('VID_0BDA&PID_8153') }
@{ Key = '1156'; Label = 'RTL8156'; Queries = @('VID_0BDA&PID_8156') }
# RTL8157 (5G) / RTL8159 (PID 815A) have NO modern catalog driver yet — the only
# match is a 2016/2018 generic legacy driver (11.19.602.2025) whose INF blankets
# ~16 old PIDs. MinVersion floors that out (11.x < 1157/1159), so these SKIP today
# and auto-pick the real per-chip driver the moment Realtek ships a 115x.x build.
@{ Key = '1157'; Label = 'RTL8157'; MinVersion = '1157'; Queries = @('VID_0BDA&PID_8157') }
@{ Key = '1159'; Label = 'RTL8159'; MinVersion = '1159'; Queries = @('VID_0BDA&PID_815A') }
@{ Key = '1157'; Label = 'RTL8157'; Queries = @('VID_0BDA&PID_8157') }
@{ Key = '1159'; Label = 'RTL8159'; Queries = @('VID_0BDA&PID_815A') }
)
}
)
Expand Down
Loading