diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4fca8d3de..f945edf9d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -217,9 +217,10 @@ jobs: retention-days: 3 compression-level: 0 - # Windows in Git's bash on GitHub's runner, with the Visual Studio Build Tools in its image (their image terms; we - # accept no licence and download no Microsoft files). The C runtime is the DLL one (the VC++ redistributable): ort's - # prebuilt ONNX Runtime is built against it, so crt-static doesn't link (LNK2019 on __imp_ symbols, 10-29). + # Windows in Git's bash on GitHub's runner, with Visual Studio in its image. The C runtime is the DLL one: ONNX + # Runtime is built against it (crt-static didn't link: LNK2019 on __imp_ symbols, 10-29), and Microsoft's + # onnxruntime.dll imports it too, so the VC++ runtime's DLLs ship beside raea.exe from this image's Visual Studio + # (tools/release/win-bundle.sh), as Microsoft documents for app-local deployment. windows: runs-on: ${{ (vars.RELEASE_WINDOWS_RUNNER && fromJSON(vars.RELEASE_WINDOWS_RUNNER)) || 'windows-latest' }} timeout-minutes: 350 @@ -333,12 +334,16 @@ jobs: # static runtime ort links by default is built for AVX2 and stopped raea.exe at start on CPUs without it - name: ONNX Runtime (tools/release/onnxruntime.sh) run: bash tools/release/onnxruntime.sh target/dist - # which DLLs raea needs from the machine (the CRT's come from the VC++ redistributable) + # and what a PC with nothing installed and no downloads needs beside raea.exe: the VC++ runtime (from this + # runner's Visual Studio), FFmpeg (raea's LGPL build) and uv, each with its licence + - name: The Windows bundle (tools/release/win-bundle.sh) + run: bash tools/release/win-bundle.sh target/dist + # which DLLs raea needs from the machine (the CRT's now ship beside it: win-bundle.sh) - name: What raea.exe imports run: | { echo '### what raea.exe, raea_bundle.dll, raea-perceive.exe and onnxruntime.dll import'; echo '```' dumpbin=$(ls "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/MSVC/*/bin/HostX64/x64/dumpbin.exe | head -1) - "$dumpbin" -nologo -dependents target/dist/raea.exe target/dist/raea_bundle.dll target/dist/raea-perceive.exe target/dist/onnxruntime.dll | grep -iE '\.dll$|Dump of' | sed 's/^ *//' + "$dumpbin" -nologo -dependents target/dist/raea.exe target/dist/raea_bundle.dll target/dist/raea-perceive.exe target/dist/onnxruntime.dll target/dist/ffmpeg.exe | grep -iE '\.dll$|Dump of' | sed 's/^ *//' echo '```'; } | tee -a "$GITHUB_STEP_SUMMARY" || true # release.sh's checks render on Mesa's lavapipe (software Vulkan, MIT; on the runner only, never in the zip): the # runner has no GPU, and WARP, Windows' own software DX12, crashes compiling one of Bevy's compute shaders there diff --git a/.github/workflows/tools-ffmpeg.yml b/.github/workflows/tools-ffmpeg.yml new file mode 100644 index 000000000..176484049 --- /dev/null +++ b/.github/workflows/tools-ffmpeg.yml @@ -0,0 +1,49 @@ +# FFmpeg for Windows as raea ships it (tools/release/ffmpeg-win.sh): built on Linux with mingw-w64 and published once +# as the prerelease tools-ffmpeg--lgpl, with FFmpeg's source tarball, its signature and the script, which are +# its complete source (LGPL 2.1 or later). io/assets/src/setup.rs pins the zip by its +# sha256, so a published zip is never replaced: a run whose release already holds one only builds it and says +# whether its own sha256 differs. +name: tools-ffmpeg +on: + workflow_dispatch: + push: + paths: [tools/release/ffmpeg-win.sh, .github/workflows/tools-ffmpeg.yml] +permissions: + contents: write +jobs: + build: + runs-on: ubuntu-24.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + with: + lfs: false + # the x86_64 cross compiler only, and non-interactive: an install that asks (needrestart, debconf) waits forever. + # The runner's own EC2 mirror has trickled (35 MB in 11 minutes, 11-19), so apt reads Ubuntu's archive first + # and Azure's mirror after it, gives up on a stalled request and retries. + - name: mingw-w64 + env: + DEBIAN_FRONTEND: noninteractive + NEEDRESTART_MODE: a + run: | + printf 'http://archive.ubuntu.com/ubuntu/\tpriority:1\nhttp://azure.archive.ubuntu.com/ubuntu/\tpriority:2\n' | sudo tee /etc/apt/apt-mirrors.txt + o="-o Acquire::Retries=5 -o Acquire::http::Timeout=30" + sudo -E apt-get $o update -q + sudo -E apt-get $o install -y -q --no-install-recommends gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 libz-mingw-w64-dev nasm make pkg-config xz-utils zip + timeout-minutes: 25 + - name: build + run: bash tools/release/ffmpeg-win.sh out + - name: publish (once) + env: + GH_TOKEN: ${{ github.token }} + run: | + v=$(sed -n 's/^v=//p' tools/release/ffmpeg-win.sh) + tag=tools-ffmpeg-$v-lgpl; zip=ffmpeg-$v-lgpl-win64.zip + if gh release view "$tag" --json assets -q '.assets[].name' 2>/dev/null | grep -qx "$zip"; then + echo "$tag already has $zip (never replaced); this run's: $(cat out/$zip.sha256)"; exit 0 + fi + curl -fsSL -o "out/ffmpeg-$v.tar.xz.asc" "https://ffmpeg.org/releases/ffmpeg-$v.tar.xz.asc" + cp tools/release/ffmpeg-win.sh out/ + gh release view "$tag" >/dev/null 2>&1 || gh release create "$tag" --prerelease --title "FFmpeg $v for Windows (LGPL), as raea ships it" \ + --notes "FFmpeg $v cross-built for Windows x64 by tools/release/ffmpeg-win.sh: static, FFmpeg's own code, zlib and libvpx's decoders (BSD), LGPL 2.1 or later; its H.264 encoder is Windows' own (Media Foundation). Its complete source is ffmpeg-$v.tar.xz (with FFmpeg's signature), the libvpx tarball and ffmpeg-win.sh, attached here. raea ships it beside raea.exe on Windows and fetches it where it isn't." + gh release upload "$tag" "out/$zip" "out/$zip.sha256" "out/ffmpeg-$v.tar.xz" "out/ffmpeg-$v.tar.xz.asc" out/libvpx-*.tar.gz out/ffmpeg-win.sh diff --git a/.github/workflows/tools-git-sources.yml b/.github/workflows/tools-git-sources.yml new file mode 100644 index 000000000..d97a1743a --- /dev/null +++ b/.github/workflows/tools-git-sources.yml @@ -0,0 +1,34 @@ +# The complete corresponding source of the Git for Windows the Windows app ships (tools/release/git-sources.sh), +# published once as the prerelease tools-git--sources, which the app's git\SOURCE.txt names: GPLv2 section 3 +# asks whoever distributes Git to make it available, and dugite-native's own repository isn't all of it (Git for +# Windows' MSYS2 runtime, bash, curl and the rest are built from their own source packages). A run whose release +# already holds the archive changes nothing. +name: tools-git-sources +on: + workflow_dispatch: + push: + paths: [tools/release/git-sources.sh, .github/workflows/tools-git-sources.yml] +permissions: + contents: write +jobs: + sources: + runs-on: ubuntu-24.04 + timeout-minutes: 60 + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v4 + with: + lfs: false + - name: publish (once) + run: | + t=$(sed -n 's/^tag=//p' tools/release/git-sources.sh) + tag=tools-git-$t-sources; tar=git-for-windows-$t-sources.tar + if gh release view "$tag" --json assets -q '.assets[].name' 2>/dev/null | grep -qx "$tar"; then + echo "$tag already has $tar"; exit 0 + fi + bash tools/release/git-sources.sh out + cp tools/release/git-sources.sh out/ + gh release view "$tag" >/dev/null 2>&1 || gh release create "$tag" --prerelease --title "Git for Windows ($t) sources, as raea's Windows app ships it" \ + --notes "The complete corresponding source of the Git for Windows (dugite-native $t) that raea's Windows app ships in its git folder: each package of its etc/package-versions.txt as the source package it was built from, from Git for Windows' pacman repository or MSYS2's source mirror (SOURCES.tsv inside says which), collected by git-sources.sh, attached here. raea runs Git as a separate program." + gh release upload "$tag" "out/$tar" "out/$tar.sha256" out/git-sources.sh diff --git a/Cargo.lock b/Cargo.lock index 5d21833f3..19eeabcd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13954,6 +13954,7 @@ name = "raea-app-notes" version = "0.1.0" dependencies = [ "raea-core-facts", + "raea-io-ffmpeg", "raea-io-home", "raea-io-trace", "serde", @@ -15867,6 +15868,7 @@ dependencies = [ "dunce", "fastrand", "image", + "raea-io-ffmpeg", "raea-sys-columns", "raea-sys-fingerprint", "serde", diff --git a/NOTICE b/NOTICE index 8dc43e596..2f9f860eb 100644 --- a/NOTICE +++ b/NOTICE @@ -20,8 +20,16 @@ animato (MIT OR Apache-2.0), usvg and resvg (Apache-2.0 OR MIT), mediabunny (MPL The Windows build (docs/ports.feature PT20) adds: junction 1.4.2 (MIT, node_modules' links in io/npm) and windows-sys 0.61.2 (Microsoft, MIT OR Apache-2.0, in io/trace); every build has dunce 1.0.5 (CC0-1.0 OR MIT-0 OR Apache-2.0, plain -paths for Windows in runtime/bundle). It ships none of Microsoft's C runtime or SDK files: the runtime comes from the -Microsoft Visual C++ Redistributable, installed on the machine. +paths for Windows in runtime/bundle). Its bin\ also carries, each with its licence beside it (tools/release/win-bundle.sh): + Microsoft's Visual C++ runtime (vcruntime140.dll, vcruntime140_1.dll, msvcp140.dll, msvcp140_1.dll), redistributed + under Microsoft's Visual Studio licence terms; ONNX Runtime's onnxruntime.dll (Microsoft, MIT); + FFmpeg 9.0.2 (ffmpeg.exe, ffprobe.exe; LGPL-2.1-or-later), built from FFmpeg's release with FFmpeg's own code, zlib + and libvpx 1.17.0's decoders (BSD-3-Clause with the WebM project's patent grant: libvpx-LICENSE.txt, + libvpx-PATENTS.txt) by tools/release/ffmpeg-win.sh, its H.264 encoder Windows' own (Media Foundation), its source + published as the release tools-ffmpeg-9.0.2-lgpl; + uv (uv.exe; Astral, MIT OR Apache-2.0). +The Windows app adds Git for Windows with Git LFS (dugite-native; GPLv2 and its parts' licences, in git\), which raea +runs as a separate program; its complete corresponding source is published as the release tools-git--sources. The native target (engine/rune, docs/targets.feature) builds on Rune (https://github.com/anomalyco/rune, Copyright 2026 Anomaly, MIT; LICENSES/rune-0.0.1/repository-LICENSE): rune, rune-kit and their crates, by a pinned rev. diff --git a/README.md b/README.md index 465d48a43..050fece8d 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,8 @@ On Windows 10 or 11, in PowerShell: irm https://raea.io/install.ps1 | iex ``` -It does the same under `~\.raea` and adds raea to your PATH. raea needs the Microsoft Visual C++ Redistributable -(x64), which most machines already have, and a DirectX 12 or Vulkan GPU driver. +It does the same under `~\.raea` and adds raea to your PATH. raea needs a DirectX 12 or Vulkan GPU driver; what +else it needs (the Visual C++ runtime, FFmpeg and uv) is in its `bin\` folder. ## Hello diff --git a/apps/notes/Cargo.toml b/apps/notes/Cargo.toml index cee121f80..0e73b5cd8 100644 --- a/apps/notes/Cargo.toml +++ b/apps/notes/Cargo.toml @@ -10,6 +10,8 @@ description = "A person's notes on a project as files the work is held to (docs/ # Note and Ask, the project found by its .raea/project, and the world a note is an entity in raea-core-facts = { path = "../../core/facts" } raea-io-home = { path = "../../io/home" } +# the H.264 encoder this machine's ffmpeg has, for a clip a person plays (raea_io_ffmpeg::h264) +raea-io-ffmpeg = { path = "../../io/ffmpeg" } # when a run of an ask's check was (UTC), as raea check stamps its record raea-io-trace = { path = "../../io/trace" } # what each ask has been through, kept as JSON (state.rs) diff --git a/apps/notes/src/check.rs b/apps/notes/src/check.rs index 1f22b2f1f..f00f1a058 100644 --- a/apps/notes/src/check.rs +++ b/apps/notes/src/check.rs @@ -131,7 +131,8 @@ fn cut(out: &Path, [a, b]: [i64; 2], fps: f64, to: &Path) -> R<()> { } let (from, len) = (format!("{:.4}", a as f64 / fps), format!("{:.4}", (b - a) as f64 / fps)); let args = ["-hide_banner", "-loglevel", "error", "-y", "-ss", &from, "-i"]; - let o = std::process::Command::new("ffmpeg").args(args).arg(out).args(["-t", &len, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac"]).arg(to).output().map_err(|e| format!("ffmpeg: {e}"))?; + let h264 = raea_io_ffmpeg::h264().ok_or("ffmpeg here has no H.264 encoder (libx264, Windows' h264_mf or VideoToolbox's) to cut the clip with")?; + let o = std::process::Command::new("ffmpeg").args(args).arg(out).args(["-t", &len]).args(h264).args(["-c:a", "aac"]).arg(to).output().map_err(|e| format!("ffmpeg: {e}"))?; if !o.status.success() { return Err(format!("ffmpeg: {}", String::from_utf8_lossy(&o.stderr).trim())); } diff --git a/docs/manual/whats-new/0.1.8.md b/docs/manual/whats-new/0.1.8.md index 77d964a79..a95afc472 100644 --- a/docs/manual/whats-new/0.1.8.md +++ b/docs/manual/whats-new/0.1.8.md @@ -24,8 +24,11 @@ On Windows, in PowerShell: `irm https://raea.io/install.ps1 | iex`. ## What changed since 0.1.7 **raea on Windows works.** -- ChatGPT, Claude, Gemini, OpenCode and Kimi install and connect on a Windows PC. A workspace is made even when Git - isn't installed. +- Nothing needs installing first, and nothing has to download. The app carries what raea needs from outside it: + Git, FFmpeg, uv (which sets up the local models) and Microsoft's Visual C++ runtime, so it works on a work PC + that blocks downloads. Before, raea.exe wouldn't start without the Visual C++ Redistributable, and a workspace + couldn't be made without Git. +- ChatGPT, Claude, Gemini, OpenCode and Kimi install and connect on a Windows PC. - The app calls your PC a PC: Ctrl, not ⌘, everywhere, the whiteboard too. - The installer asks where raea goes. It suggests a folder in your own profile, takes any empty folder you can write to (or the folder raea is already in), and says why it won't use one that already holds other files. An update goes @@ -35,9 +38,11 @@ On Windows, in PowerShell: `irm https://raea.io/install.ps1 | iex`. (#155) and on Intel's integrated graphics. 3D on DirectX 12 is now drawn as on a Mac; with `WGPU_BACKEND=dx12` set by hand, 0.1.7 drew a scene's shapes into one another. - A phone's or a camera's video plays, probes and checks. raea's own decoders read H.264 without B-frames, which is - what raea writes. The first time you open a video they can't read (most phone and camera footage: H.264 with - B-frames, HEVC, VP9), raea fetches FFmpeg once, about 114 MB, and checks it before use. Nothing needs installing - first. + what raea writes, and the FFmpeg in the app reads the rest (most phone and camera footage: H.264 with B-frames, + HEVC, VP9). It's built from FFmpeg's own source with no GPL part (FFmpeg's code and libvpx's decoders, for + WebM with transparency), so its licence is the LGPL, and its source is published beside raea's releases. A clip + raea cuts for you to play, such as `raea notes check`'s, uses Windows' own H.264 encoder. With raea from the zip and no FFmpeg on the PC, raea fetches + the same build once and checks it before use. - Agents' npm tools and MCP servers start without a shell, and their arguments arrive as written in folders with spaces or letters outside ASCII. - raea starts on a PC whose processor has no AVX2, such as an Intel Core from 2011 or 2012 (#110). The ONNX Runtime diff --git a/io/assets/src/setup.rs b/io/assets/src/setup.rs index a691f48ac..d2ae37560 100644 --- a/io/assets/src/setup.rs +++ b/io/assets/src/setup.rs @@ -30,18 +30,32 @@ fn on_path(name: &str) -> Option { std::env::split_paths(&std::env::var_os("PATH")?).map(|d| d.join(&exe)).find(|p| p.is_file()) } -/// The FFmpeg raea fetches on Windows when none is installed: GyanD's essentials build (the one winget's -/// Gyan.FFmpeg.Essentials installs), kept on GitHub for each release; its SHA-256 is GitHub's digest for the asset +/// The tool shipped beside raea's own executable: on Windows the release puts FFmpeg and uv in raea.exe's bin/// (tools/release/win-bundle.sh), so raea finds them however it was started and fetches nothing +fn beside_exe(name: &str) -> Option { + beside(&std::env::current_exe().ok()?, name) +} + +fn beside(exe_path: &Path, name: &str) -> Option { + Some(exe_path.parent()?.join(exe(name))).filter(|p| p.is_file()) +} + +/// The FFmpeg raea ships beside raea.exe on Windows and fetches where it isn't: raea's own build of FFmpeg's release, +/// LGPL 2.1 or later: FFmpeg's own code, zlib and libvpx's decoders, its H.264 encoder Windows' own (Media +/// Foundation) (tools/release/ffmpeg-win.sh, published with its source as the prerelease tools-ffmpeg-9.0.2-lgpl). Until 0.1.8 raea fetched GyanD's essentials build, GPLv3 with GPL libraries +/// linked in, which raea couldn't ship. tools/release/win-bundle.sh reads these pins. const FFMPEG: &str = "9.0.2"; -const FFMPEG_SUM: &str = "60f467265b1e312373dbcd92200c2618a74850f98d3d078e94296bb3fa2047ba"; +const FFMPEG_TOP: &str = "ffmpeg-9.0.2-lgpl-win64"; +const FFMPEG_URL: &str = "https://github.com/shinyobjectz/raea/releases/download/tools-ffmpeg-9.0.2-lgpl/ffmpeg-9.0.2-lgpl-win64.zip"; +const FFMPEG_SUM: &str = "d3a3d8cdcd3ee488a94328200293a312e9c81923902b9fc3c9fa5dd18779ba8c"; -/// `ffmpeg` or `ffprobe` as raea runs it: the one on the PATH; else raea's own in $RAEA_TOOLS_CACHE (else -/// ~/.cache/raea-tools)/ffmpeg/bin. On Windows, where FFmpeg is rarely installed, raea's own is fetched there once -/// (114 MB; ffmpeg.exe, ffprobe.exe and its LICENSE kept, about 210 MB) the first time a video raea's own decoders -/// can't read needs it, when `fetch`: H.264 with B-frames, HEVC, VP9 (a phone's or a camera's). Elsewhere FFmpeg is -/// the system's: a Mac reads those on VideoToolbox, and Linux has FFmpeg in its package manager. +/// `ffmpeg` or `ffprobe` as raea runs it: the one on the PATH; else the one beside raea's executable (the Windows +/// release ships it there); else raea's own in $RAEA_TOOLS_CACHE (else ~/.cache/raea-tools)/ffmpeg/bin. On Windows, +/// where FFmpeg is rarely installed, raea's own is fetched there once the first time a video raea's own decoders +/// can't read needs it, when `fetch`, if the release's copy is missing: H.264 with B-frames, HEVC, VP9 (a phone's or a +/// camera's). Elsewhere FFmpeg is the system's: a Mac reads those on VideoToolbox, and Linux has FFmpeg in its package +/// manager. pub fn ffmpeg_tool(name: &str, fetch: bool) -> Result { - if let Some(p) = on_path(name) { + if let Some(p) = on_path(name).or_else(|| beside_exe(name)) { return Ok(p); } let dir = raea_io_home::env_path("RAEA_TOOLS_CACHE", ".cache/raea-tools").join("ffmpeg"); @@ -63,13 +77,11 @@ pub fn ffmpeg_tool(name: &str, fetch: bool) -> Result { return Ok(bin); } raea_io_home::offline(&format!("fetching FFmpeg {FFMPEG} to read a video raea's own decoders can't"))?; - eprintln!("raea: this video needs FFmpeg, which isn't installed; fetching FFmpeg {FFMPEG} (114 MB, once) into {}", dir.display()); - let name_zip = format!("ffmpeg-{FFMPEG}-essentials_build.zip"); - let url = format!("https://github.com/GyanD/codexffmpeg/releases/download/{FFMPEG}/{name_zip}"); - let top = format!("ffmpeg-{FFMPEG}-essentials_build"); - let members = [format!("{top}/bin/ffmpeg.exe"), format!("{top}/bin/ffprobe.exe"), format!("{top}/LICENSE")]; + eprintln!("raea: this video needs FFmpeg, which isn't installed; fetching FFmpeg {FFMPEG} (once) into {}", dir.display()); + let name_zip = format!("{FFMPEG_TOP}.zip"); + let members = [format!("{FFMPEG_TOP}/bin/ffmpeg.exe"), format!("{FFMPEG_TOP}/bin/ffprobe.exe"), format!("{FFMPEG_TOP}/LICENSE")]; let part = dir.with_file_name(format!("ffmpeg.part{}", std::process::id())); - let fetched = fetch_archive(&part, &url, &name_zip, FFMPEG_SUM, true, &members.each_ref().map(String::as_str)); + let fetched = fetch_archive(&part, FFMPEG_URL, &name_zip, FFMPEG_SUM, true, &members.each_ref().map(String::as_str)); settle(&part, &dir, &bin, fetched, "FFmpeg") } @@ -78,13 +90,14 @@ pub fn venv_python(dir: &Path) -> PathBuf { if cfg!(windows) { dir.join(".venv").join("Scripts").join("python.exe") } else { dir.join(".venv").join("bin").join("python") } } -/// uv: $RAEA_UV, the one on the PATH, or raea's own, fetched the first time (about 20 MB) into $RAEA_TOOLS_CACHE (else -/// ~/.cache/raea-tools)/uv, as tools/ensure.sh does +/// uv: $RAEA_UV, the one on the PATH, the one beside raea's executable (the Windows release ships it there), or +/// raea's own, fetched the first time (about 20 MB) into $RAEA_TOOLS_CACHE (else ~/.cache/raea-tools)/uv, as +/// tools/ensure.sh does pub fn uv() -> Result { if let Some(p) = std::env::var_os("RAEA_UV").map(PathBuf::from).filter(|p| p.is_file()) { return Ok(p); } - if let Some(p) = on_path("uv") { + if let Some(p) = on_path("uv").or_else(|| beside_exe("uv")) { return Ok(p); } let dir = raea_io_home::env_path("RAEA_TOOLS_CACHE", ".cache/raea-tools").join("uv"); @@ -192,6 +205,31 @@ pub fn run_setup(script: &Path, var: &str, dir: &Path) -> Result String { String::from_utf8_lossy(&out).into_owned() } +/// The H.264 encoder this machine's ffmpeg has, as its arguments, for a clip a person plays (in a browser or on a +/// phone): libx264 where ffmpeg was built with it (Homebrew's, Linux distributions'), else the system's own (Windows' +/// Media Foundation, h264_mf, in the LGPL build raea ships there; macOS's VideoToolbox) at 8 Mb/s; None without one. +pub fn h264() -> Option> { + static ENCODERS: std::sync::OnceLock = std::sync::OnceLock::new(); + let have = ENCODERS.get_or_init(|| says("-encoders")); + let has = |c: &str| have.split_whitespace().any(|w| w == c); + let enc = ["libx264", "h264_mf", "h264_videotoolbox"].into_iter().find(|c| has(c))?; + let rate: &[&'static str] = if enc == "libx264" { &[] } else { &["-b:v", "8M"] }; + Some([&["-c:v", enc][..], rate, &["-pix_fmt", "yuv420p"]].concat()) +} + /// The facts, the presentation times, whether the colour matrix is untagged, and the decoder a VP8 or VP9 stream with /// alpha needs (libvpx: ffmpeg's own VP9 decoder drops the alpha WebM keeps beside the picture, #113). fn probe(path: &Path) -> R<(Info, Vec, bool, Option<&'static str>)> { diff --git a/systems/fingerprint-use/Cargo.toml b/systems/fingerprint-use/Cargo.toml index 26abefb4e..64ab33cdc 100644 --- a/systems/fingerprint-use/Cargo.toml +++ b/systems/fingerprint-use/Cargo.toml @@ -10,6 +10,8 @@ description = "Using a fingerprint (docs/fingerprint.feature FP3, FP6e, FP8b, FP dunce = "1" # the fingerprint: its taxonomy, folder, evidence, heads and words raea-sys-fingerprint = { path = "../fingerprint" } +# the H.264 encoder this machine's ffmpeg has, for a clip a person plays (raea_io_ffmpeg::h264) +raea-io-ffmpeg = { path = "../../io/ffmpeg" } # a piece's columns, and the frames and sound the sheet draws raea-sys-columns = { path = "../columns" } serde = { version = "1", features = ["derive"] } diff --git a/systems/fingerprint-use/src/postmortem.rs b/systems/fingerprint-use/src/postmortem.rs index 1a6ffcc93..76b19e591 100644 --- a/systems/fingerprint-use/src/postmortem.rs +++ b/systems/fingerprint-use/src/postmortem.rs @@ -70,10 +70,12 @@ pub fn picks(scored: &[Scored], trained: &Trained, fp: &Fingerprint, l: &Ledger, /// The moment cut to a clip to play beside its question (ffmpeg), else None and the whole piece plays pub fn clip(x: &Ask, out: &Path) -> Option { std::fs::create_dir_all(out.parent()?).ok()?; + let h264 = raea_io_ffmpeg::h264()?; let ok = std::process::Command::new("ffmpeg") .args(["-y", "-loglevel", "error", "-ss", &format!("{:.2}", (x.a - 0.5).max(0.0)), "-t", &format!("{:.2}", x.b - x.a + 1.0), "-i"]) .arg(&x.file) - .args(["-c:v", "libx264", "-pix_fmt", "yuv420p", "-c:a", "aac"]) + .args(h264) + .args(["-c:a", "aac"]) .arg(out) .status() .is_ok_and(|s| s.success()); diff --git a/tools/release-check.sh b/tools/release-check.sh index 7d8331752..410034070 100644 --- a/tools/release-check.sh +++ b/tools/release-check.sh @@ -150,15 +150,27 @@ api=$(cat "$check"/raea/bin/* | grep -aoE '(api|sign)\.raea\.io|RAEA_(SIGN|GEN)_ [ -z "$api" ] || fail "the binaries name raea's API ($api): build raea-cli with --no-default-features" keys=$(grep -rlE 'sk-or-v1-[0-9a-f]{20}|sk-ant-[A-Za-z0-9_-]{20}|(^|[^A-Za-z0-9+/])AKIA[0-9A-Z]{16}([^A-Za-z0-9+/=]|$)|BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY' "$check/raea" 2>/dev/null | head -5 || true) [ -z "$keys" ] || fail "key-shaped text in: $keys" -# Windows: our binaries only. Any other DLL, or a file named like the CRT, the SDK or DirectX's redistributables, is -# Microsoft's and isn't ours to ship. The one exception is ONNX Runtime's onnxruntime.dll, which Microsoft publishes -# under MIT, shipped with its licence (#110: tools/release/onnxruntime.sh) -ms=$(cd "$check/raea" && find . -type f \( -iname '*.dll' ! -path './bin/raea_bundle.dll' ! -path './bin/onnxruntime.dll' -o -iname 'vcruntime*' -o -iname 'msvcp*' -o -iname 'ucrtbase*' -o -iname 'api-ms-win*' -o -iname 'concrt*' -o -iname 'vccorlib*' -o -iname '*.lib' -o -iname '*.pdb' -o -iname 'd3dcompiler*' -o -iname 'dxcompiler*' -o -iname 'dxil*' \) | head -5) +# Windows: our binaries, and Microsoft's only where raea ships them on purpose, with their licences: ONNX Runtime's +# onnxruntime.dll (MIT, #110) and the VC++ runtime's four DLLs (tools/release/win-bundle.sh). Any other DLL, or a file +# named like the CRT, the SDK or DirectX's redistributables, isn't ours to ship. +bundle=$(cat "$(dirname "$0")/release/win-bundle.files") +allowed=$(printf './bin/%s\n' raea_bundle.dll onnxruntime.dll $bundle) +ms=$(cd "$check/raea" && find . -type f \( -iname '*.dll' -o -iname 'vcruntime*' -o -iname 'msvcp*' -o -iname 'ucrtbase*' -o -iname 'api-ms-win*' -o -iname 'concrt*' -o -iname 'vccorlib*' -o -iname '*.lib' -o -iname '*.pdb' -o -iname 'd3dcompiler*' -o -iname 'dxcompiler*' -o -iname 'dxil*' \) | grep -ivxF "$allowed" | head -5 || true) [ -z "$ms" ] || fail "files that aren't ours: $ms" if [ -f "$check/raea/bin/raea.exe" ]; then for f in onnxruntime.dll onnxruntime-LICENSE.txt onnxruntime-ThirdPartyNotices.txt; do [ -f "$check/raea/bin/$f" ] || fail "bin/$f is missing: raea.exe loads ONNX Runtime from it, and its licence goes with it (#110)" done + # what a PC with nothing installed and no downloads needs, each with its licence + for f in $bundle; do + [ -f "$check/raea/bin/$f" ] || fail "bin/$f is missing (tools/release/win-bundle.sh): a PC without it can't start raea, read a phone's video or set up a model" + done + "$check/raea/bin/ffmpeg.exe" -hide_banner -L 2>&1 | grep -q "Lesser General Public" || fail "bin/ffmpeg.exe isn't raea's LGPL build" + # alpha WebM decodes with libvpx (#113), and a clip a person plays is cut to H.264 with Windows' own encoder + for c in libvpx-vp9 h264_mf; do + "$check/raea/bin/ffmpeg.exe" -hide_banner -codecs 2>&1 | grep -q "$c" || fail "bin/ffmpeg.exe has no $c" + done + "$check/raea/bin/uv.exe" --version 2>&1 | grep -q '^uv ' || fail "bin/uv.exe doesn't run" fi echo "release: $archive checked: an unpacked copy rendered a frame and checked an app on both targets with RAEA_NO_TREE=1" rm -rf "$check" diff --git a/tools/release.sh b/tools/release.sh index d34cd1f90..df9fd5704 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -137,11 +137,15 @@ loader (Debian and Ubuntu: apt install libxkbcommon-x11-0 libxcursor1 libxi6 lib [ -f "$bin/$f" ] || { echo "release.sh: $bin has no $f (tools/release/onnxruntime.sh $bin)" >&2; exit 1; } cp "$bin/$f" "$stage/bin/" done - # the C runtime isn't in the zip (ort's ONNX Runtime needs its DLLs, and they're Microsoft's to ship): the VC++ - # redistributable, which most Windows machines already have, provides it + # and what a PC with nothing installed and no downloads needs (tools/release/win-bundle.sh): the VC++ runtime + # raea.exe and onnxruntime.dll import, FFmpeg (raea's LGPL build) and uv, each with its licence + for f in $(cat "$root/tools/release/win-bundle.files"); do + [ -f "$bin/$f" ] || { echo "release.sh: $bin has no $f (tools/release/win-bundle.sh $bin)" >&2; exit 1; } + cp "$bin/$f" "$stage/bin/" + done printf '%s\r\n' "raea $version for Windows x86_64 (Windows 10 or 11, a DirectX 12 or Vulkan GPU driver; with no GPU, Mesa's lavapipe and WGPU_BACKEND=vulkan)." \ - "It needs the Microsoft Visual C++ Redistributable (x64), which most machines already have:" \ - "https://aka.ms/vs/17/release/vc_redist.x64.exe" > "$stage/README.txt" ;; + "bin\\ carries what raea needs from outside it: Microsoft's Visual C++ runtime and ONNX Runtime, FFmpeg (LGPL) and uv," \ + "each with its licence beside it (ffmpeg-README.txt says where FFmpeg's source is)." > "$stage/README.txt" ;; *) cp "$bin/raea" "$bin/libraea_bundle.dylib" "$bin/raea-perceive" "$bin/raea-rune-host" "$bin/raea-page-host" "$stage/bin/" # stripped as they linked (tools/link-jit.sh, #88); a binary that still holds its debug map is a build from before for f in raea raea-page-host raea-rune-host raea-perceive; do diff --git a/tools/release/ffmpeg-win.sh b/tools/release/ffmpeg-win.sh new file mode 100755 index 000000000..a9e13ef75 --- /dev/null +++ b/tools/release/ffmpeg-win.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# FFmpeg for Windows x64 as raea ships it (beside raea.exe) and fetches it (io/assets/src/setup.rs): FFmpeg's own +# release, cross-built with mingw-w64 on Linux, static, with only FFmpeg's own code, zlib and libvpx's decoders, so it +# is LGPL 2.1 or later (no --enable-gpl: no x264, x265 or other GPL library) and its complete source is the tarballs and this +# script. raea uses it to read what its own decoders can't (H.264 with B-frames, HEVC, VP9 in a phone's or a camera's +# video) and to probe; it encodes with its own encoders, so no encoder library is needed. +# tools/release/ffmpeg-win.sh OUT_DIR (Ubuntu: apt install gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 libz-mingw-w64-dev nasm make pkg-config xz-utils zip) +# writes OUT_DIR/ffmpeg-$v-lgpl-win64.zip and its .sha256; .github/workflows/tools-ffmpeg.yml runs it and publishes the +# zip with the source tarball, its signature and this script. +set -euo pipefail +die() { echo "ffmpeg-win: $*" >&2; exit 1; } +out=$(mkdir -p "${1:?OUT_DIR}" && cd "$1" && pwd) +v=9.0.2 +# FFmpeg's release tarball, signed by its release key (FCF986EA15E6E293A5644F10B4322F04D67658D8; checked 11-19) +sum=8c3850283eb25fa026482078a04051e0be17347b09ef81a0849bec15a96e002e +name=ffmpeg-$v-lgpl-win64 +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +cd "$work" +curl -fsSL --retry 5 --retry-all-errors -o "ffmpeg-$v.tar.xz" "https://ffmpeg.org/releases/ffmpeg-$v.tar.xz" || die "couldn't download FFmpeg $v" +echo "$sum ffmpeg-$v.tar.xz" | sha256sum -c - >/dev/null || die "ffmpeg-$v.tar.xz isn't the tarball pinned here" +tar -xJf "ffmpeg-$v.tar.xz" +# libvpx's release (BSD 3-clause, with the WebM project's patent grant), decoders only: FFmpeg's own VP8 and VP9 +# decoders drop the alpha a WebM keeps beside its picture, so raea decodes such a stream with libvpx (io/ffmpeg, #113) +vpx=1.17.0 +vpx_sum=1020f184046187baa2985dbde38e0691f49c44088bca7a1842b0236c6081dc0a +curl -fsSL --retry 5 --retry-all-errors -o "libvpx-$vpx.tar.gz" "https://github.com/webmproject/libvpx/archive/refs/tags/v$vpx.tar.gz" || die "couldn't download libvpx $vpx" +echo "$vpx_sum libvpx-$vpx.tar.gz" | sha256sum -c - >/dev/null || die "libvpx-$vpx.tar.gz isn't the tarball pinned here" +tar -xzf "libvpx-$vpx.tar.gz" +vconf=(--target=x86_64-win64-gcc --prefix="$work/vpx" --enable-static --disable-shared --disable-examples --disable-tools + --disable-docs --disable-unit-tests --disable-vp8-encoder --disable-vp9-encoder --as=nasm) +(cd "libvpx-$vpx" && CROSS=x86_64-w64-mingw32- ./configure "${vconf[@]}" && make -j"$(nproc)" && make install) >"$work/vpx.log" 2>&1 || { tail -30 "$work/vpx.log"; die "libvpx failed"; } +export PKG_CONFIG_PATH="$work/vpx/lib/pkgconfig" +cd "ffmpeg-$v" +# --disable-autodetect keeps out every library the build machine happens to have; threads and zlib are asked for by +# name. No network (raea reads files), no capture devices (a webcam's vfwcap, a screen's gdigrab: raea reads files, +# and they pull in Windows' capture DLLs), no ffplay, no hardware decoders (raea decodes on the CPU here). Media +# Foundation for its H.264 encoder (h264_mf, Windows' own, which FFmpeg loads at run time): FFmpeg has no H.264 +# encoder of its own and libx264 is GPL, and raea cuts a clip a person plays to H.264 (io/ffmpeg's h264()). Its +# encoder is written against D3D11's types (libavcodec/mfenc.c), so D3D11VA comes with it; raea asks it for no +# hardware decoding. +conf=(--target-os=mingw32 --arch=x86_64 --cross-prefix=x86_64-w64-mingw32- --enable-cross-compile + --pkg-config=pkg-config --pkg-config-flags=--static --disable-shared --enable-static + --disable-debug --disable-doc --disable-ffplay --disable-network --disable-devices --disable-autodetect + --enable-w32threads --enable-zlib --enable-libvpx --disable-encoder=libvpx_vp8,libvpx_vp9 --enable-mediafoundation --enable-d3d11va + --extra-cflags="-I$work/vpx/include" --extra-ldflags="-static -L$work/vpx/lib") +./configure "${conf[@]}" >"$work/configure.log" 2>&1 || { tail -30 "$work/configure.log"; die "configure failed"; } +grep -q '#define FFMPEG_LICENSE "LGPL version 2.1 or later"' config.h || die "the build isn't LGPL 2.1 or later: $(grep FFMPEG_LICENSE config.h)" +for c in LIBVPX_VP8_DECODER LIBVPX_VP9_DECODER H264_MF_ENCODER; do + grep -q "#define CONFIG_$c 1" config_components.h || die "the build has no $c (configure.log: $(grep -iE 'vpx|mediafoundation' "$work/configure.log" | tail -3))" +done +make -j"$(nproc)" >"$work/make.log" 2>&1 || { tail -30 "$work/make.log"; die "make failed"; } +x86_64-w64-mingw32-strip ffmpeg.exe ffprobe.exe +# only Windows' own DLLs: nothing of mingw's (libwinpthread, libgcc) or the build machine's +for f in ffmpeg.exe ffprobe.exe; do + bad=$(x86_64-w64-mingw32-objdump -p "$f" | awk '/DLL Name:/ {print tolower($3)}' | grep -vE '^(kernel32|user32|advapi32|bcrypt|ole32|oleaut32|shell32|shlwapi|psapi|msvcrt|ws2_32|secur32|gdi32|vfw32|api-ms-win-.*)\.dll$' || true) + [ -z "$bad" ] || die "$f imports $bad" +done +mkdir -p "$work/$name/bin" +cp ffmpeg.exe ffprobe.exe "$work/$name/bin/" +cp COPYING.LGPLv2.1 "$work/$name/LICENSE" +cp "../libvpx-$vpx/LICENSE" "$work/$name/libvpx-LICENSE" +cp "../libvpx-$vpx/PATENTS" "$work/$name/libvpx-PATENTS" +{ + echo "FFmpeg $v for Windows x64, as raea ships and fetches it." + echo + echo "Built from FFmpeg's own release, ffmpeg-$v.tar.xz (sha256 $sum, signed by FFmpeg's release key), with mingw-w64," + echo "with FFmpeg's own code, zlib and libvpx $vpx's decoders (libvpx-$vpx.tar.gz, sha256 $vpx_sum). FFmpeg is licensed" + echo "under the GNU Lesser General Public License version 2.1 or later (LICENSE here); zlib under the zlib licence;" + echo "libvpx under the BSD 3-clause licence with the WebM project's patent grant (libvpx-LICENSE, libvpx-PATENTS)." + echo "This build has no GPL part. Its H.264 encoder is Windows' own, through Media Foundation." + echo + echo "Its complete source is those tarballs and the script that built it (tools/release/ffmpeg-win.sh in" + echo "https://github.com/shinyobjectz/raea), all published beside this build:" + echo " https://github.com/shinyobjectz/raea/releases/tag/tools-ffmpeg-$v-lgpl" + echo + echo "libvpx configure ${vconf[*]}" + echo "configure ${conf[*]}" +} > "$work/$name/README.txt" +(cd "$work" && rm -f "$out/$name.zip" && zip -qr -X "$out/$name.zip" "$name") +(cd "$out" && sha256sum "$name.zip" > "$name.zip.sha256") +cp "$work/ffmpeg-$v.tar.xz" "$work/libvpx-$vpx.tar.gz" "$out/" +echo "ffmpeg-win: $(cat "$out/$name.zip.sha256"), $(wc -c < "$out/$name.zip" | tr -d ' ') bytes; ffmpeg.exe $(wc -c < "$work/$name/bin/ffmpeg.exe" | tr -d ' ') bytes" diff --git a/tools/release/git-sources.sh b/tools/release/git-sources.sh new file mode 100755 index 000000000..cbba238fb --- /dev/null +++ b/tools/release/git-sources.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +# The complete corresponding source of the Git for Windows the Windows app ships (dugite-native's build, pinned in the +# feed's host/tools.ts WIN_GIT and tools/raea-app/win/build.sh), as GPLv2 section 3 asks of whoever distributes it: +# each package its etc/package-versions.txt names, as the source package it was built from. Git for Windows' own +# builds (Git, its MSYS2 runtime, bash, curl ...) from its pacman repository's releases, the rest from MSYS2's source +# mirror. tools-git-sources.yml runs it and publishes the archive as the prerelease tools-git--sources. +# tools/release/git-sources.sh --list each package and the source it resolves to (no download) +# tools/release/git-sources.sh OUT_DIR OUT_DIR/git-for-windows--sources.tar and its .sha256 +set -euo pipefail +die() { echo "git-sources: $*" >&2; exit 1; } +tag=v2.56.0-2 +url=https://github.com/desktop/dugite-native/releases/download/$tag/dugite-native-v2.56.0-a44aeca-windows-x64.tar.gz +sum=f1e17876337d7be143e5d51976da36643d65528125cfbc14d57f171de0fd5f14 +list=0; [ "${1:-}" = --list ] && list=1 +out=${1:?--list or OUT_DIR} +[ "$list" = 1 ] || out=$(mkdir -p "$out" && cd "$out" && pwd) +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT +curl -fsSL --retry 5 -o "$work/git.tgz" "$url" || die "couldn't download $url" +[ "$( (sha256sum "$work/git.tgz" 2>/dev/null || shasum -a 256 "$work/git.tgz") | cut -d' ' -f1)" = "$sum" ] || die "$url isn't the build pinned" +tar -xzf "$work/git.tgz" -C "$work" ./etc/package-versions.txt ./LICENSE.txt + +# the source package (pacman's pkgbase) a split package comes from +base() { + case $1 in + gcc-libs|cc-libs|libatomic|libgcc|libgomp|libquadmath|libstdc++) echo gcc ;; + heimdal-libs) echo heimdal ;; + libintl|gettext-runtime) echo gettext ;; + libopenssl) echo openssl ;; + libpcre) echo pcre ;; + libreadline) echo readline ;; + libsqlite) echo sqlite ;; + curl-winssl|curl-openssl-alternate) echo curl ;; + git-credential-wincred|git-for-windows-addons|git-gui|git-perl|git-send-email|git-subtree|gitk) echo git ;; + libssh2-wincng) echo libssh2 ;; + libwinpthread) echo winpthreads ;; + *) echo "$1" ;; + esac +} + +# Git for Windows' source packages: every .src.tar.gz its pacman repository has released, by name +gh api --paginate "repos/git-for-windows/pacman-repo/releases?per_page=100" \ + -q '.[].assets[] | select(.name | endswith(".src.tar.gz")) | [.name, .browser_download_url] | @tsv' > "$work/gfw.tsv" || + die "couldn't list git-for-windows/pacman-repo's releases (gh api)" +exists() { [ "$(curl -s -o /dev/null -w '%{http_code}' -I -L "$1")" = 200 ]; } + +: > "$work/sources.tsv"; missing="" +while read -r pkg ver; do + [ -n "$pkg" ] || continue + if [[ $pkg == mingw-w64-ucrt-x86_64-* ]]; then + b=mingw-w64-$(base "${pkg#mingw-w64-ucrt-x86_64-}"); mirror=https://repo.msys2.org/mingw/sources + else + b=$(base "$pkg"); mirror=https://repo.msys2.org/msys/sources + fi + src=$(awk -F'\t' -v n="$b-$ver.src.tar.gz" '$1 == n {print $2; exit}' "$work/gfw.tsv") + [ -n "$src" ] || { exists "$mirror/$b-$ver.src.tar.zst" && src=$mirror/$b-$ver.src.tar.zst; } || true + if [ -n "$src" ]; then + grep -qF "$src" "$work/sources.tsv" || printf '%s\t%s\t%s\n' "$b-$ver" "$src" "$pkg" >> "$work/sources.tsv" + else + missing="$missing $pkg-$ver($b)" + fi +done < <(tr -d '\r' < "$work/etc/package-versions.txt" | sort -u) + +if [ "$list" = 1 ]; then + column -t -s$'\t' "$work/sources.tsv" + [ -z "$missing" ] || { echo "unresolved:$missing"; exit 1; } + exit 0 +fi +[ -z "$missing" ] || die "no source found for:$missing" +mkdir -p "$work/src" +while IFS=$'\t' read -r name src _; do + curl -fsSL --retry 5 --retry-all-errors -o "$work/src/$(basename "$src")" "$src" || die "couldn't download $src" +done < "$work/sources.tsv" +cp "$work/etc/package-versions.txt" "$work/src/package-versions.txt" +cp "$work/LICENSE.txt" "$work/src/LICENSE.txt" +cut -f1,2 "$work/sources.tsv" > "$work/src/SOURCES.tsv" +{ + echo "The complete corresponding source of Git for Windows with Git LFS as raea's Windows app ships it:" + echo "dugite-native $tag ($url, sha256 $sum), built by Git for Windows and GitHub from the packages its" + echo "package-versions.txt names. Each package's source package is here, from Git for Windows' pacman repository" + echo "or MSYS2's source mirror (SOURCES.tsv says which). Collected by tools/release/git-sources.sh in" + echo "https://github.com/shinyobjectz/raea." +} > "$work/src/README.txt" +name=git-for-windows-$tag-sources +(cd "$work" && mv src "$name" && tar -cf "$out/$name.tar" "$name") +(cd "$out" && (sha256sum "$name.tar" 2>/dev/null || shasum -a 256 "$name.tar") > "$name.tar.sha256") +echo "git-sources: $out/$name.tar ($(wc -l < "$work/sources.tsv" | tr -d ' ') source packages, $(du -h "$out/$name.tar" | cut -f1))" diff --git a/tools/release/win-bundle.files b/tools/release/win-bundle.files new file mode 100644 index 000000000..58dc3df5b --- /dev/null +++ b/tools/release/win-bundle.files @@ -0,0 +1,14 @@ +vcruntime140.dll +vcruntime140_1.dll +msvcp140.dll +msvcp140_1.dll +vcruntime-NOTICE.txt +ffmpeg.exe +ffprobe.exe +ffmpeg-LICENSE.txt +ffmpeg-README.txt +libvpx-LICENSE.txt +libvpx-PATENTS.txt +uv.exe +uv-LICENSE-MIT.txt +uv-LICENSE-APACHE.txt diff --git a/tools/release/win-bundle.sh b/tools/release/win-bundle.sh new file mode 100755 index 000000000..57baf19e9 --- /dev/null +++ b/tools/release/win-bundle.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# What raea.exe needs beside it on Windows, so a PC with nothing installed and no way to download (a work PC whose +# IT blocks GitHub's downloads) starts raea, reads a phone's video and sets up a local model. tools/release.sh packs it +# into the Windows zip's bin\, and the Windows app takes that bin\ whole. +# - the Visual C++ runtime: vcruntime140.dll, vcruntime140_1.dll, msvcp140.dll and msvcp140_1.dll, which raea.exe and +# onnxruntime.dll import. Microsoft's redistributable, from the Visual Studio on the runner that built raea, put +# beside the exe as Microsoft documents for app-local deployment; until 0.1.8 a PC without the VC++ redistributable +# installed couldn't start raea.exe at all +# - FFmpeg (ffmpeg.exe, ffprobe.exe): raea's own LGPL build (tools/release/ffmpeg-win.sh), the one setup.rs fetches +# where it isn't, with its licence and where its source is +# - uv (uv.exe), the release every local model's setup was measured with (MIT or Apache 2.0), with both licences +# The pins are setup.rs's, so what ships and what's fetched are the same build. +# tools/release/win-bundle.sh DEST (on the Windows runner, in Git's bash) +set -euo pipefail +die() { echo "win-bundle: $*" >&2; exit 1; } +dest=${1:?DEST} +root=$(cd "$(dirname "$0")/../.." && pwd) +setup=$root/io/assets/src/setup.rs +const() { sed -n "s/^const $1: &str = \"\\(.*\\)\";$/\\1/p" "$setup"; } +sha() { (sha256sum "$1" 2>/dev/null || shasum -a 256 "$1") | cut -d' ' -f1; } +fetch() { curl -fsSL --retry 5 --retry-all-errors --connect-timeout 30 -o "$2" "$1" || die "couldn't download $1"; [ "$(sha "$2")" = "$3" ] || die "$1 isn't the $3 pinned"; } +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +mkdir -p "$dest" + +# the VC++ runtime, from the newest Visual Studio with the C++ tools +vswhere="/c/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" +[ -x "$vswhere" ] || die "no vswhere at $vswhere: the C runtime comes from the runner's Visual Studio" +vs=$(cygpath -u "$("$vswhere" -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | tr -d '\r')") +ver=$(tr -d '\r\n ' < "$vs/VC/Auxiliary/Build/Microsoft.VCRedistVersion.default.txt") +crt=$(ls -d "$vs/VC/Redist/MSVC/$ver/x64"/Microsoft.VC14*.CRT 2>/dev/null | tail -1) +[ -n "$crt" ] || die "no Microsoft.VC14*.CRT under $vs/VC/Redist/MSVC/$ver/x64" +for f in vcruntime140.dll vcruntime140_1.dll msvcp140.dll msvcp140_1.dll; do + [ -f "$crt/$f" ] || die "$crt has no $f" + cp "$crt/$f" "$dest/$f" +done +printf '%s\r\n' "vcruntime140.dll, vcruntime140_1.dll, msvcp140.dll and msvcp140_1.dll are Microsoft's Visual C++ runtime ($ver)," \ + "redistributed with raea as Microsoft's Visual Studio licence terms allow, so raea starts on a PC that doesn't have the" \ + "Visual C++ Redistributable installed. They're Microsoft's, not raea's." > "$dest/vcruntime-NOTICE.txt" + +# FFmpeg +url=$(const FFMPEG_URL); sum=$(const FFMPEG_SUM); top=$(const FFMPEG_TOP) +[ -n "$url" ] && [ -n "$sum" ] && [ -n "$top" ] || die "no FFMPEG_URL, FFMPEG_SUM and FFMPEG_TOP in $setup" +fetch "$url" "$tmp/ffmpeg.zip" "$sum" +unzip -q -o "$tmp/ffmpeg.zip" -d "$tmp/ff" +cp "$tmp/ff/$top/bin/ffmpeg.exe" "$tmp/ff/$top/bin/ffprobe.exe" "$dest/" +cp "$tmp/ff/$top/LICENSE" "$dest/ffmpeg-LICENSE.txt" +cp "$tmp/ff/$top/README.txt" "$dest/ffmpeg-README.txt" +cp "$tmp/ff/$top/libvpx-LICENSE" "$dest/libvpx-LICENSE.txt" +cp "$tmp/ff/$top/libvpx-PATENTS" "$dest/libvpx-PATENTS.txt" + +# uv, and its licences from its source at the same tag +uv=$(const UV) +uvsum=$(sed -n 's/^ *("x86_64-pc-windows-msvc", "\([0-9a-f]*\)"),$/\1/p' "$setup") +[ -n "$uv" ] && [ -n "$uvsum" ] || die "no UV and its x86_64-pc-windows-msvc sha256 in $setup" +fetch "https://github.com/astral-sh/uv/releases/download/$uv/uv-x86_64-pc-windows-msvc.zip" "$tmp/uv.zip" "$uvsum" +unzip -q -o "$tmp/uv.zip" uv.exe -d "$dest" +[ "$uv" = 0.12.24 ] || die "uv is $uv: pin its LICENSE-MIT and LICENSE-APACHE here for that tag" +fetch "https://raw.githubusercontent.com/astral-sh/uv/$uv/LICENSE-MIT" "$dest/uv-LICENSE-MIT.txt" 860e3d7a86b84e6a7012c7a635fc64df475cebc6cce34dfeb73a5982ec58176c +fetch "https://raw.githubusercontent.com/astral-sh/uv/$uv/LICENSE-APACHE" "$dest/uv-LICENSE-APACHE.txt" c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 + +echo "win-bundle: in $dest: the VC++ runtime $ver, FFmpeg ($top), uv $uv, with their licences"