RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Make installation paths configurable
oxydizerb94a557a1da2
diff --git a/README.md b/README.mdindex 91c1d34..fd3e500 100644--- a/README.md+++ b/README.md@@ -83,6 +83,9 @@ sh scripts/install-session.sh # install and restart the running sesssh scripts/install-session.sh --no-restart --dm # install only, plus rediwm-dm```+For custom prefixes and distribution packages, see+[Installation layouts and packaging](docs/installation.md).+## Using it| Keys | Action |diff --git a/build.zig b/build.zigindex 1a47420..eb2e1e6 100644--- a/build.zig+++ b/build.zig@@ -21,6 +21,7 @@ const localizedData = support.localizedData;const addCatalogInputs = support.addCatalogInputs;pub fn build(b: *std.Build) void {+ const layout = @import("build/install_paths.zig").Layout.init(b);const target = b.standardTargetOptions(.{});const optimize = b.standardOptimizeOption(.{});const use_llvm = b.option(bool, "llvm", "Use LLVM and LLD (default for optimized builds)") orelse (optimize != .debug);@@ -120,7 +121,7 @@ pub fn build(b: *std.Build) void {addThumbCodec(b, theme_helper.root_module);theme_helper.root_module.linkSystemLibrary("libwebp", .{});b.installArtifact(theme_helper);- b.getInstallStep().dependOn(&b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-theme.desktop"), .prefix, "share/applications/rediwm-theme.desktop").step);+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(localizedData(b, i18n_tool, layout.prefix, "data/rediwm-theme.desktop"), .prefix, "share/applications/rediwm-theme.desktop").step);b.getInstallStep().dependOn(&b.addInstallFileWithDir(b.path("data/rediwm-theme.xml"), .prefix, "share/mime/packages/rediwm-theme.xml").step);const protocol_mod = b.createModule(.{@@ -195,6 +196,7 @@ pub fn build(b: *std.Build) void {const ctx: Context = .{.b = b,+ .layout = layout,.target = target,.optimize = optimize,.use_llvm = use_llvm,@@ -252,6 +254,7 @@ pub fn build(b: *std.Build) void {inline for (.{ "cairo", "librsvg-2.0", "freetype2", "harfbuzz", "fontconfig" }) |lib| module.linkSystemLibrary(lib, .{});}inline for (.{ compositor.root_module, ui_tests_module, files.root_module, images.root_module, editor.root_module, pdf.root_module, share_picker.root_module, monitor.root_module, calculator.root_module, editor_tests.root_module, images_tests.root_module, pdf_tests.root_module, files_tests.root_module, ipc_tests_module, protocol_mod, session_supervisor.root_module, session_tests.root_module, share_picker_tests.root_module, dbus_tests.root_module }) |module| {+ module.addImport("install_paths", layout.options);module.addImport("ui", ui_mod);module.addImport("i18n", i18n_mod);module.addImport("config", config_mod);diff --git a/build/apps.zig b/build/apps.zigindex 7d2e3cf..fab47f4 100644--- a/build/apps.zig+++ b/build/apps.zig@@ -68,7 +68,7 @@ pub fn add(ctx: Context) Apps {// launcher. Its icon is installed in the hicolor fallback theme so the// start menu and taskbar can resolve the desktop entry's Icon name.const install_files_desktop_entry = b.addInstallFileWithDir(- localizedData(b, i18n_tool, "data/rediwm-files.desktop"),+ localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-files.desktop"),.prefix,"share/applications/rediwm-files.desktop",);@@ -86,7 +86,7 @@ pub fn add(ctx: Context) Apps {files_step.dependOn(&install_files.step);files_step.dependOn(&install_torrents.step);files_step.dependOn(&torrent_license.step);- const transfers_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-transfers.desktop"), .prefix, "share/applications/rediwm-transfers.desktop");+ const transfers_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-transfers.desktop"), .prefix, "share/applications/rediwm-transfers.desktop");b.getInstallStep().dependOn(&transfers_entry.step);files_step.dependOn(&transfers_entry.step);const test_torrents = b.step("test-files-torrents", "Test real loopback transfers and the Files/tray interface");@@ -126,7 +126,7 @@ pub fn add(ctx: Context) Apps {images.root_module.addImport("wayland", wayland);inline for (.{ "wayland-client", "wayland-cursor", "gdk-pixbuf-2.0", "gobject-2.0", "glib-2.0", "xkbcommon" }) |lib| images.root_module.linkSystemLibrary(lib, .{});const install_images = b.addInstallArtifact(images, .{});- const images_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-images.desktop"), .prefix, "share/applications/rediwm-images.desktop");+ const images_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-images.desktop"), .prefix, "share/applications/rediwm-images.desktop");b.getInstallStep().dependOn(&install_images.step);b.getInstallStep().dependOn(&images_entry.step);const images_step = b.step("images", "Build the standalone image viewer");@@ -144,7 +144,7 @@ pub fn add(ctx: Context) Apps {monitor.root_module.addImport("wayland", wayland);inline for (.{ "wayland-client", "wayland-cursor", "xkbcommon" }) |lib| monitor.root_module.linkSystemLibrary(lib, .{});const install_monitor = b.addInstallArtifact(monitor, .{});- const monitor_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-monitor.desktop"), .prefix, "share/applications/rediwm-monitor.desktop");+ const monitor_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-monitor.desktop"), .prefix, "share/applications/rediwm-monitor.desktop");const monitor_icon = b.addInstallFileWithDir(b.path("data/rediwm-monitor.svg"), .prefix, "share/icons/hicolor/scalable/apps/rediwm-monitor.svg");const monitor_step = b.step("monitor", "Build the standalone System Monitor");inline for (.{ &install_monitor.step, &monitor_entry.step, &monitor_icon.step }) |step| {@@ -161,7 +161,7 @@ pub fn add(ctx: Context) Apps {calculator.root_module.addImport("wayland", wayland);inline for (.{ "wayland-client", "wayland-cursor", "xkbcommon" }) |lib| calculator.root_module.linkSystemLibrary(lib, .{});const install_calculator = b.addInstallArtifact(calculator, .{});- const calculator_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-calculator.desktop"), .prefix, "share/applications/rediwm-calculator.desktop");+ const calculator_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-calculator.desktop"), .prefix, "share/applications/rediwm-calculator.desktop");const calculator_icon = b.addInstallFileWithDir(b.path("data/rediwm-calculator.svg"), .prefix, "share/icons/hicolor/scalable/apps/rediwm-calculator.svg");const calculator_step = b.step("calculator", "Build the standalone Calculator");inline for (.{ &install_calculator.step, &calculator_entry.step, &calculator_icon.step }) |step| {@@ -178,7 +178,7 @@ pub fn add(ctx: Context) Apps {editor.root_module.addImport("wayland", wayland);inline for (.{ "wayland-client", "wayland-cursor", "xkbcommon", "pangocairo" }) |lib| editor.root_module.linkSystemLibrary(lib, .{});const install_editor = b.addInstallArtifact(editor, .{});- const editor_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-editor.desktop"), .prefix, "share/applications/rediwm-editor.desktop");+ const editor_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-editor.desktop"), .prefix, "share/applications/rediwm-editor.desktop");b.getInstallStep().dependOn(&install_editor.step);b.getInstallStep().dependOn(&editor_entry.step);const editor_step = b.step("editor", "Build the standalone text editor");@@ -199,7 +199,7 @@ pub fn add(ctx: Context) Apps {pdf.root_module.linkSystemLibrary("seccomp", .{});inline for (.{ "wayland-client", "wayland-cursor", "poppler-glib", "cairo", "gio-2.0", "gobject-2.0", "glib-2.0", "xkbcommon" }) |lib| pdf.root_module.linkSystemLibrary(lib, .{});const install_pdf = b.addInstallArtifact(pdf, .{});- const pdf_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-pdf.desktop"), .prefix, "share/applications/rediwm-pdf.desktop");+ const pdf_entry = b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-pdf.desktop"), .prefix, "share/applications/rediwm-pdf.desktop");b.getInstallStep().dependOn(&install_pdf.step);b.getInstallStep().dependOn(&pdf_entry.step);const pdf_step = b.step("pdf", "Build the standalone PDF viewer");diff --git a/build/context.zig b/build/context.zigindex b72261f..6643b0d 100644--- a/build/context.zig+++ b/build/context.zig@@ -6,6 +6,7 @@ const CHeaders = @import("support.zig").CHeaders;pub const Context = struct {b: *std.Build,+ layout: @import("install_paths.zig").Layout,target: std.Build.ResolvedTarget,optimize: std.lang.Optimize,use_llvm: bool,diff --git a/build/data.zig b/build/data.zigindex 8d3b76d..f53a2a5 100644--- a/build/data.zig+++ b/build/data.zig@@ -26,13 +26,18 @@ pub fn add(ctx: Context) void {"share/xdg-desktop-portal-wlr/config",).step);b.getInstallStep().dependOn(&b.addInstallFileWithDir(- localizedData(b, i18n_tool, "data/rediwm.desktop"),+ localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm.desktop"),.prefix,"share/wayland-sessions/rediwm.desktop",).step);- b.getInstallStep().dependOn(&b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/org.rediwm.accounts.policy"), .prefix, "share/polkit-1/actions/org.rediwm.accounts.policy").step);- b.getInstallStep().dependOn(&b.addInstallFileWithDir(localizedData(b, i18n_tool, "data/rediwm-release-safe.desktop"), .prefix, "share/wayland-sessions/rediwm-release-safe.desktop").step);+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/org.rediwm.accounts.policy"), .prefix, "share/polkit-1/actions/org.rediwm.accounts.policy").step);+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(localizedData(b, i18n_tool, ctx.layout.prefix, "data/rediwm-release-safe.desktop"), .prefix, "share/wayland-sessions/rediwm-release-safe.desktop").step);++ inline for (.{ "rediwm-dm.conf", "rediwm-dm.service" }) |name| {+ const configured = @import("install_paths.zig").configure(b, "data/" ++ name, ctx.layout.prefix);+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(configured, .prefix, "share/rediwm/" ++ name).step);+ }// Wallpapers, found at runtime through share/rediwm/wallpapers next to// the binaries (wallpapers.zig); `[compositor] wallpaper` picks one.diff --git a/build/install_paths.zig b/build/install_paths.zignew file mode 100644index 0000000..a118e5c--- /dev/null+++ b/build/install_paths.zig@@ -0,0 +1,43 @@+//! Runtime paths are independent of Zig's output/staging directory.+const std = @import("std");++pub const Layout = struct {+ prefix: []const u8,+ options: *std.Build.Module,++ pub fn init(b: *std.Build) Layout {+ const raw = b.option([]const u8, "install-prefix", "Runtime installation prefix (default /usr/local; --prefix only selects build output)") orelse "/usr/local";+ // These paths appear in shell commands, desktop files, XML and systemd+ // units. Reject metacharacters rather than giving each format different+ // escaping semantics. Never allow a staging path to be inferred here.+ if (raw.len == 0 or raw[0] != '/') @panic("install-prefix must be absolute");+ for (raw) |ch| {+ if (!std.ascii.isAlphanumeric(ch) and std.mem.indexOfScalar(u8, "/_-+.", ch) == null)+ @panic("install-prefix supports only letters, digits, /, _, -, + and .");+ }+ var parts = std.mem.splitScalar(u8, raw, '/');+ while (parts.next()) |part| {+ if (std.mem.eql(u8, part, ".") or std.mem.eql(u8, part, "..")) @panic("install-prefix must not contain . or .. components");+ }+ const normalized = std.fs.path.resolve(b.allocator, &.{raw}) catch @panic("out of memory");+ const prefix = std.mem.trimEnd(u8, normalized, "/");+ const options = b.addOptions();+ options.addOption([]const u8, "prefix", prefix);+ options.addOption([]const u8, "bin", b.fmt("{s}/bin", .{prefix}));+ options.addOption([]const u8, "data", b.fmt("{s}/share", .{prefix}));+ options.addOption([]const u8, "search_path", b.fmt("{s}/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin", .{prefix}));+ options.addOption([]const u8, "data_dirs", b.fmt("{s}/share:/usr/local/share:/usr/share", .{prefix}));+ const manifest = b.addWriteFiles().add("install-prefix", b.fmt("{s}\n", .{normalized}));+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(manifest, .prefix, "install-prefix").step);+ return .{ .prefix = prefix, .options = options.createModule() };+ }+};++pub fn configure(b: *std.Build, path: []const u8, prefix: []const u8) std.Build.LazyPath {+ b.dependOnFileContents(b.path(path));+ var dir = b.root.openDir(b.graph.io, ".", .{}) catch @panic("cannot open source directory");+ defer dir.close(b.graph.io);+ const bytes = dir.readFileAlloc(b.graph.io, path, b.allocator, .limited(1024 * 1024)) catch @panic("cannot read installation template");+ const contents = std.mem.replaceOwned(u8, b.allocator, bytes, "@BINDIR@", b.fmt("{s}/bin", .{prefix})) catch @panic("out of memory");+ return b.addWriteFiles().add(std.fs.path.basename(path), contents);+}diff --git a/build/session.zig b/build/session.zigindex dbf7adb..0a8b314 100644--- a/build/session.zig+++ b/build/session.zig@@ -45,6 +45,7 @@ pub fn add(ctx: Context) Session {.use_llvm = use_llvm,.use_lld = use_llvm,});+ restart.root_module.addImport("install_paths", ctx.layout.options);b.installArtifact(restart);const child_set_mod = b.createModule(.{ .root_source_file = b.path("src/child_set.zig"), .target = target, .optimize = optimize });@@ -61,6 +62,7 @@ pub fn add(ctx: Context) Session {dm_ipc_mod.addImport("c", ctx.c.libc);ws_mod.addImport("c", ctx.c.libc);+ ws_mod.addImport("install_paths", ctx.layout.options);const dm = b.addExecutable(.{.name = "rediwm-dm",@@ -73,6 +75,7 @@ pub fn add(ctx: Context) Session {.use_llvm = use_llvm,.use_lld = use_llvm,});+ dm.root_module.addImport("install_paths", ctx.layout.options);dm.root_module.addImport("c", ctx.c.libc);dm.root_module.addImport("child_set", child_set_mod);dm.root_module.addImport("dm_ipc", dm_ipc_mod);@@ -100,11 +103,13 @@ pub fn add(ctx: Context) Session {.target = target,.optimize = optimize,}));- accounts_helper.root_module.addImport("dm_config", b.createModule(.{+ const dm_config = b.createModule(.{.root_source_file = b.path("src/dm/config.zig"),.target = target,.optimize = optimize,- }));+ });+ dm_config.addImport("install_paths", ctx.layout.options);+ accounts_helper.root_module.addImport("dm_config", dm_config);b.installArtifact(accounts_helper);b.step("accounts-helper", "Build the privileged account-management helper").dependOn(&accounts_helper.step);return .{ .session_supervisor = session_supervisor, .child_set_mod = child_set_mod, .dm_ipc_mod = dm_ipc_mod, .ws_mod = ws_mod };diff --git a/build/support.zig b/build/support.zigindex 303ecbf..8b264de 100644--- a/build/support.zig+++ b/build/support.zig@@ -148,11 +148,11 @@ pub fn addShellIcons(b: *std.Build, module: *std.Build.Module) void {}/// Localize installed metadata from the same reviewed catalog entries as UI.-pub fn localizedData(b: *std.Build, tool: *std.Build.Step.Compile, path: []const u8) std.Build.LazyPath {+pub fn localizedData(b: *std.Build, tool: *std.Build.Step.Compile, prefix: []const u8, path: []const u8) std.Build.LazyPath {const run = b.addRunArtifact(tool);run.setCwd(b.path("."));run.addArg("data");- run.addFileArg(b.path(path));+ run.addFileArg(@import("install_paths.zig").configure(b, path, prefix));const result = run.addOutputFileArg(std.fs.path.basename(path));run.addDirectoryArg(b.path("po"));addCatalogInputs(b, run);diff --git a/build/tests.zig b/build/tests.zigindex e1fb164..ccd19bf 100644--- a/build/tests.zig+++ b/build/tests.zig@@ -249,6 +249,7 @@ pub fn addZig(ctx: Context, session: Session) ZigTests {.optimize = optimize,.link_libc = true,}) });+ dm_tests.root_module.addImport("install_paths", ctx.layout.options);dm_tests.root_module.addImport("c", ctx.c.libc);dm_tests.root_module.addImport("child_set", child_set_mod);dm_tests.root_module.addImport("dm_ipc", dm_ipc_mod);diff --git a/data/org.rediwm.accounts.policy b/data/org.rediwm.accounts.policyindex b43a2c0..a65004e 100644--- a/data/org.rediwm.accounts.policy+++ b/data/org.rediwm.accounts.policy@@ -11,6 +11,6 @@<allow_inactive>auth_admin</allow_inactive><allow_active>auth_admin_keep</allow_active></defaults>- <annotate key="org.freedesktop.policykit.exec.path">/usr/local/bin/rediwm-accounts-helper</annotate>+ <annotate key="org.freedesktop.policykit.exec.path">@BINDIR@/rediwm-accounts-helper</annotate></action></policyconfig>diff --git a/data/rediwm-calculator.desktop b/data/rediwm-calculator.desktopindex 4a0f807..acb4dee 100644--- a/data/rediwm-calculator.desktop+++ b/data/rediwm-calculator.desktop@@ -2,7 +2,7 @@Type=ApplicationName=CalculatorComment=Simple arithmetic calculator-Exec=rediwm-calculator+Exec=@BINDIR@/rediwm-calculatorIcon=rediwm-calculatorTerminal=falseCategories=Utility;Calculator;diff --git a/data/rediwm-dm.conf b/data/rediwm-dm.confindex f56d981..d6f7e89 100644--- a/data/rediwm-dm.conf+++ b/data/rediwm-dm.conf@@ -8,8 +8,8 @@# change its pam_succeed_if line to match.# greeter_user = rediwm-greeter-# Command to execute for the greeter UI (default: /usr/local/bin/rediwm --greeter)-# greeter_command = /usr/local/bin/rediwm --greeter+# Command to execute for the greeter UI (default: @BINDIR@/rediwm --greeter)+# greeter_command = @BINDIR@/rediwm --greeter# Optional autologin configuration:# When set, rediwm-dm logs this user into the specified session automatically once on boot.diff --git a/data/rediwm-dm.service b/data/rediwm-dm.serviceindex 4dc0710..d9a5c13 100644--- a/data/rediwm-dm.service+++ b/data/rediwm-dm.service@@ -6,7 +6,7 @@ OnFailure=plymouth-quit.service[Service]Type=simple-ExecStart=/usr/local/bin/rediwm-dm+ExecStart=@BINDIR@/rediwm-dmRestart=alwaysRestartSec=1sdiff --git a/data/rediwm-editor.desktop b/data/rediwm-editor.desktopindex 13a33f3..01422ad 100644--- a/data/rediwm-editor.desktop+++ b/data/rediwm-editor.desktop@@ -2,7 +2,7 @@Type=ApplicationName=Text EditorComment=Edit text files in tabs-Exec=rediwm-editor %F+Exec=@BINDIR@/rediwm-editor %FIcon=accessories-text-editorTerminal=falseCategories=Utility;TextEditor;diff --git a/data/rediwm-files.desktop b/data/rediwm-files.desktopindex 6a8bd32..5d23835 100644--- a/data/rediwm-files.desktop+++ b/data/rediwm-files.desktop@@ -4,7 +4,7 @@ Version=1.0Name=RediWM FilesGenericName=File ManagerComment=Browse, open and manage local files and folders-Exec=rediwm-files %f+Exec=@BINDIR@/rediwm-files %fMimeType=inode/directory;Icon=redi-fm-iconTerminal=falsediff --git a/data/rediwm-images.desktop b/data/rediwm-images.desktopindex 356dab9..9211b60 100644--- a/data/rediwm-images.desktop+++ b/data/rediwm-images.desktop@@ -2,7 +2,7 @@Type=ApplicationName=Image ViewerComment=View images with RediWM-Exec=rediwm-images %F+Exec=@BINDIR@/rediwm-images %FIcon=image-x-genericTerminal=falseCategories=Graphics;Viewer;diff --git a/data/rediwm-monitor.desktop b/data/rediwm-monitor.desktopindex 4e0ebd6..e49247f 100644--- a/data/rediwm-monitor.desktop+++ b/data/rediwm-monitor.desktop@@ -2,7 +2,7 @@Type=ApplicationName=System MonitorComment=View CPU, memory and processes-Exec=rediwm-monitor+Exec=@BINDIR@/rediwm-monitorIcon=rediwm-monitorTerminal=falseCategories=System;Monitor;diff --git a/data/rediwm-pdf.desktop b/data/rediwm-pdf.desktopindex 60046d0..e5a1b08 100644--- a/data/rediwm-pdf.desktop+++ b/data/rediwm-pdf.desktop@@ -2,7 +2,7 @@Type=ApplicationName=PDF ViewerComment=View PDF documents with RediWM-Exec=rediwm-pdf %f+Exec=@BINDIR@/rediwm-pdf %fIcon=application-pdfTerminal=falseStartupWMClass=rediwm-pdfdiff --git a/data/rediwm-release-safe.desktop b/data/rediwm-release-safe.desktopindex 8f06364..6fb4a6d 100644--- a/data/rediwm-release-safe.desktop+++ b/data/rediwm-release-safe.desktop@@ -1,7 +1,7 @@[Desktop Entry]Name=RediWMComment=RediWM Wayland compositor-Exec=/usr/local/bin/rediwm-session-TryExec=/usr/local/bin/rediwm-session+Exec=@BINDIR@/rediwm-session+TryExec=@BINDIR@/rediwm-sessionType=ApplicationDesktopNames=rediwmdiff --git a/data/rediwm-theme.desktop b/data/rediwm-theme.desktopindex 555db3f..7e7726f 100644--- a/data/rediwm-theme.desktop+++ b/data/rediwm-theme.desktop@@ -2,7 +2,7 @@Type=ApplicationName=Install themeComment=Validate and install a RediWM theme pack-Exec=rediwm-theme install %f+Exec=@BINDIR@/rediwm-theme install %fMimeType=application/x-rediwm-theme;Icon=preferences-desktop-themeTerminal=falsediff --git a/data/rediwm-transfers.desktop b/data/rediwm-transfers.desktopindex 7102d12..6330850 100644--- a/data/rediwm-transfers.desktop+++ b/data/rediwm-transfers.desktop@@ -3,7 +3,7 @@ Type=ApplicationVersion=1.0Name=Files TransfersComment=Download torrents and magnet links in Files-Exec=rediwm-files --torrent %u+Exec=@BINDIR@/rediwm-files --torrent %uMimeType=application/x-bittorrent;x-scheme-handler/magnet;Icon=folder-downloadTerminal=falsediff --git a/data/rediwm.desktop b/data/rediwm.desktopindex 31546c8..6fb4a6d 100644--- a/data/rediwm.desktop+++ b/data/rediwm.desktop@@ -1,7 +1,7 @@[Desktop Entry]Name=RediWMComment=RediWM Wayland compositor-Exec=rediwm-session-TryExec=rediwm-session+Exec=@BINDIR@/rediwm-session+TryExec=@BINDIR@/rediwm-sessionType=ApplicationDesktopNames=rediwmdiff --git a/docs/installation.md b/docs/installation.mdnew file mode 100644index 0000000..b84b950--- /dev/null+++ b/docs/installation.md@@ -0,0 +1,38 @@+# Installation layouts and packaging++The source installer defaults to `/usr/local`. Choose another runtime prefix+with `sh scripts/install-session.sh --prefix=/usr --no-restart` (also accepted+by `scripts/install.sh`, which builds from source for this option).++For packaging, configure the runtime prefix separately from Zig's output tree:++```sh+zig build -Doptimize=ReleaseSafe -Dinstall-prefix=/usr --prefix zig-out/package+DESTDIR="$pkgdir" sh scripts/install-session-root.sh "$PWD" "$PWD/zig-out/package" yes+```++The final `yes` includes the optional display manager's systemd, sysusers,+tmpfiles and PAM files; use `no` to omit them. Staging needs no root and runs no+system commands or cache updates. Select the appropriate PAM policy for your+distribution with `REDIWM_PAM_PROFILE=arch` or `debian` (the source installer+selects Arch when `/etc/pam.d/system-local-login` exists, otherwise Debian). Packaging may instead+copy files from the output tree directly. Generated DM configuration and service+files are in `share/rediwm/`; do not install the unexpanded templates from `data/`.+`scripts/make-deb.sh` uses the prefix recorded in `zig-out/release-safe`.++`-Dinstall-prefix` defaults to `/usr/local`; `--prefix` selects only the build+output directory and never changes runtime paths. Binaries, private libraries+and data retain the relative `bin`, `lib/rediwm` and `share` layout. Supported+prefixes are absolute paths containing letters, digits, `/`, `_`, `-`, `+` and+`.` (no `.` or `..` components). Prebuilt releases retain their recorded prefix+and cannot be relocated by the installer.++System integration remains in `/etc`, `/usr/lib/{systemd/system,sysusers.d,tmpfiles.d}`+and `/usr/share/{wayland-sessions,polkit-1/actions,xdg-desktop-portal/portals}`,+under `DESTDIR` when staging. Runtime discovery of sibling executables and assets+remains relative to the running binary; privileged helper paths are fixed at+build time and match their polkit policy. Standard XDG and third-party executable+search paths still include `/usr/local` where appropriate.++Check both layouts with [tests/install_layout.py](../tests/install_layout.py)+(commands in its docstring).diff --git a/po/lint-files b/po/lint-filesindex 5b43b29..afd9c51 100644--- a/po/lint-files+++ b/po/lint-files@@ -37,6 +37,7 @@ src/control_center/sections/services.zigsrc/control_center/sections/shortcuts.zigsrc/control_center/sections/sound.zigsrc/control_center/sections/users.zig+src/control_center/sections/users_helper.zigsrc/control_center/tree.zigsrc/control_center/welcome.zigsrc/cursor_theme.zigdiff --git a/po/rediwm.pot b/po/rediwm.potindex c1ab791..fc8ab4b 100644--- a/po/rediwm.pot+++ b/po/rediwm.pot@@ -491,7 +491,7 @@ msgstr ""msgid "Authentication unavailable. Try again."msgstr ""-#: src/control_center/sections/users.zig+#: src/control_center/sections/users_helper.zigmsgid "Authentication was cancelled or denied."msgstr ""@@ -959,7 +959,7 @@ msgstr ""msgid "Changes are saved automatically. Scroll the lists for more modes."msgstr ""-#: src/control_center/sections/users.zig+#: src/control_center/sections/users_helper.zigmsgid "Changes saved."msgstr ""@@ -3683,7 +3683,7 @@ msgstr ""msgid "No changed files"msgstr ""-#: src/control_center/sections/users.zig+#: src/control_center/sections/users_helper.zigmsgid "No changes were made. Authentication was cancelled or the request failed."msgstr ""diff --git a/scripts/install-session-root.sh b/scripts/install-session-root.shindex b62f3c1..58e5a21 100755--- a/scripts/install-session-root.sh+++ b/scripts/install-session-root.sh@@ -4,114 +4,134 @@ set -eurepo_dir=$1release_dir=$2install_dm=${3:-no}+# The build records its runtime prefix. Never relocate binaries configured for+# another prefix; DESTDIR is only a staging root and never enters generated files.+prefix=$(cat "$release_dir/install-prefix")+prefix=${prefix%/}+case "$prefix" in /*|'') ;; *) echo 'Invalid installation prefix' >&2; exit 1 ;; esac+case "$prefix" in *[!a-zA-Z0-9/_+.-]*) echo 'Invalid installation prefix' >&2; exit 1 ;; esac+dest=${DESTDIR:-}+case "$dest" in /*|'') ;; *) echo 'DESTDIR must be absolute' >&2; exit 1 ;; esac+bindir="$dest$prefix/bin"+datadir="$dest$prefix/share"+libdir="$dest$prefix/lib"+system_data="$dest/usr/share"+system_lib="$dest/usr/lib"+sysconf="$dest/etc"# sudo keeps the caller's umask, and the build keeps it in file modes: a 077# shell would install root-only copies the session user can't read (the bass# plugin, wallpapers, cursors). Every copied tree is also normalized below.umask 022# Stage on the destination filesystem: rename never truncates a running executable.-install -d /usr/local/bin-stage=$(mktemp -d /usr/local/bin/.rediwm-install.XXXXXX)+install -d "${bindir}"+stage=$(mktemp -d "${bindir}/.rediwm-install.XXXXXX")trap 'rm -rf -- "$stage"' EXIT HUP INT TERM-for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper; do+for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper rediwm-restart; doinstall -m755 "$release_dir/bin/$binary" "$stage/$binary"done-install -Dm644 "$release_dir/share/applications/rediwm-theme.desktop" /usr/local/share/applications/rediwm-theme.desktop-install -Dm644 "$repo_dir/data/rediwm-theme.xml" /usr/local/share/mime/packages/rediwm-theme.xml-install -Dm644 "$release_dir/share/applications/rediwm-files.desktop" /usr/local/share/applications/rediwm-files.desktop-install -Dm644 "$release_dir/share/applications/rediwm-transfers.desktop" /usr/local/share/applications/rediwm-transfers.desktop-install -Dm644 "$release_dir/share/licenses/rediwm/libvterm-LICENSE" /usr/local/share/licenses/rediwm/libvterm-LICENSE-install -Dm644 "$release_dir/share/licenses/rediwm/libtorrent-LICENSE" /usr/local/share/licenses/rediwm/libtorrent-LICENSE-install -Dm644 "$release_dir/share/icons/hicolor/256x256/apps/redi-fm-icon.png" /usr/local/share/icons/hicolor/256x256/apps/redi-fm-icon.png-install -Dm644 "$release_dir/share/applications/rediwm-images.desktop" /usr/local/share/applications/rediwm-images.desktop-install -Dm644 "$release_dir/share/applications/rediwm-monitor.desktop" /usr/local/share/applications/rediwm-monitor.desktop-install -Dm644 "$release_dir/share/icons/hicolor/scalable/apps/rediwm-monitor.svg" /usr/local/share/icons/hicolor/scalable/apps/rediwm-monitor.svg-install -Dm644 "$release_dir/share/applications/rediwm-calculator.desktop" /usr/local/share/applications/rediwm-calculator.desktop-install -Dm644 "$release_dir/share/icons/hicolor/scalable/apps/rediwm-calculator.svg" /usr/local/share/icons/hicolor/scalable/apps/rediwm-calculator.svg-install -Dm644 "$release_dir/share/applications/rediwm-editor.desktop" /usr/local/share/applications/rediwm-editor.desktop-install -Dm644 "$release_dir/share/applications/rediwm-pdf.desktop" /usr/local/share/applications/rediwm-pdf.desktop-if command -v update-mime-database >/dev/null 2>&1; then update-mime-database /usr/local/share/mime; fi-if command -v update-desktop-database >/dev/null 2>&1; then update-desktop-database /usr/local/share/applications; fi-install -Dm644 "$repo_dir/data/rediwm-portals.conf" /usr/local/share/xdg-desktop-portal/rediwm-portals.conf+install -Dm644 "$release_dir/share/applications/rediwm-theme.desktop" "${datadir}/applications/rediwm-theme.desktop"+install -Dm644 "$repo_dir/data/rediwm-theme.xml" "${datadir}/mime/packages/rediwm-theme.xml"+install -Dm644 "$release_dir/share/applications/rediwm-files.desktop" "${datadir}/applications/rediwm-files.desktop"+install -Dm644 "$release_dir/share/applications/rediwm-transfers.desktop" "${datadir}/applications/rediwm-transfers.desktop"+install -Dm644 "$release_dir/share/licenses/rediwm/libvterm-LICENSE" "${datadir}/licenses/rediwm/libvterm-LICENSE"+install -Dm644 "$release_dir/share/licenses/rediwm/libtorrent-LICENSE" "${datadir}/licenses/rediwm/libtorrent-LICENSE"+install -Dm644 "$release_dir/share/icons/hicolor/256x256/apps/redi-fm-icon.png" "${datadir}/icons/hicolor/256x256/apps/redi-fm-icon.png"+install -Dm644 "$release_dir/share/applications/rediwm-images.desktop" "${datadir}/applications/rediwm-images.desktop"+install -Dm644 "$release_dir/share/applications/rediwm-monitor.desktop" "${datadir}/applications/rediwm-monitor.desktop"+install -Dm644 "$release_dir/share/icons/hicolor/scalable/apps/rediwm-monitor.svg" "${datadir}/icons/hicolor/scalable/apps/rediwm-monitor.svg"+install -Dm644 "$release_dir/share/applications/rediwm-calculator.desktop" "${datadir}/applications/rediwm-calculator.desktop"+install -Dm644 "$release_dir/share/icons/hicolor/scalable/apps/rediwm-calculator.svg" "${datadir}/icons/hicolor/scalable/apps/rediwm-calculator.svg"+install -Dm644 "$release_dir/share/applications/rediwm-editor.desktop" "${datadir}/applications/rediwm-editor.desktop"+install -Dm644 "$release_dir/share/applications/rediwm-pdf.desktop" "${datadir}/applications/rediwm-pdf.desktop"+if [ -z "$dest" ] && command -v update-mime-database >/dev/null 2>&1; then update-mime-database "${datadir}/mime"; fi+if [ -z "$dest" ] && command -v update-desktop-database >/dev/null 2>&1; then update-desktop-database "${datadir}/applications"; fi+install -Dm644 "$repo_dir/data/rediwm-portals.conf" "${datadir}/xdg-desktop-portal/rediwm-portals.conf"# xdg-desktop-portal reads backend descriptors only from its own datadir.-install -Dm644 "$repo_dir/data/rediwm.portal" /usr/share/xdg-desktop-portal/portals/rediwm.portal-install -Dm644 "$release_dir/share/polkit-1/actions/org.rediwm.accounts.policy" /usr/share/polkit-1/actions/org.rediwm.accounts.policy-install -Dm644 "$repo_dir/data/xdg-desktop-portal-wlr.ini" /usr/local/share/xdg-desktop-portal-wlr/config-install -Dm644 "$release_dir/share/wayland-sessions/rediwm-release-safe.desktop" /usr/share/wayland-sessions/rediwm-release-safe.desktop+install -Dm644 "$repo_dir/data/rediwm.portal" "${system_data}/xdg-desktop-portal/portals/rediwm.portal"+install -Dm644 "$release_dir/share/polkit-1/actions/org.rediwm.accounts.policy" "${system_data}/polkit-1/actions/org.rediwm.accounts.policy"+install -Dm644 "$repo_dir/data/xdg-desktop-portal-wlr.ini" "${datadir}/xdg-desktop-portal-wlr/config"+install -Dm644 "$release_dir/share/wayland-sessions/rediwm-release-safe.desktop" "${system_data}/wayland-sessions/rediwm-release-safe.desktop"# The bass boost's LADSPA plugin, and on Debian/Ubuntu builds the private# wlroots 0.20 and dependencies found through the binaries' $ORIGIN/../lib/rediwm# RUNPATH. Replaced as a whole right before the binaries so they stay in step.if [ -d "$release_dir/lib/rediwm" ]; then- rm -rf /usr/local/lib/.rediwm-new- cp -R "$release_dir/lib/rediwm" /usr/local/lib/.rediwm-new- chmod -R u=rwX,go=rX /usr/local/lib/.rediwm-new- rm -rf /usr/local/lib/rediwm- mv -T /usr/local/lib/.rediwm-new /usr/local/lib/rediwm+ install -d "$libdir"+ rm -rf "${libdir}/.rediwm-new"+ cp -R "$release_dir/lib/rediwm" "${libdir}/.rediwm-new"+ chmod -R u=rwX,go=rX "${libdir}/.rediwm-new"+ rm -rf "${libdir}/rediwm"+ mv -T "${libdir}/.rediwm-new" "${libdir}/rediwm"fi# Bundled Xcursor themes (aliases are symlinks); the compositor finds them# through $ORIGIN/../share/icons, which it adds to XCURSOR_PATH.for theme in "$release_dir"/share/icons/phinger-cursors-*/; doname=$(basename "$theme")- rm -rf "/usr/local/share/icons/.$name-new"- install -d /usr/local/share/icons- cp -a "$theme" "/usr/local/share/icons/.$name-new"- chmod -R u=rwX,go=rX "/usr/local/share/icons/.$name-new"- rm -rf "/usr/local/share/icons/$name"- mv -T "/usr/local/share/icons/.$name-new" "/usr/local/share/icons/$name"+ rm -rf "${datadir}/icons/.$name-new"+ install -d "${datadir}/icons"+ cp -a "$theme" "${datadir}/icons/.$name-new"+ chmod -R u=rwX,go=rX "${datadir}/icons/.$name-new"+ rm -rf "${datadir}/icons/$name"+ mv -T "${datadir}/icons/.$name-new" "${datadir}/icons/$name"done# Bundled wallpapers, found through $ORIGIN/../share/rediwm/wallpapers.-rm -rf /usr/local/share/rediwm/.wallpapers-new-install -d /usr/local/share/rediwm-cp -R "$release_dir/share/rediwm/wallpapers" /usr/local/share/rediwm/.wallpapers-new-chmod -R u=rwX,go=rX /usr/local/share/rediwm/.wallpapers-new-rm -rf /usr/local/share/rediwm/wallpapers-mv -T /usr/local/share/rediwm/.wallpapers-new /usr/local/share/rediwm/wallpapers+rm -rf "${datadir}/rediwm/.wallpapers-new"+install -d "${datadir}/rediwm"+cp -R "$release_dir/share/rediwm/wallpapers" "${datadir}/rediwm/.wallpapers-new"+chmod -R u=rwX,go=rX "${datadir}/rediwm/.wallpapers-new"+rm -rf "${datadir}/rediwm/wallpapers"+mv -T "${datadir}/rediwm/.wallpapers-new" "${datadir}/rediwm/wallpapers"# Packs carry artwork as well as the palettes embedded in the executables.# Replace bundled packs individually, preserving any other installed packs.for pack in "$release_dir"/share/rediwm/themes/*/; do[ -d "$pack" ] || continuename=$(basename "$pack")- install -d /usr/local/share/rediwm/themes- rm -rf "/usr/local/share/rediwm/themes/.$name-new"- cp -R "$pack" "/usr/local/share/rediwm/themes/.$name-new"- chmod -R u=rwX,go=rX "/usr/local/share/rediwm/themes/.$name-new"- rm -rf "/usr/local/share/rediwm/themes/$name"- mv -T "/usr/local/share/rediwm/themes/.$name-new" "/usr/local/share/rediwm/themes/$name"+ install -d "${datadir}/rediwm/themes"+ rm -rf "${datadir}/rediwm/themes/.$name-new"+ cp -R "$pack" "${datadir}/rediwm/themes/.$name-new"+ chmod -R u=rwX,go=rX "${datadir}/rediwm/themes/.$name-new"+ rm -rf "${datadir}/rediwm/themes/$name"+ mv -T "${datadir}/rediwm/themes/.$name-new" "${datadir}/rediwm/themes/$name"done-for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper; do- mv -fT "$stage/$binary" "/usr/local/bin/$binary"+for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper rediwm-restart; do+ mv -fT "$stage/$binary" "${bindir}/$binary"done# The compositor draws the desktop itself; the old client is retired.-rm -f /usr/local/bin/rediwm-desktop+rm -f "${bindir}/rediwm-desktop"if [ "$install_dm" = yes ]; then- install -Dm644 "$repo_dir/data/rediwm-dm.service" /usr/lib/systemd/system/rediwm-dm.service- install -Dm644 "$repo_dir/data/rediwm-dm.sysusers" /usr/lib/sysusers.d/rediwm-dm.conf- install -Dm644 "$repo_dir/data/rediwm-dm.tmpfiles" /usr/lib/tmpfiles.d/rediwm-dm.conf+ install -Dm644 "$release_dir/share/rediwm/rediwm-dm.service" "${system_lib}/systemd/system/rediwm-dm.service"+ install -Dm644 "$repo_dir/data/rediwm-dm.sysusers" "${system_lib}/sysusers.d/rediwm-dm.conf"+ install -Dm644 "$repo_dir/data/rediwm-dm.tmpfiles" "${system_lib}/tmpfiles.d/rediwm-dm.conf"- if [ -f /etc/pam.d/system-local-login ]; then- install -Dm644 "$repo_dir/data/pam/rediwm-greeter" /etc/pam.d/rediwm-greeter- install -Dm644 "$repo_dir/data/pam/arch/rediwm-dm" /etc/pam.d/rediwm-dm- install -Dm644 "$repo_dir/data/pam/arch/rediwm-dm-autologin" /etc/pam.d/rediwm-dm-autologin+ pam_profile=${REDIWM_PAM_PROFILE:-}+ if [ -z "$pam_profile" ]; then+ if [ -f /etc/pam.d/system-local-login ]; then pam_profile=arch; else pam_profile=debian; fi+ fi+ case "$pam_profile" in arch|debian) ;; *) echo 'REDIWM_PAM_PROFILE must be arch or debian' >&2; exit 1 ;; esac+ if [ "$pam_profile" = arch ]; then+ install -Dm644 "$repo_dir/data/pam/rediwm-greeter" "${sysconf}/pam.d/rediwm-greeter"+ install -Dm644 "$repo_dir/data/pam/arch/rediwm-dm" "${sysconf}/pam.d/rediwm-dm"+ install -Dm644 "$repo_dir/data/pam/arch/rediwm-dm-autologin" "${sysconf}/pam.d/rediwm-dm-autologin"else- install -Dm644 "$repo_dir/data/pam/rediwm-greeter" /etc/pam.d/rediwm-greeter- install -Dm644 "$repo_dir/data/pam/debian/rediwm-dm" /etc/pam.d/rediwm-dm- install -Dm644 "$repo_dir/data/pam/debian/rediwm-dm-autologin" /etc/pam.d/rediwm-dm-autologin+ install -Dm644 "$repo_dir/data/pam/rediwm-greeter" "${sysconf}/pam.d/rediwm-greeter"+ install -Dm644 "$repo_dir/data/pam/debian/rediwm-dm" "${sysconf}/pam.d/rediwm-dm"+ install -Dm644 "$repo_dir/data/pam/debian/rediwm-dm-autologin" "${sysconf}/pam.d/rediwm-dm-autologin"fi- if [ ! -f /etc/rediwm/dm.conf ]; then- install -d /etc/rediwm- install -m644 "$repo_dir/data/rediwm-dm.conf" /etc/rediwm/dm.conf+ if [ ! -f "${sysconf}/rediwm/dm.conf" ]; then+ install -d "${sysconf}/rediwm"+ install -m644 "$release_dir/share/rediwm/rediwm-dm.conf" "${sysconf}/rediwm/dm.conf"fi# Only our own configs: a bare call would apply every sysusers/tmpfiles# entry on the system.- if command -v systemd-sysusers >/dev/null 2>&1; then- systemd-sysusers /usr/lib/sysusers.d/rediwm-dm.conf+ if [ -z "$dest" ] && command -v systemd-sysusers >/dev/null 2>&1; then+ systemd-sysusers "${system_lib}/sysusers.d/rediwm-dm.conf"fi- if command -v systemd-tmpfiles >/dev/null 2>&1; then- systemd-tmpfiles --create /usr/lib/tmpfiles.d/rediwm-dm.conf+ if [ -z "$dest" ] && command -v systemd-tmpfiles >/dev/null 2>&1; then+ systemd-tmpfiles --create "${system_lib}/tmpfiles.d/rediwm-dm.conf"fi- if command -v systemctl >/dev/null 2>&1; then+ if [ -z "$dest" ] && command -v systemctl >/dev/null 2>&1; thensystemctl daemon-reloadfifidiff --git a/scripts/install-session.sh b/scripts/install-session.shindex f13a10f..d0d70f8 100644--- a/scripts/install-session.sh+++ b/scripts/install-session.sh@@ -25,12 +25,14 @@ dm_flag=no# --prebuilt: install.sh unpacked a release, whose zig-out/release-safe is# already built (scripts/make-release.sh), so there is nothing to compile.prebuilt=no+prefix=${REDIWM_INSTALL_PREFIX:-/usr/local}for arg in "$@"; docase "$arg" in--no-restart) restart=no ;;--dm) dm_flag=yes ;;--prebuilt) prebuilt=yes ;;- *) echo "Usage: $0 [--no-restart] [--dm] [--prebuilt]" >&2; exit 1 ;;+ --prefix=*) prefix=${arg#--prefix=} ;;+ *) echo "Usage: $0 [--no-restart] [--dm] [--prebuilt] [--prefix=/usr/local]" >&2; exit 1 ;;esacdone@@ -50,11 +52,16 @@ if [ "$prebuilt" = no ]; thencd "$repo_dir"# Set by install.sh when it built the private wlroots (see scripts/build-wlroots.sh).if [ -n "${REDIWM_WLROOTS_PREFIX:-}" ]; then- as_user sh scripts/with-wlroots.sh "$REDIWM_WLROOTS_PREFIX" zig build -Doptimize=ReleaseSafe -j"$ZIG_JOBS" --prefix "$release_dir" -Dwlroots-prefix="$REDIWM_WLROOTS_PREFIX"+ as_user sh scripts/with-wlroots.sh "$REDIWM_WLROOTS_PREFIX" zig build -Doptimize=ReleaseSafe -j"$ZIG_JOBS" --prefix "$release_dir" -Dinstall-prefix="$prefix" -Dwlroots-prefix="$REDIWM_WLROOTS_PREFIX"else- as_user zig build -Doptimize=ReleaseSafe -j"$ZIG_JOBS" --prefix "$release_dir"+ as_user zig build -Doptimize=ReleaseSafe -j"$ZIG_JOBS" --prefix "$release_dir" -Dinstall-prefix="$prefix"fifi+built_prefix=$(cat "$release_dir/install-prefix")+if [ "${built_prefix%/}" != "${prefix%/}" ]; then+ echo "Build targets $built_prefix, not $prefix. Rebuild with --prefix=$prefix (prebuilt releases cannot be relocated)." >&2+ exit 1+fifor binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-images rediwm-monitor rediwm-editor rediwm-pdf rediwm-share-picker rediwm-dm rediwm-accounts-helper rediwm-restart; dotest -x "$release_dir/bin/$binary"donediff --git a/scripts/install.sh b/scripts/install.shindex 71fecba..c22c98e 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -53,6 +53,7 @@ while [ "$n" -gt 0 ]; doarg=$1; shift; n=$((n - 1))case "$arg" in--build) BUILD=yes ;;+ --prefix=*) BUILD=yes; set -- "$@" "$arg" ;;--prebuilt-only) PREBUILT_ONLY=yes ;;# For scripts/release-build.sh: install what a release build needs.--build-deps-only) BUILD=yes; DEPS_ONLY=yes ;;@@ -74,6 +75,7 @@ elif [ -f "$0" ]; thenLOCAL_SRC_DIR=$script_repofifi+if [ -n "${REDIWM_INSTALL_PREFIX:-}" ] && [ "$REDIWM_INSTALL_PREFIX" != /usr/local ]; then BUILD=yes; fiif [ -n "$LOCAL_SRC_DIR" ]; thenBUILD=yesfidiff --git a/scripts/make-deb.sh b/scripts/make-deb.shindex 477b4bd..6a7b0de 100644--- a/scripts/make-deb.sh+++ b/scripts/make-deb.sh@@ -1,8 +1,8 @@#!/bin/sh# Builds a .deb from an existing ReleaseSafe tree (zig-out/release-safe, see# scripts/install-session.sh and scripts/release-build.sh). The layout mirrors-# scripts/install-session-root.sh, which installs under /usr/local because the-# binaries, the session entry and rediwm-restart expect it. It does not enable+# scripts/install-session-root.sh, using the runtime prefix recorded by the+# build. Build with -Dinstall-prefix=/usr for distro packages. It does not enable# rediwm-dm or touch /etc/pam.d.## scripts/make-deb.sh [OUTDIR]@@ -21,7 +21,9 @@ command -v dpkg-deb >/dev/null || die "dpkg-deb is required"root=$(mktemp -d)trap 'rm -rf "$root"' EXIT-L="$root/usr/local"+prefix=$(cat "$rel/install-prefix")+prefix=${prefix%/}+L="$root$prefix"install -d "$L/bin" "$L/lib" "$L/share" "$root/usr/share" "$root/DEBIAN"for b in $bins; do install -m755 "$rel/bin/$b" "$L/bin/$b"; done@@ -33,7 +35,7 @@ install -d "$root/usr/share/polkit-1/actions" "$root/usr/share/wayland-sessions"cp "$rel/share/polkit-1/actions/org.rediwm.accounts.policy" "$root/usr/share/polkit-1/actions/"cp "$rel/share/wayland-sessions/rediwm-release-safe.desktop" "$root/usr/share/wayland-sessions/"install -m644 "$repo/data/rediwm.portal" "$root/usr/share/xdg-desktop-portal/portals/rediwm.portal"-# Everything else lives under /usr/local/share, as the binaries expect.+# Remaining data follows the configured prefix.(cd "$rel/share" && tar -cf - --exclude=./polkit-1 --exclude=./wayland-sessions --exclude=./xdg-desktop-portal/portals .) | (cd "$L/share" && tar -xf -)install -Dm644 "$repo/data/xdg-desktop-portal-wlr.ini" "$L/share/xdg-desktop-portal-wlr/config"install -Dm644 "$repo/data/rediwm-theme.xml" "$L/share/mime/packages/rediwm-theme.xml"@@ -44,13 +46,13 @@ install -Dm644 "$repo/LICENSE-MIT" "$root/usr/share/doc/rediwm/copyright"install -Dm644 "$repo/LICENSE-APACHE" "$root/usr/share/doc/rediwm/LICENSE-APACHE"# The dm files are shipped as examples only: nothing enables the display manager.install -d "$root/usr/share/doc/rediwm/examples"-cp -r "$repo/data/pam" "$repo/data/rediwm-dm.conf" "$repo/data/rediwm-dm.service" "$repo/data/rediwm-dm.sysusers" "$repo/data/rediwm-dm.tmpfiles" "$root/usr/share/doc/rediwm/examples/"+cp -r "$repo/data/pam" "$rel/share/rediwm/rediwm-dm.conf" "$rel/share/rediwm/rediwm-dm.service" "$repo/data/rediwm-dm.sysusers" "$repo/data/rediwm-dm.tmpfiles" "$root/usr/share/doc/rediwm/examples/"find "$root" -type d -exec chmod 755 {} +-find "$root/usr" -type f ! -perm -u+x -exec chmod 644 {} ++find "$root" -type f ! -perm -u+x -exec chmod 644 {} +# cp -a and tar keep the build tree's modes: under umask 077 the bundled libraries# would ship root-only and the compositor could not load them for users.-find "$root/usr" -type f -perm -u+x -exec chmod 755 {} ++find "$root" -type f -perm -u+x -exec chmod 755 {} +# Dependencies: the packages owning every system library the ELF files need,# except the ones bundled in lib/rediwm.@@ -67,7 +69,7 @@ deps=$(done | sort -u | paste -sd, - | sed 's/,/, /g')[ -n "$deps" ] || die "no package owns the linked libraries: build on Debian or Ubuntu, where dpkg -S knows them"-size=$(du -sk "$root/usr" | cut -f1)+size=$(du -sk "$root" | cut -f1)cat > "$root/DEBIAN/control" <<EOFPackage: rediwm@@ -82,25 +84,25 @@ Recommends: xwayland, foot, polkitdDescription: RediWM Wayland compositor with its own desktop shellSingle-process wlroots compositor with taskbar, start menu, settings,lock screen, notifications, file manager and image viewer. Installed under- /usr/local, as upstream's installer does. rediwm-dm is installed but never+ $prefix. rediwm-dm is installed but neverenabled.EOF-cat > "$root/DEBIAN/postinst" <<'EOF'+cat > "$root/DEBIAN/postinst" <<EOF#!/bin/shset -e-if command -v update-mime-database >/dev/null 2>&1; then update-mime-database /usr/local/share/mime || true; fi-if command -v update-desktop-database >/dev/null 2>&1; then update-desktop-database /usr/local/share/applications || true; fi-if command -v gtk-update-icon-cache >/dev/null 2>&1; then gtk-update-icon-cache -q -t /usr/local/share/icons/hicolor 2>/dev/null || true; fi+if command -v update-mime-database >/dev/null 2>&1; then update-mime-database $prefix/share/mime || true; fi+if command -v update-desktop-database >/dev/null 2>&1; then update-desktop-database $prefix/share/applications || true; fi+if command -v gtk-update-icon-cache >/dev/null 2>&1; then gtk-update-icon-cache -q -t $prefix/share/icons/hicolor 2>/dev/null || true; fiexit 0EOF-cat > "$root/DEBIAN/postrm" <<'EOF'+cat > "$root/DEBIAN/postrm" <<EOF#!/bin/shset -e-case "$1" in+case "\$1" inremove|purge)- if command -v update-mime-database >/dev/null 2>&1 && [ -d /usr/local/share/mime/packages ]; then update-mime-database /usr/local/share/mime || true; fi- if command -v update-desktop-database >/dev/null 2>&1 && [ -d /usr/local/share/applications ]; then update-desktop-database /usr/local/share/applications || true; fi+ if command -v update-mime-database >/dev/null 2>&1 && [ -d $prefix/share/mime/packages ]; then update-mime-database $prefix/share/mime || true; fi+ if command -v update-desktop-database >/dev/null 2>&1 && [ -d $prefix/share/applications ]; then update-desktop-database $prefix/share/applications || true; fi;;esacexit 0diff --git a/src/accounts/model.zig b/src/accounts/model.zigindex 8d598cf..cd8db2e 100644--- a/src/accounts/model.zig+++ b/src/accounts/model.zig@@ -102,7 +102,7 @@ pub fn load(a: std.mem.Allocator, io: std.Io) !Snapshot {const config = std.Io.Dir.cwd().readFileAlloc(io, "/etc/rediwm/dm.conf", a, .limited(64 * 1024)) catch "";defer if (config.len > 0) a.free(config);const auto = try parseAutologin(a, config);- const sessions = ws.loadSessions(a, io, "/usr/local/share:/usr/share", "/usr/local/bin:/usr/bin:/bin") catch &.{};+ const sessions = ws.loadSessions(a, io, @import("install_paths").data_dirs, @import("install_paths").search_path) catch &.{};return .{ .users = users.items, .groups = groups.items, .sessions = sessions, .autologin_user = auto.user, .autologin_session = auto.session };}diff --git a/src/control_center/AGENTS.md b/src/control_center/AGENTS.mdindex 3f0f1c9..9b04f39 100644--- a/src/control_center/AGENTS.md+++ b/src/control_center/AGENTS.md@@ -67,3 +67,6 @@ helpers (and `panel.ControlCenter`); `sections/` one file per page.Use `showingPage`, rather than `page`, in background callbacks: an emptysearch covers the selected page. The search field owns its text across rebuilds;navigation is deferred until widget dispatch has finished.++* `sections/users_helper.zig` owns the account helper request and authorization+ lifetime; `users.zig` owns the account UI.diff --git a/src/control_center/sections/users.zig b/src/control_center/sections/users.zigindex fc98fbd..621cb90 100644--- a/src/control_center/sections/users.zig+++ b/src/control_center/sections/users.zig@@ -1,18 +1,19 @@//! Account overview and automatic-login settings.const i18n = @import("i18n");const std = @import("std");-const Child = @import("../../session/child.zig");const panel = @import("../panel.zig");const model = @import("../../accounts/model.zig");const validation = @import("../../accounts/validation.zig");const ui = @import("ui");const W = ui.layout.Widget;const gpa = @import("../../main.zig").gpa;-const c = @import("c");const secret_input = ui.widgets.secret_input;extern fn rediwm_polkit_secret_new() ?*anyopaque;extern fn rediwm_polkit_secret_free(*anyopaque) void;-extern fn rediwm_polkit_clear([*]u8, usize) void;+const helper = @import("users_helper.zig");+const AuthRequest = helper.AuthRequest;+const startHelper = helper.startHelper;+pub const cancelAuthorization = helper.cancelAuthorization;const Form = enum { none, add, details, password, delete_confirm };const max_groups = 256;@@ -52,14 +53,6 @@ pub const Section = struct {group_target_len: usize = 0,};-const AuthRequest = struct {- allocator: std.mem.Allocator,- cc: ?*panel.ControlCenter,- io: std.Io,- child: *Child,- is_authorization: bool,-};-fn text(value: []const u8, size: f32, dim: bool) W {const t = panel.palette();return .{ .kind = .{ .text = .{ .content = value, .font_size = size, .weight = if (dim) 400 else 600, .color = if (dim) t.dim else t.fg } } };@@ -737,84 +730,3 @@ fn autologinSessionChanged(owner: ?*anyopaque, _: usize, index: usize) void {cc.refresh();};}--fn startHelper(cc: *panel.ControlCenter, request: anytype, is_authorization: bool) !void {- if (cc.users.auth != null) return;- const req = try gpa.create(AuthRequest);- errdefer gpa.destroy(req);- req.* = .{ .allocator = gpa, .cc = cc, .io = cc.server.io, .child = undefined, .is_authorization = is_authorization };- const encoded = try std.json.Stringify.valueAlloc(gpa, request, .{});- const contains_secret = comptime @hasField(@TypeOf(request), "password");- defer {- if (contains_secret) rediwm_polkit_clear(encoded.ptr, encoded.len);- gpa.free(encoded);- }- var sockets: [2]c_int = undefined;- if (c.socketpair(c.AF_UNIX, c.SOCK_STREAM | c.SOCK_CLOEXEC, 0, &sockets) != 0) return error.SocketPairFailed;- defer {- if (sockets[0] >= 0) _ = c.close(sockets[0]);- if (sockets[1] >= 0) _ = c.close(sockets[1]);- }-- const executable = if (c.access("/usr/bin/pkexec", c.X_OK) == 0) "/usr/bin/pkexec" else "/bin/pkexec";- var child = try std.process.spawn(cc.server.io, .{- .argv = &.{ executable, "--disable-internal-agent", "/usr/local/bin/rediwm-accounts-helper" },- .stdin = .{ .file = .{ .handle = sockets[0], .flags = .{ .nonblocking = false } } },- .stdout = .ignore,- .stderr = .ignore,- });- errdefer {- child.kill(cc.server.io);- }- _ = c.close(sockets[0]);- sockets[0] = -1;- var written: usize = 0;- while (written < encoded.len) {- const n = c.send(sockets[1], encoded.ptr + written, encoded.len - written, c.MSG_NOSIGNAL);- if (n <= 0) return error.RequestWriteFailed;- written += @intCast(n);- }- _ = c.close(sockets[1]);- sockets[1] = -1;- req.child = try Child.watch(gpa, cc.server.wl_server.getEventLoop(), child.id.?, req, authReady);- cc.users.auth = req;- cc.users.message = "";- cc.refresh();-}--fn authReady(owner: ?*anyopaque, _: *Child, status: ?u32) void {- const req: *AuthRequest = @ptrCast(@alignCast(owner.?));- if (req.cc) |cc| {- if (cc.users.auth == req) {- cc.users.auth = null;- if (status != null and status.? == 0) {- if (req.is_authorization) {- cc.users.unlocked = true;- cc.users.message = "";- } else {- cc.users.message = i18n.tr("Changes saved.");- }- } else {- if (req.is_authorization) {- cc.users.unlocked = false;- cc.users.message = i18n.tr("Authentication was cancelled or denied.");- } else {- cc.users.message = i18n.tr("No changes were made. Authentication was cancelled or the request failed.");- }- }- cc.refresh();- }- }- req.allocator.destroy(req);-}--/// Stop a pending pkexec when its Settings window closes.-pub fn cancelAuthorization(cc: *panel.ControlCenter) void {- if (cc.users.auth) |req| {- cc.users.auth = null;- req.cc = null;- req.child.signal(.TERM);- req.child.detach();- req.allocator.destroy(req);- }-}diff --git a/src/control_center/sections/users_helper.zig b/src/control_center/sections/users_helper.zignew file mode 100644index 0000000..1ecfbd4--- /dev/null+++ b/src/control_center/sections/users_helper.zig@@ -0,0 +1,97 @@+//! Privileged account helper requests and their asynchronous lifetime.+const std = @import("std");+const i18n = @import("i18n");+const panel = @import("../panel.zig");+const Child = @import("../../session/child.zig");+const gpa = @import("../../main.zig").gpa;+const c = @import("c");+extern fn rediwm_polkit_clear([*]u8, usize) void;++pub const AuthRequest = struct {+ allocator: std.mem.Allocator,+ cc: ?*panel.ControlCenter,+ io: std.Io,+ child: *Child,+ is_authorization: bool,+};++pub fn startHelper(cc: *panel.ControlCenter, request: anytype, is_authorization: bool) !void {+ if (cc.users.auth != null) return;+ const req = try gpa.create(AuthRequest);+ errdefer gpa.destroy(req);+ req.* = .{ .allocator = gpa, .cc = cc, .io = cc.server.io, .child = undefined, .is_authorization = is_authorization };+ const encoded = try std.json.Stringify.valueAlloc(gpa, request, .{});+ const contains_secret = comptime @hasField(@TypeOf(request), "password");+ defer {+ if (contains_secret) rediwm_polkit_clear(encoded.ptr, encoded.len);+ gpa.free(encoded);+ }+ var sockets: [2]c_int = undefined;+ if (c.socketpair(c.AF_UNIX, c.SOCK_STREAM | c.SOCK_CLOEXEC, 0, &sockets) != 0) return error.SocketPairFailed;+ defer {+ if (sockets[0] >= 0) _ = c.close(sockets[0]);+ if (sockets[1] >= 0) _ = c.close(sockets[1]);+ }++ const executable = if (c.access("/usr/bin/pkexec", c.X_OK) == 0) "/usr/bin/pkexec" else "/bin/pkexec";+ var child = try std.process.spawn(cc.server.io, .{+ .argv = &.{ executable, "--disable-internal-agent", @import("install_paths").bin ++ "/rediwm-accounts-helper" },+ .stdin = .{ .file = .{ .handle = sockets[0], .flags = .{ .nonblocking = false } } },+ .stdout = .ignore,+ .stderr = .ignore,+ });+ errdefer {+ child.kill(cc.server.io);+ }+ _ = c.close(sockets[0]);+ sockets[0] = -1;+ var written: usize = 0;+ while (written < encoded.len) {+ const n = c.send(sockets[1], encoded.ptr + written, encoded.len - written, c.MSG_NOSIGNAL);+ if (n <= 0) return error.RequestWriteFailed;+ written += @intCast(n);+ }+ _ = c.close(sockets[1]);+ sockets[1] = -1;+ req.child = try Child.watch(gpa, cc.server.wl_server.getEventLoop(), child.id.?, req, authReady);+ cc.users.auth = req;+ cc.users.message = "";+ cc.refresh();+}++fn authReady(owner: ?*anyopaque, _: *Child, status: ?u32) void {+ const req: *AuthRequest = @ptrCast(@alignCast(owner.?));+ if (req.cc) |cc| {+ if (cc.users.auth == req) {+ cc.users.auth = null;+ if (status != null and status.? == 0) {+ if (req.is_authorization) {+ cc.users.unlocked = true;+ cc.users.message = "";+ } else {+ cc.users.message = i18n.tr("Changes saved.");+ }+ } else {+ if (req.is_authorization) {+ cc.users.unlocked = false;+ cc.users.message = i18n.tr("Authentication was cancelled or denied.");+ } else {+ cc.users.message = i18n.tr("No changes were made. Authentication was cancelled or the request failed.");+ }+ }+ cc.refresh();+ }+ }+ req.allocator.destroy(req);+}++/// Stop a pending pkexec when its Settings window closes.+pub fn cancelAuthorization(cc: *panel.ControlCenter) void {+ if (cc.users.auth) |req| {+ cc.users.auth = null;+ req.cc = null;+ req.child.signal(.TERM);+ req.child.detach();+ req.allocator.destroy(req);+ }+}diff --git a/src/dm/config.zig b/src/dm/config.zigindex 6c366e8..0919163 100644--- a/src/dm/config.zig+++ b/src/dm/config.zig@@ -5,7 +5,7 @@ const std = @import("std");pub const Config = struct {vt: u32 = 1,greeter_user: []const u8 = "rediwm-greeter",- greeter_command: []const u8 = "/usr/local/bin/rediwm --greeter",+ greeter_command: []const u8 = @import("install_paths").bin ++ "/rediwm --greeter",autologin_user: ?[]const u8 = null,autologin_session: ?[]const u8 = null,@@ -115,7 +115,7 @@ test "default config values" {const conf = Config{};try std.testing.expectEqual(@as(u32, 1), conf.vt);try std.testing.expectEqualStrings("rediwm-greeter", conf.greeter_user);- try std.testing.expectEqualStrings("/usr/local/bin/rediwm --greeter", conf.greeter_command);+ try std.testing.expectEqualStrings(@import("install_paths").bin ++ "/rediwm --greeter", conf.greeter_command);try std.testing.expect(conf.autologin_user == null);try std.testing.expect(conf.autologin_session == null);}diff --git a/src/dm/worker.zig b/src/dm/worker.zigindex 74b5043..66939ad 100644--- a/src/dm/worker.zig+++ b/src/dm/worker.zig@@ -29,7 +29,7 @@ const PAM_DELETE_CRED: c_int = 0x0004;/// How long a session gets to exit after SIGTERM before SIGKILL.const stop_grace_ms = 5000;-const default_path = "/usr/local/sbin:/usr/local/bin:/usr/bin:/bin";+const default_path = @import("install_paths").search_path;fn report(fd: c_int, tag: proto.Report, text: []const u8) void {proto.writeFrameParts(fd, &.{ &.{@intFromEnum(tag)}, text }) catch {};diff --git a/src/session/greeter.zig b/src/session/greeter.zigindex 97d774d..e9d555d 100644--- a/src/session/greeter.zig+++ b/src/session/greeter.zig@@ -89,8 +89,8 @@ pub const Greeter = struct {log.err("cannot list accounts: {}", .{err});break :blk &.{};};- const data_dirs = environ.getPosix("XDG_DATA_DIRS") orelse "/usr/local/share:/usr/share";- const search = environ.getPosix("PATH") orelse "/usr/local/sbin:/usr/local/bin:/usr/bin";+ const data_dirs = environ.getPosix("XDG_DATA_DIRS") orelse @import("install_paths").data_dirs;+ const search = environ.getPosix("PATH") orelse @import("install_paths").search_path;self.sessions = ws.loadSessions(a, io, data_dirs, search) catch |err| blk: {log.err("cannot list sessions: {}", .{err});break :blk &.{};diff --git a/src/session/wayland_sessions.zig b/src/session/wayland_sessions.zigindex dfce692..c0dc159 100644--- a/src/session/wayland_sessions.zig+++ b/src/session/wayland_sessions.zig@@ -3,6 +3,7 @@const std = @import("std");pub const standard_data_dirs: []const []const u8 = &.{+ @import("install_paths").data,"/usr/local/share","/usr/share",};diff --git a/src/session_restart.zig b/src/session_restart.zigindex 3b950ec..7f56ac2 100644--- a/src/session_restart.zig+++ b/src/session_restart.zig@@ -5,14 +5,14 @@//! through SO_PEERCRED that the listener is this user's process running the//! installed executable, asks it to restart, then waits until the same PID//! answers again from the new executable. Usage:-//! `rediwm-restart [installed [socket]]` (default /usr/local/bin/rediwm). The+//! `rediwm-restart [installed [socket]]` (default: configured installation). The//! socket is an argument, never `REDIWM_SOCKET`: a shell started from the live//! session inherits that variable, and a stray run would restart the desktop.const std = @import("std");const linux = std.os.linux;const c = std.posix.system;-const default_installed = "/usr/local/bin/rediwm";+const default_installed = @import("install_paths").bin ++ "/rediwm";const io_timeout_s = 3;const ready_timeout_ms = 20_000;const poll_interval_ms = 200;diff --git a/tests/install_layout.py b/tests/install_layout.pynew file mode 100644index 0000000..f1b67d2--- /dev/null+++ b/tests/install_layout.py@@ -0,0 +1,66 @@+#!/usr/bin/env python3+"""Check a built layout and stage the real installer without root or host changes.++Run for both layouts (the runtime prefix and output directory are independent):+ zig build+ python3 tests/install_layout.py zig-out /usr/local+ zig build -Dinstall-prefix=/usr --prefix zig-out/package+ python3 tests/install_layout.py zig-out/package /usr+"""+import os+from pathlib import Path+import subprocess+import sys+import tempfile+import xml.etree.ElementTree as ET++ROOT = Path(__file__).resolve().parents[1]+++def check(tree, prefix):+ bindir = prefix.rstrip('/') + '/bin'+ assert tree.joinpath('install-prefix').read_text().strip().rstrip('/') == prefix.rstrip('/')+ for name, command in [('rediwm-dm', 'rediwm --greeter'),+ ('rediwm-restart', 'rediwm'),+ ('rediwm', 'rediwm-accounts-helper')]:+ assert f'{bindir}/{command}'.encode() in (tree / 'bin' / name).read_bytes(), name++ with tempfile.TemporaryDirectory(prefix='rediwm-install-') as directory:+ stage = Path(directory)+ env = dict(os.environ, DESTDIR=directory)+ command = ['sh', str(ROOT / 'scripts/install-session-root.sh'), str(ROOT), str(tree), 'yes']+ subprocess.run(command, env=env, check=True)+ installed_bin = stage / bindir.lstrip('/')+ assert (installed_bin / 'rediwm-restart').is_file()+ assert not list(installed_bin.glob('.rediwm-install.*'))+ for path in (tree / 'share').rglob('*.desktop'):+ text = path.read_text()+ assert '@BINDIR@' not in text+ for line in text.splitlines():+ if line.startswith(('Exec=', 'TryExec=')):+ executable = line.split('=', 1)[1].split()[0]+ assert executable.startswith(bindir + '/'), (path, executable)+ assert (stage / executable.lstrip('/')).is_file(), executable+ policy = stage / 'usr/share/polkit-1/actions/org.rediwm.accounts.policy'+ annotation = ET.parse(policy).find('.//annotate')+ assert annotation.text == f'{bindir}/rediwm-accounts-helper'+ service = stage / 'usr/lib/systemd/system/rediwm-dm.service'+ assert f'ExecStart={bindir}/rediwm-dm\n' in service.read_text()+ config = stage / 'etc/rediwm/dm.conf'+ assert f'greeter_command = {bindir}/rediwm --greeter' in config.read_text()+ for path in stage.rglob('*'):+ if path.is_file() and path.suffix in ('.desktop', '.service', '.conf', '.policy'):+ contents = path.read_text()+ assert '@BINDIR@' not in contents, path+ assert directory not in contents, path+ if prefix != '/usr/local':+ assert '/usr/local/bin/rediwm' not in contents, path+ # Updates must preserve an administrator's DM configuration.+ config.write_text('greeter_command = /custom/greeter\n')+ subprocess.run(command, env=env, check=True)+ assert config.read_text() == 'greeter_command = /custom/greeter\n'+ print(f'PASS: generated files, runtime paths and staged installation for {prefix}')+++if __name__ == '__main__':+ check(Path(sys.argv[1]).resolve(), sys.argv[2])diff --git a/tests/session_restart.py b/tests/session_restart.pyindex 4e88218..94bdd39 100644--- a/tests/session_restart.py+++ b/tests/session_restart.py@@ -1,6 +1,7 @@#!/usr/bin/env python3"""Replace a live executable and restart twice, preserving PID and renewing IPC."""import os+import jsonfrom pathlib import Pathimport shutilimport subprocess@@ -14,6 +15,15 @@ def run():restart = ROOT / 'zig-out/release-safe/bin/rediwm-restart'with tempfile.TemporaryDirectory(prefix='rediwm-restart-') as directory:tmp = Path(directory)+ # Compile a helper with a private runtime prefix, so its no-argument+ # path can be exercised without writing to a system installation.+ options = tmp / 'install_paths.zig'+ options.write_text('pub const bin = ' + json.dumps(str(tmp)) + ';\n')+ configured_restart = tmp / 'rediwm-restart'+ subprocess.run(['zig', 'build-exe', '-lc', '--dep', 'install_paths',+ '-Mroot=' + str(ROOT / 'src/session_restart.zig'),+ '-Minstall_paths=' + str(options),+ '-femit-bin=' + str(configured_restart)], check=True)binary = tmp / 'rediwm'source = ROOT / 'zig-out/release-safe/bin/rediwm'shutil.copy2(source, binary)@@ -22,6 +32,11 @@ def run():env = dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WLR_BACKENDS='headless',WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER='gles2',REDIWM_CONFIG=str(config), XDG_CACHE_HOME=str(tmp / 'cache'),+ HOME=str(tmp), XDG_CONFIG_HOME=str(tmp / 'config'),+ XDG_STATE_HOME=str(tmp / 'state'), XDG_DATA_HOME=str(tmp / 'data'),+ DBUS_SYSTEM_BUS_ADDRESS='unix:path=' + str(tmp / 'no-system-bus'),+ DBUS_SESSION_BUS_ADDRESS='unix:path=' + str(tmp / 'no-session-bus'),+ REDIWM_IPC_AUTOMATION='1', REDIWM_FILES_DEVICES='0',REDIWM_SOCKET=str(tmp / 'rediwm-test.sock'))env.pop('WAYLAND_DISPLAY', None)with (tmp / 'compositor.log').open('w') as log:@@ -32,14 +47,15 @@ def run():assert proc.poll() is None, 'compositor exited at startup'assert time.monotonic() < deadline, 'IPC not ready'time.sleep(.05)- for _ in range(2):+ for command in ([str(restart), str(binary), env['REDIWM_SOCKET']],+ [str(configured_restart)]):with IPCClient(env['REDIWM_SOCKET']) as previous:assert previous.request(query='version')staged = tmp / 'replacement'shutil.copy2(source, staged)staged.replace(binary)assert os.readlink(f'/proc/{proc.pid}/exe').endswith(' (deleted)')- result = subprocess.run([str(restart), str(binary), env['REDIWM_SOCKET']], env=env, capture_output=True, text=True, timeout=40)+ result = subprocess.run(command, env=env, capture_output=True, text=True, timeout=40)assert result.returncode == 0, result.stdout + result.stderrassert 'restarted successfully' in result.stdout, result.stdoutassert proc.poll() is None, 'login process exited'@@ -47,7 +63,7 @@ def run():assert previous.sock.recv(1) == b'', 'old client connection survived restart'with IPCClient(env['REDIWM_SOCKET']) as ipc:assert ipc.request(query='outputs'), 'output missing after restart'- print('PASS: two atomic executable replacements; PID preserved, IPC renewed, output available')+ print('PASS: explicit and configured helper paths; two atomic replacements; PID preserved, IPC renewed, output available')except BaseException:log.flush()print((tmp / 'compositor.log').read_text())