11<#
22. SYNOPSIS
3- Creates a setup archive containing all files needed for CTT tests on CI.
3+ Creates an archive containing Z-Wave network state for CI.
44
55. DESCRIPTION
6- This script packages the following into setup/setup .zip:
6+ This script packages the following into setup/network-state .zip:
77 - zwave_stack/storage/ -> storage/
88 - DUT storage files (from config.json glob patterns) -> dut-storage/
9- - CTT AppData folder -> appdata/
10- - CTT Keys file (homeId-specific) -> keys/
11- - CTT binaries (from CTT_PATH or default location) -> ctt-bin/
129
1310. EXAMPLE
14- .\create-setup-archive.ps1
15-
16- . NOTES
17- Set CTT_PATH environment variable to override the default CTT installation path.
18- Default: C:\Program Files (x86)\Z-Wave Alliance\Z-Wave CTT 3
11+ .\pack-network-state-archive.ps1
1912#>
2013
2114$ErrorActionPreference = " Stop"
2215
2316$repoRoot = Split-Path - Parent (Split-Path - Parent $MyInvocation.MyCommand.Path )
24- $tempDir = Join-Path $env: TEMP " ctt-setup -staging"
25- $outputFile = Join-Path $repoRoot " setup\setup .zip"
17+ $tempDir = Join-Path $env: TEMP " network-state -staging"
18+ $outputFile = Join-Path $repoRoot " setup\network-state .zip"
2619
2720# Helper function to parse JSON with comments (JSON5-style)
2821function ConvertFrom-Json5 {
@@ -53,11 +46,8 @@ $dutStorageArchiveName = "dut-storage"
5346
5447# Source paths
5548$zwaveStorage = Join-Path $repoRoot " zwave_stack\storage"
56- $cttAppData = " C:\Users\$env: USERNAME \AppData\Roaming\Z-Wave Alliance\Z-Wave CTT 3"
57- $cttKeys = " C:\Users\$env: USERNAME \Documents\Z-Wave Alliance\Z-Wave CTT 3\Keys"
58- $cttPath = if ($env: CTT_PATH ) { $env: CTT_PATH } else { " C:\Program Files (x86)\Z-Wave Alliance\Z-Wave CTT 3" }
5949
60- Write-Host " Creating setup archive..." - ForegroundColor Cyan
50+ Write-Host " Creating network state archive..." - ForegroundColor Cyan
6151
6252# Clean up any existing temp directory
6353if (Test-Path $tempDir ) {
@@ -69,14 +59,18 @@ New-Item -ItemType Directory -Path $tempDir | Out-Null
6959
7060# Copy zwave_stack/storage
7161if (Test-Path $zwaveStorage ) {
62+ Write-Host " Copying zwave_stack/storage..." - ForegroundColor Green
7263 Copy-Item - Recurse $zwaveStorage (Join-Path $tempDir " storage" )
64+ } else {
65+ Write-Host " WARNING: zwave_stack/storage not found at $zwaveStorage " - ForegroundColor Yellow
7366}
7467
7568# Copy DUT storage files using glob patterns from config
7669$dutStagingDir = Join-Path $tempDir $dutStorageArchiveName
7770New-Item - ItemType Directory - Path $dutStagingDir | Out-Null
7871
7972if (Test-Path $dutStorageDir ) {
73+ Write-Host " Copying DUT storage files..." - ForegroundColor Green
8074 foreach ($pattern in $config.dut.storageFileFilter ) {
8175 # Replace placeholders
8276 $resolvedPattern = $pattern -replace ' %HOME_ID_LOWER%' , $homeIdLower
@@ -86,30 +80,12 @@ if (Test-Path $dutStorageDir) {
8680 $matchedFiles = Get-Item - Path $fullPattern - ErrorAction SilentlyContinue
8781
8882 foreach ($file in $matchedFiles ) {
83+ Write-Host " $ ( $file.Name ) " - ForegroundColor Gray
8984 Copy-Item $file.FullName $dutStagingDir
9085 }
9186 }
92- }
93-
94- # Copy CTT AppData
95- if (Test-Path $cttAppData ) {
96- Copy-Item - Recurse $cttAppData (Join-Path $tempDir " appdata" )
97- }
98-
99- # Copy CTT Keys - only the homeId-specific key file
100- $keysStagingDir = Join-Path $tempDir " keys"
101- New-Item - ItemType Directory - Path $keysStagingDir | Out-Null
102-
103- if (Test-Path $cttKeys ) {
104- $keyFile = Join-Path $cttKeys " $homeIdUpper .txt"
105- if (Test-Path $keyFile ) {
106- Copy-Item $keyFile $keysStagingDir
107- }
108- }
109-
110- # Copy CTT binaries
111- if (Test-Path $cttPath ) {
112- Copy-Item - Recurse $cttPath (Join-Path $tempDir " ctt-bin" )
87+ } else {
88+ Write-Host " WARNING: DUT storage directory not found at $dutStorageDir " - ForegroundColor Yellow
11389}
11490
11591# Remove old archive if it exists
@@ -118,9 +94,11 @@ if (Test-Path $outputFile) {
11894}
11995
12096# Create the zip archive using tar.exe (much faster than Compress-Archive)
97+ Write-Host " Compressing archive..." - ForegroundColor Green
12198& " $env: SystemRoot \System32\tar.exe" - a - cf $outputFile - C $tempDir *
12299
123100# Clean up temp directory
124101Remove-Item - Recurse - Force $tempDir
125102
103+ Write-Host " "
126104Write-Host " Created $outputFile " - ForegroundColor Green
0 commit comments