This repository has been archived by the owner on Dec 29, 2024. It is now read-only.
forked from Atlas-OS/sxsc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
69 lines (59 loc) · 2.47 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
param (
[string]$Thumbprint,
[string]$CabName
)
Write-Host "Thumbprint: $Thumbprint" -ForegroundColor Green
Write-Host "CAB Name: $CabName" -ForegroundColor Green
# Check if required tools exist
$latestBinPath = (Get-ChildItem -Path "$([Environment]::GetFolderPath('ProgramFilesX86'))\Windows Kits\10\bin" -Directory | Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } | Sort-Object { [Version]$_.Name } -Descending | Select-Object -First 1).FullName
$makecatPath = "$latestBinPath\x64\makecat.exe"
$signToolPath = "$latestBinPath\x64\signtool.exe"
if (-Not (Test-Path $makecatPath)) {
Write-Host "Makecat tool not found at: $makecatPath" -ForegroundColor Red
}
if (-Not (Test-Path $signToolPath)) {
Write-Host "SignTool not found at: $signToolPath" -ForegroundColor Red
}
# Ensure tools are present before continuing
if (-Not (Test-Path $makecatPath) -or -Not (Test-Path $signToolPath)) {
Write-Host "Required tools not found in the specified paths. Aborting." -ForegroundColor Red
exit 1
}
Write-Output "Making CAT..."
$cat = & $makecatPath update.cdf 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to make CAT! Error: $cat" -ForegroundColor Red
} else {
Write-Host "Successfully created CAT." -ForegroundColor Green
}
Write-Output "Signing CAT..."
$cat1 = & $signToolPath sign /debug /sm /uw /sha1 $Thumbprint /fd SHA256 update.cat 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to sign CAT! Error: $cat1" -ForegroundColor Red
} else {
Write-Host "Successfully signed CAT." -ForegroundColor Green
}
Write-Output "Making CAB..."
$cab = & makecab.exe /d "CabinetName1=$CabName" /f files.txt 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to make CAB! Error: $cab" -ForegroundColor Red
} else {
Write-Host "Successfully created CAB." -ForegroundColor Green
}
Remove-Item -Path "setup.*" -Force -ErrorAction SilentlyContinue
Write-Output "Signing CAB..."
$cab1 = & $signToolPath sign /debug /sm /uw /sha1 $Thumbprint /fd SHA256 "disk1\$CabName" 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to sign CAB! Error: $cab1" -ForegroundColor Red
} else {
Write-Host "Successfully signed CAB." -ForegroundColor Green
}
Write-Output "Copying CAB to main directory..."
try {
Copy-Item -Path "disk1\*.cab" -Destination "$env:USERPROFILE\Desktop" -Force
Write-Host "CAB copied to desktop." -ForegroundColor Green
} catch {
Write-Host "Failed to copy CAB: $_" -ForegroundColor Red
}
Write-Host "Processing complete. Press Enter to exit..."
pause