diff --git a/.github/scripts/test_update_manifest.py b/.github/scripts/test_update_manifest.py index a926408..0b70c02 100644 --- a/.github/scripts/test_update_manifest.py +++ b/.github/scripts/test_update_manifest.py @@ -6,7 +6,7 @@ class ManifestTest(unittest.TestCase): - def test_signed_assets_become_platforms_and_linux_stays_appimage_only(self): + def test_signed_assets_become_platforms_with_one_key_per_linux_format(self): with tempfile.TemporaryDirectory() as tmp: assets = Path(tmp) for name in [ @@ -15,17 +15,21 @@ def test_signed_assets_become_platforms_and_linux_stays_appimage_only(self): "LowMail-1.2.3-macos-universal.app.tar.gz", "LowMail-1.2.3-linux-x64.AppImage", "LowMail-1.2.3-linux-x64.deb", + "LowMail-1.2.3-linux-x64.rpm", + "LowMail-1.2.3-linux-x86_64.pkg.tar.zst", ]: (assets / name).write_bytes(b"x") - if not name.endswith(".deb"): + if not name.endswith(".zst"): (assets / f"{name}.sig").write_text(f"sig-{name}\n") doc = build_manifest("1.2.3", "LowBloat/LowMail", assets, "notes") self.assertEqual( sorted(doc["platforms"]), - ["darwin-aarch64", "darwin-x86_64", "linux-x86_64-appimage", - "windows-x86_64", "windows-x86_64-msi", "windows-x86_64-nsis"], + ["darwin-aarch64", "darwin-x86_64", "linux-x86_64-appimage", "linux-x86_64-deb", + "linux-x86_64-rpm", "windows-x86_64", "windows-x86_64-msi", "windows-x86_64-nsis"], ) self.assertNotIn("linux-x86_64", doc["platforms"]) + self.assertTrue(doc["platforms"]["linux-x86_64-deb"]["url"].endswith("/LowMail-1.2.3-linux-x64.deb")) + self.assertTrue(doc["platforms"]["linux-x86_64-rpm"]["url"].endswith("/LowMail-1.2.3-linux-x64.rpm")) self.assertEqual(doc["platforms"]["windows-x86_64-msi"]["signature"], "sig-LowMail-1.2.3-windows-x64.msi") self.assertTrue(doc["platforms"]["windows-x86_64"]["url"].endswith("/v1.2.3/LowMail-1.2.3-windows-x64-setup.exe")) diff --git a/.github/scripts/update_manifest.py b/.github/scripts/update_manifest.py index cabf8b8..2522e2f 100644 --- a/.github/scripts/update_manifest.py +++ b/.github/scripts/update_manifest.py @@ -21,8 +21,11 @@ def signed(keys, asset): signed(["windows-x86_64", "windows-x86_64-nsis"], f"LowMail-{version}-windows-x64-setup.exe") signed(["windows-x86_64-msi"], f"LowMail-{version}-windows-x64.msi") signed(["darwin-aarch64", "darwin-x86_64"], f"LowMail-{version}-macos-universal.app.tar.gz") - # No generic Linux key: .deb, .rpm and Arch installs must never receive an AppImage. + # One key per Linux format, never a generic one: a .deb install must get a + # .deb, an .rpm install an .rpm, and the Arch package nothing (pacman owns it). signed(["linux-x86_64-appimage"], f"LowMail-{version}-linux-x64.AppImage") + signed(["linux-x86_64-deb"], f"LowMail-{version}-linux-x64.deb") + signed(["linux-x86_64-rpm"], f"LowMail-{version}-linux-x64.rpm") return { "version": version, @@ -47,7 +50,7 @@ def signed(keys, asset): notes = result.stdout.strip() assets = Path("release-assets") doc = build_manifest(version, repo, assets, notes) - required = {"windows-x86_64", "darwin-aarch64", "linux-x86_64-appimage"} + required = {"windows-x86_64", "darwin-aarch64", "linux-x86_64-appimage", "linux-x86_64-deb", "linux-x86_64-rpm"} missing = required - doc["platforms"].keys() if missing: raise SystemExit(f"Signed updater artifacts missing for: {sorted(missing)}") diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c10d53f..57235af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -128,8 +128,14 @@ jobs: set -euo pipefail mkdir -p out bundle=target/release/bundle - cp "$(find $bundle/deb -name '*.deb' | head -n 1)" "out/LowMail-${VERSION}-linux-x64.deb" - cp "$(find $bundle/rpm -name '*.rpm' | head -n 1)" "out/LowMail-${VERSION}-linux-x64.rpm" + # Each package keeps its updater signature: .deb and .rpm installs + # update themselves through dpkg/rpm. + deb="$(find $bundle/deb -name '*.deb' | head -n 1)" + cp "$deb" "out/LowMail-${VERSION}-linux-x64.deb" + cp "$deb.sig" "out/LowMail-${VERSION}-linux-x64.deb.sig" + rpm="$(find $bundle/rpm -name '*.rpm' | head -n 1)" + cp "$rpm" "out/LowMail-${VERSION}-linux-x64.rpm" + cp "$rpm.sig" "out/LowMail-${VERSION}-linux-x64.rpm.sig" appimage="$(find $bundle/appimage -name '*.AppImage' | head -n 1)" cp "$appimage" "out/LowMail-${VERSION}-linux-x64.AppImage" cp "$appimage.sig" "out/LowMail-${VERSION}-linux-x64.AppImage.sig" diff --git a/Cargo.lock b/Cargo.lock index 4fd5e06..c55816b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2937,7 +2937,7 @@ checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" [[package]] name = "lowmail-core" -version = "0.2.1" +version = "0.2.2" dependencies = [ "ammonia", "anyhow", @@ -2970,7 +2970,7 @@ dependencies = [ [[package]] name = "lowmail-desktop" -version = "0.2.1" +version = "0.2.2" dependencies = [ "keyring", "lowmail-core", @@ -2997,7 +2997,7 @@ dependencies = [ [[package]] name = "lowmail-server" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "axum", @@ -3026,7 +3026,7 @@ dependencies = [ [[package]] name = "lowmail-testserver" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "async-imap", diff --git a/Cargo.toml b/Cargo.toml index a1c1bcb..06c6766 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "src-tauri"] default-members = ["crates/*"] [workspace.package] -version = "0.2.1" +version = "0.2.2" edition = "2024" rust-version = "1.95" license = "AGPL-3.0-only" diff --git a/README.md b/README.md index 14fa32a..8b28738 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ bun run tauri android build --apk # Android (needs the Android SDK and NDK) The first start asks for the e-mail address and password; LowMail tries the usual host names (`imap.`, `mail.`, `smtp.`, the domain and its MX hosts) and ports, keeps the first server whose certificate is valid, checks the sign-in on IMAP and SMTP, and lets you adjust everything under **Server settings**. Passwords go to the Windows Credential Manager, the macOS Keychain or the Secret Service on Linux; on Android, to the app's private storage. -Installed desktop copies (Windows installers, the macOS app, AppImage) update themselves from signed GitHub releases; packages and portable copies show when a new version exists. +Installed desktop copies (Windows installers, the macOS app, AppImage, .deb and .rpm) update themselves from signed GitHub releases: the update downloads in the background and a restart installs it (.deb and .rpm ask for the administrator password). The Arch package and portable copies show when a new version exists. ## How it works diff --git a/package.json b/package.json index 9603c05..dca947a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lowmail", - "version": "0.2.1", + "version": "0.2.2", "description": "LowMail: a light e-mail client for your own mail server, on the desktop and in the browser.", "homepage": "https://github.com/LowBloat/LowMail", "repository": { diff --git a/src-tauri/src/updates.rs b/src-tauri/src/updates.rs index 0c1551c..ee5a540 100644 --- a/src-tauri/src/updates.rs +++ b/src-tauri/src/updates.rs @@ -1,9 +1,11 @@ //! Update policy: which installations can update themselves. //! -//! Windows installers (NSIS/MSI), macOS app bundles and writable AppImages -//! download the signed update, install it and restart. Linux packages -//! (.deb/.rpm/Arch) belong to the system package manager and portable copies -//! have no installer, so they are only told a new version exists. +//! Windows installers (NSIS/MSI), macOS app bundles, writable AppImages and +//! .deb/.rpm installs download the signed update, install it and restart. For +//! .deb and .rpm the updater hands the new package to dpkg/rpm through pkexec, +//! which asks for the administrator password. The Arch package (pacman owns +//! it) and portable copies have no installer, so they are only told a new +//! version exists. use serde::Serialize; @@ -35,12 +37,19 @@ impl UpdatePolicy { target: Some(format!("linux-{}-appimage", std::env::consts::ARCH)), }; } - let channel = match bundle { - Some(BundleType::Deb) => "deb", - Some(BundleType::Rpm) => "rpm", - _ if std::env::current_exe().is_ok_and(|p| p.starts_with("/usr") || p.starts_with("/opt")) => "package", - _ => "portable", + let exe = std::env::current_exe().ok(); + // The updater picks dpkg or rpm from the bundle type built into the + // binary; only trust it when that package manager really owns this + // file (a binary copied into the Arch package keeps a marker too). + let package = match bundle { + Some(BundleType::Deb) if exe.as_deref().is_some_and(|p| owned_by(p, "dpkg-query", "-S")) => Some("deb"), + Some(BundleType::Rpm) if exe.as_deref().is_some_and(|p| owned_by(p, "rpm", "-qf")) => Some("rpm"), + _ => None, }; + if let Some(channel) = package { + return Self { channel, can_install: true, target: Some(format!("linux-{}-{channel}", std::env::consts::ARCH)) }; + } + let channel = if exe.is_some_and(|p| p.starts_with("/usr") || p.starts_with("/opt")) { "package" } else { "portable" }; return Self { channel, can_install: false, target: None }; } @@ -51,6 +60,17 @@ impl UpdatePolicy { } } +/// Whether `program` (dpkg-query -S, rpm -qf) names a package that installed `path`. +fn owned_by(path: &std::path::Path, program: &str, flag: &str) -> bool { + std::process::Command::new(program) + .arg(flag) + .arg(path) + .stdout(std::process::Stdio::null()) + .stderr(std::process::Stdio::null()) + .status() + .is_ok_and(|status| status.success()) +} + fn dir_is_writable(dir: &std::path::Path) -> bool { let probe = dir.join(format!(".lowmail-update-check-{}", std::process::id())); let ok = std::fs::write(&probe, b"").is_ok(); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index e3704a5..0cea649 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "LowMail", - "version": "0.2.1", + "version": "0.2.2", "identifier": "dev.lowbloat.lowmail", "build": { "beforeDevCommand": "bun run dev", diff --git a/src/lib/components/Shell.svelte b/src/lib/components/Shell.svelte index 8d95587..00e8e89 100644 --- a/src/lib/components/Shell.svelte +++ b/src/lib/components/Shell.svelte @@ -115,9 +115,9 @@ {/each}
- {#if updates.available} -{t("about.license")}
{#if updates.supported}