From a248e9242a27ced44fe33f36076fedb87ff626d8 Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Wed, 14 Oct 2026 22:12:29 +0200 Subject: [PATCH] Ship the launcher as Horizon.app in a .dmg, and in Linux's menus macOS: packaging/macos/package.sh (run by launcher.yml) builds Horizon.app (Info.plist, bundle id dev.horizon.launcher, macOS 11+, the .icns), signs it ad hoc, and makes the two release assets: horizon-launcher-macos-arm64.dmg, the installer (the app and an Applications link over a background, laid out by dmgbuild without a GUI), and the .zip the launcher updates from. A launcher inside the app replaces the whole bundle: copied beside it with ditto, swapped in by renames, restarted; a bare binary, as older launchers are, still finds its binary in the zip. A macOS test zips, unpacks, swaps and re-verifies a signed bundle. Signing for real is a MACOS_SIGN_IDENTITY away (packaging/macos/README.md, with what Gatekeeper asks meanwhile). Linux: release builds keep horizon-launcher.desktop (with the binary's current path), horizon.desktop (hidden, for the game window's icon) and the hicolor icons under $XDG_DATA_HOME, without root; `horizon-launcher desktop-entry --remove` takes them out and stops it, `desktop-entry` puts them back. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/launcher.yml | 25 ++-- docs/media/brand/README.md | 4 +- launcher/src/backend.rs | 180 ++++++++++++++++++++++++++ launcher/src/cli.rs | 19 +++ launcher/src/desktop.rs | 202 ++++++++++++++++++++++++++++++ launcher/src/lib.rs | 1 + launcher/src/main.rs | 11 ++ packaging/macos/Info.plist | 35 ++++++ packaging/macos/README.md | 39 ++++++ packaging/macos/background.html | 17 +++ packaging/macos/background.png | Bin 0 -> 5152 bytes packaging/macos/background@2x.png | Bin 0 -> 11958 bytes packaging/macos/package.sh | 57 +++++++++ 13 files changed, 579 insertions(+), 11 deletions(-) create mode 100644 launcher/src/desktop.rs create mode 100644 packaging/macos/Info.plist create mode 100644 packaging/macos/README.md create mode 100644 packaging/macos/background.html create mode 100644 packaging/macos/background.png create mode 100644 packaging/macos/background@2x.png create mode 100755 packaging/macos/package.sh diff --git a/.github/workflows/launcher.yml b/.github/workflows/launcher.yml index 3f25e7f0b..d41b38092 100644 --- a/.github/workflows/launcher.yml +++ b/.github/workflows/launcher.yml @@ -187,20 +187,27 @@ jobs: rm -rf "$HORIZON_LAUNCHER_HOME" - name: Package run: | - rm -rf dist ${{ matrix.asset }} && mkdir -p dist - cp target/release/${{ matrix.binary }} dist/ - cd dist - if [[ "${{ matrix.asset }}" == *.tar.gz ]]; then - tar czf ../${{ matrix.asset }} ${{ matrix.binary }} - elif [[ "$RUNNER_OS" == "Windows" ]]; then - 7z a ../${{ matrix.asset }} ${{ matrix.binary }} + rm -rf dist out && mkdir -p out + if [[ "$RUNNER_OS" == "macOS" ]]; then + # Horizon.app, zipped (self-update) and in a .dmg (installer): packaging/macos. + python3 -m venv "$RUNNER_TEMP/dmg" && "$RUNNER_TEMP/dmg/bin/pip" install --quiet dmgbuild==1.6.5 + version=${HORIZON_LAUNCHER_VERSION:-$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)} + DMGBUILD="$RUNNER_TEMP/dmg/bin/dmgbuild" ../packaging/macos/package.sh target/release/${{ matrix.binary }} "$version" out + rm -rf out/Horizon.app else - zip ../${{ matrix.asset }} ${{ matrix.binary }} + mkdir -p dist + cp target/release/${{ matrix.binary }} dist/ + if [[ "${{ matrix.asset }}" == *.tar.gz ]]; then + (cd dist && tar czf ../out/${{ matrix.asset }} ${{ matrix.binary }}) + else + (cd dist && 7z a ../out/${{ matrix.asset }} ${{ matrix.binary }}) + fi fi + ls -l out - uses: actions/upload-artifact@v4 with: name: ${{ matrix.asset }} - path: launcher/${{ matrix.asset }} + path: launcher/out/* retention-days: 7 release: diff --git a/docs/media/brand/README.md b/docs/media/brand/README.md index a453f4470..c038126cb 100644 --- a/docs/media/brand/README.md +++ b/docs/media/brand/README.md @@ -23,9 +23,9 @@ places it in the design system; `candidates/` keeps the two alternatives that we | Output | Used by | |--------|---------| | `packaging/icons/hicolor//apps/horizon.png` (16–512) and `scalable/apps/horizon.svg` | Linux: copy the tree into `~/.local/share/icons/hicolor` (or `/usr/share/icons/hicolor`) | -| `packaging/linux/horizon-launcher.desktop`, `horizon.desktop` (hand-written) | Linux: `~/.local/share/applications`; Wayland matches the windows' app ids `horizon-launcher` and `horizon` | +| `packaging/linux/horizon-launcher.desktop`, `horizon.desktop` (hand-written) | Linux: the launcher installs both and the hicolor icons itself, under `$XDG_DATA_HOME` (`~/.local/share`), with its own path in `Exec` (`launcher/src/desktop.rs`; `horizon-launcher desktop-entry --remove` takes them out). Wayland matches the windows' app ids `horizon-launcher` and `horizon` | | `packaging/icons/horizon.ico` | Windows: embedded in `horizon-client.exe`, its tools and `horizon-launcher.exe` as icon resource 1 (`build.rs` of each, Windows builds only) | -| `packaging/icons/horizon.icns` | macOS: an app bundle's `Contents/Resources/horizon.icns` (`CFBundleIconFile`) | +| `packaging/icons/horizon.icns` | macOS: `Horizon.app/Contents/Resources/horizon.icns`, packaged with the .dmg by `packaging/macos/package.sh` | | `crates/horizon-theme/icons/horizon-64.png` | the game window's icon at run time (X11 and Windows title bars, `window::icon`) | | `website/public/favicon.svg`, `favicon-32.png`, `apple-touch-icon.png` | the website | | `icon-1024.png`, `icon-macos-1024.png` | previews, store listings | diff --git a/launcher/src/backend.rs b/launcher/src/backend.rs index d1ddc2b8c..e2918dda8 100644 --- a/launcher/src/backend.rs +++ b/launcher/src/backend.rs @@ -1280,6 +1280,77 @@ fn replace_binary(new: &Path, _exe: &Path) -> std::io::Result<()> { self_replace::self_replace(new) } +/// The app bundle the launcher runs from (`…/Horizon.app` for `…/Horizon.app/Contents/MacOS/ +/// horizon-launcher`), or None for a bare binary, as launchers before the .app shipped. +pub fn app_bundle(exe: &Path) -> Option<&Path> { + let macos = exe.parent()?; + let contents = macos.parent()?; + let app = contents.parent()?; + (macos.file_name()? == "MacOS" + && contents.file_name()? == "Contents" + && app.extension()? == "app") + .then_some(app) +} + +/// Finds the first `*.app` folder under `dir`. +fn find_app(dir: &Path) -> Option { + for entry in fs::read_dir(dir).ok()?.flatten() { + let path = entry.path(); + if path.is_dir() { + if path.extension().is_some_and(|e| e == "app") { + return Some(path); + } + if let Some(found) = find_app(&path) { + return Some(found); + } + } + } + None +} + +/// Puts the bundle `new` in place of `app`: copied beside it first (`ditto` keeps its links, +/// modes and signature), then the old one is moved aside and the new one renamed in, so `app` is +/// never half written. The running launcher keeps its open files and works on. +#[cfg(target_os = "macos")] +fn replace_bundle(new: &Path, app: &Path) -> Result<(), String> { + let dir = app.parent().ok_or("The app has no folder.")?; + let name = app.file_name().unwrap_or_default().to_string_lossy(); + let staged = dir.join(format!(".{name}.update-{}", std::process::id())); + let old = dir.join(format!(".{name}.old-{}", std::process::id())); + let _ = fs::remove_dir_all(&staged); + let copied = Command::new("ditto") + .arg(new) + .arg(&staged) + .status() + .map_err(|e| format!("ditto: {e}"))?; + if !copied.success() { + let _ = fs::remove_dir_all(&staged); + return Err(format!( + "Could not copy the new app next to {}.", + app.display() + )); + } + fs::rename(app, &old).map_err(|e| { + let _ = fs::remove_dir_all(&staged); + format!("Could not move {} aside: {e}", app.display()) + })?; + if let Err(e) = fs::rename(&staged, app) { + let _ = fs::rename(&old, app); + let _ = fs::remove_dir_all(&staged); + return Err(format!( + "Could not put the new app at {}: {e}", + app.display() + )); + } + let _ = fs::remove_dir_all(&old); + Ok(()) +} + +#[cfg(not(target_os = "macos"))] +fn replace_bundle(_new: &Path, _app: &Path) -> Result<(), String> { + Err("App bundles are a macOS thing.".into()) +} + /// Downloads a launcher release and puts its binary in place of this one. The running process /// keeps working; `restart` starts the new one. When the file there already is that release or /// a newer one (updated from the command line or another window), there is nothing to do. @@ -1302,6 +1373,17 @@ pub fn self_update(release: &Release, progress: impl Fn(f32)) -> Result<(), Stri download(&url, size, &archive, &progress)?; let unpacked = work.join("unpacked"); unpack(&archive, &url, &unpacked)?; + // A launcher inside Horizon.app replaces the whole bundle (its Info.plist, icon and + // signature belong with the binary); a bare binary, as older launchers are, only the binary, + // which the macOS archive also holds (Horizon.app/Contents/MacOS/horizon-launcher). + if let Some(app) = app_bundle(exe_path()) { + if let Some(new) = find_app(&unpacked) { + replace_bundle(&new, app)?; + let _ = fs::remove_dir_all(&work); + progress(1.0); + return Ok(()); + } + } let binary = find_file(&unpacked, LAUNCHER_BINARY).ok_or("The download has no launcher binary.")?; replace_binary(&binary, exe_path()).map_err(|e| { @@ -1521,6 +1603,10 @@ pub struct Settings { /// Off by default, so the opening animation shows unless the player turns it off. #[serde(default)] pub skip_opening: bool, + /// Linux: whether the launcher keeps its entry in the applications menu (`desktop`). Unset + /// means yes; removing the entry stores `false`, so it doesn't come back on the next start. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub desktop_entry: Option, } impl Settings { @@ -1530,6 +1616,10 @@ impl Settings { pub fn parse(text: &str) -> Self { serde_json::from_str(text).unwrap_or_default() } + /// Whether the launcher keeps its entry in the applications menu (Linux). + pub fn desktop_entry(&self) -> bool { + self.desktop_entry.unwrap_or(true) + } /// Whether new Horizon versions are installed automatically. pub fn auto_install(&self) -> bool { self.install_new_versions.unwrap_or(true) @@ -1878,6 +1968,96 @@ mod tests { let _ = fs::remove_dir_all(&versions); } + #[test] + fn finds_the_app_bundle_around_the_binary() { + let exe = Path::new("/Applications/Horizon.app/Contents/MacOS/horizon-launcher"); + assert_eq!( + app_bundle(exe), + Some(Path::new("/Applications/Horizon.app")) + ); + assert_eq!(app_bundle(Path::new("/Users/me/horizon-launcher")), None); + assert_eq!( + app_bundle(Path::new("/x/Contents/MacOS/horizon-launcher")), + None + ); + let work = std::env::temp_dir().join(format!("horizon-find-app-{}", std::process::id())); + let _ = fs::remove_dir_all(&work); + fs::create_dir_all(work.join("dist/Horizon.app/Contents/MacOS")).unwrap(); + assert_eq!(find_app(&work), Some(work.join("dist/Horizon.app"))); + let _ = fs::remove_dir_all(&work); + } + + /// The whole update of an app bundle, as the release ships it: signed, zipped with `ditto`, + /// unpacked by the launcher, swapped in place of the installed one, still valid. + #[cfg(target_os = "macos")] + #[test] + fn an_app_bundle_updates_in_place() { + use std::os::unix::fs::PermissionsExt; + let work = std::env::temp_dir().join(format!("horizon-bundle-{}", std::process::id())); + let _ = fs::remove_dir_all(&work); + let make = |dir: &Path, version: &str| { + let app = dir.join("Horizon.app"); + fs::create_dir_all(app.join("Contents/MacOS")).unwrap(); + fs::create_dir_all(app.join("Contents/Resources")).unwrap(); + let bin = app.join("Contents/MacOS/horizon-launcher"); + fs::copy("/usr/bin/true", &bin).unwrap(); + fs::set_permissions(&bin, fs::Permissions::from_mode(0o755)).unwrap(); + fs::write(app.join("Contents/Resources/version"), version).unwrap(); + fs::write( + app.join("Contents/Info.plist"), + "\n\ + CFBundleExecutablehorizon-launcher\ + CFBundleIdentifierdev.horizon.test\ + CFBundlePackageTypeAPPL\n", + ) + .unwrap(); + let signed = Command::new("codesign") + .args(["--force", "--sign", "-"]) + .arg(&app) + .status() + .unwrap(); + assert!(signed.success()); + app + }; + let installed = make(&work.join("Applications"), "1.0.0"); + let release = make(&work.join("release"), "2.0.0"); + let zip = work.join("release.zip"); + let zipped = Command::new("ditto") + .args(["-c", "-k", "--norsrc", "--noextattr", "--keepParent"]) + .arg(&release) + .arg(&zip) + .status() + .unwrap(); + assert!(zipped.success()); + unpack(&zip, "release.zip", &work.join("unpacked")).unwrap(); + let new = find_app(&work.join("unpacked")).unwrap(); + replace_bundle(&new, &installed).unwrap(); + let version = fs::read_to_string(installed.join("Contents/Resources/version")).unwrap(); + assert_eq!(version, "2.0.0"); + let bin = installed.join("Contents/MacOS/horizon-launcher"); + assert!( + Command::new(&bin).status().unwrap().success(), + "still executable" + ); + let valid = Command::new("codesign") + .args(["--verify", "--strict"]) + .arg(&installed) + .status() + .unwrap(); + assert!(valid.success(), "the updated bundle's signature holds"); + let left: Vec<_> = fs::read_dir(work.join("Applications")) + .unwrap() + .flatten() + .map(|e| e.file_name()) + .collect(); + assert_eq!( + left, + ["Horizon.app"], + "nothing staged or moved aside is left" + ); + let _ = fs::remove_dir_all(&work); + } + #[test] fn launcher_versions_read_from_the_binary() { assert_eq!( diff --git a/launcher/src/cli.rs b/launcher/src/cli.rs index 43cb39482..095d25c4a 100644 --- a/launcher/src/cli.rs +++ b/launcher/src/cli.rs @@ -106,6 +106,13 @@ enum Cmd { #[arg(long)] check: bool, }, + /// Linux: put Horizon in the applications menu (an entry and the icon, under + /// $XDG_DATA_HOME), or take it out with --remove + DesktopEntry { + /// Remove the entry and the icon, and stop adding them back + #[arg(long)] + remove: bool, + }, /// Serve the Model Context Protocol on stdin and stdout, for AI agents Mcp, } @@ -312,6 +319,18 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> { } } Cmd::Update { check } => update(check, as_json)?, + Cmd::DesktopEntry { remove } => { + let mut settings = backend::Settings::load(); + settings.desktop_entry = Some(!remove); + settings.save(); + if remove { + horizon_launcher::desktop::remove()?; + println!("Removed Horizon from the applications menu."); + } else { + horizon_launcher::desktop::install(backend::exe_path())?; + println!("Horizon is in the applications menu."); + } + } Cmd::Mcp => unreachable!(), } Ok(()) diff --git a/launcher/src/desktop.rs b/launcher/src/desktop.rs new file mode 100644 index 000000000..f97433139 --- /dev/null +++ b/launcher/src/desktop.rs @@ -0,0 +1,202 @@ +//! Linux: the launcher puts itself in the applications menu. It writes +//! `applications/horizon-launcher.desktop` (pointing at wherever the binary is now) and Horizon's +//! icon into the `hicolor` theme, under `$XDG_DATA_HOME` (`~/.local/share` by default), so no root +//! is needed; `horizon.desktop` (hidden from menus) gives the game's window its icon on Wayland. +//! A release build does this when it starts, and again whenever the binary has moved; the +//! Settings switch and `horizon-launcher desktop-entry --remove` take it all away again. +use std::fs; +use std::io; +use std::path::{Path, PathBuf}; + +/// The icon theme sizes, as `packaging/icons/hicolor` holds them (`cargo run -p xtask -- icons`). +const ICONS: [(&str, &[u8]); 9] = [ + ( + "16x16", + include_bytes!("../../packaging/icons/hicolor/16x16/apps/horizon.png"), + ), + ( + "24x24", + include_bytes!("../../packaging/icons/hicolor/24x24/apps/horizon.png"), + ), + ( + "32x32", + include_bytes!("../../packaging/icons/hicolor/32x32/apps/horizon.png"), + ), + ( + "48x48", + include_bytes!("../../packaging/icons/hicolor/48x48/apps/horizon.png"), + ), + ( + "64x64", + include_bytes!("../../packaging/icons/hicolor/64x64/apps/horizon.png"), + ), + ( + "128x128", + include_bytes!("../../packaging/icons/hicolor/128x128/apps/horizon.png"), + ), + ( + "256x256", + include_bytes!("../../packaging/icons/hicolor/256x256/apps/horizon.png"), + ), + ( + "512x512", + include_bytes!("../../packaging/icons/hicolor/512x512/apps/horizon.png"), + ), + ( + "scalable", + include_bytes!("../../packaging/icons/hicolor/scalable/apps/horizon.svg"), + ), +]; + +const LAUNCHER_ENTRY: &str = "horizon-launcher.desktop"; +const GAME_ENTRY: &str = "horizon.desktop"; +const GAME_ENTRY_TEXT: &str = include_str!("../../packaging/linux/horizon.desktop"); + +/// `$XDG_DATA_HOME`, or `~/.local/share` when it is unset or not absolute (as the spec says). +pub fn data_home() -> Option { + std::env::var_os("XDG_DATA_HOME") + .map(PathBuf::from) + .filter(|p| p.is_absolute()) + .or_else(|| dirs::home_dir().map(|h| h.join(".local/share"))) +} + +/// Quotes a path for an `Exec` key: inside double quotes, `"`, `` ` ``, `$` and `\` are escaped. +fn quote(path: &Path) -> String { + let mut out = String::from("\""); + for c in path.to_string_lossy().chars() { + if matches!(c, '"' | '`' | '$' | '\\') { + out.push('\\'); + } + out.push(c); + } + out.push('"'); + out +} + +/// The launcher's entry, starting the binary at `exe`. +pub fn launcher_entry(exe: &Path) -> String { + format!( + "[Desktop Entry]\n\ + Type=Application\n\ + Name=Horizon\n\ + GenericName=Game launcher\n\ + Comment=Install, prepare and play Horizon, Minecraft: Java Edition 26.3 rewritten in Rust\n\ + Exec={}\n\ + TryExec={}\n\ + Icon=horizon\n\ + Terminal=false\n\ + Categories=Game;\n\ + StartupWMClass=horizon-launcher\n", + quote(exe), + exe.display() + ) +} + +/// Every file this module writes, with its contents, under `data`. +fn files(data: &Path, exe: &Path) -> Vec<(PathBuf, Vec)> { + let mut out = vec![ + ( + data.join("applications").join(LAUNCHER_ENTRY), + launcher_entry(exe).into_bytes(), + ), + ( + data.join("applications").join(GAME_ENTRY), + GAME_ENTRY_TEXT.as_bytes().to_vec(), + ), + ]; + for (size, bytes) in ICONS { + let name = if size == "scalable" { + "horizon.svg" + } else { + "horizon.png" + }; + out.push(( + data.join("icons/hicolor") + .join(size) + .join("apps") + .join(name), + bytes.to_vec(), + )); + } + out +} + +/// Writes whatever is missing or out of date (a moved binary changes the entry). Returns +/// whether anything was written. +pub fn install_in(data: &Path, exe: &Path) -> io::Result { + let mut wrote = false; + for (path, bytes) in files(data, exe) { + if fs::read(&path).ok().as_deref() == Some(&bytes[..]) { + continue; + } + if let Some(dir) = path.parent() { + fs::create_dir_all(dir)?; + } + // Written beside and renamed, so a menu never reads half an entry. + let temp = path.with_extension("horizon-tmp"); + fs::write(&temp, &bytes)?; + fs::rename(&temp, &path)?; + wrote = true; + } + Ok(wrote) +} + +/// Removes every file `install_in` writes (the folders stay: other apps share them). +pub fn remove_in(data: &Path) -> io::Result<()> { + for (path, _) in files(data, Path::new("")) { + match fs::remove_file(&path) { + Err(e) if e.kind() != io::ErrorKind::NotFound => return Err(e), + _ => {} + } + } + Ok(()) +} + +pub fn install(exe: &Path) -> Result { + let data = data_home().ok_or("No home folder to put the menu entry in.")?; + install_in(&data, exe).map_err(|e| format!("{}: {e}", data.display())) +} + +pub fn remove() -> Result<(), String> { + let data = data_home().ok_or("No home folder.")?; + remove_in(&data).map_err(|e| format!("{}: {e}", data.display())) +} + +/// Whether the launcher's entry is there. +pub fn installed() -> bool { + data_home().is_some_and(|d| d.join("applications").join(LAUNCHER_ENTRY).exists()) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn exec_paths_are_quoted() { + let entry = launcher_entry(Path::new("/home/a b/Horizon \"x\"/horizon-launcher")); + assert!(entry.contains("Exec=\"/home/a b/Horizon \\\"x\\\"/horizon-launcher\"\n")); + assert!(entry.contains("TryExec=/home/a b/Horizon \"x\"/horizon-launcher\n")); + assert!(entry.contains("Icon=horizon\n")); + } + + #[test] + fn installs_follows_a_moved_binary_and_removes() { + let data = std::env::temp_dir().join(format!("horizon-desktop-{}", std::process::id())); + let _ = fs::remove_dir_all(&data); + assert!(install_in(&data, Path::new("/opt/a/horizon-launcher")).unwrap()); + assert!(!install_in(&data, Path::new("/opt/a/horizon-launcher")).unwrap()); + let png = data.join("icons/hicolor/48x48/apps/horizon.png"); + assert!(fs::read(&png).unwrap().starts_with(b"\x89PNG")); + assert!(data + .join("icons/hicolor/scalable/apps/horizon.svg") + .exists()); + assert!(install_in(&data, Path::new("/opt/b/horizon-launcher")).unwrap()); + let entry = fs::read_to_string(data.join("applications").join(LAUNCHER_ENTRY)).unwrap(); + assert!(entry.contains("Exec=\"/opt/b/horizon-launcher\"")); + remove_in(&data).unwrap(); + assert!(!data.join("applications").join(LAUNCHER_ENTRY).exists()); + assert!(!png.exists()); + remove_in(&data).unwrap(); + let _ = fs::remove_dir_all(&data); + } +} diff --git a/launcher/src/lib.rs b/launcher/src/lib.rs index cac481c4a..f19e310d6 100644 --- a/launcher/src/lib.rs +++ b/launcher/src/lib.rs @@ -1,3 +1,4 @@ //! The launcher's core, shared by the GUI, the CLI and the MCP server. pub mod account; pub mod backend; +pub mod desktop; diff --git a/launcher/src/main.rs b/launcher/src/main.rs index bbbbc5b53..276b31193 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -189,6 +189,17 @@ impl Launcher { if settings.server_dir.is_none() { settings.server_dir = Some(backend::data_dir().join("server")); } + // Release builds on Linux keep their entry in the applications menu up to date (a moved + // binary changes it); `HORIZON_LAUNCHER_DESKTOP_ENTRY=1` does it in a development build. + if cfg!(target_os = "linux") + && settings.desktop_entry() + && (!cfg!(debug_assertions) + || std::env::var_os("HORIZON_LAUNCHER_DESKTOP_ENTRY").is_some()) + { + std::thread::spawn(|| { + let _ = horizon_launcher::desktop::install(backend::exe_path()); + }); + } let installed = backend::installed(); if settings .selected diff --git a/packaging/macos/Info.plist b/packaging/macos/Info.plist new file mode 100644 index 000000000..b50e509c7 --- /dev/null +++ b/packaging/macos/Info.plist @@ -0,0 +1,35 @@ + + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Horizon + CFBundleExecutable + horizon-launcher + CFBundleIconFile + horizon + CFBundleIdentifier + dev.horizon.launcher + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Horizon + CFBundlePackageType + APPL + CFBundleShortVersionString + @VERSION@ + CFBundleVersion + @VERSION@ + LSApplicationCategoryType + public.app-category.games + LSMinimumSystemVersion + 11.0 + NSHighResolutionCapable + + NSHumanReadableCopyright + Horizon is MIT licensed. Not an official Minecraft product; not approved by or associated with Mojang or Microsoft. + + diff --git a/packaging/macos/README.md b/packaging/macos/README.md new file mode 100644 index 000000000..7441ccf77 --- /dev/null +++ b/packaging/macos/README.md @@ -0,0 +1,39 @@ +# The macOS launcher: Horizon.app in a .dmg + +`package.sh BINARY VERSION OUTDIR` (run by `.github/workflows/launcher.yml` on macOS) makes: + +- `Horizon.app`: `Contents/MacOS/horizon-launcher`, `Contents/Info.plist` (this folder's, bundle + id `dev.horizon.launcher`, macOS 11 or later), `Contents/Resources/horizon.icns` + (`packaging/icons`, from `cargo run -p xtask -- icons`). +- `horizon-launcher-macos-arm64.dmg`: the installer. Opening it shows the app and a link to + Applications over `background.png` / `background@2x.png` (drawn from `background.html`); the + player drags one onto the other. Built by [dmgbuild](https://github.com/dmgbuild/dmgbuild), + which writes the Finder layout without a GUI session. +- `horizon-launcher-macos-arm64.zip`: the same app, zipped with `ditto`. The launcher updates + itself from this: inside Horizon.app it replaces the whole bundle (copied beside it, then + swapped in by renaming, then restarted); a bare `horizon-launcher` binary, as launchers before + the app shipped, finds the binary inside the zip and replaces only itself. + +## Signing and Gatekeeper + +The app is signed **ad hoc** (`codesign --sign -`): no Apple account is needed, the bundle is +consistent and runs on Apple Silicon, but Gatekeeper doesn't know the developer. The first time +a player opens it after downloading: + +- macOS 14 and earlier: right-click (or Control-click) Horizon in Applications, choose **Open**, + then **Open** in the dialog. +- macOS 15 and later: open it once (it is refused), then **System Settings › Privacy & Security**, + **Open Anyway** next to "Horizon was blocked", and confirm. + +After that it opens normally, and its own updates don't ask again (they aren't downloaded by a +browser, so they carry no quarantine flag). + +To sign and notarize for real (Ludovic's Apple Developer account): import the "Developer ID +Application" certificate into the runner's keychain, set `MACOS_SIGN_IDENTITY` to its name for +`package.sh` (it then signs with the hardened runtime and a timestamp), and after it, notarize and +staple the disk image: + +```sh +xcrun notarytool submit dist/horizon-launcher-macos-arm64.dmg --keychain-profile horizon --wait +xcrun stapler staple dist/horizon-launcher-macos-arm64.dmg +``` diff --git a/packaging/macos/background.html b/packaging/macos/background.html new file mode 100644 index 000000000..6f08e90cd --- /dev/null +++ b/packaging/macos/background.html @@ -0,0 +1,17 @@ + + + +
Horizon
+
+
DRAG HORIZON TO APPLICATIONS
+ diff --git a/packaging/macos/background.png b/packaging/macos/background.png new file mode 100644 index 0000000000000000000000000000000000000000..727e9df1340b89baa2d52aab70dad3c3ca7cc56e GIT binary patch literal 5152 zcmeI0X;>22`oL+m$uVcHw`okxW=c(O>J%Bd0F73TxizMlqLP`Kk+|R%h*nNEEvDt3 zBAHv_C@HB4f|)69XzsBHxetmUp)7)Mo#**~`hULn)7)?Gd7tN;=UvY4ocDbnT<~z# z*}Z=^007W&`Q?lk0I)R&0N7H#YwM;40R0gL0DJ>*IrFo3Qn6rCCpu>h_fFhq)Ra|x zb9cmPllt2Q_8o@BpAC=GhCFiZygX{I|2msoOKqwO!L^V)sEdI_YwmS=OVdEcCCu1( z&5LRFkwCk|nJAQ@|0mU;PPzHr+yhZ|_ zDq@g^zNI84ngI?z(KP`a{HJ*5?JFM)0C&HQ0_-~1y5->a|7k_#KW3<8OX|9iTO<;? zWxiQU1}9|-?6(3`#}ug#5;unE*Ydx>dgWa@%?__u#p)tUOCnaRhaaR>rb($JXq&Je zZvv2qocPh_h190nQb}*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b{?39d`}_Ob za&QUPi>t~B0cPs27!j2I3hsF${V?6@Gku%fIN}GqM_Z$B+bw*HRTd9lRve;9D^9O< zi$4e9>1nY=S#8m>zv@`z)|k$~_%g^c#Dz!Qi&Mg3QapPtz%JP+4E^U@*2o zi%QMTeP__A=n3qo_5JQ=R{~Zxn!V`AD=ENyd|A?D*ikznYVM_H!AKtC(ZE{6J`c>M zRpjs6Xcx?9M7ygAPD$OIn*icL-C!sAq*W3ETP8 zTJ7!YB44)lq%!(=9adwqD!1lY9%-O&Fq5We%L&!o#~e2vD6YWjt?-P`y{J(DruyWs z|7<-tP_}0uFT|86z<#NCOe z7)AnKfNBInZxY(Dsqx=2$uY$nh%l{_$$R1|%y!+BSCAuN=h7e3Z2QB4Zo}zIL-oO$ zR?HgPokPqUiJ&u9h!a|e!VDl4pZrT1C=4WQxhP?;xc^zkI|aMT|Nj5Q#6jL)`!U4& yV|@32_eAq|*>(UxCi_&lAjbi)ZKJ$Y0Q|D0?IFzfk8ko7faPWIrQ*Nt{QX}vQrkQL literal 0 HcmV?d00001 diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh new file mode 100755 index 000000000..5743343f5 --- /dev/null +++ b/packaging/macos/package.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# Packages the macOS launcher: Horizon.app (the binary, Info.plist, the icon), signed, then the +# two release assets, horizon-launcher-macos-arm64.zip (what the launcher updates itself from; +# older launchers find the binary inside it) and horizon-launcher-macos-arm64.dmg (the installer: +# the app and an Applications link over a background, to drag one onto the other). +# +# packaging/macos/package.sh BINARY VERSION OUTDIR +# +# Needs macOS (ditto, codesign, hdiutil) and dmgbuild (pip install dmgbuild==1.6.5; $DMGBUILD +# names it if it isn't on PATH). Signing: ad hoc by default, which needs no Apple account; +# set MACOS_SIGN_IDENTITY to a "Developer ID Application: …" identity in the keychain to sign +# for real (then notarize the .dmg: see packaging/macos/README.md). +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +binary=$1 +version=$2 +out=$(mkdir -p "$3" && cd "$3" && pwd) +app=$out/Horizon.app + +rm -rf "$app" +mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" +cp "$binary" "$app/Contents/MacOS/horizon-launcher" +chmod 755 "$app/Contents/MacOS/horizon-launcher" +cp "$here/../icons/horizon.icns" "$app/Contents/Resources/horizon.icns" +sed "s/@VERSION@/$version/g" "$here/Info.plist" > "$app/Contents/Info.plist" +printf 'APPL????' > "$app/Contents/PkgInfo" +plutil -lint "$app/Contents/Info.plist" + +identity=${MACOS_SIGN_IDENTITY:--} +if [[ "$identity" == "-" ]]; then + codesign --force --sign - "$app" +else + codesign --force --options runtime --timestamp --sign "$identity" "$app" +fi +codesign --verify --strict --verbose=2 "$app" + +rm -f "$out/horizon-launcher-macos-arm64.zip" "$out/horizon-launcher-macos-arm64.dmg" +# No resource forks or extended attributes: they would land as ._ files inside the bundle. +(cd "$out" && ditto -c -k --norsrc --noextattr --noqtn --keepParent Horizon.app horizon-launcher-macos-arm64.zip) + +cat > "$out/dmg.json" </dev/null +echo "Packaged $out/horizon-launcher-macos-arm64.zip and .dmg"