Skip to content

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.

APT repository for in-place updates: archive key, sources file, tools/release/apt-repo.sh

Federico Pereira059d2008aed4
diff --git a/packaging/apt/lordos.sources b/packaging/apt/lordos.sources
new file mode 100644
index 0000000..4ac7e3e
--- /dev/null
+++ b/packaging/apt/lordos.sources
@@ -0,0 +1,8 @@
+# LordOS updates: the signed LordOS package repository (docs/UPDATES.md).
+# Store → Updates and apt both read this file. The lordos package adds it when it is missing
+# and removes it with the package; to stop LordOS updates, add the line "Enabled: no".
+Types: deb
+URIs: https://lordos.org/apt
+Suites: stable
+Components: main
+Signed-By: /usr/share/keyrings/lordos-archive-keyring.gpg
diff --git a/packaging/keys/lordos-archive-keyring.asc b/packaging/keys/lordos-archive-keyring.asc
new file mode 100644
index 0000000..c351a20
--- /dev/null
+++ b/packaging/keys/lordos-archive-keyring.asc
@@ -0,0 +1,10 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mDMEatV5EhYJKwYBBAHaRw8BAQdA2+gqY+hPSvtQcbKutH+pRlr9EIWAbV6fRnFY
+H+KvL320MUxvcmRPUyBBcmNoaXZlIFNpZ25pbmcgS2V5IDxsb3JkLmJhc2V4QGdt
+YWlsLmNvbT6ItQQTFgoAXRYhBB3a85AQffJk+ooJGDlyzG3k2iM2BQJq1XkSGxSA
+AAAAAAQADm1hbnUyLDIuNSsxLjEyLDAsMwIbAwUJCWYBgAULCQgHAgIiAgYVCgkI
+CwIEFgIDAQIeBwIXgAAKCRA5csxt5NojNlNsAP9Nme0bDTzfVjHBVu/TQVYrKHwV
+sImXUkOPBA6ikqgHVwEAjoIVACcWwTxt0zkDem/LPqLcc+r79DCyPeRGUBRWiwE=
+=gjXh
+-----END PGP PUBLIC KEY BLOCK-----
diff --git a/packaging/keys/lordos-archive-keyring.gpg b/packaging/keys/lordos-archive-keyring.gpg
new file mode 100644
index 0000000..c883c16
Binary files /dev/null and b/packaging/keys/lordos-archive-keyring.gpg differ
diff --git a/server/Makefile b/server/Makefile
index bdfd7fd..832ff4f 100644
--- a/server/Makefile
+++ b/server/Makefile
@@ -54,7 +54,7 @@ MEDIA_SRC := src/media/media.c src/media/mview.c src/media/capture.c src/media/a
SEC_SRC := src/sec/json.c src/sec/sign.c src/sec/pkgstate.c src/sec/perms.c src/sec/cgroup.c src/sec/sandbox.c src/sec/brokersrv.c src/sec/brokercam.c src/sec/brokerkr.c src/sec/restrict.c src/sec/appid.c src/sec/pwguard.c
# App mode: lord-server --app <id> runs an .lpk app as an isolated Wayland client (src/app)
APP_SRC := src/app/appclient.c src/app/appspawn.c src/ui/js_broker.c src/ui/js_brokercam.c
-SRC := src/main.c src/kms.c src/gpu/gpu.c src/input.c src/canvas.c src/admin.c src/install/install.c src/apps.c src/lpk.c src/fsops.c src/remote/mirror.c src/remote/remote_admin.c src/remote/ssh_admin.c src/users/users_admin.c src/users/homedirs.c src/keyboard.c src/ime.c src/wl/wl.c \
+SRC := src/main.c src/kms.c src/gpu/gpu.c src/input.c src/canvas.c src/admin.c src/install/install.c src/apps.c src/lpk.c src/fsops.c src/remote/mirror.c src/remote/remote_admin.c src/remote/ssh_admin.c src/users/users_admin.c src/users/homedirs.c src/keyboard.c src/keylag.c src/ime.c src/wl/wl.c \
src/ui/node.c src/ui/style.c src/ui/layout.c src/ui/transform.c src/ui/text.c src/ui/image.c \
src/ui/paint.c src/ui/js.c src/ui/js_sys.c src/ui/js_term.c src/ui/js_wasm.c src/wasm/wasm.c src/wasm/wasm_run.c src/ui/js_sound.c src/ui/js_net.c src/sound/snd.c src/sound/pulse.c src/ui/otf.c src/ui/fonts.c \
src/ui/unicode.c src/ui/bidi.c src/ui/shape.c src/ui/shape_indic.c src/ui/shape_syl.c src/ui/shape_khmer.c src/ui/shape_myanmar.c src/ui/shape_use.c src/ui/thbrk.c src/ui/textlayout.c \
diff --git a/server/src/keylag.c b/server/src/keylag.c
new file mode 100644
index 0000000..36ca080
--- /dev/null
+++ b/server/src/keylag.c
@@ -0,0 +1,151 @@
+/* keylag.c — key latency trace, see keylag.h (privacy rules there) and docs/TROUBLESHOOTING.md. */
+#include "keylag.h"
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+int keylag_enabled;
+
+#define KL_MAX 32
+#define KL_GIVE_UP_MS 2000.0 /* a stage that never came: printed with -1 */
+#define KL_WINDOW_MS 120000.0 /* stops by itself this long after the first traced key */
+#define KL_MAX_LINES 4000
+
+typedef struct {
+ unsigned n;
+ int press;
+ double ev, rx, sent, flush, commit, rendered; /* CLOCK_MONOTONIC ms; 0 = not yet */
+} Key;
+
+static Key keys[KL_MAX];
+static int nkeys;
+static Key pending; /* the key being dispatched (not counted yet) */
+static int has_pending;
+static unsigned seq, lines;
+static double started;
+static FILE *out;
+
+static double mono_ms(void) {
+ struct timespec t;
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ return t.tv_sec * 1e3 + t.tv_nsec / 1e6;
+}
+
+void keylag_init(int greeter) {
+ const char *e = getenv("LORD_INPUT_DEBUG");
+ keylag_enabled = !greeter && e && !strcmp(e, "1");
+ if (keylag_enabled) fprintf(stderr, "keylag: key latency trace on (LORD_INPUT_DEBUG=1), in $XDG_RUNTIME_DIR/lordos-keylag.log\n");
+}
+
+static void stop(const char *why) {
+ keylag_enabled = 0;
+ nkeys = 0;
+ has_pending = 0;
+ if (out) { fprintf(out, "keylag stop: %s\n", why); fclose(out); out = NULL; }
+ fprintf(stderr, "keylag: trace stopped (%s)\n", why);
+}
+
+/* The trace file, created on the first traced key: only in the session's runtime folder, 0600. */
+static int open_out(void) {
+ if (out) return 0;
+ const char *rt = getenv("XDG_RUNTIME_DIR");
+ char path[512];
+ if (!rt || rt[0] != '/' || snprintf(path, sizeof path, "%s/lordos-keylag.log", rt) >= (int)sizeof path) return -1;
+ unlink(path); /* a trace left by an earlier session of this user */
+ int fd = open(path, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, 0600);
+ if (fd < 0) return -1;
+ if (!(out = fdopen(fd, "w"))) { close(fd); return -1; }
+ setvbuf(out, NULL, _IOLBF, 0);
+ fprintf(out, "keylag start: times in ms after the kernel's evdev timestamp\n");
+ return 0;
+}
+
+static double rel(double t, double ev) { return t > 0 ? t - ev : -1; }
+
+static void print_key(const Key *k, double shown) {
+ if (!out) return;
+ fprintf(out, "keylag n=%u ev=%.3f %s rx=%.2f sent=%.2f flush=%.2f commit=%.2f shown=%.2f\n", k->n, k->ev,
+ k->press ? "press" : "release", rel(k->rx, k->ev), rel(k->sent, k->ev), rel(k->flush, k->ev),
+ rel(k->commit, k->ev), rel(shown, k->ev));
+ if (++lines >= KL_MAX_LINES) stop("line limit");
+}
+
+static void drop_first(void) {
+ memmove(keys, keys + 1, sizeof(Key) * (size_t)(nkeys - 1));
+ nkeys--;
+}
+
+/* Keys that have waited too long for a stage are printed as they are; the window closes. */
+static void expire(double now) {
+ while (keylag_enabled && nkeys && now - keys[0].ev > KL_GIVE_UP_MS) {
+ print_key(&keys[0], 0);
+ if (keylag_enabled) drop_first();
+ }
+ if (keylag_enabled && started && now - started > KL_WINDOW_MS) stop("120 s window over");
+}
+
+void keylag_rx(int value, const struct timeval *tv) {
+ has_pending = 0;
+ if (!keylag_enabled || value == 2) return; /* autorepeat: the apps repeat on their own */
+ double now = mono_ms();
+ struct timespec real;
+ clock_gettime(CLOCK_REALTIME, &real);
+ /* evdev stamps with CLOCK_REALTIME (the default clock id): moved to the monotonic clock */
+ double real_ms = real.tv_sec * 1e3 + real.tv_nsec / 1e6, ev_ms = tv->tv_sec * 1e3 + tv->tv_usec / 1e3;
+ pending = (Key){ .press = value == 1, .ev = now - (real_ms - ev_ms), .rx = now };
+ has_pending = 1;
+}
+
+void keylag_sent_wl(int traceable) {
+ if (!keylag_enabled || !has_pending) return;
+ has_pending = 0;
+ if (!traceable) return; /* protected: not traced and not counted */
+ double now = mono_ms();
+ expire(now);
+ if (!keylag_enabled || open_out()) { if (keylag_enabled) stop("cannot create the trace file"); return; }
+ if (!started) started = now;
+ if (nkeys == KL_MAX) { print_key(&keys[0], 0); if (!keylag_enabled) return; drop_first(); }
+ pending.n = ++seq;
+ pending.sent = now;
+ keys[nkeys++] = pending;
+}
+
+void keylag_handled(void) { has_pending = 0; } /* not sent to an app: LordOS's own, never traced */
+
+void keylag_flushed(void) {
+ if (!keylag_enabled) return;
+ double now = 0;
+ for (int i = 0; i < nkeys; i++)
+ if (!keys[i].flush) keys[i].flush = now ? now : (now = mono_ms());
+}
+
+void keylag_commit(void) {
+ if (!keylag_enabled) return;
+ double now = 0;
+ for (int i = 0; i < nkeys; i++)
+ if (keys[i].flush && !keys[i].commit) keys[i].commit = now ? now : (now = mono_ms());
+}
+
+void keylag_render(void) {
+ if (!keylag_enabled) return;
+ double now = 0;
+ for (int i = 0; i < nkeys; i++)
+ if (!keys[i].rendered && keys[i].commit) keys[i].rendered = now ? now : (now = mono_ms());
+}
+
+void keylag_presented(uint64_t flip_ns) {
+ if (!keylag_enabled) return;
+ double shown = flip_ns ? flip_ns / 1e6 : mono_ms();
+ int kept = 0;
+ for (int i = 0; i < nkeys && keylag_enabled; i++) {
+ if (keys[i].rendered) print_key(&keys[i], shown);
+ else keys[kept++] = keys[i];
+ }
+ if (!keylag_enabled) return;
+ nkeys = kept;
+ expire(mono_ms());
+}
diff --git a/server/src/keylag.h b/server/src/keylag.h
new file mode 100644
index 0000000..b8497ee
--- /dev/null
+++ b/server/src/keylag.h
@@ -0,0 +1,41 @@
+/* keylag.h — key latency trace (docs/TROUBLESHOOTING.md, "Typing feels slow").
+ *
+ * Off by default and free when off (one branch per key). It only turns on when lord-server starts
+ * with LORD_INPUT_DEBUG=1, which lord-sessiond passes to user sessions (never the login screen)
+ * only when the kernel command line has lordos.inputdebug=1 or its own service sets
+ * LORD_INPUT_DEBUG=1: root decides, for one boot. There is no run-time switch.
+ *
+ * Privacy: it is a timing trace, not a key log. No key code, character or modifier is ever written:
+ * only an opaque sequence number and press/release. Only keys handed to a Linux (Wayland) app are
+ * traced, never keys that go to LordOS itself (the theme, its text fields, the Terminal, the
+ * Passwords app, keyring and admin prompts), to an isolated LordOS app, or to a protected window;
+ * those are skipped without being counted. The trace goes to its own file,
+ * $XDG_RUNTIME_DIR/lordos-keylag.log (0600, tmpfs, gone at logout), never to the session log, and
+ * stops by itself 120 s after the first traced key or after 4000 lines.
+ *
+ * One line per traced key, times in ms after the kernel's evdev timestamp (ev, CLOCK_MONOTONIC ms):
+ *
+ * keylag n=12 ev=81234.567 press rx=0.08 sent=0.10 flush=0.31 commit=6.20 shown=16.90
+ *
+ * rx: lord-server read it; sent: wl_keyboard.key queued for the focused app; flush: written to
+ * the app's socket; commit: the app's next commit after that (its reaction: the glyph, or simply
+ * its next frame if it is animating); shown: the page flip with that content finished. -1 = the
+ * stage did not happen (no flip yet, an app that drew nothing). */
+#ifndef LORD_KEYLAG_H
+#define LORD_KEYLAG_H
+
+#include <stdint.h>
+#include <sys/time.h>
+
+extern int keylag_enabled;
+
+void keylag_init(int greeter); /* reads LORD_INPUT_DEBUG once, at start */
+void keylag_rx(int value, const struct timeval *ev_time); /* main.c: a key (not kept unless sent below) */
+void keylag_sent_wl(int traceable); /* wl.c: wl_keyboard.key queued; 0 = protected, skip it */
+void keylag_handled(void); /* main.c: js_key returned; a key not sent to an app is dropped */
+void keylag_flushed(void); /* wl.c: wl_display_flush_clients */
+void keylag_commit(void); /* wl.c: the focused app committed */
+void keylag_render(void); /* main.c: a frame is being composed */
+void keylag_presented(uint64_t flip_ns); /* main.c: the flip finished (CLOCK_MONOTONIC ns) */
+
+#endif
diff --git a/server/src/main.c b/server/src/main.c
index f9144d3..cb1502f 100644
--- a/server/src/main.c
+++ b/server/src/main.c
@@ -16,6 +16,7 @@
* recuperan en el próximo arranque; las dos primeras formas los cierran.
*/
#include "admin.h"
+#include "keylag.h"
#include "net/net.h"
#include "disk/disk.h"
#include "backup/backup.h"
@@ -102,6 +103,7 @@ typedef struct {
Rect stale[2], curs[2];
int full_copy, was_fs;
int gpu; /* its GPU output (gpu_frame), -1 = composed by the CPU */
+ int wl_new; /* GPU path: a Linux app's window has new content not presented here yet */
} Out;
typedef struct {
@@ -532,6 +534,7 @@ static void cpu_takeover(Server *s) {
o->kms.custom = 0;
o->gpu = -1;
o->full_copy = 2;
+ o->wl_new = 0;
}
s->hw_cursor = 0;
}
@@ -850,7 +853,11 @@ static void on_input(void *ud, const InputDevice *d, const struct input_event *e
int button = ev->code == BTN_LEFT ? 0 : ev->code == BTN_MIDDLE ? 1 : ev->code == BTN_RIGHT ? 2 : -1;
if (button >= 0 && ev->value != 2 && s->nbuttons < MAX_BUTTONS)
s->buttons[s->nbuttons++] = (ButtonEvent){ ev->value == 1, button };
- else if (ev->code < BTN_MISC) js_key(ev->code, ev->value);
+ else if (ev->code < BTN_MISC) {
+ if (keylag_enabled) keylag_rx(ev->value, &ev->time);
+ js_key(ev->code, ev->value);
+ if (keylag_enabled) keylag_handled();
+ }
break;
}
case EV_SYN:
@@ -1219,7 +1226,7 @@ static void present_memory(Server *s, Out *o, int index, int feed) {
/* Does this display have something to show? (damage, a moved cursor on it, a fullscreen app) */
static int out_needs(const Server *s, const Out *o) {
if (!o->on) return 0;
- if (o->full || !box_empty(o->pend)) return 1;
+ if (o->full || !box_empty(o->pend) || o->wl_new) return 1;
if (!o->cdirty) return 0;
if (o->cur_on) return 1;
ORect me = { o->v.x, o->v.y, o->v.w, o->v.h };
@@ -1234,6 +1241,13 @@ static void render_frame(Server *s) {
double t0 = now_ms();
ui.layout_ms = ui.paint_ms = 0;
ui.damage_px = 0;
+ if (keylag_enabled) keylag_render();
+ /* GPU path: a Linux app's new frame is only a texture (wl.c damage_node), not UI damage. Every
+ * GPU display must still present it: before 0.8.1 nothing was flipped until some other part of
+ * the screen changed (the clock, the cursor...), so typing in Chromium or Firefox showed up to a
+ * second late and Chromium logged "buggy presentation feedback" (docs/TROUBLESHOOTING.md). */
+ if (wl_wants_frame() && gpu_active())
+ for (int i = 0; i < OUT_MAX; i++) if (s->out[i].on && s->out[i].gpu >= 0) s->out[i].wl_new = 1;
paint_ui(s);
s->last_render = now_ms();
if (s->cursor_dirty) {
@@ -1252,7 +1266,8 @@ static void render_frame(Server *s) {
full_damage(s);
paint_ui(s);
}
- Out *feed = feed_out(s);
+ Out *feed = feed_out(s), *mo = main_out(s);
+ int main_shown = 0; /* the main display got this frame */
if (s->headless) {
Out *o = &s->out[0];
paint_out(s, o, 0, 1);
@@ -1273,6 +1288,7 @@ static void render_frame(Server *s) {
view_reset();
gpu_out = NULL;
o->cdirty = 0;
+ o->wl_new = 0;
if (failed) {
fprintf(stderr, "gpu: a frame failed; going on by CPU\n");
gpu_shutdown();
@@ -1280,6 +1296,7 @@ static void render_frame(Server *s) {
full_damage(s);
}
} else present_cpu(s, o, i, r, o == feed);
+ if (o == mo) main_shown = 1;
}
/* every display in one frame for the remote desktop and recording (capture view) */
Out *c = &s->cap;
@@ -1298,6 +1315,16 @@ static void render_frame(Server *s) {
}
s->frames++;
wl_frame_done((unsigned)now_ms());
+ /* No flip event will come (a modeset instead of a page flip: the first frame, or a driver
+ * without page flip): the frame is on screen already, so its presentation feedback goes now.
+ * Otherwise the apps' feedback would wait for some later flip. */
+ if (main_shown && !s->headless && !mo->kms.flip_pending) {
+ struct timespec t;
+ clock_gettime(CLOCK_MONOTONIC, &t);
+ uint64_t ns = (uint64_t)t.tv_sec * 1000000000ull + (uint64_t)t.tv_nsec;
+ wl_presented(ns, mo->kms.flip_seq, mo->kms.mode.vrefresh ? 1000000000u / mo->kms.mode.vrefresh : 16666667u);
+ if (keylag_enabled) keylag_presented(ns);
+ }
frame_stats(s, now_ms() - t0, ui.layout_ms + ui.paint_ms);
}
@@ -1492,6 +1519,7 @@ int main(int argc, char **argv) {
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
sigprocmask(SIG_BLOCK, &mask, NULL);
+ keylag_init(s.greeter); /* key latency trace, only with LORD_INPUT_DEBUG=1 (keylag.h) */
int sfd = signalfd(-1, &mask, SFD_CLOEXEC);
char current[sizeof ui.theme_request];
@@ -1534,6 +1562,16 @@ int main(int argc, char **argv) {
/* sin monitor y sin nadie mirando no se dibuja (al conectarse alguien llega un cuadro entero) */
int unseen = s.headless && !mirror_clients() && !media_needs_cpu(); /* grabando la pantalla, sí */
if (!s.headless && display_is_off()) unseen = 1; /* screen off after idle (DPMS): nothing to draw */
+ /* nothing is drawn: the Linux apps waiting for a frame get it at most once a second (wl.c) */
+ if (unseen) {
+ static double unseen_tick;
+ double since = now_ms() - unseen_tick;
+ if (since >= 1000) { wl_frame_unseen((unsigned)now_ms()); unseen_tick = now_ms(); since = 0; }
+ if (wl_wants_frame() || ui.dirty) {
+ double left = 1000 - since;
+ if (delay < 0 || left < delay) delay = left;
+ }
+ }
int wants = !unseen && (ui.dirty || s.cursor_dirty || js_wants_frame() || wl_wants_frame() || media_wants_frame() || outs_have_work(&s));
/* sin monitor no hay vblank: a lo sumo 60 cuadros por segundo */
double pace = s.headless ? s.last_render + 16.6 - now_ms() : 0;
@@ -1591,8 +1629,10 @@ int main(int argc, char **argv) {
for (int i = 0; i < OUT_MAX; i++) if (s.out[i].on && s.out[i].kms.fd >= 0) heads[nh++] = &s.out[i].kms;
if (nh) kms_dispatch_heads(heads, nh);
/* wp_presentation follows the main display's vblank */
- if (was && !mk->flip_pending)
+ if (was && !mk->flip_pending) {
wl_presented(mk->flip_ns, mk->flip_seq, mk->mode.vrefresh ? 1000000000u / mk->mode.vrefresh : 16666667u);
+ if (keylag_enabled) keylag_presented(mk->flip_ns);
+ }
}
if (pfd[1].revents & POLLIN) break;
int lost[INPUT_MAX_DEVICES], nlost = 0;
diff --git a/server/src/remote/sess.c b/server/src/remote/sess.c
index 30459e4..7615af0 100644
--- a/server/src/remote/sess.c
+++ b/server/src/remote/sess.c
@@ -30,6 +30,7 @@
static char log_prefix[96] = "lord-sessiond";
char sd_gpu_env[24];
+int sd_input_debug;
void sd_log_prefix(const char *prefix) { snprintf(log_prefix, sizeof log_prefix, "%s", prefix); }
@@ -258,6 +259,7 @@ static void spawn(const struct passwd *pw, const char *rt, const char *lang, int
env[ne++] = home;
env[ne++] = "LORDOS_SESSIOND=1";
if (sd_gpu_env[0]) env[ne++] = sd_gpu_env;
+ if (sd_input_debug && !greeter) env[ne++] = "LORD_INPUT_DEBUG=1"; /* key latency trace, never the login screen */
env[ne] = NULL;
if (!greeter) cgroup_delegate_session(uid, pw->pw_gid); /* cgroup subtree for the apps (docs/SESSIONS.md) */
const char *const a_user[] = { rd_conf.server, "--headless", size, "--user", user, "--theme", rd_conf.theme,
diff --git a/server/src/remote/sessiond.c b/server/src/remote/sessiond.c
index 3f68b3d..b7a28cf 100644
--- a/server/src/remote/sessiond.c
+++ b/server/src/remote/sessiond.c
@@ -886,6 +886,13 @@ int main(int argc, char **argv) {
const char *g = getenv("LORD_GPU");
if (strstr(cmd, "lordos.gpu=0")) snprintf(sd_gpu_env, sizeof sd_gpu_env, "LORD_GPU=0");
else if (g && (!strcmp(g, "0") || !strcmp(g, "1"))) snprintf(sd_gpu_env, sizeof sd_gpu_env, "LORD_GPU=%s", g);
+ /* key latency trace for this boot (docs/TROUBLESHOOTING.md): only root can ask for it, from the
+ * boot menu or the service; timings only, see keylag.h */
+ const char *k = getenv("LORD_INPUT_DEBUG");
+ for (const char *p = cmd; (p = strstr(p, "lordos.inputdebug=1")) != NULL; p++)
+ if ((p == cmd || p[-1] == ' ') && (p[19] == 0 || p[19] == ' ' || p[19] == '\n')) sd_input_debug = 1;
+ if (k && !strcmp(k, "1")) sd_input_debug = 1;
+ if (sd_input_debug) sd_log("key latency trace on for user sessions (lordos.inputdebug=1)");
}
sd_log("sessions with %s%s%s", rd_conf.server, sd_gpu_env[0] ? ", " : "", sd_gpu_env);
int wk[2];
diff --git a/server/src/remote/sessiond.h b/server/src/remote/sessiond.h
index 564b603..6ce3c9c 100644
--- a/server/src/remote/sessiond.h
+++ b/server/src/remote/sessiond.h
@@ -93,6 +93,7 @@ void sd_cgroup_tick(void); /* restarts it if it died */
/* "LORD_GPU=0" with lordos.gpu=0 on the kernel command line (or the service's LORD_GPU), or empty */
extern char sd_gpu_env[24];
+extern int sd_input_debug; /* LORD_INPUT_DEBUG=1 for user sessions (keylag.h) */
/* ---- conn.c: one remote desktop connection (in a child process) ---- */
void rd_serve(SSL_CTX *ctx, int fd, const char *ip);
diff --git a/server/src/wl/wl.c b/server/src/wl/wl.c
index 0fecfc8..d3d827e 100644
--- a/server/src/wl/wl.c
+++ b/server/src/wl/wl.c
@@ -16,6 +16,7 @@
* app cursors, text-input (LordOS input methods inside Wayland apps),
* Xwayland. */
#include "wl.h"
+#include "../keylag.h"
#include <errno.h>
#include <math.h>
@@ -508,6 +509,7 @@ static void srf_region(struct wl_client *c, struct wl_resource *r, struct wl_res
static void srf_commit(struct wl_client *c, struct wl_resource *r) {
(void)c;
Surf *s = wl_resource_get_user_data(r);
+ if (keylag_enabled && key_focus && c == key_focus->client) keylag_commit();
if (s->p_attached) {
take_buffer(s, s->p_buf);
if (s->p_buf) { wl_list_remove(&s->p_buf_destroy.link); wl_list_init(&s->p_buf_destroy.link); }
@@ -2054,6 +2056,23 @@ void wl_frame_done(unsigned t) {
wl_list_init(&s->feedback);
}
wl_display_flush_clients(dpy);
+ if (keylag_enabled) keylag_flushed();
+}
+
+int wl_frame_unseen(unsigned t) {
+ if (!dpy) return 0;
+ int waiting = 0;
+ for (int i = 0; i < MAX_SURF; i++) {
+ Surf *s = surfs[i];
+ if (!s) continue;
+ struct wl_resource *r, *tmp;
+ wl_resource_for_each_safe(r, tmp, &s->frames) { wl_callback_send_done(r, t); wl_resource_destroy(r); waiting = 1; }
+ wl_resource_for_each_safe(r, tmp, &s->feedback) { wp_presentation_feedback_send_discarded(r); wl_resource_destroy(r); waiting = 1; }
+ wl_resource_for_each_safe(r, tmp, &s->sent_feedback) { wp_presentation_feedback_send_discarded(r); wl_resource_destroy(r); waiting = 1; }
+ }
+ need_frame = 0;
+ if (waiting) wl_display_flush_clients(dpy);
+ return waiting;
}
/* ---- input ---- */
@@ -2177,8 +2196,20 @@ int wl_send_paste(void) {
return 1;
}
+static int focus_is_lord_app(void);
+static int node_protected(int node);
+static Surf *toplevel_of(Surf *s);
+
+/* Key latency trace (keylag.h): only keys for a Linux app, never an isolated LordOS app or a
+ * protected window. */
+static int keylag_traceable(void) {
+ Surf *top = toplevel_of(key_focus);
+ return !focus_is_lord_app() && !(top && node_protected(top->node));
+}
+
static void send_key_to_focus(int code, int value) {
unsigned t = now_ms();
+ if (keylag_enabled) keylag_sent_wl(keylag_traceable());
uint32_t d, l, lk, g;
kb_mods(&d, &l, &lk, &g);
struct wl_resource *kb;
@@ -2887,6 +2918,7 @@ void wl_flush(void) {
offer_to_focus();
}
wl_display_flush_clients(dpy);
+ if (keylag_enabled) keylag_flushed();
}
/* ---- for wl_input.c (gestures, fine scrolling and touches) ---- */
diff --git a/server/src/wl/wl.h b/server/src/wl/wl.h
index fc0e8d5..1888655 100644
--- a/server/src/wl/wl.h
+++ b/server/src/wl/wl.h
@@ -16,6 +16,10 @@ void wl_dispatch(void); /* there is something on wl_fd */
void wl_flush(void); /* sends what is pending to the clients */
const char *wl_socket(void); /* "wayland-0" */
void wl_frame_done(unsigned time_ms); /* after presenting a frame */
+/* Nothing is being drawn (screen off, the session away from the monitor, nobody watching): apps
+ * still waiting for a frame callback get it and their presentation feedback is discarded, so
+ * none stalls. 1 if some app was waiting. */
+int wl_frame_unseen(unsigned time_ms);
/* Input (main.c). hit = node under the pointer; down[i]/button[i] = buttons of this event
* (0 left, 1 middle, 2 right). Returns 1 if the pointer is over a Wayland app and 2 if
diff --git a/tools/release/apt-repo.sh b/tools/release/apt-repo.sh
new file mode 100755
index 0000000..d45ff7b
--- /dev/null
+++ b/tools/release/apt-repo.sh
@@ -0,0 +1,244 @@
+#!/bin/sh
+# apt-repo.sh — the signed LordOS APT repository on lordos.org (docs/UPDATES.md, docs/RELEASING.md).
+#
+# tools/release/apt-repo.sh build <target> [--notes VERSION=SECTION]… <file.deb>…
+# tools/release/apt-repo.sh publish <target>
+# tools/release/apt-repo.sh verify <target>
+#
+# <target> is "staging" (https://lordos.org/apt-staging, for tests) or "live" (https://lordos.org/apt,
+# what every LordOS system reads). Both have one suite, "stable", component "main", for amd64 and arm64.
+#
+# build copies the published pool down from S3, adds the .debs, writes the indexes with Debian's
+# apt-ftparchive (in a debian:trixie container when this machine has none), the release notes
+# of each lordos version from CHANGELOG.md (main/notes/ReleaseNotes), and signs Release
+# with the LordOS archive key: InRelease and Release.gpg. Then it checks the signatures.
+# publish uploads the pool first, then the indexes, the signed files last; the archive keyring to
+# lordos.org/keys/ and lordos.sources next to the repository; invalidates the CDN.
+# verify downloads InRelease over https AND http (the Store's package engine has no TLS of its
+# own and reads https sources over http), checks the signature and every index hash.
+#
+# --notes VERSION=SECTION takes the notes of lordos VERSION from CHANGELOG.md section SECTION (for
+# example 0.8.1~staging1=Unreleased). By default the section is "VERSION" or "VERSION-<suffix>".
+#
+# The private key lives ONLY on the maintainer's machine, next to the release key:
+# ~/.config/lordos-release/apt-gnupg (a GnuPG home, mode 0700; LORDOS_APT_GNUPGHOME overrides)
+# Never copy it to a VM, a server or the repository. The public key is
+# packaging/keys/lordos-archive-keyring.gpg (shipped in the lordos package) and the script refuses to
+# sign with any other key. Uploads use only the AWS profile "lordos" (tools/web/deploy.sh's).
+set -eu
+
+ROOT=$(cd "$(dirname "$0")/../.." && pwd)
+PROFILE=lordos
+BUCKET=lordos.org
+DISTRIBUTION=E35DXDFJ83X7Z8
+SUITE=stable
+ARCHES="amd64 arm64"
+KEYRING=$ROOT/packaging/keys/lordos-archive-keyring.gpg
+GNUPGHOME=${LORDOS_APT_GNUPGHOME:-$HOME/.config/lordos-release/apt-gnupg}
+WORKDIR=${LORDOS_APT_DIR:-$HOME/.local/share/lordos-apt}
+IMAGE=lordos-apt-tools:trixie
+export GNUPGHOME
+
+die() { echo "apt-repo.sh: $*" >&2; exit 1; }
+usage() { sed -n '3,6p' "$0" >&2; exit 2; }
+aws() { command aws --profile "$PROFILE" "$@"; }
+
+[ $# -ge 2 ] || usage
+cmd=$1; target=$2; shift 2
+case "$target" in
+ staging) PREFIX=apt-staging ;;
+ live) PREFIX=apt ;;
+ *) die "target must be staging or live, not $target" ;;
+esac
+TREE=$WORKDIR/$target
+URL=https://$BUCKET/$PREFIX
+
+# apt-ftparchive and dpkg-deb: this machine's (a Debian build host) or a debian:trixie container's
+debtool() {
+ if command -v apt-ftparchive >/dev/null 2>&1 && command -v dpkg-deb >/dev/null 2>&1; then
+ (cd "$TREE" && "$@")
+ return
+ fi
+ command -v docker >/dev/null 2>&1 || die "needs apt-ftparchive and dpkg-deb (apt-utils, dpkg) or docker"
+ if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
+ printf 'FROM debian:trixie\nRUN apt-get update -q && apt-get install -y -q --no-install-recommends apt-utils dpkg-dev xz-utils && rm -rf /var/lib/apt/lists/*\n' |
+ docker build -q -t "$IMAGE" - >/dev/null || die "could not build the $IMAGE container"
+ fi
+ docker run --rm -u "$(id -u):$(id -g)" -v "$TREE:/repo" -w /repo "$IMAGE" "$@"
+}
+
+# the fingerprint of the one key in packaging/keys/lordos-archive-keyring.gpg
+expected_fpr() {
+ t=$(mktemp -d)
+ GNUPGHOME=$t gpg --batch --quiet --import "$KEYRING" 2>/dev/null
+ GNUPGHOME=$t gpg --batch --with-colons --list-keys | awk -F: '/^fpr/ { print $10; exit }'
+ rm -rf "$t"
+}
+
+check_key() {
+ [ -d "$GNUPGHOME" ] || die "no signing key in $GNUPGHOME (see docs/UPDATES.md, \"The keys\")"
+ FPR=$(expected_fpr)
+ [ -n "$FPR" ] || die "cannot read $KEYRING"
+ gpg --batch --with-colons --list-secret-keys "$FPR" >/dev/null 2>&1 \
+ || die "the secret key for $FPR (packaging/keys/lordos-archive-keyring.gpg) is not in $GNUPGHOME"
+}
+
+# CHANGELOG.md section → deb822 "Notes" lines (one leading space, " ." for an empty line)
+notes_for() {
+ version=$1; section=$2
+ if [ -z "$section" ]; then
+ section=$(sed -n 's/^## \[\([^]]*\)\].*/\1/p' "$ROOT/CHANGELOG.md" |
+ awk -v v="$version" '$0 == v || index($0, v "-") == 1 { print; exit }')
+ fi
+ [ -n "$section" ] || return 0
+ # the release body without its fixed footer (downloads, verification and links)
+ "$ROOT/tools/release/release-notes.sh" "$section" 2>/dev/null |
+ awk '/^---$/ { cut = NR } { line[NR] = $0 } END { n = cut ? cut - 1 : NR; while (n > 0 && line[n] == "") n--; for (i = 1; i <= n; i++) print line[i] }' |
+ sed -e 's/^$/./' -e 's/^/ /'
+}
+
+do_build() {
+ NOTES_MAP=""
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ --notes) [ $# -ge 2 ] || die "--notes needs VERSION=SECTION"; NOTES_MAP="$NOTES_MAP $2"; shift ;;
+ --notes=*) NOTES_MAP="$NOTES_MAP ${1#*=}" ;;
+ -*) die "unknown option $1" ;;
+ *) break ;;
+ esac
+ shift
+ done
+ check_key
+ mkdir -p "$TREE/pool/main"
+ # the pool is append-only: start from what is published (old versions stay installable)
+ if [ -z "${LORDOS_APT_OFFLINE:-}" ]; then
+ aws s3 sync "s3://$BUCKET/$PREFIX/pool" "$TREE/pool" --only-show-errors || die "could not read s3://$BUCKET/$PREFIX/pool"
+ fi
+ for deb in "$@"; do
+ [ -f "$deb" ] || die "no such file: $deb"
+ mkdir -p "$TREE/incoming"
+ cp "$deb" "$TREE/incoming/"
+ b=$(basename "$deb")
+ name=$(debtool dpkg-deb -f "incoming/$b" Package)
+ ver=$(debtool dpkg-deb -f "incoming/$b" Version)
+ arch=$(debtool dpkg-deb -f "incoming/$b" Architecture)
+ case "$name" in lib?*) dir=$(printf %s "$name" | cut -c1-4) ;; *) dir=$(printf %s "$name" | cut -c1) ;; esac
+ dest="pool/main/$dir/$name/${name}_${ver#*:}_$arch.deb"
+ if [ -f "$TREE/$dest" ] && ! cmp -s "$TREE/incoming/$b" "$TREE/$dest"; then
+ die "$dest is already published with different contents: a version is never replaced (bump it)"
+ fi
+ mkdir -p "$(dirname "$TREE/$dest")"
+ mv "$TREE/incoming/$b" "$TREE/$dest"
+ echo " $dest"
+ done
+ rm -rf "$TREE/incoming"
+
+ D=dists/$SUITE
+ rm -rf "${TREE:?}/dists"
+ for a in $ARCHES; do
+ mkdir -p "$TREE/$D/main/binary-$a"
+ debtool apt-ftparchive --arch "$a" packages pool/main > "$TREE/$D/main/binary-$a/Packages"
+ xz -9 -k -f "$TREE/$D/main/binary-$a/Packages"
+ gzip -9 -n -k -f "$TREE/$D/main/binary-$a/Packages"
+ printf 'Archive: %s\nOrigin: LordOS\nLabel: LordOS\nComponent: main\nArchitecture: %s\n' "$SUITE" "$a" > "$TREE/$D/main/binary-$a/Release"
+ done
+
+ # release notes of every lordos version in the pool (Store → Updates shows the candidate's)
+ mkdir -p "$TREE/$D/main/notes"
+ : > "$TREE/$D/main/notes/ReleaseNotes"
+ versions=$(awk '/^Package: lordos$/ { p = 1; next } /^Package:/ { p = 0 } p && /^Version:/ { print $2 }' "$TREE"/$D/main/binary-*/Packages | sort -u)
+ for v in $versions; do
+ section=""
+ for m in $NOTES_MAP; do [ "${m%%=*}" = "$v" ] && section=${m#*=}; done
+ body=$(notes_for "$v" "$section")
+ [ -n "$body" ] || { echo " (no CHANGELOG section for lordos $v: no release notes)"; continue; }
+ printf 'Package: lordos\nVersion: %s\nNotes:\n%s\n\n' "$v" "$body" >> "$TREE/$D/main/notes/ReleaseNotes"
+ echo " notes for lordos $v"
+ done
+ xz -9 -k -f "$TREE/$D/main/notes/ReleaseNotes"
+
+ debtool apt-ftparchive \
+ -o APT::FTPArchive::Release::Origin=LordOS \
+ -o APT::FTPArchive::Release::Label=LordOS \
+ -o APT::FTPArchive::Release::Suite="$SUITE" \
+ -o APT::FTPArchive::Release::Codename="$SUITE" \
+ -o APT::FTPArchive::Release::Architectures="$ARCHES" \
+ -o APT::FTPArchive::Release::Components=main \
+ -o APT::FTPArchive::Release::Description="LordOS updates for Debian 13 (trixie)" \
+ -o APT::FTPArchive::Release::Patterns::=ReleaseNotes -o APT::FTPArchive::Release::Patterns::=ReleaseNotes.xz \
+ release "$D" > "$TREE/Release.new"
+ mv "$TREE/Release.new" "$TREE/$D/Release"
+
+ # sign on this machine (the key never leaves it): clear-signed InRelease and detached Release.gpg
+ gpg --batch --yes --local-user "$FPR" --digest-algo SHA512 --clearsign -o "$TREE/$D/InRelease" "$TREE/$D/Release"
+ gpg --batch --yes --local-user "$FPR" --digest-algo SHA512 --armor --detach-sign -o "$TREE/$D/Release.gpg" "$TREE/$D/Release"
+ check_signatures "$TREE/$D/InRelease" "$TREE/$D/Release" "$TREE/$D/Release.gpg"
+ echo "built $TREE ($(find "$TREE/pool" -name '*.deb' | wc -l | tr -d ' ') packages); publish with: $0 publish $target"
+}
+
+# the signatures against the public keyring that the lordos package ships (not the signing home)
+check_signatures() {
+ t=$(mktemp -d)
+ GNUPGHOME=$t gpg --batch --quiet --import "$KEYRING" 2>/dev/null
+ GNUPGHOME=$t gpg --batch --quiet --verify "$1" 2>/dev/null || { rm -rf "$t"; die "InRelease does not verify with $KEYRING"; }
+ GNUPGHOME=$t gpg --batch --quiet --verify "$3" "$2" 2>/dev/null || { rm -rf "$t"; die "Release.gpg does not verify with $KEYRING"; }
+ rm -rf "$t"
+ echo " signatures verified with packaging/keys/lordos-archive-keyring.gpg"
+}
+
+do_publish() {
+ [ -f "$TREE/dists/$SUITE/InRelease" ] || die "nothing built in $TREE: run $0 build $target first"
+ check_signatures "$TREE/dists/$SUITE/InRelease" "$TREE/dists/$SUITE/Release" "$TREE/dists/$SUITE/Release.gpg"
+ # 1. packages (never change once published), 2. indexes, 3. the signed files that point at them
+ aws s3 sync "$TREE/pool" "s3://$BUCKET/$PREFIX/pool" --cache-control "public, max-age=31536000, immutable" \
+ --content-type application/vnd.debian.binary-package --only-show-errors
+ aws s3 sync "$TREE/dists" "s3://$BUCKET/$PREFIX/dists" --delete --cache-control "no-cache" \
+ --exclude "*/InRelease" --exclude "*/Release" --exclude "*/Release.gpg" --only-show-errors
+ for f in Release Release.gpg InRelease; do
+ aws s3 cp "$TREE/dists/$SUITE/$f" "s3://$BUCKET/$PREFIX/dists/$SUITE/$f" --cache-control "no-cache" \
+ --content-type "text/plain; charset=utf-8" --only-show-errors
+ done
+ # the sources file of this target (live: byte for byte the one the package installs)
+ sed "s#^URIs: https://lordos.org/apt\$#URIs: $URL#" "$ROOT/packaging/apt/lordos.sources" > "$TREE/lordos.sources"
+ aws s3 cp "$TREE/lordos.sources" "s3://$BUCKET/$PREFIX/lordos.sources" --cache-control "no-cache" \
+ --content-type "text/plain; charset=utf-8" --only-show-errors
+ aws s3 cp "$KEYRING" "s3://$BUCKET/keys/lordos-archive-keyring.gpg" --cache-control "no-cache" \
+ --content-type application/pgp-keys --only-show-errors
+ aws s3 cp "${KEYRING%.gpg}.asc" "s3://$BUCKET/keys/lordos-archive-keyring.asc" --cache-control "no-cache" \
+ --content-type "text/plain; charset=utf-8" --only-show-errors
+ id=$(aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" \
+ --paths "/$PREFIX/dists/*" "/$PREFIX/lordos.sources" "/keys/*" --query Invalidation.Id --output text)
+ echo "published $URL (invalidation $id); check it with: $0 verify $target"
+}
+
+do_verify() {
+ t=$(mktemp -d)
+ trap 'rm -rf "$t"' EXIT
+ GNUPGHOME=$t gpg --batch --quiet --import "$KEYRING" 2>/dev/null
+ for scheme in https http; do
+ u=$scheme://$BUCKET/$PREFIX/dists/$SUITE
+ code=$(curl -s -o "$t/InRelease.$scheme" -w '%{http_code}' "$u/InRelease")
+ [ "$code" = 200 ] || die "$u/InRelease: HTTP $code (http must be served as is, not redirected: docs/UPDATES.md)"
+ GNUPGHOME=$t gpg --batch --quiet --verify "$t/InRelease.$scheme" 2>/dev/null || die "$u/InRelease: bad signature"
+ echo " $u/InRelease: signature good"
+ done
+ cmp -s "$t/InRelease.https" "$t/InRelease.http" || die "http and https serve different InRelease files (CDN cache? try again in a minute)"
+ GNUPGHOME=$t gpg --batch --quiet --decrypt "$t/InRelease.https" 2>/dev/null > "$t/Release"
+ awk '/^SHA256:/ { s = 1; next } /^[^ ]/ { s = 0 } s { print $1, $3 }' "$t/Release" | while read -r sum path; do
+ case "$path" in */Release) continue ;; esac
+ curl -fsS -o "$t/f" "http://$BUCKET/$PREFIX/dists/$SUITE/$path" || die "missing $path"
+ got=$(shasum -a 256 "$t/f" | cut -d' ' -f1)
+ [ "$got" = "$sum" ] || die "$path: SHA-256 does not match InRelease"
+ done
+ echo " every index matches InRelease"
+ curl -fsS "http://$BUCKET/$PREFIX/dists/$SUITE/main/binary-amd64/Packages" | awk '/^Package:|^Version:|^Architecture:/' | paste - - - | sed 's/^/ /'
+ curl -fsS "http://$BUCKET/$PREFIX/dists/$SUITE/main/binary-arm64/Packages" | awk '/^Package:|^Version:|^Architecture:/' | paste - - - | sed 's/^/ /'
+ echo "verified $URL"
+}
+
+case "$cmd" in
+ build) do_build "$@" ;;
+ publish) do_publish ;;
+ verify) do_verify ;;
+ *) usage ;;
+esac
diff --git a/tools/web/deploy.sh b/tools/web/deploy.sh
index e080579..22160f9 100755
--- a/tools/web/deploy.sh
+++ b/tools/web/deploy.sh
@@ -29,7 +29,7 @@ aws() { command aws --profile "$PROFILE" "$@"; }
aws s3 sync "$DIST/assets" "s3://$BUCKET/assets" --cache-control "public, max-age=31536000, immutable" --only-show-errors
# 2. Pages and the other root files, always revalidated.
-aws s3 sync "$DIST" "s3://$BUCKET" --exclude "assets/*" --exclude "install.sh" --exclude "lordos-release.pub.pem" --exclude ".well-known/*" \
+aws s3 sync "$DIST" "s3://$BUCKET" --exclude "assets/*" --exclude "apt/*" --exclude "apt-staging/*" --exclude "keys/*" --exclude "install.sh" --exclude "lordos-release.pub.pem" --exclude ".well-known/*" \
--cache-control "no-cache" --only-show-errors
# 3. install.sh (curl … | sh), the release key and security.txt as plain text, readable in a browser.
@@ -38,8 +38,10 @@ aws s3 cp "$DIST/install.sh" "s3://$BUCKET/install.sh" --cache-control "no-cache
aws s3 cp "$DIST/lordos-release.pub.pem" "s3://$BUCKET/lordos-release.pub.pem" --cache-control "no-cache" --content-type "text/plain; charset=utf-8" --only-show-errors
# 4. Remove pages and root files the build no longer produces. Old hashed assets stay for pages
-# that are already open in a browser; they are small and never referenced again.
-aws s3 sync "$DIST" "s3://$BUCKET" --delete --exclude "assets/*" --exclude "install.sh" --exclude "lordos-release.pub.pem" --exclude ".well-known/*" \
+# that are already open in a browser; they are small and never referenced again. The APT
+# repository (apt/, apt-staging/) and its key (keys/) belong to tools/release/apt-repo.sh: never
+# touched here.
+aws s3 sync "$DIST" "s3://$BUCKET" --delete --exclude "assets/*" --exclude "apt/*" --exclude "apt-staging/*" --exclude "keys/*" --exclude "install.sh" --exclude "lordos-release.pub.pem" --exclude ".well-known/*" \
--cache-control "no-cache" --only-show-errors
id=$(aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION" --paths "/*" --query Invalidation.Id --output text)