refactor: organize factory host release layout
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
param(
|
||||
[string]$Output = "build\firmware"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$factoryHostRoot = Split-Path -Parent $scriptRoot
|
||||
$projectRoot = Split-Path -Parent $factoryHostRoot
|
||||
$audioImage = Join-Path $factoryHostRoot "build\audio\customer_fs.bin"
|
||||
$configuredImage = Join-Path $projectRoot "ql-config\config\EG800AKCN_11LG\customer_fs.bin"
|
||||
$flashPackage = Join-Path $projectRoot "target\EG800AKCN_11LG\EG800AKCN_11LG.zip"
|
||||
$outDir = if ([System.IO.Path]::IsPathRooted($Output)) { $Output } else { Join-Path $factoryHostRoot $Output }
|
||||
$backup = Join-Path $outDir "customer_fs.business-backup.bin"
|
||||
$export = Join-Path $outDir "EG800AKCN_11LG-FT1-factory-test.zip"
|
||||
|
||||
if (-not (Test-Path -LiteralPath $audioImage)) {
|
||||
throw "Factory audio image is missing. Run build_factory_audio_package.py first."
|
||||
}
|
||||
if ((Get-Item -LiteralPath $audioImage).Length -ne 262144) {
|
||||
throw "Factory customer_fs.bin is not 262144 bytes."
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||
Copy-Item -LiteralPath $configuredImage -Destination $backup -Force
|
||||
$originalHash = (Get-FileHash -LiteralPath $configuredImage -Algorithm SHA256).Hash
|
||||
$audioHash = (Get-FileHash -LiteralPath $audioImage -Algorithm SHA256).Hash
|
||||
|
||||
try {
|
||||
Copy-Item -LiteralPath $audioImage -Destination $configuredImage -Force
|
||||
if ((Get-FileHash -LiteralPath $configuredImage -Algorithm SHA256).Hash -ne $audioHash) {
|
||||
throw "Temporary customer_fs.bin hash verification failed."
|
||||
}
|
||||
|
||||
& cmd.exe /d /c "build.bat app"
|
||||
if ($LASTEXITCODE -ne 0) { throw "build.bat app failed with exit code $LASTEXITCODE" }
|
||||
& cmd.exe /d /c "build.bat firmware"
|
||||
if ($LASTEXITCODE -ne 0) { throw "build.bat firmware failed with exit code $LASTEXITCODE" }
|
||||
if (-not (Test-Path -LiteralPath $flashPackage)) {
|
||||
throw "Flashable inner package was not generated: $flashPackage"
|
||||
}
|
||||
Copy-Item -LiteralPath $flashPackage -Destination $export -Force
|
||||
$exportHash = (Get-FileHash -LiteralPath $export -Algorithm SHA256).Hash
|
||||
@{
|
||||
package = (Split-Path -Leaf $export)
|
||||
bytes = (Get-Item -LiteralPath $export).Length
|
||||
sha256 = $exportHash
|
||||
customer_fs_sha256 = $audioHash
|
||||
git_revision = (& git -C $projectRoot rev-parse HEAD).Trim()
|
||||
generated_at = (Get-Date).ToString("o")
|
||||
} | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $outDir "firmware_manifest.json") -Encoding UTF8
|
||||
Write-Host "Factory firmware: $export"
|
||||
Write-Host "SHA256: $exportHash"
|
||||
}
|
||||
finally {
|
||||
Copy-Item -LiteralPath $backup -Destination $configuredImage -Force
|
||||
$restoredHash = (Get-FileHash -LiteralPath $configuredImage -Algorithm SHA256).Hash
|
||||
if ($restoredHash -ne $originalHash) {
|
||||
throw "Business customer_fs.bin restore verification failed. Backup: $backup"
|
||||
}
|
||||
Write-Host "Business customer_fs.bin restored: $restoredHash"
|
||||
}
|
||||
Reference in New Issue
Block a user