Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/scripts/test_update_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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"))

Expand Down
7 changes: 5 additions & 2 deletions .github/scripts/update_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)}")
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
38 changes: 29 additions & 9 deletions src-tauri/src/updates.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 };
}

Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/components/Shell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
</Tooltip>
{/each}
<div class="lm-spacer"></div>
{#if updates.available}
<Tooltip content={t("updates.available", { version: updates.available.version })} side="right">
<button type="button" class="lm-rail__item lm-rail__update" aria-label={t("updates.available", { version: updates.available.version })} onclick={() => (updates.dialogOpen = true)}>
{#if updates.offered}
<Tooltip content={updates.label} side="right">
<button type="button" class="lm-rail__item lm-rail__update" aria-label={updates.label} onclick={() => (updates.dialogOpen = true)}>
<ArrowUpCircle size={19} />
</button>
</Tooltip>
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/desktop/UpdateDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
<Alert severity="info">{updates.manualHint}</Alert>
{:else if compose.active && !updates.installing}
<Alert severity="warning">{t("updates.draftOpen")}</Alert>
{:else if updates.ready && !updates.installing}
<Alert severity="info">{t("updates.readyHint")}</Alert>
{/if}
{#if updates.installing}
<Progress
Expand All @@ -83,7 +85,7 @@
{#if updates.policy?.canInstall}
<Button variant="filled" loading={updates.installing} onclick={() => updates.install()}>
{#snippet leading()}<RefreshCw size={15} />{/snippet}
{t("updates.install")}
{updates.ready ? t("updates.restart") : t("updates.install")}
</Button>
{:else}
<Button variant="filled" onclick={() => updates.download()}>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/settings/SettingsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@
<p class="lm-hint">{t("about.license")}</p>
{#if updates.supported}
<div class="lm-about__update">
{#if updates.available}
<Button variant="filled" size="sm" onclick={() => (updates.dialogOpen = true)}>{t("updates.available", { version: updates.available.version })}</Button>
{#if updates.offered}
<Button variant="filled" size="sm" onclick={() => (updates.dialogOpen = true)}>{updates.label}</Button>
{:else}
<Button variant="outlined" size="sm" loading={updates.checking} onclick={() => updates.check(true)}>{t("updates.check")}</Button>
{/if}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,9 @@ export const en: Dict = {
"updates.later": "Later",
"updates.install": "Install and restart",
"updates.download": "Download",
"updates.manual.deb": "Installed from a .deb package: download the new package or update it with your package manager.",
"updates.manual.rpm": "Installed from an .rpm package: download the new package or update it with your package manager.",
"updates.ready": "Restart to update to {version}",
"updates.readyHint": "The update is downloaded and verified. Restarting installs it.",
"updates.restart": "Restart now",
"updates.manual.package": "Installed by the system package manager: update it there or download the new package.",
"updates.manual.appimage": "This AppImage is in a read-only folder: download the new AppImage to replace it.",
"updates.manual.portable": "Portable copy: download the new version and replace this one, or use the installer for automatic updates.",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/i18n/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,9 @@ export const pt: Dict = {
"updates.later": "Depois",
"updates.install": "Instalar e reiniciar",
"updates.download": "Baixar",
"updates.manual.deb": "Instalado por um pacote .deb: baixe o pacote novo ou atualize pelo gerenciador de pacotes.",
"updates.manual.rpm": "Instalado por um pacote .rpm: baixe o pacote novo ou atualize pelo gerenciador de pacotes.",
"updates.ready": "Reiniciar para atualizar para {version}",
"updates.readyHint": "A atualização já foi baixada e verificada. Ao reiniciar, ela é instalada.",
"updates.restart": "Reiniciar agora",
"updates.manual.package": "Instalado pelo gerenciador de pacotes do sistema: atualize por ele ou baixe o pacote novo.",
"updates.manual.appimage": "Este AppImage está numa pasta sem permissão de escrita: baixe o AppImage novo para substituí-lo.",
"updates.manual.portable": "Cópia portátil: baixe a versão nova e substitua esta, ou use o instalador para receber atualizações automáticas.",
Expand Down
Loading
Loading