LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.
C cdebiandesktop-environmentebpffirewalllandlocklinuxlinux-distributionopen-sourceprivacyquickjsraspberry-pi-5reactsecuritywaylandwayland-compositor
Store → Updates: update LordOS in place, with release notes and a restart notice
Federico Pereiraa1d0b53ef001
diff --git a/apps/store/debian.js b/apps/store/debian.jsindex 6465e07..d0c7c5f 100644--- a/apps/store/debian.js+++ b/apps/store/debian.js@@ -6,6 +6,7 @@ import { createElement as h, useEffect, useState } from 'react';import {View, Text, Image, Button, EmptyState, GroupBox, useTheme, useStore, createStore, admin, formatBytes, formatDate,refreshApps, launchApp, useLauncherApps, LetterIcon, typeScale, spacing, direction, t, locale, errorText, statusText,+ Markdown, Toggle, LordOSLogo, session, lordosUpdate, restartNeeded, updatePrefs, setUpdatePrefs,} from '@lordos/sdk';const available = () => typeof lord.pkg !== 'undefined';@@ -230,10 +231,72 @@ function Discover({ query }) {h(Grid, { items: list, onOpen: setOpen }));}-function Updates() {+// LordOS itself (docs/UPDATES.md): "LordOS <version> is available", its release notes and Update.+function LordOSCard({ up }) {const th = useTheme();const { job } = useStore(state);const [plan, setPlan] = useState(null);+ const [all, setAll] = useState(false);+ const isAdmin = admin.available();+ const notes = (up.notes || '').trim();+ const lines = notes.split('\n');+ const long = lines.length > 14;+ const confirm = () => {+ const extra = plan.items.some((i) => i.action === 'remove' && !i.requested);+ runJob('pkg-install', extra ? 'lordos --allow-remove' : 'lordos', t('store.system.updateJob', { version: up.version }));+ setPlan(null);+ };+ return h(View, { style: boxStyle(th, { gap: spacing.m }) },+ h(View, { style: { flexDirection: 'row', alignItems: 'center', gap: spacing.l } },+ h(LordOSLogo, { size: 56 }),+ h(View, { style: { flex: 1, minWidth: 0, gap: 2 } },+ h(Text, { style: { fontSize: typeScale.title, fontWeight: 600, color: th.text, textAlign: 'start' } }, t('store.system.available', { version: up.version })),+ h(Text, { style: { fontSize: typeScale.callout, color: th.textDim, textAlign: 'start' } },+ t('store.system.availableDetail', { installed: up.installed, size: formatBytes(up.size || 0) }))),+ h(Button, { primary: true, label: t('store.system.update'), disabled: !isAdmin || !!job,+ onClick: () => isAdmin && !job && setPlan(lord.pkg.plan({ install: ['lordos'] })) })),+ !isAdmin && h(Text, { style: { fontSize: typeScale.caption, color: '#ff9f0a', textAlign: 'start' } }, t('store.debian.needAdmin')),+ plan && h(View, { style: { gap: spacing.s } },+ h(PlanView, { plan }),+ h(Text, { style: { fontSize: typeScale.caption, color: th.textDim, lineHeight: 1.4, textAlign: 'start' } }, t('store.system.keepWorking')),+ h(View, { style: { flexDirection: 'row', gap: spacing.s, justifyContent: 'flex-end' } },+ h(Button, { label: t('store.cancel'), onClick: () => setPlan(null) }),+ plan.ok && h(Button, { primary: true, label: t('store.system.update'), onClick: confirm }))),+ notes ? h(View, { style: { gap: spacing.xs } },+ h(Hr, { th }),+ h(Text, { style: { fontSize: typeScale.body, fontWeight: 600, color: th.text, textAlign: 'start' } }, t('store.system.whatsNew')),+ h(Markdown, { source: all || !long ? notes : lines.slice(0, 14).join('\n') }),+ long ? h(Button, { plain: true, small: true, label: all ? t('store.system.less') : t('store.system.more'), onClick: () => setAll(!all), style: { alignSelf: 'flex-start' } }) : null)+ : h(Text, { style: { fontSize: typeScale.callout, color: th.textDim, textAlign: 'start' } }, t('store.system.noNotes')));+}++const Hr = ({ th }) => h(View, { style: { height: 1, backgroundColor: th.separator, marginVertical: spacing.xs } });++// "Restart required": an installed update takes effect after a restart. Never restarts on its own.+function RestartCard({ need }) {+ const th = useTheme();+ const [later, setLater] = useState(false);+ if (later) return null;+ const canRestart = typeof session.canPower === 'function' && session.canPower();+ const kernel = need.packages.some((p) => p.startsWith('linux-image'));+ const what = need.packages.includes('lordos') ? t('store.restart.lordos') : kernel ? t('store.restart.kernel') : t('store.restart.other');+ return h(View, { style: boxStyle(th, { flexDirection: 'row', alignItems: 'center', gap: spacing.l, borderColor: th.accent }) },+ h(View, { style: { width: 36, height: 36, borderRadius: 18, backgroundColor: th.accent, alignItems: 'center', justifyContent: 'center' } },+ h(Text, { style: { fontSize: 20, color: '#fff', lineHeight: 36 } }, '⟳')),+ h(View, { style: { flex: 1, minWidth: 0, gap: 2 } },+ h(Text, { style: { fontSize: typeScale.body, fontWeight: 600, color: th.text, textAlign: 'start' } }, t('store.restart.title')),+ h(Text, { style: { fontSize: typeScale.callout, color: th.textDim, lineHeight: 1.4, textAlign: 'start' } },+ `${what} ${canRestart ? t('store.restart.save') : t('store.restart.how')}`)),+ h(Button, { label: t('store.restart.later'), onClick: () => setLater(true) }),+ canRestart ? h(Button, { primary: true, label: t('store.restart.now'), onClick: () => session.restart() }) : null);+}++function Updates() {+ const th = useTheme();+ const { job, gen } = useStore(state);+ const [plan, setPlan] = useState(null);+ const [prefs, setPrefs] = useState(updatePrefs);+ void gen;if (!ready()) {return available()? h(EmptyState, { icon: h(StoreGlyph), title: t('store.debian.noIndexTitle'), hint: t('store.debian.noIndex'), style: { minHeight: 380 },@@ -241,12 +304,18 @@ function Updates() {: h(EmptyState, { mascot: 'confused', title: t('store.debian.unavailable'), style: { minHeight: 360 } });}const ups = lord.pkg.upgrades();+ const own = lordosUpdate(lang2());+ const others = ups.filter((u) => u.name !== 'lordos');+ const need = !job ? restartNeeded() : null;+ const auto = (on) => { setUpdatePrefs({ autoCheck: on }); setPrefs(updatePrefs()); };return h(View, { style: { gap: 12 } },- h(Progress),h(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 } },- h(Text, { style: { flex: 1, ...titleStyle(th) } }, t('store.updates.title')),- h(Button, { label: t('store.debian.update'), onClick: () => !job && runJob('pkg-update', '', t('store.job.update')) }),- ups.length ? h(Button, { primary: true, label: t('store.updates.all'), onClick: () => !job && setPlan(lord.pkg.plan({ upgrade: true })) }) : null),+ h(Text, { style: { flex: 1, ...titleStyle(th), textAlign: 'start' } }, t('store.updates.title')),+ h(Button, { label: t('store.debian.update'), disabled: !!job, onClick: () => !job && runJob('pkg-update', '', t('store.job.update')) }),+ ups.length ? h(Button, { primary: !own?.available, label: t('store.updates.all'), disabled: !!job,+ onClick: () => !job && setPlan(lord.pkg.plan({ upgrade: true })) }) : null),+ h(Progress),+ need ? h(RestartCard, { need }) : null,plan && h(View, { style: boxStyle(th) },h(PlanView, { plan }),h(View, { style: { flexDirection: 'row', gap: 8, justifyContent: 'flex-end', marginTop: 4 } },@@ -255,13 +324,23 @@ function Updates() {const extra = plan.items.some((i) => i.action === 'remove');runJob('pkg-upgrade', extra ? '--allow-remove' : '', t('store.job.upgrade')); setPlan(null);} }))),- ups.length === 0 ? h(EmptyState, { mascot: 'celebrate', title: t('store.updates.none'), style: { minHeight: 300 } }) : null,- ...ups.map((u) => h(View, { key: u.name, style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 8 } },- h(PkgIcon, { name: u.name, size: 32 }),+ own?.available ? h(LordOSCard, { up: own }) : null,+ own && !own.available && !ups.length ? h(Text, { style: { fontSize: typeScale.callout, color: th.textDim, textAlign: 'start' } },+ t('store.system.current', { version: own.installed })) : null,+ ups.length === 0 ? h(EmptyState, { mascot: 'celebrate', title: t('store.updates.none'), style: { minHeight: 260 } }) : null,+ others.length ? h(View, { style: { marginTop: spacing.s } },+ h(Header, { th }, t('store.updates.debian', { count: others.length })),+ h(GroupBox, null, ...others.map((u) => h(View, { key: u.name, style: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingVertical: 8 } },+ h(PkgIcon, { name: u.name, size: 32 }),+ h(View, { style: { flex: 1, minWidth: 0, gap: 2 } },+ h(Text, { style: { fontSize: 13, fontWeight: 600, color: th.text, textAlign: 'start' } }, u.name),+ h(Text, { style: { fontSize: 11, color: th.textDim, whiteSpace: 'nowrap', overflow: 'hidden', textAlign: 'start' } }, `${u.from} → ${u.to} · ${u.summary}`)),+ h(Text, { style: { fontSize: 11, color: th.textDim } }, formatBytes(u.size)))))) : null,+ h(View, { style: { flexDirection: 'row', alignItems: 'center', gap: spacing.m, marginTop: spacing.m, paddingHorizontal: spacing.xs } },h(View, { style: { flex: 1, minWidth: 0, gap: 2 } },- h(Text, { style: { fontSize: 13, fontWeight: 600, color: th.text } }, u.name),- h(Text, { style: { fontSize: 11, color: th.textDim, whiteSpace: 'nowrap', overflow: 'hidden' } }, `${u.from} → ${u.to} · ${u.summary}`)),- h(Text, { style: { fontSize: 11, color: th.textDim } }, formatBytes(u.size)))));+ h(Text, { style: { fontSize: typeScale.body, color: th.text, textAlign: 'start' } }, t('store.updates.auto')),+ h(Text, { style: { fontSize: typeScale.caption, color: th.textDim, lineHeight: 1.4, textAlign: 'start' } }, t('store.updates.autoHint'))),+ h(Toggle, { on: prefs.autoCheck, onChange: auto })));}// Sidebar footer: when the list was last checked.diff --git a/assets/locales/en/store.json b/assets/locales/en/store.jsonindex dddfef0..77d26b9 100644--- a/assets/locales/en/store.json+++ b/assets/locales/en/store.json@@ -116,5 +116,37 @@"info.size": "Size on disk","info.suite": "Distribution","info.homepage": "Website",- "debian.noneHint": "Try another word, or the name of the Debian package."+ "debian.noneHint": "Try another word, or the name of the Debian package.",+ "notify.title": {+ "one": "{count} update is available",+ "other": "{count} updates are available"+ },+ "notify.body": "Open the Store to see them and install them when you want.",+ "notify.lordosTitle": "LordOS {version} is available",+ "notify.lordosBody": "See what's new and update from the Store, without reinstalling.",+ "notify.open": "Open Updates",+ "restart.title": "Restart required",+ "restart.lordos": "The new version of LordOS is installed and is used after a restart.",+ "restart.kernel": "A new kernel is installed and is used after a restart.",+ "restart.other": "Some updates are used after a restart.",+ "restart.save": "Save your work first.",+ "restart.how": "Save your work, log out and choose Restart on the login screen.",+ "restart.later": "Later",+ "restart.now": "Restart Now…",+ "system.available": "LordOS {version} is available",+ "system.availableDetail": "You have {installed} · {size} to download",+ "system.update": "Update",+ "system.updateJob": "Updating LordOS to {version}",+ "system.keepWorking": "You can keep working while it updates. Your files and settings are kept; the new version starts after a restart.",+ "system.whatsNew": "What's new",+ "system.more": "Show all",+ "system.less": "Show less",+ "system.noNotes": "No release notes were published for this version.",+ "system.current": "LordOS {version} is up to date.",+ "updates.debian": {+ "one": "Debian updates ({count})",+ "other": "Debian updates ({count})"+ },+ "updates.auto": "Check for updates automatically",+ "updates.autoHint": "Once a day, and only to tell you. Nothing is installed without asking."}diff --git a/assets/locales/es/store.json b/assets/locales/es/store.jsonindex 16a7a0d..d84d6b8 100644--- a/assets/locales/es/store.json+++ b/assets/locales/es/store.json@@ -116,5 +116,37 @@"info.size": "Tamaño en disco","info.suite": "Distribución","info.homepage": "Sitio web",- "debian.noneHint": "Probá con otra palabra o con el nombre del paquete de Debian."+ "debian.noneHint": "Probá con otra palabra o con el nombre del paquete de Debian.",+ "notify.title": {+ "one": "Hay {count} actualización disponible",+ "other": "Hay {count} actualizaciones disponibles"+ },+ "notify.body": "Abrí la Tienda para verlas e instalarlas cuando quieras.",+ "notify.lordosTitle": "LordOS {version} está disponible",+ "notify.lordosBody": "Mirá las novedades y actualizá desde la Tienda, sin reinstalar.",+ "notify.open": "Abrir Actualizaciones",+ "restart.title": "Hay que reiniciar",+ "restart.lordos": "La nueva versión de LordOS está instalada y se usa después de reiniciar.",+ "restart.kernel": "Hay un kernel nuevo instalado y se usa después de reiniciar.",+ "restart.other": "Algunas actualizaciones se usan después de reiniciar.",+ "restart.save": "Guardá tu trabajo antes.",+ "restart.how": "Guardá tu trabajo, cerrá la sesión y elegí Reiniciar en la pantalla de inicio de sesión.",+ "restart.later": "Más tarde",+ "restart.now": "Reiniciar ahora…",+ "system.available": "LordOS {version} está disponible",+ "system.availableDetail": "Tenés la {installed} · {size} para descargar",+ "system.update": "Actualizar",+ "system.updateJob": "Actualizando LordOS a {version}",+ "system.keepWorking": "Podés seguir trabajando mientras se actualiza. Tus archivos y ajustes se conservan; la nueva versión arranca después de reiniciar.",+ "system.whatsNew": "Novedades",+ "system.more": "Ver todo",+ "system.less": "Ver menos",+ "system.noNotes": "No se publicaron notas para esta versión.",+ "system.current": "LordOS {version} está al día.",+ "updates.debian": {+ "one": "Actualizaciones de Debian ({count})",+ "other": "Actualizaciones de Debian ({count})"+ },+ "updates.auto": "Buscar actualizaciones automáticamente",+ "updates.autoHint": "Una vez por día, y solo para avisarte. No se instala nada sin preguntar."}diff --git a/assets/locales/pt/store.json b/assets/locales/pt/store.jsonindex ab61c25..a873f35 100644--- a/assets/locales/pt/store.json+++ b/assets/locales/pt/store.json@@ -116,5 +116,37 @@"info.size": "Tamanho em disco","info.suite": "Distribuição","info.homepage": "Site",- "debian.noneHint": "Tente outra palavra ou o nome do pacote do Debian."+ "debian.noneHint": "Tente outra palavra ou o nome do pacote do Debian.",+ "notify.title": {+ "one": "Há {count} atualização disponível",+ "other": "Há {count} atualizações disponíveis"+ },+ "notify.body": "Abra a Loja para vê-las e instalá-las quando quiser.",+ "notify.lordosTitle": "LordOS {version} está disponível",+ "notify.lordosBody": "Veja as novidades e atualize pela Loja, sem reinstalar.",+ "notify.open": "Abrir Atualizações",+ "restart.title": "É preciso reiniciar",+ "restart.lordos": "A nova versão do LordOS está instalada e passa a ser usada depois de reiniciar.",+ "restart.kernel": "Um kernel novo está instalado e passa a ser usado depois de reiniciar.",+ "restart.other": "Algumas atualizações passam a valer depois de reiniciar.",+ "restart.save": "Salve seu trabalho antes.",+ "restart.how": "Salve seu trabalho, encerre a sessão e escolha Reiniciar na tela de login.",+ "restart.later": "Mais tarde",+ "restart.now": "Reiniciar agora…",+ "system.available": "LordOS {version} está disponível",+ "system.availableDetail": "Você tem a {installed} · {size} para baixar",+ "system.update": "Atualizar",+ "system.updateJob": "Atualizando o LordOS para {version}",+ "system.keepWorking": "Você pode continuar trabalhando enquanto atualiza. Seus arquivos e ajustes são mantidos; a nova versão começa depois de reiniciar.",+ "system.whatsNew": "Novidades",+ "system.more": "Ver tudo",+ "system.less": "Ver menos",+ "system.noNotes": "Nenhuma nota foi publicada para esta versão.",+ "system.current": "O LordOS {version} está em dia.",+ "updates.debian": {+ "one": "Atualizações do Debian ({count})",+ "other": "Atualizações do Debian ({count})"+ },+ "updates.auto": "Procurar atualizações automaticamente",+ "updates.autoHint": "Uma vez por dia, e só para avisar. Nada é instalado sem perguntar."}diff --git a/sdk/index.js b/sdk/index.jsindex 7e3d444..8827657 100644--- a/sdk/index.js+++ b/sdk/index.js@@ -89,6 +89,7 @@ export {export { media, useMedia, usePlayer, nowPlaying, useNowPlaying, NowPlayingTile, mediaFormatTime, thumbFor, useThumb, userDirs } from './media.js';export { disks, useDisks } from './disks.js';export { backup, useBackup, backupStatus } from './backup.js'; // Backups (docs/SYSTEM.md)+export { lordosUpdate, restartNeeded, updatePrefs, setUpdatePrefs, UPDATE_DEFAULTS } from './updates.js'; // updating LordOS in place (docs/UPDATES.md)export { vaultAvailable, vaultRequest, onVaultEvent, keyring, autofill, autofillReveal, KeyringPrompt, AutofillButton } from './vault.js'; // Passwords and keyring (docs/PASSWORDS.md)import { KeyringPrompt } from './vault.js';// Mail, Calendar, Contacts and Reminders through the sandboxed helper lord-maild (docs/MAIL.md)diff --git a/sdk/settings.js b/sdk/settings.jsindex f7782e6..3ff6496 100644--- a/sdk/settings.js+++ b/sdk/settings.js@@ -15,10 +15,24 @@ const DEFAULTS = {theme: null, // id of the chosen theme (folder in themes/)};+// Per-user settings migrations (docs/UPDATES.md, "Migrations"): when an update changes the shape or+// meaning of a setting, it appends [schema, (settings) => newSettings] here. Each runs once per user,+// in order, when the session loads the file; "schema" records the last one applied. The system-wide+// migrations (as root) are the lordos package's (packaging/migrations).+export const SETTINGS_SCHEMA = 1;+const MIGRATIONS = [+ [1, (s) => s], // 0.8.1: the schema number starts being recorded; nothing changes+];+export function migrateSettings(s) {+ let out = s;+ for (const [to, fn] of MIGRATIONS) if ((out.schema || 0) < to) out = { ...fn(out), schema: to };+ return out;+}+function load() {try {const txt = lord.settings.load();- return txt ? { ...DEFAULTS, ...JSON.parse(txt) } : { ...DEFAULTS };+ return txt ? migrateSettings({ ...DEFAULTS, ...JSON.parse(txt) }) : { ...DEFAULTS, schema: SETTINGS_SCHEMA };} catch (e) {console.warn('unreadable settings, using the defaults:', e);return { ...DEFAULTS };diff --git a/sdk/updates.js b/sdk/updates.jsnew file mode 100644index 0000000..a85acde--- /dev/null+++ b/sdk/updates.js@@ -0,0 +1,95 @@+// updates.js — updating LordOS in place (docs/UPDATES.md).+//+// lordosUpdate(lang) { installed, version, available, size, notes } of the lordos package, or null+// restartNeeded() null, or { packages: [...] } when an installed update needs a restart+// updatePrefs() { autoCheck } (settings.json "updates"); setUpdatePrefs({ autoCheck })+//+// The packages come from the signed LordOS repository on lordos.org (and Debian's), through our own+// package engine (lord.pkg, admin.run('pkg-update' | 'pkg-install' | 'pkg-upgrade')). The optional+// daily check only downloads the signed lists and notifies; it never installs anything.+import { settings } from './settings.js';+import { admin } from './admin.js';+import { notify } from './notify.js';+import { t } from './i18n.js';+import { wm } from './windows.js';+import { lordosVersion } from './system.js';++const has = () => typeof lord !== 'undefined' && !!lord.pkg && typeof lord.pkg.rebootRequired === 'function';++export const UPDATE_DEFAULTS = { autoCheck: true, notified: '' };+export const updatePrefs = (s = settings.get()) => ({ ...UPDATE_DEFAULTS, ...(s.updates || {}) });+export function setUpdatePrefs(patch) {+ settings.set((s) => ({ ...s, updates: { ...updatePrefs(s), ...patch } }));+}++// The lordos package: what is installed, the newest version offered and its release notes.+export function lordosUpdate(lang) {+ if (!has() || !lord.pkg.available()) return null;+ const info = lord.pkg.info('lordos', { lang });+ if (!info || !info.installed) return null;+ const offered = (info.versions || []).find((v) => v.version === info.version);+ return {+ installed: info.installed,+ version: info.version,+ available: !!info.upgradable,+ size: offered ? offered.size : info.size,+ notes: info.upgradable ? lord.pkg.releaseNotes('lordos', info.version) : null,+ };+}++// A restart is needed when a package asked for one (/run/reboot-required: a new kernel, or the+// lordos postinst) or when the installed LordOS is not the one running in this session.+export function restartNeeded() {+ if (!has()) return null;+ const asked = lord.pkg.rebootRequired() || null;+ let changed = false;+ if (lord.pkg.available()) {+ const installed = lord.pkg.info('lordos')?.installed;+ const running = lordosVersion().version;+ changed = !!installed && !!running && installed !== running;+ }+ if (!asked && !changed) return null;+ const packages = [...new Set([...(asked || []), ...(changed ? ['lordos'] : [])])];+ return { packages };+}++// ---- the daily check (on by default, Store → Updates turns it off) ----++const DAY = 24 * 3600;+// A short fingerprint of what can be upgraded, to notify once per new set of updates.+function fingerprint(ups) {+ let h = 5381;+ for (const s of ups.map((u) => `${u.name}=${u.to}`).sort().join(',')) h = ((h * 33) ^ s.charCodeAt(0)) >>> 0;+ return ups.length ? `${ups.length}:${h.toString(36)}` : '';+}++function maybeNotify() {+ const ups = lord.pkg.upgrades();+ const key = fingerprint(ups);+ if (!key || key === updatePrefs().notified) return;+ setUpdatePrefs({ notified: key });+ const own = ups.find((u) => u.name === 'lordos');+ const open = [{ id: 'open', label: t('store.notify.open'), run: () => wm.open('store', { args: { page: 'updates' } }) }];+ notify({+ app: 'store',+ title: own ? t('store.notify.lordosTitle', { version: own.to }) : t('store.notify.title', { count: ups.length }),+ body: own ? t('store.notify.lordosBody') : t('store.notify.body'),+ actions: open,+ });+}++let checking = false;+function check() {+ if (checking || !updatePrefs().autoCheck || !admin.available()) return;+ const last = lord.pkg.available() ? lord.pkg.lastUpdate() : 0;+ if (Date.now() / 1000 - last < DAY - 600) return;+ checking = true;+ admin.run('pkg-update', '', null, { quiet: true })+ .then(maybeNotify, () => { /* offline or busy: the next hour tries again */ })+ .finally(() => { checking = false; });+}++// Only in a user's desktop session (not the login screen or an isolated app's process).+if (has() && typeof lord.admin !== 'undefined' && typeof lord.greeter === 'undefined') {+ setTimeout(() => { check(); setInterval(check, 3600 * 1000); }, 5 * 60 * 1000);+}