- Add streamd serve start|stop|restart|status|update with auto-written streamd.yaml - Panel modules: STREAMD_MODULES_DIR for describe, YAML channel fallback, textarea value fix - Per-stream WireGuard/SOCKS egress profiles + Settings UI - Drop drm-* from release builds; track streamd-bg.sh / streamd-update.sh wrappers - Docs: streamd-server-setup lifecycle and update flow
149 lines
6 KiB
PowerShell
149 lines
6 KiB
PowerShell
# Cross-compile host streamd and on-device proxy-android-arm64 into dist/release/.
|
|
# Usage:
|
|
# .\scripts\build-release.ps1
|
|
# .\scripts\build-release.ps1 -Version v1.2.3
|
|
param(
|
|
[string]$Version = "",
|
|
[string]$Out = ""
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
|
if (-not $Out) { $Out = Join-Path $Root "dist\release" }
|
|
if (-not $Version) {
|
|
try { $Version = (git -C $Root describe --tags --always --dirty 2>$null) } catch { $Version = "dev" }
|
|
if (-not $Version) { $Version = "dev" }
|
|
}
|
|
|
|
function Resolve-Go {
|
|
$cmd = Get-Command go -ErrorAction SilentlyContinue
|
|
if ($cmd) { return $cmd.Source }
|
|
$candidates = @(
|
|
"$env:USERPROFILE\go-sdk\go\bin\go.exe",
|
|
"$env:USERPROFILE\sdk\go\bin\go.exe",
|
|
"$env:USERPROFILE\go\bin\go.exe",
|
|
"$env:LOCALAPPDATA\Programs\Go\bin\go.exe",
|
|
"C:\Program Files\Go\bin\go.exe",
|
|
"C:\Go\bin\go.exe",
|
|
"$env:GOROOT\bin\go.exe"
|
|
)
|
|
foreach ($c in $candidates) {
|
|
if ($c -and (Test-Path $c)) { return $c }
|
|
}
|
|
throw "go not found. Install Go or add it to PATH (looked in go-sdk, Program Files, GOROOT)."
|
|
}
|
|
|
|
$GoExe = Resolve-Go
|
|
Write-Host "==> using $GoExe"
|
|
& $GoExe version
|
|
|
|
New-Item -ItemType Directory -Force -Path $Out | Out-Null
|
|
Get-ChildItem $Out -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^(streamd-|drm-|proxy-android-arm64|SHA256SUMS)' } | Remove-Item -Force
|
|
|
|
function Build-Host([string]$Goos, [string]$Goarch, [string]$Ext = "") {
|
|
$name = "streamd-$Goos-$Goarch$Ext"
|
|
Write-Host " - $name"
|
|
$env:GOOS = $Goos
|
|
$env:GOARCH = $Goarch
|
|
$env:CGO_ENABLED = "0"
|
|
Push-Location $Root
|
|
try {
|
|
& $GoExe -C apps/cli build -trimpath -ldflags="-s -w" -o (Join-Path $Out $name) .
|
|
if ($LASTEXITCODE -ne 0) { throw "go build failed for $name" }
|
|
} finally {
|
|
Pop-Location
|
|
Remove-Item Env:GOOS -ErrorAction SilentlyContinue
|
|
Remove-Item Env:GOARCH -ErrorAction SilentlyContinue
|
|
Remove-Item Env:CGO_ENABLED -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
|
|
Write-Host "==> building on-device MITM (linux/arm64) first (embedded into streamd.exe)"
|
|
$env:GOOS = "linux"
|
|
$env:GOARCH = "arm64"
|
|
$env:CGO_ENABLED = "0"
|
|
Push-Location (Join-Path $Root "apps\proxy\device")
|
|
try {
|
|
& $GoExe build -trimpath -ldflags="-s -w" -o (Join-Path $Out "proxy-android-arm64") .
|
|
if ($LASTEXITCODE -ne 0) { throw "proxy-android-arm64 build failed" }
|
|
} finally {
|
|
Pop-Location
|
|
Remove-Item Env:GOOS -ErrorAction SilentlyContinue
|
|
Remove-Item Env:GOARCH -ErrorAction SilentlyContinue
|
|
Remove-Item Env:CGO_ENABLED -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# Stage into bootstrap embed so a lone streamd.exe can extract bin/proxy-android-arm64.
|
|
$embedProxy = Join-Path $Root "apps\pkg\bootstrap\embedded\bin\proxy-android-arm64"
|
|
New-Item -ItemType Directory -Force -Path (Split-Path $embedProxy) | Out-Null
|
|
Copy-Item (Join-Path $Out "proxy-android-arm64") $embedProxy -Force
|
|
Write-Host " staged embed: $embedProxy"
|
|
|
|
Write-Host "==> building host streamd ($Version) into $Out"
|
|
Build-Host windows amd64 ".exe"
|
|
Build-Host windows arm64 ".exe"
|
|
Build-Host linux amd64
|
|
Build-Host linux arm64
|
|
Build-Host darwin amd64
|
|
Build-Host darwin arm64
|
|
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $Root "bin"), (Join-Path $Root "apps\proxy") | Out-Null
|
|
Copy-Item (Join-Path $Out "proxy-android-arm64") (Join-Path $Root "bin\proxy-android-arm64") -Force
|
|
Copy-Item (Join-Path $Out "proxy-android-arm64") (Join-Path $Root "apps\proxy\proxy-android-arm64") -Force
|
|
try {
|
|
Copy-Item (Join-Path $Out "streamd-windows-amd64.exe") (Join-Path $Root "bin\streamd.exe") -Force
|
|
} catch {
|
|
Write-Host "WARN: could not refresh bin\streamd.exe (file in use): $($_.Exception.Message)"
|
|
}
|
|
# Restore tiny embed stub so the 9MB MITM binary is not left in the source tree.
|
|
$stub = Join-Path $Root "apps\pkg\bootstrap\embedded\bin\proxy-android-arm64"
|
|
[System.IO.File]::WriteAllBytes($stub, [byte[]](0x7F, 0x45, 0x4C, 0x46))
|
|
|
|
Write-Host "==> checksums"
|
|
$sumsPath = Join-Path $Out "SHA256SUMS.txt"
|
|
$tmpSums = Join-Path $Out "SHA256SUMS.txt.tmp"
|
|
$lines = Get-ChildItem $Out -File |
|
|
Where-Object { $_.Name -match '^(streamd-|proxy-android)' } |
|
|
Get-FileHash -Algorithm SHA256 |
|
|
ForEach-Object { "{0} {1}" -f $_.Hash.ToLower(), (Split-Path $_.Path -Leaf) }
|
|
[System.IO.File]::WriteAllLines($tmpSums, @($lines))
|
|
Move-Item -Force $tmpSums $sumsPath
|
|
|
|
# Portable Windows folder: binaries + minimal config (no Go / no full source).
|
|
$win = Join-Path $Out "windows-amd64"
|
|
New-Item -ItemType Directory -Force -Path @(
|
|
$win,
|
|
(Join-Path $win "bin"),
|
|
(Join-Path $win "apps\pkg"),
|
|
(Join-Path $win "apps\proxy\device"),
|
|
(Join-Path $win "outputs")
|
|
) | Out-Null
|
|
Copy-Item (Join-Path $Out "streamd-windows-amd64.exe") (Join-Path $win "bin\streamd.exe") -Force
|
|
Copy-Item (Join-Path $Out "proxy-android-arm64") (Join-Path $win "bin\proxy-android-arm64") -Force
|
|
Copy-Item (Join-Path $Out "streamd-windows-amd64.exe") (Join-Path $win "streamd.exe") -Force
|
|
Copy-Item (Join-Path $Out "proxy-android-arm64") (Join-Path $win "proxy-android-arm64") -Force
|
|
Copy-Item (Join-Path $Root "apps\proxy\device\tproxy_iptables.sh") (Join-Path $win "apps\proxy\device\") -Force
|
|
Copy-Item (Join-Path $Root "apps\pkg\go.mod") (Join-Path $win "apps\pkg\") -Force
|
|
Copy-Item (Join-Path $Root "README.md") (Join-Path $win "README.md") -Force -ErrorAction SilentlyContinue
|
|
@"
|
|
Streamd — Windows portable
|
|
|
|
Scaffold (streamd.exe also creates this on first run if you only download the exe):
|
|
bin\streamd.exe
|
|
bin\proxy-android-arm64
|
|
apps\proxy\device\tproxy_iptables.sh
|
|
|
|
Upload provider modules in the streamd Modules page, or add modules/<name>/ locally.
|
|
|
|
bin\streamd.exe serve --bind 127.0.0.1:8083
|
|
bin\streamd.exe proxy install-ca --reinject
|
|
adb shell am force-stop bbc.iplayer.android
|
|
bin\streamd.exe capture --app bbc --channel bbcone --wait 120
|
|
|
|
NordVPN UK on the phone. First install-ca creates data\proxy-ca.* (private CA).
|
|
"@ | Set-Content -Encoding utf8 (Join-Path $win "README.txt")
|
|
|
|
Write-Host "==> done ($Version)"
|
|
Get-ChildItem $Out | Format-Table Name, Length
|
|
Write-Host "==> portable Windows folder: $win"
|
|
Get-ChildItem $win | Format-Table Name, Length
|