JJ_MKVMaker/tool/fetch_tor_android.ps1

45 lines
2.4 KiB
PowerShell

# Android 용 Tor 준비: 공식 Tor Expert Bundle (Android aarch64) 을 받아 SHA-256 을 확인하고
# tor/libTor.so (실행 파일) 를 third_party/tor/android/arm64-v8a/libtor.so 로 둔다 (APK 의 jniLibs, android/app/build.gradle.kts).
# 판 · SHA-256 은 lib/app/tor_bundle.dart 의 TorBundle 과 같아야 한다 (공식 sha256sums-signed-build.txt 에서 확인).
# 사용 (app 폴더에서): powershell -File tool\fetch_tor_android.ps1
param(
[string]$Version = '15.0.24',
[string]$Sha256 = '2a7a02484149b05f64b582a4a1e8eb8aabb9f6cd32daca4e03c58e09839bb7a8'
)
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$out = Join-Path $root 'third_party\tor\android\arm64-v8a'
$file = "tor-expert-bundle-android-aarch64-$Version.tar.gz"
$work = Join-Path ([System.IO.Path]::GetTempPath()) ("jj_tor_" + [guid]::NewGuid().ToString('N'))
New-Item -ItemType Directory -Force $work | Out-Null
try {
$archive = Join-Path $work $file
$ok = $false
foreach ($base in @("https://archive.torproject.org/tor-package-archive/torbrowser/$Version", "https://dist.torproject.org/torbrowser/$Version")) {
try {
Write-Host "받는 중: $base/$file"
Invoke-WebRequest -UseBasicParsing -Uri "$base/$file" -OutFile $archive
$ok = $true
break
} catch {
Write-Host "실패: $_"
}
}
if (-not $ok) { throw "받을 수 없습니다: $file" }
$got = (Get-FileHash -Algorithm SHA256 $archive).Hash.ToLower()
if ($got -ne $Sha256.ToLower()) { throw "SHA-256 이 다릅니다: $got (기대 $Sha256)" }
$x = Join-Path $work 'x'
New-Item -ItemType Directory -Force $x | Out-Null
tar -xzf $archive -C $x
if ($LASTEXITCODE -ne 0) { throw "압축을 풀 수 없습니다" }
New-Item -ItemType Directory -Force $out | Out-Null
Copy-Item (Join-Path $x 'tor\libTor.so') (Join-Path $out 'libtor.so') -Force
# 라이선스 원문 (앱의 assets/licenses/TOR_LICENSES.txt 는 tool/licenses/fetch_licenses.py 가 만든다)
$docs = Join-Path $root 'third_party\tor\android\docs'
New-Item -ItemType Directory -Force $docs | Out-Null
Copy-Item (Join-Path $x 'docs\*') $docs -Force
Write-Host ("완료: {0} ({1:N0} 바이트)" -f (Join-Path $out 'libtor.so'), (Get-Item (Join-Path $out 'libtor.so')).Length)
} finally {
Remove-Item -Recurse -Force $work -ErrorAction SilentlyContinue
}