summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2025-03-23 22:48:06 +0900
committerChristopher Baines <mail@cbaines.net>2025-04-11 12:42:47 +0100
commit41c40bc1cf8a3dbcf4ee4dd2a1915ea1f89d5ba3 (patch)
tree9bb87065051aac5570fd18a04ec7706e812d0923
parent383f7f5c89caf4342a7af6f88cad1d41e3af74ff (diff)
gnu: localed: Update to 257.4.
* gnu/packages/freedesktop.scm (localed): Update to 257.4. [source]: Streamline snippet; no longer adjust to use /var/run instead of /run. [arguments] <#:phases>: Adjust set-xkeyboard-config-file-name phase. * gnu/packages/patches/localed-xorg-keyboard.patch: Rebase patch. Change-Id: I3853ee2b64b7f48ea4592aa206ecee86a7164185
-rw-r--r--gnu/packages/freedesktop.scm13
-rw-r--r--gnu/packages/patches/localed-xorg-keyboard.patch340
2 files changed, 173 insertions, 180 deletions
diff --git a/gnu/packages/freedesktop.scm b/gnu/packages/freedesktop.scm
index 8e955dd417..f1e31424d3 100644
--- a/gnu/packages/freedesktop.scm
+++ b/gnu/packages/freedesktop.scm
@@ -1060,7 +1060,7 @@ This library provides just sd-bus (and the busctl utility).")
;; that it would make more sense to maintain a fork of the bits we need.
(package
(name "localed")
- (version "241")
+ (version "257.4")
(source (origin
(method git-fetch)
(uri (git-reference
@@ -1068,18 +1068,11 @@ This library provides just sd-bus (and the busctl utility).")
(commit (string-append "v" version))))
(sha256
(base32
- "0sy91flzbhpq58k7v0294pa2gxpr0bk27rcnxlbhk2fi6nc51d28"))
+ "06fackmig43p9xx1155vrr5bx8a6a1cfb958x5acxvvahi8lkg7a"))
(file-name (git-file-name name version))
(modules '((guix build utils)))
(snippet
'(begin
- ;; Connect to the right location for our D-Bus daemon.
- (substitute* '("src/basic/def.h"
- "src/libsystemd/sd-bus/sd-bus.c"
- "src/stdio-bridge/stdio-bridge.c")
- (("/run/dbus/system_bus_socket")
- "/var/run/dbus/system_bus_socket"))
-
;; Don't insist on having systemd as PID 1 (otherwise
;; 'localectl' would exit without doing anything.)
(substitute* "src/shared/bus-util.c"
@@ -1143,7 +1136,7 @@ This library provides just sd-bus (and the busctl utility).")
(substitute* "src/locale/localectl.c"
(("/usr/share/X11/xkb/rules")
(string-append xkb "/share/X11/xkb/rules")))
- (substitute* "src/basic/def.h"
+ (substitute* "src/shared/kbd-util.c"
(("/usr/share/keymaps")
(string-append kbd "/share/keymaps"))))))
(replace 'install
diff --git a/gnu/packages/patches/localed-xorg-keyboard.patch b/gnu/packages/patches/localed-xorg-keyboard.patch
index 9a9071ba0a..762bc70ed0 100644
--- a/gnu/packages/patches/localed-xorg-keyboard.patch
+++ b/gnu/packages/patches/localed-xorg-keyboard.patch
@@ -9,39 +9,55 @@ stateful bits that would write configuration to /etc/vconsole.conf
and /etc/X11, which are unused in Guix anyway.
Patch by Ludovic Courtès <ludo@gnu.org>.
+Ported from v241 to v257 by Maxim Cournoyer <maxim.cournoyer@gmail.com>
-diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c
-index 6b6b32a591..46aab472b0 100644
---- a/src/locale/keymap-util.c
-+++ b/src/locale/keymap-util.c
-@@ -174,32 +174,16 @@ int vconsole_read_data(Context *c, sd_bus_message *m) {
+diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c
+index 6413288ea3..c2a1c70e9e 100644
+--- a/src/locale/localed-util.c
++++ b/src/locale/localed-util.c
+@@ -349,47 +349,18 @@ int vconsole_read_data(Context *c, sd_bus_message *m) {
c->vc_cache = sd_bus_message_ref(m);
}
-- if (stat("/etc/vconsole.conf", &st) < 0) {
-- if (errno != ENOENT)
-- return -errno;
--
-- c->vc_mtime = USEC_INFINITY;
-- context_free_vconsole(c);
+- fd = RET_NERRNO(open("/etc/vconsole.conf", O_CLOEXEC | O_PATH));
+- if (fd == -ENOENT) {
+- c->vc_stat = (struct stat) {};
+- vc_context_clear(&c->vc);
+- x11_context_clear(&c->x11_from_vc);
- return 0;
- }
+- if (fd < 0)
+- return fd;
-
-- /* If mtime is not changed, then we do not need to re-read */
-- t = timespec_load(&st.st_mtim);
-- if (c->vc_mtime != USEC_INFINITY && t == c->vc_mtime)
-- return 0;
+- if (fstat(fd, &st) < 0)
+- return -errno;
-
-- c->vc_mtime = t;
-+ c->vc_mtime = USEC_INFINITY;
- context_free_vconsole(c);
+- /* If the file is not changed, then we do not need to re-read */
+- if (stat_inode_unmodified(&c->vc_stat, &st))
+- return 0;
-
-- r = parse_env_file(NULL, "/etc/vconsole.conf",
-- "KEYMAP", &c->vc_keymap,
-- "KEYMAP_TOGGLE", &c->vc_keymap_toggle);
+- c->vc_stat = st;
++ c->vc_stat = (struct stat) {};
+ vc_context_clear(&c->vc);
+ x11_context_clear(&c->x11_from_vc);
+
+- r = parse_env_file_fd(
+- fd, "/etc/vconsole.conf",
+- "KEYMAP", &c->vc.keymap,
+- "KEYMAP_TOGGLE", &c->vc.toggle,
+- "XKBLAYOUT", &c->x11_from_vc.layout,
+- "XKBMODEL", &c->x11_from_vc.model,
+- "XKBVARIANT", &c->x11_from_vc.variant,
+- "XKBOPTIONS", &c->x11_from_vc.options);
- if (r < 0)
- return r;
-
+- if (vc_context_verify(&c->vc) < 0)
+- vc_context_clear(&c->vc);
+-
+- if (x11_context_verify(&c->x11_from_vc) < 0)
+- x11_context_clear(&c->x11_from_vc);
+-
return 0;
}
@@ -51,52 +67,52 @@ index 6b6b32a591..46aab472b0 100644
+}
+
int x11_read_data(Context *c, sd_bus_message *m) {
+ _cleanup_close_ int fd = -EBADF;
_cleanup_fclose_ FILE *f = NULL;
- bool in_section = false;
-@@ -216,258 +200,27 @@ int x11_read_data(Context *c, sd_bus_message *m) {
+@@ -408,195 +379,23 @@ int x11_read_data(Context *c, sd_bus_message *m) {
c->x11_cache = sd_bus_message_ref(m);
}
-- if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &st) < 0) {
-- if (errno != ENOENT)
-- return -errno;
--
-- c->x11_mtime = USEC_INFINITY;
-- context_free_x11(c);
+- fd = RET_NERRNO(open("/etc/X11/xorg.conf.d/00-keyboard.conf", O_CLOEXEC | O_PATH));
+- if (fd == -ENOENT) {
+- c->x11_stat = (struct stat) {};
+- x11_context_clear(&c->x11_from_xorg);
- return 0;
- }
+- if (fd < 0)
+- return fd;
-
-- /* If mtime is not changed, then we do not need to re-read */
-- t = timespec_load(&st.st_mtim);
-- if (c->x11_mtime != USEC_INFINITY && t == c->x11_mtime)
+- if (fstat(fd, &st) < 0)
+- return -errno;
+-
+- /* If the file is not changed, then we do not need to re-read */
+- if (stat_inode_unmodified(&c->x11_stat, &st))
- return 0;
-
-- c->x11_mtime = t;
-+ c->x11_mtime = 0;
- context_free_x11(c);
+- c->x11_stat = st;
++ c->x11_stat = (struct stat) {};
+ x11_context_clear(&c->x11_from_xorg);
-- f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
-- if (!f)
-- return -errno;
+- r = fdopen_independent(fd, "re", &f);
+- if (r < 0)
+- return r;
-
- for (;;) {
- _cleanup_free_ char *line = NULL;
-- char *l;
-
-- r = read_line(f, LONG_LINE_MAX, &line);
+- r = read_stripped_line(f, LONG_LINE_MAX, &line);
- if (r < 0)
- return r;
- if (r == 0)
- break;
-
-- l = strstrip(line);
-- if (IN_SET(l[0], 0, '#'))
+- if (IN_SET(line[0], 0, '#'))
- continue;
-
-- if (in_section && first_word(l, "Option")) {
+- if (in_section && first_word(line, "Option")) {
- _cleanup_strv_free_ char **a = NULL;
-
-- r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
+- r = strv_split_full(&a, line, WHITESPACE, EXTRACT_UNQUOTE);
- if (r < 0)
- return r;
-
@@ -104,146 +120,93 @@ index 6b6b32a591..46aab472b0 100644
- char **p = NULL;
-
- if (streq(a[1], "XkbLayout"))
-- p = &c->x11_layout;
+- p = &c->x11_from_xorg.layout;
- else if (streq(a[1], "XkbModel"))
-- p = &c->x11_model;
+- p = &c->x11_from_xorg.model;
- else if (streq(a[1], "XkbVariant"))
-- p = &c->x11_variant;
+- p = &c->x11_from_xorg.variant;
- else if (streq(a[1], "XkbOptions"))
-- p = &c->x11_options;
+- p = &c->x11_from_xorg.options;
-
-- if (p) {
+- if (p)
- free_and_replace(*p, a[2]);
-- }
- }
-
-- } else if (!in_section && first_word(l, "Section")) {
+- } else if (!in_section && first_word(line, "Section")) {
- _cleanup_strv_free_ char **a = NULL;
-
-- r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
+- r = strv_split_full(&a, line, WHITESPACE, EXTRACT_UNQUOTE);
- if (r < 0)
- return -ENOMEM;
-
- if (strv_length(a) == 2 && streq(a[1], "InputClass"))
- in_section = true;
-
-- } else if (in_section && first_word(l, "EndSection"))
+- } else if (in_section && first_word(line, "EndSection"))
- in_section = false;
- }
-+ c->x11_layout = getenv_strdup("GUIX_XKB_LAYOUT");
-+ c->x11_model = getenv_strdup("GUIX_XKB_MODEL");
-+ c->x11_variant = getenv_strdup("GUIX_XKB_VARIANT");
-+ c->x11_options = getenv_strdup("GUIX_XKB_OPTIONS");
+-
+- if (x11_context_verify(&c->x11_from_xorg) < 0)
+- x11_context_clear(&c->x11_from_xorg);
++ c->x11_from_xorg.layout = getenv_strdup("GUIX_XKB_LAYOUT");
++ c->x11_from_xorg.model = getenv_strdup("GUIX_XKB_MODEL");
++ c->x11_from_xorg.variant = getenv_strdup("GUIX_XKB_VARIANT");
++ c->x11_from_xorg.options = getenv_strdup("GUIX_XKB_OPTIONS");
return 0;
}
- int locale_write_data(Context *c, char ***settings) {
-- _cleanup_strv_free_ char **l = NULL;
-- struct stat st;
-- int r, p;
--
-- /* Set values will be returned as strv in *settings on success. */
--
-- for (p = 0; p < _VARIABLE_LC_MAX; p++) {
-- _cleanup_free_ char *t = NULL;
-- char **u;
-- const char *name;
--
-- name = locale_variable_to_string(p);
-- assert(name);
--
-- if (isempty(c->locale[p]))
-- continue;
--
-- if (asprintf(&t, "%s=%s", name, c->locale[p]) < 0)
-- return -ENOMEM;
--
-- u = strv_env_set(l, t);
-- if (!u)
-- return -ENOMEM;
--
-- strv_free_and_replace(l, u);
-- }
--
-- if (strv_isempty(l)) {
-- if (unlink("/etc/locale.conf") < 0)
-- return errno == ENOENT ? 0 : -errno;
--
-- c->locale_mtime = USEC_INFINITY;
-- return 0;
-- }
--
-- r = write_env_file_label("/etc/locale.conf", l);
-- if (r < 0)
-- return r;
--
-- *settings = TAKE_PTR(l);
--
-- if (stat("/etc/locale.conf", &st) >= 0)
-- c->locale_mtime = timespec_load(&st.st_mtim);
--
-- return 0;
-+ return -ENOSYS;
- }
-
int vconsole_write_data(Context *c) {
- _cleanup_strv_free_ char **l = NULL;
-- struct stat st;
+- const X11Context *xc;
- int r;
-
+- assert(c);
+-
+- xc = context_get_x11_context(c);
+-
- r = load_env_file(NULL, "/etc/vconsole.conf", &l);
- if (r < 0 && r != -ENOENT)
- return r;
-
-- if (isempty(c->vc_keymap))
-- l = strv_env_unset(l, "KEYMAP");
-- else {
-- _cleanup_free_ char *s = NULL;
-- char **u;
--
-- s = strappend("KEYMAP=", c->vc_keymap);
-- if (!s)
-- return -ENOMEM;
--
-- u = strv_env_set(l, s);
-- if (!u)
-- return -ENOMEM;
+- r = strv_env_assign(&l, "KEYMAP", empty_to_null(c->vc.keymap));
+- if (r < 0)
+- return r;
-
-- strv_free_and_replace(l, u);
-- }
+- r = strv_env_assign(&l, "KEYMAP_TOGGLE", empty_to_null(c->vc.toggle));
+- if (r < 0)
+- return r;
-
-- if (isempty(c->vc_keymap_toggle))
-- l = strv_env_unset(l, "KEYMAP_TOGGLE");
-- else {
-- _cleanup_free_ char *s = NULL;
-- char **u;
+- r = strv_env_assign(&l, "XKBLAYOUT", empty_to_null(xc->layout));
+- if (r < 0)
+- return r;
-
-- s = strappend("KEYMAP_TOGGLE=", c->vc_keymap_toggle);
-- if (!s)
-- return -ENOMEM;
+- r = strv_env_assign(&l, "XKBMODEL", empty_to_null(xc->model));
+- if (r < 0)
+- return r;
-
-- u = strv_env_set(l, s);
-- if (!u)
-- return -ENOMEM;
+- r = strv_env_assign(&l, "XKBVARIANT", empty_to_null(xc->variant));
+- if (r < 0)
+- return r;
-
-- strv_free_and_replace(l, u);
-- }
+- r = strv_env_assign(&l, "XKBOPTIONS", empty_to_null(xc->options));
+- if (r < 0)
+- return r;
-
- if (strv_isempty(l)) {
- if (unlink("/etc/vconsole.conf") < 0)
- return errno == ENOENT ? 0 : -errno;
-
-- c->vc_mtime = USEC_INFINITY;
+- c->vc_stat = (struct stat) {};
- return 0;
- }
-
-- r = write_env_file_label("/etc/vconsole.conf", l);
+- r = write_vconsole_conf_label(l);
- if (r < 0)
- return r;
-
-- if (stat("/etc/vconsole.conf", &st) >= 0)
-- c->vc_mtime = timespec_load(&st.st_mtim);
+- if (stat("/etc/vconsole.conf", &c->vc_stat) < 0)
+- return -errno;
-
- return 0;
+ return -ENOSYS;
@@ -251,72 +214,109 @@ index 6b6b32a591..46aab472b0 100644
int x11_write_data(Context *c) {
- _cleanup_fclose_ FILE *f = NULL;
-- _cleanup_free_ char *temp_path = NULL;
-- struct stat st;
+- _cleanup_(unlink_and_freep) char *temp_path = NULL;
+- const X11Context *xc;
- int r;
-
-- if (isempty(c->x11_layout) &&
-- isempty(c->x11_model) &&
-- isempty(c->x11_variant) &&
-- isempty(c->x11_options)) {
+- assert(c);
-
+- xc = context_get_x11_context(c);
+- if (x11_context_isempty(xc)) {
- if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
- return errno == ENOENT ? 0 : -errno;
-
-- c->vc_mtime = USEC_INFINITY;
+- c->x11_stat = (struct stat) {};
- return 0;
- }
-
-- mkdir_p_label("/etc/X11/xorg.conf.d", 0755);
--
+- (void) mkdir_p_label("/etc/X11/xorg.conf.d", 0755);
- r = fopen_temporary("/etc/X11/xorg.conf.d/00-keyboard.conf", &f, &temp_path);
- if (r < 0)
- return r;
-
-- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
- (void) fchmod(fileno(f), 0644);
-
- fputs("# Written by systemd-localed(8), read by systemd-localed and Xorg. It's\n"
- "# probably wise not to edit this file manually. Use localectl(1) to\n"
-- "# instruct systemd-localed to update it.\n"
+- "# update this file.\n"
- "Section \"InputClass\"\n"
- " Identifier \"system-keyboard\"\n"
- " MatchIsKeyboard \"on\"\n", f);
-
-- if (!isempty(c->x11_layout))
-- fprintf(f, " Option \"XkbLayout\" \"%s\"\n", c->x11_layout);
+- if (!isempty(xc->layout))
+- fprintf(f, " Option \"XkbLayout\" \"%s\"\n", xc->layout);
-
-- if (!isempty(c->x11_model))
-- fprintf(f, " Option \"XkbModel\" \"%s\"\n", c->x11_model);
+- if (!isempty(xc->model))
+- fprintf(f, " Option \"XkbModel\" \"%s\"\n", xc->model);
-
-- if (!isempty(c->x11_variant))
-- fprintf(f, " Option \"XkbVariant\" \"%s\"\n", c->x11_variant);
+- if (!isempty(xc->variant))
+- fprintf(f, " Option \"XkbVariant\" \"%s\"\n", xc->variant);
-
-- if (!isempty(c->x11_options))
-- fprintf(f, " Option \"XkbOptions\" \"%s\"\n", c->x11_options);
+- if (!isempty(xc->options))
+- fprintf(f, " Option \"XkbOptions\" \"%s\"\n", xc->options);
-
- fputs("EndSection\n", f);
-
- r = fflush_sync_and_check(f);
- if (r < 0)
-- goto fail;
+- return r;
-
-- if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) {
-- r = -errno;
-- goto fail;
-- }
+- if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
+- return -errno;
-
-- if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &st) >= 0)
-- c->x11_mtime = timespec_load(&st.st_mtim);
+- if (stat("/etc/X11/xorg.conf.d/00-keyboard.conf", &c->x11_stat) < 0)
+- return -errno;
-
- return 0;
++ return -ENOSYS;
+ }
+
+ static int read_next_mapping(
+diff --git a/src/shared/locale-setup.c b/src/shared/locale-setup.c
+index 5c4580cfff..b181e24c78 100644
+--- a/src/shared/locale-setup.c
++++ b/src/shared/locale-setup.c
+@@ -184,42 +184,7 @@ int locale_context_build_env(const LocaleContext *c, char ***ret_set, char ***re
+ }
+
+ int locale_context_save(LocaleContext *c, char ***ret_set, char ***ret_unset) {
+- _cleanup_strv_free_ char **set = NULL, **unset = NULL;
+- int r;
+-
+- assert(c);
+-
+- /* Set values will be returned as strv in *ret on success. */
+-
+- r = locale_context_build_env(c, &set, ret_unset ? &unset : NULL);
+- if (r < 0)
+- return r;
+-
+- if (strv_isempty(set)) {
+- if (unlink("/etc/locale.conf") < 0)
+- return errno == ENOENT ? 0 : -errno;
+-
+- c->st = (struct stat) {};
-
--fail:
-- if (temp_path)
-- (void) unlink(temp_path);
+- if (ret_set)
+- *ret_set = NULL;
+- if (ret_unset)
+- *ret_unset = NULL;
+- return 0;
+- }
-
-- return r;
+- r = write_env_file_label(AT_FDCWD, "/etc/locale.conf", NULL, set);
+- if (r < 0)
+- return r;
+-
+- if (stat("/etc/locale.conf", &c->st) < 0)
+- return -errno;
+-
+- if (ret_set)
+- *ret_set = TAKE_PTR(set);
+- if (ret_unset)
+- *ret_unset = TAKE_PTR(unset);
+- return 0;
+ return -ENOSYS;
}
- static int read_next_mapping(const char* filename,
+ int locale_context_merge(const LocaleContext *c, char *l[_VARIABLE_LC_MAX]) {