mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 21:20:33 +02:00
build/activation: Simplify the creation of /etc.
Do not add a an extraneous /etc/static layer of indirection. * gnu/build/activation.scm (activate-etc) <realpath>: New nested procedure. Do not create /etc/static. Symlink instead of copy all files under /etc, except for /etc/sudoers. Change-Id: I8ea16d07de256482efac37d2ff9482a5f56bd585 Reviewed-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr>
|
;;; Copyright © 2022 Tobias Geerinckx-Rice <me@tobias.gr>
|
||||||
;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
|
;;; Copyright © 2024 Nicolas Graves <ngraves@ngraves.fr>
|
||||||
;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
|
;;; Copyright © 2024 Giacomo Leidi <goodoldpaul@autistici.org>
|
||||||
|
;;; Copyright © 2025 Maxim Cournoyer <maxim@guixotic.coop>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
@@ -278,6 +279,17 @@ they already exist."
|
|||||||
|
|
||||||
(for-each ensure-user-home users))
|
(for-each ensure-user-home users))
|
||||||
|
|
||||||
|
(define* (canonicalize-path* file)
|
||||||
|
"A safe version of `canonicalize-path' that warns rather than raises on errors.
|
||||||
|
`canonicalize-path' uses `realpath(2)', which can return various errors like
|
||||||
|
EINVAL, ELOOP, etc."
|
||||||
|
(or (false-if-exception (canonicalize-path file))
|
||||||
|
(begin
|
||||||
|
(format (warning-error-port)
|
||||||
|
"warning: could not canonicalize file `~a'; using as-is~%"
|
||||||
|
file)
|
||||||
|
file)))
|
||||||
|
|
||||||
(define (activate-etc etc)
|
(define (activate-etc etc)
|
||||||
"Install ETC, a directory in the store, as the source of static files for
|
"Install ETC, a directory in the store, as the source of static files for
|
||||||
/etc."
|
/etc."
|
||||||
@@ -300,26 +312,23 @@ they already exist."
|
|||||||
(rm-f "/etc/ssl")
|
(rm-f "/etc/ssl")
|
||||||
(symlink "/run/current-system/profile/etc/ssl" "/etc/ssl")
|
(symlink "/run/current-system/profile/etc/ssl" "/etc/ssl")
|
||||||
|
|
||||||
(rm-f "/etc/static")
|
|
||||||
(symlink etc "/etc/static")
|
|
||||||
(for-each (lambda (file)
|
(for-each (lambda (file)
|
||||||
(let ((target (string-append "/etc/" file))
|
(let ((target (string-append "/etc/" file))
|
||||||
(source (string-append "/etc/static/" file)))
|
;; Canonicalize the file names to resolve any symlinks, to
|
||||||
|
;; ensure /etc/localtime points to a timezone data file in
|
||||||
|
;; the store containing the timezone name. This is done
|
||||||
|
;; for compatibility with software expecting this systemd
|
||||||
|
;; convention to be followed.
|
||||||
|
(source (canonicalize-path* (string-append etc "/" file))))
|
||||||
(rm-f target)
|
(rm-f target)
|
||||||
|
(if (string=? (basename target) "sudoers")
|
||||||
;; Things such as /etc/sudoers must be regular files, not
|
(begin
|
||||||
;; symlinks; furthermore, they could be modified behind our
|
;; /etc/sudoers must be a regular file.
|
||||||
;; back---e.g., with 'visudo'. Thus, make a copy instead of
|
(copy-file source target)
|
||||||
;; symlinking them.
|
;; XXX: dirty hack to meet sudo's expectations
|
||||||
(if (file-is-directory? source)
|
(chmod target #o440))
|
||||||
(symlink source target)
|
(symlink source target)))) ;usual case
|
||||||
(copy-file source target))
|
|
||||||
|
|
||||||
;; XXX: Dirty hack to meet sudo's expectations.
|
|
||||||
(when (string=? (basename target) "sudoers")
|
|
||||||
(chmod target #o440))))
|
|
||||||
(scandir etc (negate dot-or-dot-dot?)
|
(scandir etc (negate dot-or-dot-dot?)
|
||||||
|
|
||||||
;; The default is 'string-locale<?', but we don't have
|
;; The default is 'string-locale<?', but we don't have
|
||||||
;; it when run from the initrd's statically-linked
|
;; it when run from the initrd's statically-linked
|
||||||
;; Guile.
|
;; Guile.
|
||||||
|
|||||||
Reference in New Issue
Block a user