From cc54b21b145d1cfa07936848e36210b98fa2f3cd Mon Sep 17 00:00:00 2001 From: AkariiinMKII <6019344+AkariiinMKII@users.noreply.github.com> Date: Sat, 27 Jun 2026 15:36:34 +0000 Subject: [PATCH 1/5] speccy: Recover app dependencies in pre_install scripts --- bucket/speccy.json | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/bucket/speccy.json b/bucket/speccy.json index 3942e8e0e687d0..b32545b4191acd 100644 --- a/bucket/speccy.json +++ b/bucket/speccy.json @@ -13,20 +13,31 @@ ] ], "pre_install": [ - "# Construct EXE file name based on $architecture", - "$FileName = [string] 'Speccy{0}.exe' -f $(if($architecture -eq '64bit'){'64'})", - "# Copy EXE to $dir root and rename it to Speccy.exe if 64 bit", - "Get-ChildItem -Recurse -File -Path \"$dir\" -Name $FileName -ErrorAction Stop |", - " ForEach-Object -Process {", - " Move-Item -Path \"$dir\\$_\" -Destination \"$dir\\Speccy.exe\"", + "$ExeFile = [string] 'Speccy{0}.exe' -f $(if ($architecture -eq '64bit') {'64'})", + "# Do not assume the executable file is always in subfolder", + "if (-not (Test-Path \"$dir\\$ExeFile\")) {", + " Get-ChildItem -Path \"$dir\" -Filter \"$ExeFile\" -Recurse | ForEach-Object -Process { Move-Item -Path $_.FullName -Destination \"$dir\" -ErrorAction Stop }", + "}", + "Get-ChildItem -Path \"$dir\" -Exclude \"$ExeFile\", \"Lang\" | ForEach-Object -Process { Remove-Item -Recurse -Force -Path $_.FullName -ErrorAction Stop }", + "if ($architecture -eq '64bit') { Rename-Item -Path \"$dir\\Speccy64.exe\" -NewName \"Speccy.exe\" -ErrorAction Stop }", + "# Recover app dependencies", + "$CachedInstaller = cache_path \"speccy\" $manifest.version $manifest.url", + "if (Test-Path \"$CachedInstaller\") {", + " Write-Host \"`nExtracting app dependencies from cached installer...\"", + " try {", + " 7z x \"$CachedInstaller\" \"cpuidsdk.dll\" \"-o$dir\" -aou | Out-Null", + " # Assuming 64bit uses the larger one", + " switch ($architecture) {", + " '64bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -First 1 | Remove-Item -Force -ErrorAction Stop }", + " '32bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -Last 1 | Remove-Item -Force -ErrorAction Stop }", + " }", + " Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Rename-Item -NewName \"cpuidsdk.dll\" -ErrorAction Stop", + " } catch {", + " Write-Warning \"Failed! Please check the installer file.\"", " }", - "# Remove everything else", - "Get-ChildItem -Path $dir |", - " Where-Object -Property 'Name' -ne 'Speccy.exe' |", - " ForEach-Object -Process {", - " Remove-Item -Recurse -Force -Path $_.FullName", - " }", - "# Set settings", + "} else {", + " Write-Warning \"Cached installer not found! App functions may be limited due to missing dependencies.\"", + "}", "Set-Content -Path \"$dir\\portable.dat\" -Value '#PORTABLE#' -Encoding ASCII", "if (-not (Test-Path \"$persist_dir\\Speccy.ini\")) {", " Set-Content \"$dir\\Speccy.ini\" (@('[Software\\Piriform\\Speccy]', 'NeedUpdate=0') -join \"`r`n\") -Encoding ASCII", From 18ed67ce50dc37902a8be57182c2bbffcad5190a Mon Sep 17 00:00:00 2001 From: AkariiinMKII <6019344+AkariiinMKII@users.noreply.github.com> Date: Sun, 28 Jun 2026 01:16:22 +0800 Subject: [PATCH 2/5] Use scoop built-in method --- bucket/speccy.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bucket/speccy.json b/bucket/speccy.json index b32545b4191acd..e00fcce7492b16 100644 --- a/bucket/speccy.json +++ b/bucket/speccy.json @@ -21,22 +21,25 @@ "Get-ChildItem -Path \"$dir\" -Exclude \"$ExeFile\", \"Lang\" | ForEach-Object -Process { Remove-Item -Recurse -Force -Path $_.FullName -ErrorAction Stop }", "if ($architecture -eq '64bit') { Rename-Item -Path \"$dir\\Speccy64.exe\" -NewName \"Speccy.exe\" -ErrorAction Stop }", "# Recover app dependencies", + "Write-Host \"`nExtracting app dependencies from installer...\" -NoNewline", "$CachedInstaller = cache_path \"speccy\" $manifest.version $manifest.url", "if (Test-Path \"$CachedInstaller\") {", - " Write-Host \"`nExtracting app dependencies from cached installer...\"", " try {", - " 7z x \"$CachedInstaller\" \"cpuidsdk.dll\" \"-o$dir\" -aou | Out-Null", + " Expand-7zipArchive -Path \"$CachedInstaller\" -DestinationPath \"$dir\" -Switches \"cpuidsdk.dll\" -Overwrite Rename", " # Assuming 64bit uses the larger one", " switch ($architecture) {", " '64bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -First 1 | Remove-Item -Force -ErrorAction Stop }", " '32bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -Last 1 | Remove-Item -Force -ErrorAction Stop }", " }", " Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Rename-Item -NewName \"cpuidsdk.dll\" -ErrorAction Stop", + " Write-Host \"success!\" -ForegroundColor Green", " } catch {", - " Write-Warning \"Failed! Please check the installer file.\"", + " Write-Host \"failed!\" -ForegroundColor Red", + " Write-Warning \"Failed to extract app dependencies, please check the cached installer file.\"", " }", "} else {", - " Write-Warning \"Cached installer not found! App functions may be limited due to missing dependencies.\"", + " Write-Host \"failed!\" -ForegroundColor Red", + " Write-Warning \"Can not find cached installer file! App functions may be limited due to missing dependencies.\"", "}", "Set-Content -Path \"$dir\\portable.dat\" -Value '#PORTABLE#' -Encoding ASCII", "if (-not (Test-Path \"$persist_dir\\Speccy.ini\")) {", From 371b1baf6024234e6f681ad25ec40951e03e32de Mon Sep 17 00:00:00 2001 From: AkariiinMKII <6019344+AkariiinMKII@users.noreply.github.com> Date: Sun, 28 Jun 2026 10:07:11 +0800 Subject: [PATCH 3/5] Adjust docs --- bucket/speccy.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bucket/speccy.json b/bucket/speccy.json index e00fcce7492b16..9842e48d3b06f2 100644 --- a/bucket/speccy.json +++ b/bucket/speccy.json @@ -14,19 +14,18 @@ ], "pre_install": [ "$ExeFile = [string] 'Speccy{0}.exe' -f $(if ($architecture -eq '64bit') {'64'})", - "# Do not assume the executable file is always in subfolder", + "# The executable file might be in a subfolder, or not.", "if (-not (Test-Path \"$dir\\$ExeFile\")) {", " Get-ChildItem -Path \"$dir\" -Filter \"$ExeFile\" -Recurse | ForEach-Object -Process { Move-Item -Path $_.FullName -Destination \"$dir\" -ErrorAction Stop }", "}", "Get-ChildItem -Path \"$dir\" -Exclude \"$ExeFile\", \"Lang\" | ForEach-Object -Process { Remove-Item -Recurse -Force -Path $_.FullName -ErrorAction Stop }", "if ($architecture -eq '64bit') { Rename-Item -Path \"$dir\\Speccy64.exe\" -NewName \"Speccy.exe\" -ErrorAction Stop }", - "# Recover app dependencies", "Write-Host \"`nExtracting app dependencies from installer...\" -NoNewline", "$CachedInstaller = cache_path \"speccy\" $manifest.version $manifest.url", "if (Test-Path \"$CachedInstaller\") {", " try {", " Expand-7zipArchive -Path \"$CachedInstaller\" -DestinationPath \"$dir\" -Switches \"cpuidsdk.dll\" -Overwrite Rename", - " # Assuming 64bit uses the larger one", + " # There are usually two, assuming 64bit uses the larger one.", " switch ($architecture) {", " '64bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -First 1 | Remove-Item -Force -ErrorAction Stop }", " '32bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -Last 1 | Remove-Item -Force -ErrorAction Stop }", From ecba04c0c8df9914349f4f8d39c8a37027893de4 Mon Sep 17 00:00:00 2001 From: AkariiinMKII <6019344+AkariiinMKII@users.noreply.github.com> Date: Sun, 28 Jun 2026 12:30:03 +0000 Subject: [PATCH 4/5] Reorder processes, add hash check --- bucket/speccy.json | 52 ++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/bucket/speccy.json b/bucket/speccy.json index 9842e48d3b06f2..6189d59d195930 100644 --- a/bucket/speccy.json +++ b/bucket/speccy.json @@ -14,35 +14,47 @@ ], "pre_install": [ "$ExeFile = [string] 'Speccy{0}.exe' -f $(if ($architecture -eq '64bit') {'64'})", - "# The executable file might be in a subfolder, or not.", + "# The executable file might be in a subfolder, or not. Keep this check for backwards compatibility.", "if (-not (Test-Path \"$dir\\$ExeFile\")) {", " Get-ChildItem -Path \"$dir\" -Filter \"$ExeFile\" -Recurse | ForEach-Object -Process { Move-Item -Path $_.FullName -Destination \"$dir\" -ErrorAction Stop }", "}", "Get-ChildItem -Path \"$dir\" -Exclude \"$ExeFile\", \"Lang\" | ForEach-Object -Process { Remove-Item -Recurse -Force -Path $_.FullName -ErrorAction Stop }", "if ($architecture -eq '64bit') { Rename-Item -Path \"$dir\\Speccy64.exe\" -NewName \"Speccy.exe\" -ErrorAction Stop }", + "Set-Content -Path \"$dir\\portable.dat\" -Value '#PORTABLE#' -Encoding ASCII", + "if (-not (Test-Path \"$persist_dir\\Speccy.ini\")) {", + " Set-Content \"$dir\\Speccy.ini\" (@('[Software\\Piriform\\Speccy]', 'NeedUpdate=0') -join \"`r`n\") -Encoding ASCII", + "}", "Write-Host \"`nExtracting app dependencies from installer...\" -NoNewline", "$CachedInstaller = cache_path \"speccy\" $manifest.version $manifest.url", - "if (Test-Path \"$CachedInstaller\") {", - " try {", - " Expand-7zipArchive -Path \"$CachedInstaller\" -DestinationPath \"$dir\" -Switches \"cpuidsdk.dll\" -Overwrite Rename", - " # There are usually two, assuming 64bit uses the larger one.", - " switch ($architecture) {", - " '64bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -First 1 | Remove-Item -Force -ErrorAction Stop }", - " '32bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -Last 1 | Remove-Item -Force -ErrorAction Stop }", - " }", - " Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Rename-Item -NewName \"cpuidsdk.dll\" -ErrorAction Stop", - " Write-Host \"success!\" -ForegroundColor Green", - " } catch {", - " Write-Host \"failed!\" -ForegroundColor Red", - " Write-Warning \"Failed to extract app dependencies, please check the cached installer file.\"", - " }", - "} else {", + "if (-not (Test-Path \"$CachedInstaller\")) {", " Write-Host \"failed!\" -ForegroundColor Red", - " Write-Warning \"Can not find cached installer file! App functions may be limited due to missing dependencies.\"", + " Write-Warning \"Can not find cached installer file in path $CachedInstaller\"", + " Write-Warning \"App functions may be limited due to missing dependencies.\"", + " Write-Warning \"Please check the downloaded cache and try again.\"", + " return", "}", - "Set-Content -Path \"$dir\\portable.dat\" -Value '#PORTABLE#' -Encoding ASCII", - "if (-not (Test-Path \"$persist_dir\\Speccy.ini\")) {", - " Set-Content \"$dir\\Speccy.ini\" (@('[Software\\Piriform\\Speccy]', 'NeedUpdate=0') -join \"`r`n\") -Encoding ASCII", + "if ($manifest.hash -ne (Get-FileHash -Path \"$CachedInstaller\" -Algorithm SHA256).Hash) {", + " Write-Host \"failed!\" -ForegroundColor Red", + " Write-Warning \"Cached installer file hash mismatch in path $CachedInstaller\"", + " Write-Warning \"App functions may be limited due to missing dependencies.\"", + " Write-Warning \"Please check the downloaded cache and try again.\"", + " return", + "}", + "try {", + " Expand-7zipArchive -Path \"$CachedInstaller\" -DestinationPath \"$dir\" -Switches \"cpuidsdk.dll\" -Overwrite Rename", + " # There are usually two, assuming 64bit uses the larger one.", + " switch ($architecture) {", + " '64bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -First 1 | Remove-Item -Force -ErrorAction Stop }", + " '32bit' { Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Sort-Object -Property Length | Select-Object -Last 1 | Remove-Item -Force -ErrorAction Stop }", + " }", + " Get-ChildItem -Path \"$dir\" -Filter \"cpuidsdk*.dll\" | Rename-Item -NewName \"cpuidsdk.dll\" -ErrorAction Stop", + " if (-not (Test-Path \"$dir\\cpuidsdk.dll\")) { throw }", + " Write-Host \"success!\" -ForegroundColor Green", + "} catch {", + " Write-Host \"failed!\" -ForegroundColor Red", + " Write-Warning \"Failed to extract app dependencies from $CachedInstaller\"", + " Write-Warning \"App functions may be limited due to missing dependencies.\"", + " Write-Warning \"Please check the downloaded cache and try again.\"", "}" ], "persist": "Speccy.ini", From 72856a9599a516f81ac5869f9b2276a0c075f0d8 Mon Sep 17 00:00:00 2001 From: AkariiinMKII <6019344+AkariiinMKII@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:22:12 +0800 Subject: [PATCH 5/5] Update warning output method --- bucket/speccy.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bucket/speccy.json b/bucket/speccy.json index 6189d59d195930..2a853f7c220a24 100644 --- a/bucket/speccy.json +++ b/bucket/speccy.json @@ -28,16 +28,16 @@ "$CachedInstaller = cache_path \"speccy\" $manifest.version $manifest.url", "if (-not (Test-Path \"$CachedInstaller\")) {", " Write-Host \"failed!\" -ForegroundColor Red", - " Write-Warning \"Can not find cached installer file in path $CachedInstaller\"", - " Write-Warning \"App functions may be limited due to missing dependencies.\"", - " Write-Warning \"Please check the downloaded cache and try again.\"", + " warn \"Can not find cached installer file in path $CachedInstaller\"", + " warn \"App functions may be limited due to missing dependencies.\"", + " warn \"Please check the downloaded cache and try again.\"", " return", "}", "if ($manifest.hash -ne (Get-FileHash -Path \"$CachedInstaller\" -Algorithm SHA256).Hash) {", " Write-Host \"failed!\" -ForegroundColor Red", - " Write-Warning \"Cached installer file hash mismatch in path $CachedInstaller\"", - " Write-Warning \"App functions may be limited due to missing dependencies.\"", - " Write-Warning \"Please check the downloaded cache and try again.\"", + " warn \"Cached installer file hash mismatch in path $CachedInstaller\"", + " warn \"App functions may be limited due to missing dependencies.\"", + " warn \"Please check the downloaded cache and try again.\"", " return", "}", "try {", @@ -52,9 +52,9 @@ " Write-Host \"success!\" -ForegroundColor Green", "} catch {", " Write-Host \"failed!\" -ForegroundColor Red", - " Write-Warning \"Failed to extract app dependencies from $CachedInstaller\"", - " Write-Warning \"App functions may be limited due to missing dependencies.\"", - " Write-Warning \"Please check the downloaded cache and try again.\"", + " warn \"Failed to extract app dependencies from $CachedInstaller\"", + " warn \"App functions may be limited due to missing dependencies.\"", + " warn \"Please check the downloaded cache and try again.\"", "}" ], "persist": "Speccy.ini",