# Mirror sibling project firmware archives into cydweb/firmware for public deploy. # Usage (from cydweb): # .\scripts\sync-firmware.ps1 $ErrorActionPreference = "Stop" $root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) $cydRoot = Split-Path -Parent $root $dstRoot = Join-Path $root "firmware" New-Item -ItemType Directory -Force -Path $dstRoot | Out-Null $required = @("bootloader.bin", "partitions.bin", "boot_app0.bin", "firmware.bin") $count = 0 Get-ChildItem $cydRoot -Directory | Where-Object { $_.Name -ne "cydweb" } | ForEach-Object { $proj = $_.Name $fwRoot = Join-Path $_.FullName "firmware" if (-not (Test-Path $fwRoot)) { return } Get-ChildItem $fwRoot -Directory -ErrorAction SilentlyContinue | ForEach-Object { $variant = $_.Name $src = $_.FullName $ok = $true foreach ($f in $required) { if (-not (Test-Path (Join-Path $src $f))) { $ok = $false; break } } if (-not $ok) { return } $dst = Join-Path $dstRoot (Join-Path $proj $variant) New-Item -ItemType Directory -Force -Path $dst | Out-Null Copy-Item (Join-Path $src "*") $dst -Force -Recurse Write-Host "Synced $proj/$variant" $script:count++ } } Write-Host "Done. $count firmware package(s) -> $dstRoot"