Package a per-user Windows installer and signed full update packages (#57)
Work in progress carried over from the main checkout: scripts/package builds one version from one commit, packs it with vpk 1.2.161 (full packages only), signs a manifest with Ed25519 and checks the result with the built executable. The core verifies the signed manifest and package digest before any unpacking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d07a9641f
commit
f90ae109b9
12 files changed
+395
No files matched your search
@@ -9,6 +9,7 @@ profile = ["gpui-kit/profiler"]
|
||||
|
||||
[dependencies]
|
||||
arena-tracker-core = { path = "../core" }
|
||||
base64 = { version = "0.23.1", default-features = false, features = ["std"] }
|
||||
gpui-kit = "=0.9.1"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
||||
@@ -1,2 +1,24 @@
|
||||
// GPUI loads icon resource 1 for the window and its taskbar entry; File Explorer shows it too.
|
||||
1 ICON "icon.ico"
|
||||
|
||||
#ifdef ARENA_RELEASE
|
||||
#include "release-version.h"
|
||||
1 VERSIONINFO
|
||||
FILEVERSION ARENA_VERSION_NUMBERS
|
||||
PRODUCTVERSION ARENA_VERSION_NUMBERS
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "ProductName", "Arena Tracker"
|
||||
VALUE "FileVersion", ARENA_VERSION_TEXT
|
||||
VALUE "ProductVersion", ARENA_VERSION_TEXT
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 1200
|
||||
END
|
||||
END
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
mod champion_table;
|
||||
#[cfg(feature = "profile")]
|
||||
mod profile;
|
||||
mod release;
|
||||
mod settings;
|
||||
mod single_instance;
|
||||
mod stats_page;
|
||||
@@ -262,6 +263,7 @@ fn init_theme(cx: &mut App) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
release::handle_command();
|
||||
let Some(single_instance::Primary {
|
||||
instance: _instance,
|
||||
starting,
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
use std::fs::File;
|
||||
use std::io::{self, Read};
|
||||
use std::path::Path;
|
||||
|
||||
use base64::prelude::{BASE64_STANDARD, Engine};
|
||||
|
||||
/// The Windows installer invokes these fast callbacks and waits for the process to exit.
|
||||
/// The SDK's ordinary startup path opens cached packages even with auto-apply disabled.
|
||||
pub fn handle_command() {
|
||||
let mut args = std::env::args_os().skip(1);
|
||||
let Some(command) = args.next() else { return };
|
||||
match command.to_str() {
|
||||
Some(
|
||||
"--veloapp-install"
|
||||
| "--veloapp-updated"
|
||||
| "--veloapp-obsolete"
|
||||
| "--veloapp-uninstall",
|
||||
) => {
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some("--verify-release") => {
|
||||
let ok = args.next().is_some_and(|dir| {
|
||||
verify_release(Path::new(&dir))
|
||||
.inspect_err(|err| eprintln!("{err}"))
|
||||
.is_ok()
|
||||
});
|
||||
std::process::exit(if ok { 0 } else { 1 });
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn verify_release(dir: &Path) -> io::Result<()> {
|
||||
let missing = || io::Error::other("Executable built without release identity");
|
||||
let channel = option_env!("ARENA_RELEASE_CHANNEL").ok_or_else(missing)?;
|
||||
let version = option_env!("ARENA_RELEASE_VERSION").ok_or_else(missing)?;
|
||||
let key = BASE64_STANDARD
|
||||
.decode(option_env!("ARENA_RELEASE_PUBLIC_KEY").ok_or_else(missing)?)
|
||||
.map_err(io::Error::other)?;
|
||||
let mut manifest = Vec::new();
|
||||
File::open(dir.join(format!("release-{channel}.json")))?
|
||||
.take(4097)
|
||||
.read_to_end(&mut manifest)?;
|
||||
if manifest.len() > 4096 {
|
||||
return Err(io::Error::other("Oversized release manifest"));
|
||||
}
|
||||
let mut signature = Vec::new();
|
||||
File::open(dir.join(format!("release-{channel}.sig")))?
|
||||
.take(65)
|
||||
.read_to_end(&mut signature)?;
|
||||
let package = File::open(dir.join(format!("ArenaTracker-{version}-{channel}-full.nupkg")))?;
|
||||
let commit = arena_tracker_core::verify_update_package(
|
||||
&key, channel, version, &manifest, &signature, package,
|
||||
)?;
|
||||
if Some(commit.as_str()) != option_env!("ARENA_RELEASE_COMMIT") {
|
||||
return Err(io::Error::other("Unexpected release commit"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user