fix: 무인 프로비저닝이 통째로 안 돌던 인코딩/파이프라인 결함 3건

실제 설치에서 드러난 것들이다. 셋 다 증상이 원인과 전혀 안 닮아서 기록해 둔다.

1) provision.ps1 이 1행부터 파싱 실패 - 'Missing closing }'
   Windows PowerShell 5.1 은 BOM 없는 .ps1 을 ANSI(CP1252)로 읽는다.
   한글 주석의 UTF-8 바이트가 CP1252 에서 스마트따옴표(0x93/0x94 = " ")로
   변하고, 파서가 그걸 문자열 시작으로 보고 뒤를 전부 삼킨다.
   -> build.sh 가 ISO 에 넣을 때 UTF-8 BOM 을 붙인다.

2) stage2.ps1 의 1행이 주석으로 인식되지 않음
   agent 가 받은 본문에 BOM 이 있으면 Set-Content -Encoding UTF8 이 BOM 을
   한 번 더 붙여 BOM 이 두 개가 된다. PowerShell 은 첫 개만 벗겨내고 남은
   U+FEFF 때문에 '#' 이 줄 맨 앞이 아니게 된다.
   -> agent 가 TrimStart(U+FEFF), 서버는 charset=utf-8 을 명시한다.

3) Git 설치가 'Cannot convert System.Object[] to System.String' 로 실패
   Log 가 Write-Output 이라 함수 안에서 부르면 그 함수의 반환값에 로그가
   섞인다. Get-File 이 배열을 돌려주니 Start-Process 가 죽었다.
   -> Log 를 Write-Host 로 바꿨다.

덤으로 시리얼/HTTP 로그의 한글이 '?' 로 깨지던 것도 고쳤다 (SerialPort 기본
인코딩이 ASCII). 그리고 러너 토큰이 없어도 워크플로와 같은 단계를 VM 안에서
직접 돌리는 검증 절차를 stage2 에 붙였다.
This commit is contained in:
EJClaw
2026-09-25 22:50:08 +09:00
parent e41d0cb441
commit ae295dc308
6 changed files with 172 additions and 5 deletions

View File

@@ -13,7 +13,11 @@ $ErrorActionPreference = 'Stop'
$Dl = 'C:\win-ci\dl'
New-Item -ItemType Directory -Force -Path $Dl | Out-Null
function Log($m) { Write-Output "$m" }
# Write-Output 를 쓰면 안 된다. 함수 안에서 부르면 그 함수의 반환값에
# 로그 문자열이 섞여 들어가 $f 가 배열이 되고, Start-Process 가
# "Cannot convert System.Object[] to System.String" 으로 죽는다.
# 실제로 이것 때문에 Git 설치가 실패했다.
function Log($m) { Write-Host "$m" }
function Get-File($url, $name) {
$out = Join-Path $Dl $name
@@ -195,3 +199,66 @@ try {
Log "화면 열거 실패: $($_.Exception.Message)"
}
Log "=== stage2 완료 ==="
# ==================================================================
# Windows 전용 경로 실제 검증
#
# 러너 등록 토큰이 없어도 여기서 워크플로와 똑같은 단계를 직접 돌린다.
# 이게 VM 을 만든 진짜 이유다 - 리눅스에서 못 돌리던 경로(WASAPI, 전역
# 단축키, 모니터 열거, PyInstaller exe)가 실제로 통과하는지 본다.
#
# 통째로 try/catch 로 감싼다. 검증이 실패해도 stage2 자체는 성공이어야
# agent 가 무한 재시도에 빠지지 않는다. 결과는 로그로 남는다.
# ==================================================================
$Repo = 'C:\win-ci\live-app-translator'
function Step($name, $block) {
Log "--- [$name] 시작"
try {
& $block
Log "--- [$name] 통과"
return $true
} catch {
Log "--- [$name] 실패: $($_.Exception.Message)"
return $false
}
}
$ErrorActionPreference = 'Continue'
try {
Sync-Path
if (Test-Path $Repo) {
Log "저장소 갱신"
Push-Location $Repo; & git fetch --all -q; & git reset --hard origin/main -q; Pop-Location
} else {
Log "저장소 clone"
& git clone -q https://git.tkrmagid.kr/tkrmagid/live-app-translator $Repo
}
Push-Location $Repo
$py = Join-Path $Repo '.venv-ci\Scripts\python.exe'
if (-not (Test-Path $py)) { & python -m venv .venv-ci }
& $py -m pip install --upgrade pip --quiet
& $py -m pip install -r packaging\requirements-portable.txt --quiet
& $py -m pip install pytest ruff --quiet
# 워크플로와 같은 조건인지 - torch 가 없어야 "포터블에서 1~3티어가 된다"를
# 실제로 검증한 셈이 된다.
& $py -c "import importlib.util,sys; sys.exit(0 if importlib.util.find_spec('torch') is None else 1)"
Log "포터블 조건(torch 없음) = $($LASTEXITCODE -eq 0)"
$env:PYTHONPATH = 'src'
$r = @{}
$r['pytest'] = Step 'pytest' { & $py -m pytest tests -q 2>&1 | Select-Object -Last 8 | ForEach-Object { Log " $_" }; if ($LASTEXITCODE -ne 0) { throw "exit $LASTEXITCODE" } }
$r['ruff'] = Step 'ruff' { & $py -m ruff check src tests scripts 2>&1 | Select-Object -Last 5 | ForEach-Object { Log " $_" }; if ($LASTEXITCODE -ne 0) { throw "exit $LASTEXITCODE" } }
$r['windows경로'] = Step 'windows_smoke' { & $py packaging\windows_smoke.py 2>&1 | ForEach-Object { Log " $_" }; if ($LASTEXITCODE -ne 0) { throw "exit $LASTEXITCODE" } }
$r['exe빌드'] = Step 'pyinstaller' { & $py -m pip install pyinstaller --quiet; & $py -m PyInstaller packaging\livesub.spec --noconfirm 2>&1 | Select-Object -Last 4 | ForEach-Object { Log " $_" }; if (-not (Test-Path 'dist\LiveSub.exe')) { throw 'dist\LiveSub.exe 없음' }; Log " exe 크기 $([math]::Round((Get-Item 'dist\LiveSub.exe').Length/1MB,1)) MB" }
$r['exe기동'] = Step 'exe 실행' { & $py packaging\windows_smoke.py --exe dist\LiveSub.exe 2>&1 | ForEach-Object { Log " $_" }; if ($LASTEXITCODE -ne 0) { throw "exit $LASTEXITCODE" } }
Log "=== Windows 검증 결과 ==="
foreach ($k in $r.Keys) { Log ("{0,-14} {1}" -f $k, $(if ($r[$k]) { 'PASS' } else { 'FAIL' })) }
Log "=== 검증 끝 ==="
Pop-Location
} catch {
Log "검증 준비 단계에서 실패: $($_.Exception.Message)"
try { Pop-Location } catch {}
}