更新
This commit is contained in:
@@ -4,6 +4,7 @@ set -euo pipefail
|
||||
project_root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
python_bin="${PYINSTALLER_PYTHON:-$project_root/.venv-build/bin/python}"
|
||||
companion_root="$project_root/video_companion"
|
||||
macos_icon="$project_root/resources/branding/app-icon.icns"
|
||||
|
||||
if [[ "$(uname -s)" != "Darwin" ]]; then
|
||||
echo "The macOS bundle must be built on macOS." >&2
|
||||
@@ -13,6 +14,10 @@ if [[ ! -x "$python_bin" ]]; then
|
||||
echo "Build Python was not found: $python_bin" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ ! -f "$macos_icon" ]]; then
|
||||
echo "macOS application icon was not found: $macos_icon" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ "${SKIP_FRONTEND_INSTALL:-0}" != "1" ]]; then
|
||||
npm ci --prefix "$companion_root" --no-audit --no-fund
|
||||
|
||||
@@ -8,6 +8,7 @@ $ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$CompanionRoot = Join-Path $ProjectRoot "video_companion"
|
||||
$Spec = Join-Path $ProjectRoot "packaging\doctor_workstation.spec"
|
||||
$WindowsIcon = Join-Path $ProjectRoot "resources\branding\app-icon.ico"
|
||||
|
||||
function Invoke-FrozenGate {
|
||||
param(
|
||||
@@ -153,6 +154,9 @@ if (-not [System.IO.Path]::IsPathRooted($Python)) {
|
||||
if (-not (Test-Path -LiteralPath $Python -PathType Leaf)) {
|
||||
throw "Build Python was not found: $Python"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $WindowsIcon -PathType Leaf)) {
|
||||
throw "Windows application icon was not found: $WindowsIcon"
|
||||
}
|
||||
|
||||
$Npm = (Get-Command npm.cmd -ErrorAction Stop).Source
|
||||
Push-Location $ProjectRoot
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
$ToolVersion = "6.7.3"
|
||||
$ToolRoot = Join-Path $ProjectRoot ".build-tools\inno-setup-$ToolVersion"
|
||||
$Compiler = Join-Path $ToolRoot "ISCC.exe"
|
||||
$DownloadRoot = Join-Path $ProjectRoot ".build-tools\downloads"
|
||||
$Installer = Join-Path $DownloadRoot "innosetup-$ToolVersion.exe"
|
||||
$InstallerUrl = (
|
||||
"https://github.com/jrsoftware/issrc/releases/download/" +
|
||||
"is-6_7_3/innosetup-$ToolVersion.exe"
|
||||
)
|
||||
$InstallerSha256 = "9C73C3BAE7ED48D44112A0F48E66742C00090BDB5BEF71D9D3C056C66E97B732"
|
||||
$LanguageRoot = Join-Path $ProjectRoot ".build-tools\inno-languages"
|
||||
$ChineseMessages = Join-Path $LanguageRoot "ChineseSimplified.isl"
|
||||
$ChineseMessagesUrl = (
|
||||
"https://raw.githubusercontent.com/jrsoftware/issrc/" +
|
||||
"6ef32198ef1f7b7b375cd4b6b90896c2a58eb4c2/Files/Languages/ChineseSimplified.isl"
|
||||
)
|
||||
$ChineseMessagesSha256 = "E0B0B350E2245F3C5E65586DFE43D574F6E7F06F2261149ABA284954B3FC9A8D"
|
||||
|
||||
function Test-Compiler {
|
||||
param([Parameter(Mandatory = $true)][string]$Candidate)
|
||||
|
||||
if (-not (Test-Path -LiteralPath $Candidate -PathType Leaf)) {
|
||||
return $false
|
||||
}
|
||||
$ReleaseNotes = Join-Path (Split-Path -Parent $Candidate) "whatsnew.htm"
|
||||
if (-not (Test-Path -LiteralPath $ReleaseNotes -PathType Leaf)) {
|
||||
return $false
|
||||
}
|
||||
$ReleaseText = [System.IO.File]::ReadAllText($ReleaseNotes)
|
||||
$VersionMatch = [regex]::Match($ReleaseText, '<span class="ver">([0-9.]+)')
|
||||
return $VersionMatch.Success -and $VersionMatch.Groups[1].Value -eq $ToolVersion
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $LanguageRoot -Force | Out-Null
|
||||
if (Test-Path -LiteralPath $ChineseMessages -PathType Leaf) {
|
||||
$ExistingLanguageHash = (Get-FileHash -LiteralPath $ChineseMessages -Algorithm SHA256).Hash
|
||||
if ($ExistingLanguageHash -ne $ChineseMessagesSha256) {
|
||||
Remove-Item -LiteralPath $ChineseMessages -Force
|
||||
}
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $ChineseMessages -PathType Leaf)) {
|
||||
Write-Host "Downloading the pinned Simplified Chinese installer messages..."
|
||||
Invoke-WebRequest -Uri $ChineseMessagesUrl -OutFile $ChineseMessages -UseBasicParsing
|
||||
}
|
||||
$ActualLanguageHash = (Get-FileHash -LiteralPath $ChineseMessages -Algorithm SHA256).Hash
|
||||
if ($ActualLanguageHash -ne $ChineseMessagesSha256) {
|
||||
throw "Inno Setup language checksum mismatch. Expected $ChineseMessagesSha256; found $ActualLanguageHash"
|
||||
}
|
||||
|
||||
foreach ($Candidate in @(
|
||||
$Compiler,
|
||||
(Join-Path ${env:ProgramFiles(x86)} "Inno Setup 6\ISCC.exe"),
|
||||
(Join-Path $env:LOCALAPPDATA "Programs\Inno Setup 6\ISCC.exe")
|
||||
)) {
|
||||
if ($Candidate -and (Test-Compiler -Candidate $Candidate)) {
|
||||
Write-Output (Resolve-Path -LiteralPath $Candidate).Path
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $DownloadRoot -Force | Out-Null
|
||||
if (Test-Path -LiteralPath $Installer -PathType Leaf) {
|
||||
$ExistingHash = (Get-FileHash -LiteralPath $Installer -Algorithm SHA256).Hash
|
||||
if ($ExistingHash -ne $InstallerSha256) {
|
||||
Remove-Item -LiteralPath $Installer -Force
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $Installer -PathType Leaf)) {
|
||||
Write-Host "Downloading pinned Inno Setup $ToolVersion compiler..."
|
||||
Invoke-WebRequest -Uri $InstallerUrl -OutFile $Installer -UseBasicParsing
|
||||
}
|
||||
|
||||
$ActualHash = (Get-FileHash -LiteralPath $Installer -Algorithm SHA256).Hash
|
||||
if ($ActualHash -ne $InstallerSha256) {
|
||||
throw "Inno Setup download checksum mismatch. Expected $InstallerSha256; found $ActualHash"
|
||||
}
|
||||
$Signature = Get-AuthenticodeSignature -LiteralPath $Installer
|
||||
if ($Signature.Status -ne [System.Management.Automation.SignatureStatus]::Valid) {
|
||||
throw "Inno Setup download does not have a valid Authenticode signature: $($Signature.Status)"
|
||||
}
|
||||
if (-not $Signature.SignerCertificate -or
|
||||
$Signature.SignerCertificate.Subject -notmatch "O=Pyrsys B\.V\.") {
|
||||
throw "Inno Setup download has an unexpected signer"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $ToolRoot -Force | Out-Null
|
||||
Write-Host "Installing the pinned Inno Setup compiler into $ToolRoot ..."
|
||||
& $Installer /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /CURRENTUSER "/DIR=$ToolRoot"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Inno Setup compiler installation failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
if (-not (Test-Compiler -Candidate $Compiler)) {
|
||||
throw "Inno Setup installation completed without ISCC.exe: $Compiler"
|
||||
}
|
||||
|
||||
Write-Output $Compiler
|
||||
@@ -0,0 +1,139 @@
|
||||
"""Generate deterministic application-brand assets from the approved master PNG."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
DEFAULT_MASTER = PROJECT_ROOT / "resources" / "branding" / "brand-master.png"
|
||||
BRANDING_ROOT = PROJECT_ROOT / "resources" / "branding"
|
||||
VIDEO_PUBLIC_ROOT = PROJECT_ROOT / "video_companion" / "public"
|
||||
ICON_SIZES = (16, 20, 24, 32, 40, 48, 64, 128, 256)
|
||||
|
||||
|
||||
def _transparent_connected_background(image: Image.Image) -> Image.Image:
|
||||
"""Remove only near-white pixels connected to the crop boundary.
|
||||
|
||||
The logo contains intentional white ECG strokes. A global color-key would
|
||||
erase them, whereas a connected-background mask preserves enclosed whites.
|
||||
"""
|
||||
|
||||
rgb = image.convert("RGB")
|
||||
candidates = Image.new("L", rgb.size)
|
||||
candidates.putdata(
|
||||
[
|
||||
255
|
||||
if min(pixel) >= 185 and max(pixel) - min(pixel) <= 70
|
||||
else 0
|
||||
for pixel in rgb.getdata()
|
||||
]
|
||||
)
|
||||
ImageDraw.floodfill(candidates, (0, 0), 128, thresh=0)
|
||||
alpha = candidates.point(lambda value: 0 if value == 128 else 255)
|
||||
rgba = rgb.convert("RGBA")
|
||||
rgba.putalpha(alpha)
|
||||
return rgba
|
||||
|
||||
|
||||
def _square_icon(image: Image.Image, size: int = 1024, padding: int = 72) -> Image.Image:
|
||||
available = size - padding * 2
|
||||
scale = min(available / image.width, available / image.height)
|
||||
rendered = image.resize(
|
||||
(round(image.width * scale), round(image.height * scale)),
|
||||
Image.Resampling.LANCZOS,
|
||||
)
|
||||
tile = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
||||
tile_mask = Image.new("L", (size, size), 0)
|
||||
ImageDraw.Draw(tile_mask).rounded_rectangle(
|
||||
(24, 24, size - 24, size - 24),
|
||||
radius=190,
|
||||
fill=255,
|
||||
)
|
||||
white_tile = Image.new("RGBA", (size, size), (255, 255, 255, 255))
|
||||
tile.paste(white_tile, mask=tile_mask)
|
||||
tile.alpha_composite(
|
||||
rendered.convert("RGBA"),
|
||||
((size - rendered.width) // 2, (size - rendered.height) // 2),
|
||||
)
|
||||
return tile
|
||||
|
||||
|
||||
def generate(master_path: Path) -> tuple[Path, ...]:
|
||||
master = Image.open(master_path).convert("RGB")
|
||||
if master.size != (1254, 1254):
|
||||
raise ValueError(f"expected a 1254x1254 brand master, got {master.size}")
|
||||
|
||||
BRANDING_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
VIDEO_PUBLIC_ROOT.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
lockup_bbox = _transparent_connected_background(master).getchannel("A").getbbox()
|
||||
if lockup_bbox is None:
|
||||
raise ValueError("brand lockup extraction produced an empty image")
|
||||
left, top, right, bottom = lockup_bbox
|
||||
full_lockup = master.crop(
|
||||
(
|
||||
max(0, left - 28),
|
||||
max(0, top - 28),
|
||||
min(master.width, right + 28),
|
||||
min(master.height, bottom + 28),
|
||||
)
|
||||
)
|
||||
|
||||
# The supplied artwork places the pictorial mark wholly above y=720. The
|
||||
# crop intentionally excludes the Chinese and English lockup for legible
|
||||
# Windows/macOS small icons.
|
||||
mark_crop = master.crop((300, 110, 980, 720))
|
||||
mark_bbox = _transparent_connected_background(mark_crop).getchannel("A").getbbox()
|
||||
if mark_bbox is None:
|
||||
raise ValueError("application icon extraction produced an empty image")
|
||||
left, top, right, bottom = mark_bbox
|
||||
app_icon = _square_icon(
|
||||
mark_crop.crop(
|
||||
(
|
||||
max(0, left - 12),
|
||||
max(0, top - 12),
|
||||
min(mark_crop.width, right + 12),
|
||||
min(mark_crop.height, bottom + 12),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
lockup_path = BRANDING_ROOT / "brand-lockup.png"
|
||||
icon_png_path = BRANDING_ROOT / "app-icon.png"
|
||||
icon_ico_path = BRANDING_ROOT / "app-icon.ico"
|
||||
icon_icns_path = BRANDING_ROOT / "app-icon.icns"
|
||||
favicon_path = VIDEO_PUBLIC_ROOT / "favicon.png"
|
||||
|
||||
full_lockup.save(lockup_path, optimize=True)
|
||||
app_icon.save(icon_png_path, optimize=True)
|
||||
app_icon.save(
|
||||
icon_ico_path,
|
||||
format="ICO",
|
||||
sizes=[(size, size) for size in ICON_SIZES],
|
||||
)
|
||||
app_icon.save(icon_icns_path, format="ICNS")
|
||||
app_icon.resize((64, 64), Image.Resampling.LANCZOS).save(
|
||||
favicon_path,
|
||||
optimize=True,
|
||||
)
|
||||
|
||||
return lockup_path, icon_png_path, icon_ico_path, icon_icns_path, favicon_path
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--master", type=Path, default=DEFAULT_MASTER)
|
||||
args = parser.parse_args()
|
||||
master_path = args.master.resolve()
|
||||
if not master_path.is_file():
|
||||
parser.error(f"brand master is missing: {master_path}")
|
||||
for output in generate(master_path):
|
||||
print(output)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -17,8 +17,12 @@ $Executable = Join-Path $Artifact "DoctorWorkstation.exe"
|
||||
$DistributionRoot = Join-Path $ProjectRoot "dist"
|
||||
$ReleaseLauncherTemplate = Join-Path $ProjectRoot "packaging\windows\start_release.bat"
|
||||
$ReleaseLauncher = Join-Path $DistributionRoot "Start_DoctorWorkstation.bat"
|
||||
$InstallerDefinition = Join-Path $ProjectRoot "packaging\windows\doctor_workstation.iss"
|
||||
$EnsureInstallerCompiler = Join-Path $PSScriptRoot "ensure_inno_setup.ps1"
|
||||
$InstallerMessagesFile = Join-Path $ProjectRoot ".build-tools\inno-languages\ChineseSimplified.isl"
|
||||
$ProjectMetadata = Join-Path $ProjectRoot "pyproject.toml"
|
||||
$MediaSmokeHook = Join-Path $ProjectRoot "packaging\runtime_media_smoke.py"
|
||||
$WindowsIcon = Join-Path $ProjectRoot "resources\branding\app-icon.ico"
|
||||
|
||||
function Test-BuildPython {
|
||||
param([Parameter(Mandatory = $true)][string]$Candidate)
|
||||
@@ -51,7 +55,10 @@ try {
|
||||
(Join-Path $ProjectRoot "uv.lock"),
|
||||
$ProjectMetadata,
|
||||
$MediaSmokeHook,
|
||||
$ReleaseLauncherTemplate
|
||||
$WindowsIcon,
|
||||
$ReleaseLauncherTemplate,
|
||||
$InstallerDefinition,
|
||||
$EnsureInstallerCompiler
|
||||
)) {
|
||||
if (-not (Test-Path -LiteralPath $RequiredFile -PathType Leaf)) {
|
||||
throw "Required build file is missing: $RequiredFile"
|
||||
@@ -76,7 +83,7 @@ try {
|
||||
-not (Test-BuildPython -Candidate $FallbackPython)) {
|
||||
throw "Neither uv nor a usable Python environment with build dependencies was found."
|
||||
}
|
||||
Write-Host "Windows package entry validation passed."
|
||||
Write-Host "Windows package entry validation passed. No artifacts were generated."
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -161,6 +168,8 @@ try {
|
||||
$ReleaseZip = Join-Path $DistributionRoot (
|
||||
"DoctorWorkstation-Windows-x64-$ProjectVersion.zip"
|
||||
)
|
||||
$InstallerBaseName = "DoctorWorkstation-Setup-Windows-x64-$ProjectVersion"
|
||||
$InstallerArtifact = Join-Path $DistributionRoot "$InstallerBaseName.exe"
|
||||
$ChecksumFile = Join-Path $DistributionRoot "SHA256SUMS.txt"
|
||||
Copy-Item -LiteralPath $ReleaseLauncherTemplate -Destination $ReleaseLauncher -Force
|
||||
if (Test-Path -LiteralPath $ReleaseZip) {
|
||||
@@ -192,15 +201,54 @@ try {
|
||||
throw "Packaging completed without the expected ZIP: $ReleaseZip"
|
||||
}
|
||||
|
||||
if (Test-Path -LiteralPath $InstallerArtifact) {
|
||||
Remove-Item -LiteralPath $InstallerArtifact -Force
|
||||
}
|
||||
Write-Host "Preparing the pinned Inno Setup compiler..."
|
||||
$InnoCompiler = (& $EnsureInstallerCompiler | Select-Object -Last 1)
|
||||
if (-not $InnoCompiler -or
|
||||
-not (Test-Path -LiteralPath $InnoCompiler -PathType Leaf)) {
|
||||
throw "Unable to locate the Inno Setup compiler"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $InstallerMessagesFile -PathType Leaf)) {
|
||||
throw "Simplified Chinese installer messages are missing: $InstallerMessagesFile"
|
||||
}
|
||||
|
||||
Write-Host "Creating the Windows installer..."
|
||||
& $InnoCompiler `
|
||||
"/DAppVersion=$ProjectVersion" `
|
||||
"/DSourceDir=$Artifact" `
|
||||
"/DOutputDir=$DistributionRoot" `
|
||||
"/DSetupBaseName=$InstallerBaseName" `
|
||||
"/DChineseMessagesFile=$InstallerMessagesFile" `
|
||||
"/DAppIconFile=$WindowsIcon" `
|
||||
$InstallerDefinition
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Inno Setup failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
if (-not (Test-Path -LiteralPath $InstallerArtifact -PathType Leaf)) {
|
||||
throw "Installer compilation completed without the expected artifact: $InstallerArtifact"
|
||||
}
|
||||
|
||||
$ReleaseHash = (Get-FileHash -LiteralPath $ReleaseZip -Algorithm SHA256).Hash
|
||||
$ChecksumLine = "$ReleaseHash $([System.IO.Path]::GetFileName($ReleaseZip))`r`n"
|
||||
$InstallerHash = (Get-FileHash -LiteralPath $InstallerArtifact -Algorithm SHA256).Hash
|
||||
$ChecksumLines = @(
|
||||
"$InstallerHash $([System.IO.Path]::GetFileName($InstallerArtifact))",
|
||||
"$ReleaseHash $([System.IO.Path]::GetFileName($ReleaseZip))"
|
||||
)
|
||||
$Utf8WithoutBom = New-Object System.Text.UTF8Encoding($false)
|
||||
[System.IO.File]::WriteAllText($ChecksumFile, $ChecksumLine, $Utf8WithoutBom)
|
||||
[System.IO.File]::WriteAllText(
|
||||
$ChecksumFile,
|
||||
(($ChecksumLines -join "`r`n") + "`r`n"),
|
||||
$Utf8WithoutBom
|
||||
)
|
||||
|
||||
Write-Host "Windows package complete." -ForegroundColor Green
|
||||
Write-Host "Artifact: $Artifact" -ForegroundColor Green
|
||||
Write-Host "Installer: $InstallerArtifact" -ForegroundColor Green
|
||||
Write-Host "Release ZIP: $ReleaseZip" -ForegroundColor Green
|
||||
Write-Host "SHA-256: $ReleaseHash" -ForegroundColor Green
|
||||
Write-Host "Installer SHA-256: $InstallerHash" -ForegroundColor Green
|
||||
Write-Host "ZIP SHA-256: $ReleaseHash" -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
catch {
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Installer
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
|
||||
|
||||
function Get-AssociatedIconHash {
|
||||
param([Parameter(Mandatory = $true)][string]$FilePath)
|
||||
|
||||
$Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($FilePath)
|
||||
if (-not $Icon) {
|
||||
throw "Unable to extract the Windows icon from: $FilePath"
|
||||
}
|
||||
$Bitmap = New-Object System.Drawing.Bitmap 32, 32
|
||||
$Graphics = [System.Drawing.Graphics]::FromImage($Bitmap)
|
||||
$Stream = New-Object System.IO.MemoryStream
|
||||
$Hasher = [System.Security.Cryptography.SHA256]::Create()
|
||||
try {
|
||||
$Graphics.Clear([System.Drawing.Color]::Transparent)
|
||||
$Graphics.DrawIcon($Icon, 0, 0)
|
||||
$Bitmap.Save($Stream, [System.Drawing.Imaging.ImageFormat]::Png)
|
||||
$Hash = $Hasher.ComputeHash($Stream.ToArray())
|
||||
return ([System.BitConverter]::ToString($Hash)).Replace("-", "")
|
||||
}
|
||||
finally {
|
||||
$Hasher.Dispose()
|
||||
$Stream.Dispose()
|
||||
$Graphics.Dispose()
|
||||
$Bitmap.Dispose()
|
||||
$Icon.Dispose()
|
||||
}
|
||||
}
|
||||
if (-not $Installer) {
|
||||
$Installer = Get-ChildItem `
|
||||
-LiteralPath (Join-Path $ProjectRoot "dist") `
|
||||
-Filter "DoctorWorkstation-Setup-Windows-x64-*.exe" `
|
||||
-File |
|
||||
Sort-Object LastWriteTime -Descending |
|
||||
Select-Object -First 1 -ExpandProperty FullName
|
||||
}
|
||||
if (-not $Installer -or -not (Test-Path -LiteralPath $Installer -PathType Leaf)) {
|
||||
throw "Windows installer was not found: $Installer"
|
||||
}
|
||||
$Installer = (Resolve-Path -LiteralPath $Installer).Path
|
||||
$InstallerIconHash = Get-AssociatedIconHash -FilePath $Installer
|
||||
|
||||
$TempBase = [System.IO.Path]::GetFullPath([System.IO.Path]::GetTempPath())
|
||||
$SmokeRoot = [System.IO.Path]::GetFullPath((Join-Path $TempBase (
|
||||
"doctor-workstation-installer-smoke-" + [guid]::NewGuid().ToString("N")
|
||||
)))
|
||||
if (-not $SmokeRoot.StartsWith($TempBase, [System.StringComparison]::OrdinalIgnoreCase) -or
|
||||
-not ([System.IO.Path]::GetFileName($SmokeRoot)).StartsWith(
|
||||
"doctor-workstation-installer-smoke-"
|
||||
)) {
|
||||
throw "Refusing to use an unsafe installer smoke directory: $SmokeRoot"
|
||||
}
|
||||
|
||||
$InstallDirectory = Join-Path $SmokeRoot "install"
|
||||
$SetupLog = Join-Path $SmokeRoot "setup.log"
|
||||
$UninstallLog = Join-Path $SmokeRoot "uninstall.log"
|
||||
New-Item -ItemType Directory -Path $SmokeRoot -Force | Out-Null
|
||||
|
||||
$SetupProcess = Start-Process `
|
||||
-FilePath $Installer `
|
||||
-ArgumentList @(
|
||||
"/VERYSILENT",
|
||||
"/SUPPRESSMSGBOXES",
|
||||
"/NORESTART",
|
||||
"/CURRENTUSER",
|
||||
"/DIR=$InstallDirectory",
|
||||
"/MERGETASKS=!desktopicon",
|
||||
"/LOG=$SetupLog"
|
||||
) `
|
||||
-Wait `
|
||||
-PassThru `
|
||||
-WindowStyle Hidden
|
||||
if ($SetupProcess.ExitCode -ne 0) {
|
||||
throw "Installer exited with code $($SetupProcess.ExitCode). See $SetupLog"
|
||||
}
|
||||
|
||||
$InstalledExecutable = Join-Path $InstallDirectory "DoctorWorkstation.exe"
|
||||
if (-not (Test-Path -LiteralPath $InstalledExecutable -PathType Leaf)) {
|
||||
throw "Installed executable is missing: $InstalledExecutable"
|
||||
}
|
||||
$Uninstaller = Join-Path $InstallDirectory "unins000.exe"
|
||||
if (-not (Test-Path -LiteralPath $Uninstaller -PathType Leaf)) {
|
||||
throw "Uninstaller is missing: $Uninstaller"
|
||||
}
|
||||
$InstalledIconHash = Get-AssociatedIconHash -FilePath $InstalledExecutable
|
||||
$UninstallerIconHash = Get-AssociatedIconHash -FilePath $Uninstaller
|
||||
if ($InstalledIconHash -ne $InstallerIconHash) {
|
||||
throw "Installed executable icon does not match the installer brand icon"
|
||||
}
|
||||
if ($UninstallerIconHash -ne $InstallerIconHash) {
|
||||
throw "Uninstaller icon does not match the installer brand icon"
|
||||
}
|
||||
|
||||
$Environment = @{
|
||||
"DOCTOR_CONFIG_DIR" = (Join-Path $SmokeRoot "config")
|
||||
"DOCTOR_LOG_DIR" = (Join-Path $SmokeRoot "logs")
|
||||
"DOCTOR_API_BASE_URL" = "https://127.0.0.1:9"
|
||||
"DOCTOR_DEMO_MODE" = "true"
|
||||
"DOCTOR_VIDEO_MODE" = "embedded"
|
||||
"DOCTOR_SMOKE_TEST" = "1"
|
||||
"QT_QPA_PLATFORM" = "offscreen"
|
||||
}
|
||||
$PreviousEnvironment = @{}
|
||||
$ApplicationExitCode = $null
|
||||
$UninstallExitCode = $null
|
||||
try {
|
||||
foreach ($Name in $Environment.Keys) {
|
||||
$PreviousEnvironment[$Name] = [Environment]::GetEnvironmentVariable($Name, "Process")
|
||||
[Environment]::SetEnvironmentVariable($Name, $Environment[$Name], "Process")
|
||||
}
|
||||
$ApplicationProcess = Start-Process `
|
||||
-FilePath $InstalledExecutable `
|
||||
-ArgumentList "--smoke-test" `
|
||||
-Wait `
|
||||
-PassThru `
|
||||
-WindowStyle Hidden
|
||||
$ApplicationExitCode = $ApplicationProcess.ExitCode
|
||||
}
|
||||
finally {
|
||||
foreach ($Name in $Environment.Keys) {
|
||||
[Environment]::SetEnvironmentVariable($Name, $PreviousEnvironment[$Name], "Process")
|
||||
}
|
||||
if (Test-Path -LiteralPath $Uninstaller -PathType Leaf) {
|
||||
$UninstallProcess = Start-Process `
|
||||
-FilePath $Uninstaller `
|
||||
-ArgumentList @(
|
||||
"/VERYSILENT",
|
||||
"/SUPPRESSMSGBOXES",
|
||||
"/NORESTART",
|
||||
"/LOG=$UninstallLog"
|
||||
) `
|
||||
-Wait `
|
||||
-PassThru `
|
||||
-WindowStyle Hidden
|
||||
$UninstallExitCode = $UninstallProcess.ExitCode
|
||||
}
|
||||
}
|
||||
if ($ApplicationExitCode -ne 0) {
|
||||
throw "Installed application smoke test exited with code $ApplicationExitCode"
|
||||
}
|
||||
if ($UninstallExitCode -ne 0) {
|
||||
throw "Uninstaller exited with code $UninstallExitCode. See $UninstallLog"
|
||||
}
|
||||
Start-Sleep -Milliseconds 500
|
||||
if (Test-Path -LiteralPath $InstalledExecutable) {
|
||||
throw "Uninstaller left the installed executable behind: $InstalledExecutable"
|
||||
}
|
||||
|
||||
Write-Host "Installer icon/install/start/uninstall smoke test passed." -ForegroundColor Green
|
||||
Write-Host "Smoke logs and isolated user data: $SmokeRoot"
|
||||
Reference in New Issue
Block a user