From e692cb6035d29bd44b950d20c03200c4677ff1a2 Mon Sep 17 00:00:00 2001 From: zimoun Date: Mon, 5 Dec 2022 16:38:51 +0100 Subject: gnu: julia-documenter: Fix test suite regression. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/julia-xyz.scm (julia-documenter)[arguments]<#:phases>: Substitute a work around to fix the change of 'git submodule' default behaviour introduced by Git v2.38.1. Signed-off-by: Ludovic Courtès --- gnu/packages/julia-xyz.scm | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gnu') diff --git a/gnu/packages/julia-xyz.scm b/gnu/packages/julia-xyz.scm index 28c759a5c0..ac6584825b 100644 --- a/gnu/packages/julia-xyz.scm +++ b/gnu/packages/julia-xyz.scm @@ -1472,6 +1472,15 @@ valuable enough at this time.") (("pip install") (string-append (search-input-file inputs "bin/pip") " install"))))) + (add-after 'link-depot 'fix-test-git-submodule + ;; Git v2.38.1 fixes security issues and changes the default + ;; behaviour of `git submodule`. This substitution is a backport + ;; of the upstream patch, not yet released, fixing the test suite. + ;; https://github.com/JuliaDocs/Documenter.jl/commit/b5a5c65d02d136743e7c18ffebf8baba900484fc + (lambda* (#:key inputs #:allow-other-keys) + (substitute* "test/utilities.jl" + (("submodule add") + "-c protocol.file.allow=always submodule add")))) (add-after 'link-depot 'remove-javascript-downloads (lambda _ (substitute* "src/Writers/HTMLWriter.jl" -- cgit 1.4.1 From 43e18fd6c66b311e7f8266e80d8d8e49fe4a11f0 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 28 Nov 2022 14:10:14 -0500 Subject: system: Add e2fsprogs to %base-packages-utils. Rationale: Even when not using an ext file system, the utilities provided by e2fsprogs are useful, for example to set the copy-on-write attribute of a Btrfs file system. * gnu/system.scm (%base-packages-utils): Add e2fsprogs. --- gnu/system.scm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gnu') diff --git a/gnu/system.scm b/gnu/system.scm index 3478afcec4..3891d5a467 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -858,6 +858,8 @@ of PROVENANCE-SERVICE-TYPE to its services." (cons* procps psmisc which (@ (gnu packages admin) shadow-with-man-pages) ;for 'passwd' + e2fsprogs ;for lsattr, chattr, etc. + guile-3.0-latest ;; The packages below are also in %FINAL-INPUTS, so take them from -- cgit 1.4.1 From aeecd06ab9f748b0b40573e5520ea6c642060e12 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 28 Nov 2022 13:57:58 -0500 Subject: system: Rename and move %base-packages-disk-utilities. Rationale: It is only used in INSTALLATION-OS and doesn't make sense to be used in another context, given that file systems now automatically pull their dependencies since commit 45eac6cdf5c8d9d7b0c564b105c790d2d2007799 (services: Add file system utilities to profile). * gnu/system.scm (%base-packages-disk-utilities): Deprecate and rename to... * gnu/system/install.scm (%installer-disk-utilities): ... this. (installation-os) [packages]: Adjust accordingly. --- gnu/system.scm | 19 ++----------------- gnu/system/install.scm | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'gnu') diff --git a/gnu/system.scm b/gnu/system.scm index 3891d5a467..62c8e0c2b6 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -38,6 +38,7 @@ #:use-module (guix gexp) #:use-module (guix records) #:use-module (guix packages) + #:use-module (guix deprecation) #:use-module (guix derivations) #:use-module (guix profiles) #:use-module ((guix utils) #:select (substitute-keyword-arguments)) @@ -49,9 +50,6 @@ #:use-module (gnu packages bash) #:use-module (gnu packages compression) #:use-module (gnu packages cross-base) - #:use-module (gnu packages cryptsetup) - #:use-module (gnu packages disk) - #:use-module (gnu packages file-systems) #:use-module (gnu packages firmware) #:use-module (gnu packages gawk) #:use-module (gnu packages guile) @@ -898,20 +896,7 @@ of PROVENANCE-SERVICE-TYPE to its services." ;; many people are familiar with, so keep it around. iw wireless-tools)) -(define %base-packages-disk-utilities - ;; A well-rounded set of packages for interacting with disks, - ;; partitions and filesystems, included with the Guix installation - ;; image. - (list parted gptfdisk ddrescue - ;; We used to provide fdisk from GNU fdisk, but as of version 2.0.0a - ;; it pulls Guile 1.8, which takes unreasonable space; furthermore - ;; util-linux's fdisk is already available, in %base-packages-linux. - cryptsetup mdadm - dosfstools - btrfs-progs - f2fs-tools - jfsutils - xfsprogs)) +(define-deprecated %base-packages-disk-utilities #f '()) (define %base-packages ;; Default set of packages globally visible. It should include anything diff --git a/gnu/system/install.scm b/gnu/system/install.scm index 003c49a3e7..d34d974338 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -48,6 +48,9 @@ #:use-module (gnu packages bootloaders) #:use-module (gnu packages certs) #:use-module (gnu packages compression) + #:use-module (gnu packages cryptsetup) + #:use-module (gnu packages disk) + #:use-module (gnu packages file-systems) #:use-module (gnu packages fonts) #:use-module (gnu packages fontutils) #:use-module (gnu packages guile) @@ -458,6 +461,20 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m \x1b[1;33mUse Alt-F2 for documentation.\x1b[0m ") +(define %installer-disk-utilities + ;; A well-rounded set of packages for interacting with disks, partitions and + ;; file systems, included with the Guix installation image. + (list parted gptfdisk ddrescue + ;; We used to provide fdisk from GNU fdisk, but as of version 2.0.0a + ;; it pulls Guile 1.8, which takes unreasonable space; furthermore + ;; util-linux's fdisk is already available, in %base-packages-linux. + cryptsetup mdadm + dosfstools + btrfs-progs + f2fs-tools + jfsutils + xfsprogs)) + (define installation-os ;; The operating system used on installation images for USB sticks etc. (operating-system @@ -530,7 +547,7 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m font-dejavu font-gnu-unifont grub ; mostly so xrefs to its manual work nss-certs) ; To access HTTPS, use git, etc. - %base-packages-disk-utilities + %installer-disk-utilities %base-packages)))) (define* (os-with-u-boot os board #:key (bootloader-target "/dev/mmcblk0") -- cgit 1.4.1 From ba4aed0f1feff98559e5712bf11190be78e2aadc Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 28 Nov 2022 14:03:58 -0500 Subject: install: Add missing e2fsprogs utility. * gnu/system/install.scm (%installer-disk-utilities): Add e2fsprogs. Reported-by: Adam Kandur --- gnu/system/install.scm | 1 + 1 file changed, 1 insertion(+) (limited to 'gnu') diff --git a/gnu/system/install.scm b/gnu/system/install.scm index d34d974338..f6f1923121 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -471,6 +471,7 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m cryptsetup mdadm dosfstools btrfs-progs + e2fsprogs f2fs-tools jfsutils xfsprogs)) -- cgit 1.4.1 From 2493de0d1a481f079580a354430b26977afbdbd1 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 5 Dec 2022 10:51:25 -0500 Subject: Revert "tests: install: Fix iso-image-installer test." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0f66ef9aa99d2043abccbc80d858bdeca57534ac. e2fsprogs is now included in the installation operating system since 34f69bc6e6ea555929ecca83ee7592f5261ff5f2, making this workaround obsolete. Suggested-by: Ludovic Courtès --- gnu/tests/install.scm | 2 -- 1 file changed, 2 deletions(-) (limited to 'gnu') diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 30a9026d5f..4e0e274e66 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -471,8 +471,6 @@ reboot\n") (mlet* %store-monad ((images (run-install %minimal-os-on-vda %minimal-os-on-vda-source - #:packages - (list e2fsprogs) #:script %simple-installation-script-for-/dev/vda #:installation-image-type -- cgit 1.4.1 From f59aa79ca342ef311a20dafc782adea6eed29b1a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 15:06:35 +0100 Subject: system: vm: Non-volatile 'run-vm.sh' creates a CoW image. Previously, copying the image would consume a lot of space and was I/O-intensive, to the point that the marionette connection timeout of 20s could be reached when running tests like "docker-system". * gnu/system/vm.scm (common-qemu-options): Pass 'format=' for each '-drive' option. (system-qemu-image/shared-store-script)[copy-image]: New variable. [builder]: Use it when VOLATILE? is false. --- gnu/system/vm.scm | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'gnu') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index c2f7efa966..b7bccd72a4 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2013-2022 Ludovic Courtès ;;; Copyright © 2016 Christine Lemmer-Webber ;;; Copyright © 2016, 2017 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe @@ -234,8 +234,8 @@ with '-virtfs' options for the host file systems listed in SHARED-FS." #$@(map virtfs-option shared-fs) #$@(if rw-image? - #~((format #f "-drive file=~a,if=virtio" #$image)) - #~((format #f "-drive file=~a,if=virtio,cache=writeback,werror=report,readonly=on" + #~((format #f "-drive file=~a,format=qcow2,if=virtio" #$image)) + #~((format #f "-drive file=~a,format=raw,if=virtio,cache=writeback,werror=report,readonly=on" #$image))))) (define* (system-qemu-image/shared-store-script os @@ -303,17 +303,26 @@ useful when FULL-BOOT? is true." "-m " (number->string #$memory-size) #$@options)) + (define copy-image + ;; Script that "copies" BASE-IMAGE to /tmp. Make a copy-on-write image, + ;; which is much cheaper than actually copying it. + (program-file "copy-image" + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (unless (file-exists? #$rw-image) + (invoke #+(file-append qemu "/bin/qemu-img") + "create" "-b" #$base-image + "-F" "raw" "-f" "qcow2" #$rw-image)))))) + (define builder #~(call-with-output-file #$output (lambda (port) (format port "#!~a~%" #+(file-append bash "/bin/sh")) - (when (not #$volatile?) - (format port "~a~%" - #$(program-file "copy-image" - #~(unless (file-exists? #$rw-image) - (copy-file #$base-image #$rw-image) - (chmod #$rw-image #o640))))) + #$@(if volatile? + #~() + #~((format port "~a~%" #+copy-image))) (format port "exec ~a \"$@\"~%" (string-join #$qemu-exec " ")) (chmod port #o555)))) -- cgit 1.4.1 From 6232959311b5717c19552e1116f6e4fea9797282 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 15:10:24 +0100 Subject: tests: docker-system: Increase image size. * gnu/tests/docker.scm (run-docker-system-test)[vm]: Increase 'disk-image-size'. --- gnu/tests/docker.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/tests/docker.scm b/gnu/tests/docker.scm index 3e780d8a60..4267ff89a8 100644 --- a/gnu/tests/docker.scm +++ b/gnu/tests/docker.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Danny Milosavljevic -;;; Copyright © 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2019-2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -209,7 +209,7 @@ inside %DOCKER-OS." (virtual-machine (operating-system os) (volatile? #f) - (disk-image-size (* 5000 (expt 2 20))) + (disk-image-size (* 5500 (expt 2 20))) (memory-size 2048) (port-forwardings '()))) -- cgit 1.4.1 From 9ad14196ce48d5161fcaa7fc5fd26259e517cb30 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 15:11:44 +0100 Subject: image: Clarify comment. * gnu/system/image.scm: Adjust comment. --- gnu/system/image.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gnu') diff --git a/gnu/system/image.scm b/gnu/system/image.scm index f07a4a5217..d518a05a51 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -972,9 +972,9 @@ image, depending on IMAGE format." (G_ "~a: unsupported image format") image-format))))))) -;; -;; Image detection. -;; +;;; +;;; Image type discovery. +;;; (define (image-modules) "Return the list of image modules." -- cgit 1.4.1 From fe563a87ad7c171448c56ed6b628c8e32a52c94a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 15:21:21 +0100 Subject: gnu: texinfo, info-reader: Do not run tests when cross-compiling. Fixes a regression introduced in a3264f31df9774ea514e18ed8e7b6bcb44061edc. Reported by Mathieu Othacehe . * gnu/packages/texinfo.scm (texinfo)[arguments]: Change #:tests? to not run tests when cross-compiling. --- gnu/packages/texinfo.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gnu') diff --git a/gnu/packages/texinfo.scm b/gnu/packages/texinfo.scm index 25498ae36e..7108d1e067 100644 --- a/gnu/packages/texinfo.scm +++ b/gnu/packages/texinfo.scm @@ -75,7 +75,8 @@ %standard-phases) ;; XXX: Work around . - #:tests? ,(not (hurd-target?)))) + #:tests? ,(and (not (hurd-target?)) + (not (%current-target-system))))) (inputs (list ncurses perl)) ;; When cross-compiling, texinfo will build some of its own binaries with ;; the native compiler. This means ncurses is needed both in both inputs -- cgit 1.4.1 From e45c83c3979c2554119fafdee7bb204d27e138b5 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 17:05:34 +0100 Subject: services: fail2ban: 'stop' returns #f when the dameon is stopped. * gnu/services/security.scm (fail2ban-shepherd-service): Change FAIL2BAN-ACTION to return an 'invoke' gexp. Adjust the shepherd 'start' and 'stop' fields accordingly. Have 'stop' return #f on success. --- gnu/services/security.scm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'gnu') diff --git a/gnu/services/security.scm b/gnu/services/security.scm index 15fae7a628..2d048ab47b 100644 --- a/gnu/services/security.scm +++ b/gnu/services/security.scm @@ -356,13 +356,12 @@ provided as a list of file-like objects.")) (config-dir (file-append (config->fail2ban-etc-directory config) "/etc/fail2ban")) (fail2ban-action (lambda args - #~(lambda _ - (invoke #$fail2ban-server - "-c" #$config-dir - "-p" #$pid-file - "-s" #$socket-file - "-b" - #$@args))))) + #~(invoke #$fail2ban-server + "-c" #$config-dir + "-p" #$pid-file + "-s" #$socket-file + "-b" + #$@args)))) ;; TODO: Add 'reload' action. (list (shepherd-service @@ -371,8 +370,11 @@ provided as a list of file-like objects.")) (requirement '(user-processes)) (modules `((ice-9 match) ,@%default-modules)) - (start (fail2ban-action "start")) - (stop (fail2ban-action "stop"))))))) + (start #~(lambda () + #$(fail2ban-action "start"))) + (stop #~(lambda (_) + #$(fail2ban-action "stop") + #f))))))) ;successfully stopped (define fail2ban-service-type (service-type (name 'fail2ban) -- cgit 1.4.1 From a508b5c7785bcd040c5a9e890be71ccd97f198fb Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 17:07:46 +0100 Subject: services: fail2ban: Remove unnecessary Shepherd 'modules' field. * gnu/services/security.scm (fail2ban-shepherd-service): Remove unnecessary 'modules' field. --- gnu/services/security.scm | 2 -- 1 file changed, 2 deletions(-) (limited to 'gnu') diff --git a/gnu/services/security.scm b/gnu/services/security.scm index 2d048ab47b..2010f9143a 100644 --- a/gnu/services/security.scm +++ b/gnu/services/security.scm @@ -368,8 +368,6 @@ provided as a list of file-like objects.")) (provision '(fail2ban)) (documentation "Run the fail2ban daemon.") (requirement '(user-processes)) - (modules `((ice-9 match) - ,@%default-modules)) (start #~(lambda () #$(fail2ban-action "start"))) (stop #~(lambda (_) -- cgit 1.4.1 From a420b4f34e7449319f6ec73301ffb932845b66d6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 6 Dec 2022 17:46:45 +0100 Subject: services: fail2ban: Start server in the foreground. Previously, we were passing '-b', thereby starting the server in the background. Consequently the 'start' method could complete before the server was ready to accept connections on its socket, leading to non-deterministic test failures. Reported by Mathieu Othacehe . * gnu/services/security.scm (fail2ban-shepherd-service): Change FAIL2BAN-ACTION to invoke 'fail2ban-client'. Change 'start' method to use 'make-forkexec-constructor'; start the server in the foreground with '-f' and pass '-x' to force execution of the server, as done upstream in 'fail2ban.service.in'. --- gnu/services/security.scm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'gnu') diff --git a/gnu/services/security.scm b/gnu/services/security.scm index 2010f9143a..50111455fb 100644 --- a/gnu/services/security.scm +++ b/gnu/services/security.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 muradm +;;; Copyright © 2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -351,25 +352,24 @@ provided as a list of file-like objects.")) (match-record config (fail2ban run-directory) (let* ((fail2ban-server (file-append fail2ban "/bin/fail2ban-server")) + (fail2ban-client (file-append fail2ban "/bin/fail2ban-client")) (pid-file (in-vicinity run-directory "fail2ban.pid")) (socket-file (in-vicinity run-directory "fail2ban.sock")) (config-dir (file-append (config->fail2ban-etc-directory config) "/etc/fail2ban")) (fail2ban-action (lambda args - #~(invoke #$fail2ban-server - "-c" #$config-dir - "-p" #$pid-file - "-s" #$socket-file - "-b" - #$@args)))) - - ;; TODO: Add 'reload' action. + #~(invoke #$fail2ban-client #$@args)))) + + ;; TODO: Add 'reload' action (see 'fail2ban.service.in' in the source). (list (shepherd-service (provision '(fail2ban)) (documentation "Run the fail2ban daemon.") (requirement '(user-processes)) - (start #~(lambda () - #$(fail2ban-action "start"))) + (start #~(make-forkexec-constructor + (list #$fail2ban-server + "-c" #$config-dir "-s" #$socket-file + "-p" #$pid-file "-xf" "start") + #:pid-file #$pid-file)) (stop #~(lambda (_) #$(fail2ban-action "stop") #f))))))) ;successfully stopped -- cgit 1.4.1 From 754a7660a1716998b557aedeb805ee9040afdcdf Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 19 Nov 2022 17:23:04 +0100 Subject: records: 'match-record' checks fields at macro-expansion time. This allows 'match-record' to be more efficient (field offsets are computed at compilation time) and to report unknown fields at macro-expansion time. * guix/records.scm (map-fields): New macro. (define-record-type*)[rtd-identifier]: New procedure. Define TYPE as a macro and use a separate identifier for the RTD. (lookup-field, match-record-inner): New macros. (match-record): Rewrite in terms of 'match-error-inner'. * tests/records.scm ("match-record, simple") ("match-record, unknown field"): New tests. * gnu/services/cuirass.scm (cuirass-shepherd-service): Rename 'log-file' local variable to 'main-log-file'. * gnu/services/getmail.scm (serialize-getmail-configuration-file): Move after definition. --- gnu/services/cuirass.scm | 4 +-- gnu/services/getmail.scm | 22 ++++++------ guix/records.scm | 87 ++++++++++++++++++++++++++++++++++++++++++------ tests/records.scm | 33 ++++++++++++++++++ 4 files changed, 122 insertions(+), 24 deletions(-) (limited to 'gnu') diff --git a/gnu/services/cuirass.scm b/gnu/services/cuirass.scm index 52de5ca7c0..d7c6ab9877 100644 --- a/gnu/services/cuirass.scm +++ b/gnu/services/cuirass.scm @@ -125,7 +125,7 @@ (let ((cuirass (cuirass-configuration-cuirass config)) (cache-directory (cuirass-configuration-cache-directory config)) (web-log-file (cuirass-configuration-web-log-file config)) - (log-file (cuirass-configuration-log-file config)) + (main-log-file (cuirass-configuration-log-file config)) (user (cuirass-configuration-user config)) (group (cuirass-configuration-group config)) (interval (cuirass-configuration-interval config)) @@ -169,7 +169,7 @@ #:user #$user #:group #$group - #:log-file #$log-file)) + #:log-file #$main-log-file)) (stop #~(make-kill-destructor))) ,(shepherd-service (documentation "Run Cuirass web interface.") diff --git a/gnu/services/getmail.scm b/gnu/services/getmail.scm index fb82d054ca..19faea782f 100644 --- a/gnu/services/getmail.scm +++ b/gnu/services/getmail.scm @@ -215,17 +215,6 @@ lines.") (parameter-alist '()) "Extra options to include.")) -(define (serialize-getmail-configuration-file field-name val) - (match-record val - (retriever destination options) - #~(string-append - "[retriever]\n" - #$(serialize-getmail-retriever-configuration #f retriever) - "\n[destination]\n" - #$(serialize-getmail-destination-configuration #f destination) - "\n[options]\n" - #$(serialize-getmail-options-configuration #f options)))) - (define-configuration getmail-configuration-file (retriever (getmail-retriever-configuration (getmail-retriever-configuration)) @@ -237,6 +226,17 @@ lines.") (getmail-options-configuration (getmail-options-configuration)) "Configure getmail.")) +(define (serialize-getmail-configuration-file field-name val) + (match-record val + (retriever destination options) + #~(string-append + "[retriever]\n" + #$(serialize-getmail-retriever-configuration #f retriever) + "\n[destination]\n" + #$(serialize-getmail-destination-configuration #f destination) + "\n[options]\n" + #$(serialize-getmail-options-configuration #f options)))) + (define (serialize-symbol field-name val) "") (define (serialize-getmail-configuration field-name val) "") diff --git a/guix/records.scm b/guix/records.scm index ed94c83dac..13463647c8 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2012-2022 Ludovic Courtès ;;; Copyright © 2018 Mark H Weaver ;;; ;;; This file is part of GNU Guix. @@ -104,6 +104,10 @@ error-reporting purposes." (() #t))))))) +(define-syntax map-fields + (lambda (x) + (syntax-violation 'map-fields "bad use of syntactic keyword" x x))) + (define-syntax-parameter this-record (lambda (s) "Return the record being defined. This macro may only be used in the @@ -325,6 +329,15 @@ This expression returns a new object equal to 'x' except for its 'name' field and its 'loc' field---the latter is marked as \"innate\", so it is not inherited." + (define (rtd-identifier type) + ;; Return an identifier derived from TYPE to name its record type + ;; descriptor (RTD). + (let ((type-name (syntax->datum type))) + (datum->syntax + type + (string->symbol + (string-append "% " (symbol->string type-name) " rtd"))))) + (define (field-default-value s) (syntax-case s (default) ((field (default val) _ ...) @@ -428,10 +441,31 @@ inherited." field))) field-spec))) #`(begin - (define-record-type type + (define-record-type #,(rtd-identifier #'type) (ctor field ...) pred field-spec* ...) + + ;; Rectify the vtable type name... + (set-struct-vtable-name! #,(rtd-identifier #'type) 'type) + (cond-expand + (guile-3 + ;; ... and the record type name. + (struct-set! #,(rtd-identifier #'type) vtable-offset-user + 'type)) + (else #f)) + + (define-syntax type + (lambda (s) + "This macro lets us query record type info at +macro-expansion time." + (syntax-case s (map-fields) + ((_ map-fields macro) + #'(macro (field ...))) + (id + (identifier? #'id) + #'#,(rtd-identifier #'type))))) + (define #,(current-abi-identifier #'type) #,cookie) @@ -535,19 +569,50 @@ pairs. Stop upon an empty line (after consuming it) or EOF." (else (error "unmatched line" line)))))))) + +;;; +;;; Pattern matching. +;;; + +(define-syntax lookup-field + (lambda (s) + "Look up FIELD in the given list and return an expression that represents +its offset in the record. Raise a syntax violation when the field is not +found." + (syntax-case s () + ((_ field offset ()) + (syntax-violation 'lookup-field "unknown record type field" + s #'field)) + ((_ field offset (head tail ...)) + (free-identifier=? #'field #'head) + #'offset) + ((_ field offset (_ tail ...)) + #'(lookup-field field (+ 1 offset) (tail ...)))))) + +(define-syntax match-record-inner + (lambda (s) + (syntax-case s () + ((_ record type (field rest ...) body ...) + #`(let-syntax ((field-offset (syntax-rules () + ((_ f) + (lookup-field field 0 f))))) + (let* ((offset (type map-fields field-offset)) + (field (struct-ref record offset))) + (match-record-inner record type (rest ...) body ...)))) + ((_ record type () body ...) + #'(begin body ...))))) + (define-syntax match-record (syntax-rules () "Bind each FIELD of a RECORD of the given TYPE to it's FIELD name. +The order in which fields appear does not matter. A syntax error is raised if +an unknown field is queried. + The current implementation does not support thunked and delayed fields." - ((_ record type (field fields ...) body ...) + ;; TODO support thunked and delayed fields + ((_ record type (fields ...) body ...) (if (eq? (struct-vtable record) type) - ;; TODO compute indices and report wrong-field-name errors at - ;; expansion time - ;; TODO support thunked and delayed fields - (let ((field ((record-accessor type 'field) record))) - (match-record record type (fields ...) body ...)) - (throw 'wrong-type-arg record))) - ((_ record type () body ...) - (begin body ...)))) + (match-record-inner record type (fields ...) body ...) + (throw 'wrong-type-arg record))))) ;;; records.scm ends here diff --git a/tests/records.scm b/tests/records.scm index 00c58b0736..8504c8d5a5 100644 --- a/tests/records.scm +++ b/tests/records.scm @@ -528,4 +528,37 @@ Description: 1st line, '("a" "b" "c") '("a"))) +(test-equal "match-record, simple" + '((1 2) (a b)) + (let () + (define-record-type* foo make-foo + foo? + (first foo-first (default 1)) + (second foo-second)) + + (list (match-record (foo (second 2)) + (first second) + (list first second)) + (match-record (foo (first 'a) (second 'b)) + (second first) + (list first second))))) + +(test-equal "match-record, unknown field" + 'syntax-error + (catch 'syntax-error + (lambda () + (eval '(begin + (use-modules (guix records)) + + (define-record-type* foo make-foo + foo? + (first foo-first (default 1)) + (second foo-second)) + + (match-record (foo (second 2)) + (one two) + #f)) + (make-fresh-user-module))) + (lambda (key . args) key))) + (test-end) -- cgit 1.4.1 From 93d37985da59fbd5a42c0d868dc3616b0f8d05cc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 19 Nov 2022 17:37:24 +0100 Subject: home: services: Use 'match-record' instead of 'match'. * gnu/home/services/mcron.scm (home-mcron-shepherd-services): Use 'match-record' instead of 'match'. * gnu/home/services/shells.scm (home-bash-extensions): Likewise. * gnu/home/services/xdg.scm (serialize-xdg-desktop-entry): Likewise. --- gnu/home/services/mcron.scm | 58 ++++++++++++++++++++++---------------------- gnu/home/services/shells.scm | 50 +++++++++++++++++++------------------- gnu/home/services/xdg.scm | 38 ++++++++++++++--------------- 3 files changed, 73 insertions(+), 73 deletions(-) (limited to 'gnu') diff --git a/gnu/home/services/mcron.scm b/gnu/home/services/mcron.scm index 1d294a997c..5f35bfe054 100644 --- a/gnu/home/services/mcron.scm +++ b/gnu/home/services/mcron.scm @@ -77,35 +77,35 @@ Each message is also prefixed by a timestamp by GNU Shepherd.")) (define shepherd-schedule-action (@@ (gnu services mcron) shepherd-schedule-action)) -(define home-mcron-shepherd-services - (match-lambda - (($ mcron '()) ; no jobs to run - '()) - (($ mcron jobs log? log-format) - (let ((files (job-files mcron jobs))) - (list (shepherd-service - (documentation "User cron jobs.") - (provision '(mcron)) - (modules `((srfi srfi-1) - (srfi srfi-26) - (ice-9 popen) ; for the 'schedule' action - (ice-9 rdelim) - (ice-9 match) - ,@%default-modules)) - (start #~(make-forkexec-constructor - (list (string-append #$mcron "/bin/mcron") - #$@(if log? - #~("--log" "--log-format" #$log-format) - #~()) - #$@files) - #:log-file (string-append - (or (getenv "XDG_LOG_HOME") - (format #f "~a/.local/var/log" - (getenv "HOME"))) - "/mcron.log"))) - (stop #~(make-kill-destructor)) - (actions - (list (shepherd-schedule-action mcron files))))))))) +(define (home-mcron-shepherd-services config) + (match-record config + (mcron jobs log? log-format) + (if (null? jobs) + '() ;no jobs to run + (let ((files (job-files mcron jobs))) + (list (shepherd-service + (documentation "User cron jobs.") + (provision '(mcron)) + (modules `((srfi srfi-1) + (srfi srfi-26) + (ice-9 popen) ;for the 'schedule' action + (ice-9 rdelim) + (ice-9 match) + ,@%default-modules)) + (start #~(make-forkexec-constructor + (list (string-append #$mcron "/bin/mcron") + #$@(if log? + #~("--log" "--log-format" #$log-format) + #~()) + #$@files) + #:log-file (string-append + (or (getenv "XDG_LOG_HOME") + (format #f "~a/.local/var/log" + (getenv "HOME"))) + "/mcron.log"))) + (stop #~(make-kill-destructor)) + (actions + (list (shepherd-schedule-action mcron files))))))))) (define home-mcron-profile (compose list home-mcron-configuration-mcron)) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index 3e346c3813..b529c8e798 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -25,6 +25,7 @@ #:use-module (gnu packages bash) #:use-module (guix gexp) #:use-module (guix packages) + #:use-module (guix records) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (ice-9 match) @@ -479,31 +480,30 @@ with text blocks from other extensions and the base service.") with text blocks from other extensions and the base service.")) (define (home-bash-extensions original-config extension-configs) - (match original-config - (($ _ _ environment-variables aliases - bash-profile bashrc bash-logout) - (home-bash-configuration - (inherit original-config) - (environment-variables - (append environment-variables - (append-map - home-bash-extension-environment-variables extension-configs))) - (aliases - (append aliases - (append-map - home-bash-extension-aliases extension-configs))) - (bash-profile - (append bash-profile - (append-map - home-bash-extension-bash-profile extension-configs))) - (bashrc - (append bashrc - (append-map - home-bash-extension-bashrc extension-configs))) - (bash-logout - (append bash-logout - (append-map - home-bash-extension-bash-logout extension-configs))))))) + (match-record original-config + (environment-variables aliases bash-profile bashrc bash-logout) + (home-bash-configuration + (inherit original-config) + (environment-variables + (append environment-variables + (append-map + home-bash-extension-environment-variables extension-configs))) + (aliases + (append aliases + (append-map + home-bash-extension-aliases extension-configs))) + (bash-profile + (append bash-profile + (append-map + home-bash-extension-bash-profile extension-configs))) + (bashrc + (append bashrc + (append-map + home-bash-extension-bashrc extension-configs))) + (bash-logout + (append bash-logout + (append-map + home-bash-extension-bash-logout extension-configs)))))) (define home-bash-service-type (service-type (name 'home-bash) diff --git a/gnu/home/services/xdg.scm b/gnu/home/services/xdg.scm index 63c6041cd4..3c6cb773ad 100644 --- a/gnu/home/services/xdg.scm +++ b/gnu/home/services/xdg.scm @@ -383,25 +383,25 @@ configuration." (define (serialize-alist config) (generic-serialize-alist append format-config config)) - (define (serialize-xdg-desktop-action action) - (match action - (($ action name config) - `(,(format #f "[Desktop Action ~a]\n" - (string-capitalize (maybe-object->string action))) - ,(format #f "Name=~a\n" name) - ,@(serialize-alist config))))) - - (match entry - (($ file name type config actions) - (list (if (string-suffix? file ".desktop") - file - (string-append file ".desktop")) - `("[Desktop Entry]\n" - ,(format #f "Name=~a\n" name) - ,(format #f "Type=~a\n" - (string-capitalize (symbol->string type))) - ,@(serialize-alist config) - ,@(append-map serialize-xdg-desktop-action actions)))))) + (define (serialize-xdg-desktop-action desktop-action) + (match-record desktop-action + (action name config) + `(,(format #f "[Desktop Action ~a]\n" + (string-capitalize (maybe-object->string action))) + ,(format #f "Name=~a\n" name) + ,@(serialize-alist config)))) + + (match-record entry + (file name type config actions) + (list (if (string-suffix? file ".desktop") + file + (string-append file ".desktop")) + `("[Desktop Entry]\n" + ,(format #f "Name=~a\n" name) + ,(format #f "Type=~a\n" + (string-capitalize (symbol->string type))) + ,@(serialize-alist config) + ,@(append-map serialize-xdg-desktop-action actions))))) (define-configuration home-xdg-mime-applications-configuration (added -- cgit 1.4.1 From 156a8810019dd5b8d19f2026be80f199f8e40015 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 19 Nov 2022 17:54:26 +0100 Subject: services: base: Use 'match-record' instead of 'match'. * gnu/services/base.scm (agetty-shepherd-service) (mingetty-shepherd-service) (nscd.conf-file) (udev-shepherd-service) (udev-etc) (gpm-shepherd-service) (network-set-up/linux) (network-tear-down/linux) (static-networking-shepherd-service) (greetd-agreety-tty-session-command) (greetd-agreety-tty-xdg-session-command): Use 'match-record' instead of 'match'. (guix-accounts): Use accessors. (udev-service-type): Use accessors. --- gnu/services/base.scm | 922 +++++++++++++++++++++++++------------------------- 1 file changed, 460 insertions(+), 462 deletions(-) (limited to 'gnu') diff --git a/gnu/services/base.scm b/gnu/services/base.scm index d99548573d..370696a55e 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -977,148 +977,148 @@ to use as the tty. This is primarily useful for headless systems." ((device-name _ ...) device-name)))))))) -(define agetty-shepherd-service - (match-lambda - (($ agetty tty term baud-rate auto-login - login-program login-pause? eight-bits? no-reset? remote? flow-control? - host no-issue? init-string no-clear? local-line extract-baud? - skip-login? no-newline? login-options chroot hangup? keep-baud? timeout - detect-case? wait-cr? no-hints? no-hostname? long-hostname? - erase-characters kill-characters chdir delay nice extra-options - shepherd-requirement) - (list - (shepherd-service - (documentation "Run agetty on a tty.") - (provision (list (symbol-append 'term- (string->symbol (or tty "console"))))) - - ;; Since the login prompt shows the host name, wait for the 'host-name' - ;; service to be done. Also wait for udev essentially so that the tty - ;; text is not lost in the middle of kernel messages (see also - ;; mingetty-shepherd-service). - (requirement (cons* 'user-processes 'host-name 'udev - shepherd-requirement)) - - (modules '((ice-9 match) (gnu build linux-boot))) - (start - (with-imported-modules (source-module-closure - '((gnu build linux-boot))) - #~(lambda args - (let ((defaulted-tty #$(or tty (default-serial-port)))) - (apply - (if defaulted-tty - (make-forkexec-constructor - (list #$(file-append util-linux "/sbin/agetty") - #$@extra-options - #$@(if eight-bits? - #~("--8bits") - #~()) - #$@(if no-reset? - #~("--noreset") - #~()) - #$@(if remote? - #~("--remote") - #~()) - #$@(if flow-control? - #~("--flow-control") - #~()) - #$@(if host - #~("--host" #$host) - #~()) - #$@(if no-issue? - #~("--noissue") - #~()) - #$@(if init-string - #~("--init-string" #$init-string) - #~()) - #$@(if no-clear? - #~("--noclear") - #~()) +(define (agetty-shepherd-service config) + (match-record config + (agetty tty term baud-rate auto-login + login-program login-pause? eight-bits? no-reset? remote? flow-control? + host no-issue? init-string no-clear? local-line extract-baud? + skip-login? no-newline? login-options chroot hangup? keep-baud? timeout + detect-case? wait-cr? no-hints? no-hostname? long-hostname? + erase-characters kill-characters chdir delay nice extra-options + shepherd-requirement) + (list + (shepherd-service + (documentation "Run agetty on a tty.") + (provision (list (symbol-append 'term- (string->symbol (or tty "console"))))) + + ;; Since the login prompt shows the host name, wait for the 'host-name' + ;; service to be done. Also wait for udev essentially so that the tty + ;; text is not lost in the middle of kernel messages (see also + ;; mingetty-shepherd-service). + (requirement (cons* 'user-processes 'host-name 'udev + shepherd-requirement)) + + (modules '((ice-9 match) (gnu build linux-boot))) + (start + (with-imported-modules (source-module-closure + '((gnu build linux-boot))) + #~(lambda args + (let ((defaulted-tty #$(or tty (default-serial-port)))) + (apply + (if defaulted-tty + (make-forkexec-constructor + (list #$(file-append util-linux "/sbin/agetty") + #$@extra-options + #$@(if eight-bits? + #~("--8bits") + #~()) + #$@(if no-reset? + #~("--noreset") + #~()) + #$@(if remote? + #~("--remote") + #~()) + #$@(if flow-control? + #~("--flow-control") + #~()) + #$@(if host + #~("--host" #$host) + #~()) + #$@(if no-issue? + #~("--noissue") + #~()) + #$@(if init-string + #~("--init-string" #$init-string) + #~()) + #$@(if no-clear? + #~("--noclear") + #~()) ;;; FIXME This doesn't work as expected. According to agetty(8), if this option ;;; is not passed, then the default is 'auto'. However, in my tests, when that ;;; option is selected, agetty never presents the login prompt, and the ;;; term-ttyS0 service respawns every few seconds. - #$@(if local-line - #~(#$(match local-line - ('auto "--local-line=auto") - ('always "--local-line=always") - ('never "-local-line=never"))) - #~()) - #$@(if tty - #~() - #~("--keep-baud")) - #$@(if extract-baud? - #~("--extract-baud") - #~()) - #$@(if skip-login? - #~("--skip-login") - #~()) - #$@(if no-newline? - #~("--nonewline") - #~()) - #$@(if login-options - #~("--login-options" #$login-options) - #~()) - #$@(if chroot - #~("--chroot" #$chroot) - #~()) - #$@(if hangup? - #~("--hangup") - #~()) - #$@(if keep-baud? - #~("--keep-baud") - #~()) - #$@(if timeout - #~("--timeout" #$(number->string timeout)) - #~()) - #$@(if detect-case? - #~("--detect-case") - #~()) - #$@(if wait-cr? - #~("--wait-cr") - #~()) - #$@(if no-hints? - #~("--nohints?") - #~()) - #$@(if no-hostname? - #~("--nohostname") - #~()) - #$@(if long-hostname? - #~("--long-hostname") - #~()) - #$@(if erase-characters - #~("--erase-chars" #$erase-characters) - #~()) - #$@(if kill-characters - #~("--kill-chars" #$kill-characters) - #~()) - #$@(if chdir - #~("--chdir" #$chdir) - #~()) - #$@(if delay - #~("--delay" #$(number->string delay)) - #~()) - #$@(if nice - #~("--nice" #$(number->string nice)) - #~()) - #$@(if auto-login - (list "--autologin" auto-login) - '()) - #$@(if login-program - #~("--login-program" #$login-program) - #~()) - #$@(if login-pause? - #~("--login-pause") - #~()) - defaulted-tty - #$@(if baud-rate - #~(#$baud-rate) - #~()) - #$@(if term - #~(#$term) - #~()))) - (const #f)) ; never start. - args))))) - (stop #~(make-kill-destructor))))))) + #$@(if local-line + #~(#$(match local-line + ('auto "--local-line=auto") + ('always "--local-line=always") + ('never "-local-line=never"))) + #~()) + #$@(if tty + #~() + #~("--keep-baud")) + #$@(if extract-baud? + #~("--extract-baud") + #~()) + #$@(if skip-login? + #~("--skip-login") + #~()) + #$@(if no-newline? + #~("--nonewline") + #~()) + #$@(if login-options + #~("--login-options" #$login-options) + #~()) + #$@(if chroot + #~("--chroot" #$chroot) + #~()) + #$@(if hangup? + #~("--hangup") + #~()) + #$@(if keep-baud? + #~("--keep-baud") + #~()) + #$@(if timeout + #~("--timeout" #$(number->string timeout)) + #~()) + #$@(if detect-case? + #~("--detect-case") + #~()) + #$@(if wait-cr? + #~("--wait-cr") + #~()) + #$@(if no-hints? + #~("--nohints?") + #~()) + #$@(if no-hostname? + #~("--nohostname") + #~()) + #$@(if long-hostname? + #~("--long-hostname") + #~()) + #$@(if erase-characters + #~("--erase-chars" #$erase-characters) + #~()) + #$@(if kill-characters + #~("--kill-chars" #$kill-characters) + #~()) + #$@(if chdir + #~("--chdir" #$chdir) + #~()) + #$@(if delay + #~("--delay" #$(number->string delay)) + #~()) + #$@(if nice + #~("--nice" #$(number->string nice)) + #~()) + #$@(if auto-login + (list "--autologin" auto-login) + '()) + #$@(if login-program + #~("--login-program" #$login-program) + #~()) + #$@(if login-pause? + #~("--login-pause") + #~()) + defaulted-tty + #$@(if baud-rate + #~(#$baud-rate) + #~()) + #$@(if term + #~(#$term) + #~()))) + (const #f)) ; never start. + args))))) + (stop #~(make-kill-destructor)))))) (define agetty-service-type (service-type (name 'agetty) @@ -1148,42 +1148,42 @@ the tty to run, among other things." (clear-on-logout? mingetty-clear-on-logout? ;Boolean (default #t))) -(define mingetty-shepherd-service - (match-lambda - (($ mingetty tty auto-login login-program - login-pause? clear-on-logout?) - (list - (shepherd-service - (documentation "Run mingetty on an tty.") - (provision (list (symbol-append 'term- (string->symbol tty)))) - - ;; Since the login prompt shows the host name, wait for the 'host-name' - ;; service to be done. Also wait for udev essentially so that the tty - ;; text is not lost in the middle of kernel messages (XXX). - (requirement '(user-processes host-name udev virtual-terminal)) - - (start #~(make-forkexec-constructor - (list #$(file-append mingetty "/sbin/mingetty") - - ;; Avoiding 'vhangup' allows us to avoid 'setfont' - ;; errors down the path where various ioctls get - ;; EIO--see 'hung_up_tty_ioctl' in driver/tty/tty_io.c - ;; in Linux. - "--nohangup" #$tty - - #$@(if clear-on-logout? - #~() - #~("--noclear")) - #$@(if auto-login - #~("--autologin" #$auto-login) - #~()) - #$@(if login-program - #~("--loginprog" #$login-program) - #~()) - #$@(if login-pause? - #~("--loginpause") - #~())))) - (stop #~(make-kill-destructor))))))) +(define (mingetty-shepherd-service config) + (match-record config + (mingetty tty auto-login login-program + login-pause? clear-on-logout?) + (list + (shepherd-service + (documentation "Run mingetty on an tty.") + (provision (list (symbol-append 'term- (string->symbol tty)))) + + ;; Since the login prompt shows the host name, wait for the 'host-name' + ;; service to be done. Also wait for udev essentially so that the tty + ;; text is not lost in the middle of kernel messages (XXX). + (requirement '(user-processes host-name udev virtual-terminal)) + + (start #~(make-forkexec-constructor + (list #$(file-append mingetty "/sbin/mingetty") + + ;; Avoiding 'vhangup' allows us to avoid 'setfont' + ;; errors down the path where various ioctls get + ;; EIO--see 'hung_up_tty_ioctl' in driver/tty/tty_io.c + ;; in Linux. + "--nohangup" #$tty + + #$@(if clear-on-logout? + #~() + #~("--noclear")) + #$@(if auto-login + #~("--autologin" #$auto-login) + #~()) + #$@(if login-program + #~("--loginprog" #$login-program) + #~()) + #$@(if login-pause? + #~("--loginpause") + #~())))) + (stop #~(make-kill-destructor)))))) (define mingetty-service-type (service-type (name 'mingetty) @@ -1260,46 +1260,47 @@ the tty to run, among other things." (define (nscd.conf-file config) "Return the @file{nscd.conf} configuration file for @var{config}, an @code{} object." - (define cache->config - (match-lambda - (($ (= symbol->string database) - positive-ttl negative-ttl size check-files? - persistent? shared? max-size propagate?) - (string-append "\nenable-cache\t" database "\tyes\n" - - "positive-time-to-live\t" database "\t" - (number->string positive-ttl) "\n" - "negative-time-to-live\t" database "\t" - (number->string negative-ttl) "\n" - "suggested-size\t" database "\t" - (number->string size) "\n" - "check-files\t" database "\t" - (if check-files? "yes\n" "no\n") - "persistent\t" database "\t" - (if persistent? "yes\n" "no\n") - "shared\t" database "\t" - (if shared? "yes\n" "no\n") - "max-db-size\t" database "\t" - (number->string max-size) "\n" - "auto-propagate\t" database "\t" - (if propagate? "yes\n" "no\n"))))) - - (match config - (($ log-file debug-level caches) - (plain-file "nscd.conf" - (string-append "\ + (define (cache->config cache) + (match-record cache + (database positive-time-to-live negative-time-to-live + suggested-size check-files? + persistent? shared? max-database-size auto-propagate?) + (let ((database (symbol->string database))) + (string-append "\nenable-cache\t" database "\tyes\n" + + "positive-time-to-live\t" database "\t" + (number->string positive-time-to-live) "\n" + "negative-time-to-live\t" database "\t" + (number->string negative-time-to-live) "\n" + "suggested-size\t" database "\t" + (number->string suggested-size) "\n" + "check-files\t" database "\t" + (if check-files? "yes\n" "no\n") + "persistent\t" database "\t" + (if persistent? "yes\n" "no\n") + "shared\t" database "\t" + (if shared? "yes\n" "no\n") + "max-db-size\t" database "\t" + (number->string max-database-size) "\n" + "auto-propagate\t" database "\t" + (if auto-propagate? "yes\n" "no\n"))))) + + (match-record config + (log-file debug-level caches) + (plain-file "nscd.conf" + (string-append "\ # Configuration of libc's name service cache daemon (nscd).\n\n" - (if log-file - (string-append "logfile\t" log-file) - "") - "\n" - (if debug-level - (string-append "debug-level\t" - (number->string debug-level)) - "") - "\n" - (string-concatenate - (map cache->config caches))))))) + (if log-file + (string-append "logfile\t" log-file) + "") + "\n" + (if debug-level + (string-append "debug-level\t" + (number->string debug-level)) + "") + "\n" + (string-concatenate + (map cache->config caches)))))) (define (nscd-action-procedure nscd config option) ;; XXX: This is duplicated from mcron; factorize. @@ -1797,17 +1798,15 @@ proxy of 'guix-daemon'...~%") (define (guix-accounts config) "Return the user accounts and user groups for CONFIG." - (match config - (($ _ build-group build-accounts) - (cons (user-group - (name build-group) - (system? #t) - - ;; Use a fixed GID so that we can create the store with the right - ;; owner. - (id 30000)) - (guix-build-accounts build-accounts - #:group build-group))))) + (cons (user-group + (name (guix-configuration-build-group config)) + (system? #t) + + ;; Use a fixed GID so that we can create the store with the right + ;; owner. + (id 30000)) + (guix-build-accounts (guix-configuration-build-accounts config) + #:group (guix-configuration-build-group config)))) (define (guix-activation config) "Return the activation gexp for CONFIG." @@ -2130,95 +2129,94 @@ item of @var{packages}." (udev-rule "90-kvm.rules" "KERNEL==\"kvm\", GROUP=\"kvm\", MODE=\"0660\"\n")) -(define udev-shepherd-service +(define (udev-shepherd-service config) ;; Return a for UDEV with RULES. - (match-lambda - (($ udev) - (list - (shepherd-service - (provision '(udev)) - - ;; Udev needs /dev to be a 'devtmpfs' mount so that new device nodes can - ;; be added: see - ;; . - (requirement '(root-file-system)) - - (documentation "Populate the /dev directory, dynamically.") - (start - (with-imported-modules (source-module-closure - '((gnu build linux-boot))) - #~(lambda () - (define udevd - ;; 'udevd' from eudev. - #$(file-append udev "/sbin/udevd")) - - (define (wait-for-udevd) - ;; Wait until someone's listening on udevd's control - ;; socket. - (let ((sock (socket AF_UNIX SOCK_SEQPACKET 0))) - (let try () - (catch 'system-error - (lambda () - (connect sock PF_UNIX "/run/udev/control") - (close-port sock)) - (lambda args - (format #t "waiting for udevd...~%") - (usleep 500000) - (try)))))) - - ;; Allow udev to find the modules. - (setenv "LINUX_MODULE_DIRECTORY" - "/run/booted-system/kernel/lib/modules") - - (let* ((kernel-release - (utsname:release (uname))) - (linux-module-directory - (getenv "LINUX_MODULE_DIRECTORY")) - (directory - (string-append linux-module-directory "/" - kernel-release)) - (old-umask (umask #o022))) - ;; If we're in a container, DIRECTORY might not exist, - ;; for instance because the host runs a different - ;; kernel. In that case, skip it; we'll just miss a few - ;; nodes like /dev/fuse. - (when (file-exists? directory) - (make-static-device-nodes directory)) - (umask old-umask)) - - (let ((pid (fork+exec-command - (list udevd) - #:environment-variables - (cons* - ;; The first one is for udev, the second one for - ;; eudev. - "UDEV_CONFIG_FILE=/etc/udev/udev.conf" - "EUDEV_RULES_DIRECTORY=/etc/udev/rules.d" - (string-append "LINUX_MODULE_DIRECTORY=" - (getenv "LINUX_MODULE_DIRECTORY")) - (default-environment-variables))))) - ;; Wait until udevd is up and running. This appears to - ;; be needed so that the events triggered below are - ;; actually handled. - (wait-for-udevd) - - ;; Trigger device node creation. - (system* #$(file-append udev "/bin/udevadm") - "trigger" "--action=add") - - ;; Wait for things to settle down. - (system* #$(file-append udev "/bin/udevadm") - "settle") - pid)))) - (stop #~(make-kill-destructor)) - - ;; When halting the system, 'udev' is actually killed by - ;; 'user-processes', i.e., before its own 'stop' method was called. - ;; Thus, make sure it is not respawned. - (respawn? #f) - ;; We need additional modules. - (modules `((gnu build linux-boot) ;'make-static-device-nodes' - ,@%default-modules))))))) + (let ((udev (udev-configuration-udev config))) + (list + (shepherd-service + (provision '(udev)) + + ;; Udev needs /dev to be a 'devtmpfs' mount so that new device nodes can + ;; be added: see + ;; . + (requirement '(root-file-system)) + + (documentation "Populate the /dev directory, dynamically.") + (start + (with-imported-modules (source-module-closure + '((gnu build linux-boot))) + #~(lambda () + (define udevd + ;; 'udevd' from eudev. + #$(file-append udev "/sbin/udevd")) + + (define (wait-for-udevd) + ;; Wait until someone's listening on udevd's control + ;; socket. + (let ((sock (socket AF_UNIX SOCK_SEQPACKET 0))) + (let try () + (catch 'system-error + (lambda () + (connect sock PF_UNIX "/run/udev/control") + (close-port sock)) + (lambda args + (format #t "waiting for udevd...~%") + (usleep 500000) + (try)))))) + + ;; Allow udev to find the modules. + (setenv "LINUX_MODULE_DIRECTORY" + "/run/booted-system/kernel/lib/modules") + + (let* ((kernel-release + (utsname:release (uname))) + (linux-module-directory + (getenv "LINUX_MODULE_DIRECTORY")) + (directory + (string-append linux-module-directory "/" + kernel-release)) + (old-umask (umask #o022))) + ;; If we're in a container, DIRECTORY might not exist, + ;; for instance because the host runs a different + ;; kernel. In that case, skip it; we'll just miss a few + ;; nodes like /dev/fuse. + (when (file-exists? directory) + (make-static-device-nodes directory)) + (umask old-umask)) + + (let ((pid (fork+exec-command + (list udevd) + #:environment-variables + (cons* + ;; The first one is for udev, the second one for + ;; eudev. + "UDEV_CONFIG_FILE=/etc/udev/udev.conf" + "EUDEV_RULES_DIRECTORY=/etc/udev/rules.d" + (string-append "LINUX_MODULE_DIRECTORY=" + (getenv "LINUX_MODULE_DIRECTORY")) + (default-environment-variables))))) + ;; Wait until udevd is up and running. This appears to + ;; be needed so that the events triggered below are + ;; actually handled. + (wait-for-udevd) + + ;; Trigger device node creation. + (system* #$(file-append udev "/bin/udevadm") + "trigger" "--action=add") + + ;; Wait for things to settle down. + (system* #$(file-append udev "/bin/udevadm") + "settle") + pid)))) + (stop #~(make-kill-destructor)) + + ;; When halting the system, 'udev' is actually killed by + ;; 'user-processes', i.e., before its own 'stop' method was called. + ;; Thus, make sure it is not respawned. + (respawn? #f) + ;; We need additional modules. + (modules `((gnu build linux-boot) ;'make-static-device-nodes' + ,@%default-modules)))))) (define udev.conf (computed-file "udev.conf" @@ -2226,14 +2224,15 @@ item of @var{packages}." (lambda (port) (format port "udev_rules=\"/etc/udev/rules.d\"~%"))))) -(define udev-etc - (match-lambda - (($ udev rules) - `(("udev" - ,(file-union - "udev" `(("udev.conf" ,udev.conf) - ("rules.d" ,(udev-rules-union (cons* udev kvm-udev-rule - rules)))))))))) +(define (udev-etc config) + (match-record config + (udev rules) + `(("udev" + ,(file-union "udev" + `(("udev.conf" ,udev.conf) + ("rules.d" + ,(udev-rules-union (cons* udev kvm-udev-rule + rules))))))))) (define udev-service-type (service-type (name 'udev) @@ -2243,11 +2242,11 @@ item of @var{packages}." (service-extension etc-service-type udev-etc))) (compose concatenate) ;concatenate the list of rules (extend (lambda (config rules) - (match config - (($ udev initial-rules) - (udev-configuration - (udev udev) - (rules (append initial-rules rules))))))) + (let ((initial-rules + (udev-configuration-rules config))) + (udev-configuration + (inherit config) + (rules (append initial-rules rules)))))) (default-value (udev-configuration)) (description "Run @command{udev}, which populates the @file{/dev} @@ -2385,23 +2384,23 @@ instance." (options gpm-configuration-options ;list of strings (default %default-gpm-options))) -(define gpm-shepherd-service - (match-lambda - (($ gpm options) - (list (shepherd-service - (requirement '(udev)) - (provision '(gpm)) - ;; 'gpm' runs in the background and sets a PID file. - ;; Note that it requires running as "root". - (start #~(make-forkexec-constructor - (list #$(file-append gpm "/sbin/gpm") - #$@options) - #:pid-file "/var/run/gpm.pid" - #:pid-file-timeout 3)) - (stop #~(lambda (_) - ;; Return #f if successfully stopped. - (not (zero? (system* #$(file-append gpm "/sbin/gpm") - "-k")))))))))) +(define (gpm-shepherd-service config) + (match-record config + (gpm options) + (list (shepherd-service + (requirement '(udev)) + (provision '(gpm)) + ;; 'gpm' runs in the background and sets a PID file. + ;; Note that it requires running as "root". + (start #~(make-forkexec-constructor + (list #$(file-append gpm "/sbin/gpm") + #$@options) + #:pid-file "/var/run/gpm.pid" + #:pid-file-timeout 3)) + (stop #~(lambda (_) + ;; Return #f if successfully stopped. + (not (zero? (system* #$(file-append gpm "/sbin/gpm") + "-k"))))))))) (define gpm-service-type (service-type (name 'gpm) @@ -2654,32 +2653,64 @@ to CONFIG." "/servers/socket/2") #f)))) -(define network-set-up/linux - (match-lambda - (($ addresses links routes) - (scheme-file "set-up-network" - (with-extensions (list guile-netlink) - #~(begin - (use-modules (ip addr) (ip link) (ip route)) - - #$@(map (lambda (address) - #~(begin - (addr-add #$(network-address-device address) - #$(network-address-value address) - #:ipv6? - #$(network-address-ipv6? address)) - ;; FIXME: loopback? - (link-set #$(network-address-device address) - #:multicast-on #t - #:up #t))) - addresses) - #$@(map (match-lambda - (($ name type arguments) - #~(link-add #$name #$type - #:type-args '#$arguments))) - links) - #$@(map (lambda (route) - #~(route-add #$(network-route-destination route) +(define (network-set-up/linux config) + (match-record config + (addresses links routes) + (scheme-file "set-up-network" + (with-extensions (list guile-netlink) + #~(begin + (use-modules (ip addr) (ip link) (ip route)) + + #$@(map (lambda (address) + #~(begin + (addr-add #$(network-address-device address) + #$(network-address-value address) + #:ipv6? + #$(network-address-ipv6? address)) + ;; FIXME: loopback? + (link-set #$(network-address-device address) + #:multicast-on #t + #:up #t))) + addresses) + #$@(map (match-lambda + (($ name type arguments) + #~(link-add #$name #$type + #:type-args '#$arguments))) + links) + #$@(map (lambda (route) + #~(route-add #$(network-route-destination route) + #:device + #$(network-route-device route) + #:ipv6? + #$(network-route-ipv6? route) + #:via + #$(network-route-gateway route) + #:src + #$(network-route-source route))) + routes) + #t))))) + +(define (network-tear-down/linux config) + (match-record config + (addresses links routes) + (scheme-file "tear-down-network" + (with-extensions (list guile-netlink) + #~(begin + (use-modules (ip addr) (ip link) (ip route) + (netlink error) + (srfi srfi-34)) + + (define-syntax-rule (false-if-netlink-error exp) + (guard (c ((netlink-error? c) #f)) + exp)) + + ;; Wrap calls in 'false-if-netlink-error' so this + ;; script goes as far as possible undoing the effects + ;; of "set-up-network". + + #$@(map (lambda (route) + #~(false-if-netlink-error + (route-del #$(network-route-destination route) #:device #$(network-route-device route) #:ipv6? @@ -2687,80 +2718,47 @@ to CONFIG." #:via #$(network-route-gateway route) #:src - #$(network-route-source route))) - routes) - #t)))))) - -(define network-tear-down/linux - (match-lambda - (($ addresses links routes) - (scheme-file "tear-down-network" - (with-extensions (list guile-netlink) - #~(begin - (use-modules (ip addr) (ip link) (ip route) - (netlink error) - (srfi srfi-34)) - - (define-syntax-rule (false-if-netlink-error exp) - (guard (c ((netlink-error? c) #f)) - exp)) - - ;; Wrap calls in 'false-if-netlink-error' so this - ;; script goes as far as possible undoing the effects - ;; of "set-up-network". - - #$@(map (lambda (route) - #~(false-if-netlink-error - (route-del #$(network-route-destination route) - #:device - #$(network-route-device route) - #:ipv6? - #$(network-route-ipv6? route) - #:via - #$(network-route-gateway route) - #:src - #$(network-route-source route)))) - routes) - #$@(map (match-lambda - (($ name type arguments) - #~(false-if-netlink-error - (link-del #$name)))) - links) - #$@(map (lambda (address) + #$(network-route-source route)))) + routes) + #$@(map (match-lambda + (($ name type arguments) #~(false-if-netlink-error - (addr-del #$(network-address-device - address) - #$(network-address-value address) - #:ipv6? - #$(network-address-ipv6? address)))) - addresses) - #f)))))) + (link-del #$name)))) + links) + #$@(map (lambda (address) + #~(false-if-netlink-error + (addr-del #$(network-address-device + address) + #$(network-address-value address) + #:ipv6? + #$(network-address-ipv6? address)))) + addresses) + #f))))) (define (static-networking-shepherd-service config) - (match config - (($ addresses links routes - provision requirement name-servers) - (let ((loopback? (and provision (memq 'loopback provision)))) - (shepherd-service + (match-record config + (addresses links routes provision requirement name-servers) + (let ((loopback? (and provision (memq 'loopback provision)))) + (shepherd-service - (documentation - "Bring up the networking interface using a static IP address.") - (requirement requirement) - (provision provision) + (documentation + "Bring up the networking interface using a static IP address.") + (requirement requirement) + (provision provision) - (start #~(lambda _ - ;; Return #t if successfully started. - (load #$(let-system (system target) - (if (string-contains (or target system) "-linux") - (network-set-up/linux config) - (network-set-up/hurd config)))))) - (stop #~(lambda _ - ;; Return #f is successfully stopped. + (start #~(lambda _ + ;; Return #t if successfully started. (load #$(let-system (system target) (if (string-contains (or target system) "-linux") - (network-tear-down/linux config) - (network-tear-down/hurd config)))))) - (respawn? #f)))))) + (network-set-up/linux config) + (network-set-up/hurd config)))))) + (stop #~(lambda _ + ;; Return #f is successfully stopped. + (load #$(let-system (system target) + (if (string-contains (or target system) "-linux") + (network-tear-down/linux config) + (network-tear-down/hurd config)))))) + (respawn? #f))))) (define (static-networking-shepherd-services networks) (map static-networking-shepherd-service networks)) @@ -2873,33 +2871,33 @@ to handle." (extra-env greetd-agreety-extra-env (default '())) (xdg-env? greetd-agreety-xdg-env? (default #t))) -(define greetd-agreety-tty-session-command - (match-lambda - (($ _ command args extra-env) - (program-file - "agreety-tty-session-command" - #~(begin - (use-modules (ice-9 match)) - (for-each (match-lambda ((var . val) (setenv var val))) - (quote (#$@extra-env))) - (apply execl #$command #$command (list #$@args))))))) - -(define greetd-agreety-tty-xdg-session-command - (match-lambda - (($ _ command args extra-env) - (program-file - "agreety-tty-xdg-session-command" - #~(begin - (use-modules (ice-9 match)) - (let* - ((username (getenv "USER")) - (useruid (passwd:uid (getpwuid username))) - (useruid (number->string useruid))) - (setenv "XDG_SESSION_TYPE" "tty") - (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))) - (for-each (match-lambda ((var . val) (setenv var val))) - (quote (#$@extra-env))) - (apply execl #$command #$command (list #$@args))))))) +(define (greetd-agreety-tty-session-command config) + (match-record config + (command command-args extra-env) + (program-file + "agreety-tty-session-command" + #~(begin + (use-modules (ice-9 match)) + (for-each (match-lambda ((var . val) (setenv var val))) + (quote (#$@extra-env))) + (apply execl #$command #$command (list #$@command-args)))))) + +(define (greetd-agreety-tty-xdg-session-command config) + (match-record config + (command command-args extra-env) + (program-file + "agreety-tty-xdg-session-command" + #~(begin + (use-modules (ice-9 match)) + (let* + ((username (getenv "USER")) + (useruid (passwd:uid (getpwuid username))) + (useruid (number->string useruid))) + (setenv "XDG_SESSION_TYPE" "tty") + (setenv "XDG_RUNTIME_DIR" (string-append "/run/user/" useruid))) + (for-each (match-lambda ((var . val) (setenv var val))) + (quote (#$@extra-env))) + (apply execl #$command #$command (list #$@command-args)))))) (define-gexp-compiler (greetd-agreety-session-compiler (session ) -- cgit 1.4.1 From 755c4b496e24f2df5f1b0f4a3873e9e00bae1fdc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 9 Dec 2022 16:40:53 +0100 Subject: system: Remove unused yggdrasil OS template. This file was added in fe1cd098d2b83737e96f19438612291f5a9316e4 but it's not referenced from anywhere, not even gnu/local.mk. Furthermore, we don't normally add full OS examples for the purposes of illustrating the use of a single service. * gnu/system/examples/yggdrasil.tmpl: Remove. --- gnu/system/examples/yggdrasil.tmpl | 60 -------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 gnu/system/examples/yggdrasil.tmpl (limited to 'gnu') diff --git a/gnu/system/examples/yggdrasil.tmpl b/gnu/system/examples/yggdrasil.tmpl deleted file mode 100644 index 4d34f49b54..0000000000 --- a/gnu/system/examples/yggdrasil.tmpl +++ /dev/null @@ -1,60 +0,0 @@ -;; This is an operating system configuration template -;; for a "bare bones" setup, with no X11 display server. - -(use-modules (gnu)) -(use-service-modules networking ssh) -(use-package-modules admin curl networking screen) - -(operating-system - (host-name "ruby-guard-5545") - (timezone "Europe/Budapest") - (locale "en_US.utf8") - - ;; Boot in "legacy" BIOS mode, assuming /dev/sdX is the - ;; target hard disk, and "my-root" is the label of the target - ;; root file system. - (bootloader (bootloader-configuration - (bootloader grub-bootloader) - (targets '("/dev/sdX")))) - (file-systems (cons (file-system - (device (file-system-label "my-root")) - (mount-point "/") - (type "ext4")) - %base-file-systems)) - (users (cons (user-account - (name "alice") - (comment "Bob's sister") - (group "users") - ;; adding her to the yggdrasil group means she can use - ;; yggdrasilctl to modify the configuration - (supplementary-groups '("wheel" "yggdrasil"))) - %base-user-accounts)) - - ;; Globally-installed packages. - (packages (cons* screen curl %base-packages)) - - ;; Add services to the baseline: a DHCP client and - ;; an SSH server. - ;; If you add an /etc/yggdrasil-private.conf, you can log in to ssh - ;; using your Yggdrasil IPv6 address from another machine running Yggdrasil. - ;; Alternatively, the client can sit behind a router that has Yggdrasil. - ;; That file is specifically _not_ handled by Guix, because we don't want its - ;; contents to sit in the world-readable /gnu/store. - (services - (append - (list - (service dhcp-client-service-type) - (service yggdrasil-service-type - (yggdrasil-configuration - (log-to 'stdout) - (log-level 'debug) - (autoconf? #f) - (json-config - ;; choose a few from - ;; https://github.com/yggdrasil-network/public-peers - '((peers . #("tcp://1.2.3.4:1337")))) - (config-file #f))) - (service openssh-service-type - (openssh-configuration - (port-number 2222)))) - %base-services))) -- cgit 1.4.1 From 556520a33c8a62fc80ac9ab925f86f08986d138b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 9 Dec 2022 16:43:25 +0100 Subject: services: nscd: Use nscd from 'glibc-final' on native builds. This reduces the closure size of systems by removing one glibc copy--namely (@ (gnu packages base) glibc) in addition to (@ (gnu packages commencement) glibc-final). * gnu/services/base.scm ()[glibc]: Change default value to use 'let-system' and 'canonical-package' as appropriate. --- gnu/services/base.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 370696a55e..2b1974d77e 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -61,7 +61,8 @@ util-linux xfsprogs)) #:use-module (gnu packages bash) #:use-module ((gnu packages base) - #:select (coreutils glibc glibc-utf8-locales tar)) + #:select (coreutils glibc glibc-utf8-locales tar + canonical-package)) #:use-module ((gnu packages compression) #:select (gzip)) #:autoload (gnu packages guile-xyz) (guile-netlink) #:autoload (gnu packages hurd) (hurd) @@ -1211,7 +1212,13 @@ the tty to run, among other things." (name-services nscd-configuration-name-services ;list of file-like (default '())) (glibc nscd-configuration-glibc ;file-like - (default glibc))) + (default (let-system (system target) + ;; Unless we're cross-compiling, arrange to use nscd + ;; from 'glibc-final' instead of pulling in a second + ;; glibc copy. + (if target + glibc + (canonical-package glibc)))))) (define-record-type* nscd-cache make-nscd-cache nscd-cache? -- cgit 1.4.1 From 591af24ade1021d91a3e7c62fcc7a8c90f00d4bb Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 9 Dec 2022 17:47:08 +0100 Subject: installer: Print progress bars and such as soon as \r is read. Fixes . Previously progress bars and related things would be buffered by 'run-external-command-with-line-hooks' until \n is read. * gnu/installer/utils.scm (run-external-command-with-line-hooks): Use 'read-delimited' rather than 'get-line'. Pass 'concat as the last argument. (%display-line-hook): Remove. (run-command): Use 'display' instead of '%display-line-hook'. (%syslog-line-hook): Add "\n" when LINE doesn't end in \n. (%installer-log-line-hook): Do not add an extra newline. (installer-log-line): Add an extra newline. --- gnu/installer/newt.scm | 2 +- gnu/installer/utils.scm | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'gnu') diff --git a/gnu/installer/newt.scm b/gnu/installer/newt.scm index 798ff53af2..e1c4453168 100644 --- a/gnu/installer/newt.scm +++ b/gnu/installer/newt.scm @@ -116,7 +116,7 @@ report it by email to ~a.") uploaded-name %guix-bug-report-address) (define command-output "") (define (line-accumulator line) (set! command-output - (string-append/shared command-output line "\n"))) + (string-append/shared command-output line))) (define result (run-external-command-with-line-hooks (list line-accumulator) args)) (define exit-val (status:exit-val result)) diff --git a/gnu/installer/utils.scm b/gnu/installer/utils.scm index 061493e6a7..6838410166 100644 --- a/gnu/installer/utils.scm +++ b/gnu/installer/utils.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018, 2020 Mathieu Othacehe -;;; Copyright © 2019, 2020 Ludovic Courtès +;;; Copyright © 2019, 2020, 2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -159,7 +159,9 @@ COMMAND will be run in a pseudoterminal. Returns the integer status value of the child process as returned by waitpid." (define (handler input) (and - (and=> (get-line input) + ;; Lines for progress bars etc. end in \r; treat is as a line ending so + ;; those lines are printed right away. + (and=> (read-delimited "\r\n" input 'concat) (lambda (line) (if (eof-object? line) #f @@ -186,7 +188,7 @@ in a pseudoterminal." (installer-log-line "running command ~s" command) (define result (run-external-command-with-line-hooks - (list %display-line-hook) command + (list display) command #:tty? tty?)) (define exit-val (status:exit-val result)) (define term-sig (status:term-sig result)) @@ -264,7 +266,10 @@ values." (or port (%make-void-port "w"))))) (define (%syslog-line-hook line) - (format (syslog-port) "installer[~d]: ~a~%" (getpid) line)) + (let ((line (if (string-suffix? "\r" line) + (string-append (string-drop-right line 1) "\n") + line))) + (format (syslog-port) "installer[~d]: ~a" (getpid) line))) (define-syntax syslog (lambda (s) @@ -293,11 +298,7 @@ values." port))) (define (%installer-log-line-hook line) - (format (installer-log-port) "~a~%" line)) - -(define (%display-line-hook line) - (display line) - (newline)) + (display line (installer-log-port))) (define %default-installer-line-hooks (list %syslog-line-hook @@ -309,9 +310,10 @@ values." (syntax-case s () ((_ fmt args ...) (string? (syntax->datum #'fmt)) - #'(let ((formatted (format #f fmt args ...))) - (for-each (lambda (f) (f formatted)) - %default-installer-line-hooks)))))) + (with-syntax ((fmt (string-append (syntax->datum #'fmt) "\n"))) + #'(let ((formatted (format #f fmt args ...))) + (for-each (lambda (f) (f formatted)) + %default-installer-line-hooks))))))) ;;; -- cgit 1.4.1 From 1ab48edb1674e0454d4368fdbed16cbbdfd9bf06 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Thu, 8 Dec 2022 13:24:02 +0100 Subject: installer: Detect mapped installation devices. Fixes: * gnu/installer/parted.scm (mapped-device?, mapped-device-parent-partition): New procedures. (eligible-devices): Detect mapped installation devices using the new procedures. --- gnu/installer/parted.scm | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'gnu') diff --git a/gnu/installer/parted.scm b/gnu/installer/parted.scm index 82375d29e3..51fa7cf9d9 100644 --- a/gnu/installer/parted.scm +++ b/gnu/installer/parted.scm @@ -379,12 +379,44 @@ fail. See rereadpt function in wipefs.c of util-linux for an explanation." (define %min-device-size (* 2 GIBIBYTE-SIZE)) ;2GiB +(define (mapped-device? device) + "Return #true if DEVICE is a mapped device, false otherwise." + (string-prefix? "/dev/dm-" device)) + +;; TODO: Use DM_TABLE_DEPS ioctl instead of dmsetup. +(define (mapped-device-parent-partition device) + "Return the parent partition path of the mapped DEVICE." + (let* ((command `("dmsetup" "deps" ,device "-o" "devname")) + (parent #f) + (handler + (lambda (input) + ;; We are parsing an output that should look like: + ;; 1 dependencies : (sda2) + (let ((result + (string-match "\\(([^\\)]+)\\)" + (get-string-all input)))) + (and result + (set! parent + (format #f "/dev/~a" + (match:substring result 1)))))))) + (run-external-command-with-handler handler command) + parent)) + (define (eligible-devices) "Return all the available devices except the install device and the devices which are smaller than %MIN-DEVICE-SIZE." (define the-installer-root-partition-path - (installer-root-partition-path)) + (let ((root (installer-root-partition-path))) + (cond + ((mapped-device? root) + ;; If the partition is a mapped device (/dev/dm-X), locate the parent + ;; partition. It is the case when Ventoy is used to host the + ;; installation image. + (let ((parent (mapped-device-parent-partition root))) + (installer-log-line "mapped device ~a -> ~a" parent root) + parent)) + (else root)))) (define (small-device? device) (let ((length (device-length device)) -- cgit 1.4.1 From 61b7e9687757aff013b99e4ab15669a950c8b222 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 10 Dec 2022 14:33:51 +0100 Subject: install: 'umount-cow-store' retries upon EBUSY. Possibly fixes . * gnu/build/install.scm (umount*): New procedure. (unmount-cow-store): Use it instead of 'umount'. --- gnu/build/install.scm | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/build/install.scm b/gnu/build/install.scm index 33a9616c0d..d4982650c1 100644 --- a/gnu/build/install.scm +++ b/gnu/build/install.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2013-2020, 2022 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2022 Maxim Cournoyer ;;; @@ -282,12 +282,31 @@ disk." (mount "/.rw-store" (%store-directory) "" MS_MOVE) (rmdir "/.rw-store"))) +(define (umount* directory) + "Unmount DIRECTORY, but retry a few times upon EBUSY." + (let loop ((attempts 5)) + (catch 'system-error + (lambda () + (umount directory)) + (lambda args + (if (and (= EBUSY (system-error-errno args)) + (> attempts 0)) + (begin + (sleep 1) + (loop (- attempts 1))) + (apply throw args)))))) + (define (unmount-cow-store target backing-directory) "Unmount copy-on-write store." (let ((tmp-dir "/remove")) (mkdir-p tmp-dir) (mount (%store-directory) tmp-dir "" MS_MOVE) - (umount tmp-dir) + + ;; We might get EBUSY at this point, possibly because of lingering + ;; processes with open file descriptors. Use 'umount*' to retry upon + ;; EBUSY, leaving a bit of time. See . + (umount* tmp-dir) + (rmdir tmp-dir) (delete-file-recursively (string-append target backing-directory)))) -- cgit 1.4.1 From 6dbdb5fcf5640c126ac65479b835aba83aea2a6d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 10 Dec 2022 18:19:22 +0100 Subject: gnu: guix: Update to 1.4.0rc2. --- gnu/packages/package-management.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm index b5b6b3875c..5a09b1fcf8 100644 --- a/gnu/packages/package-management.scm +++ b/gnu/packages/package-management.scm @@ -164,8 +164,8 @@ ;; Latest version of Guix, which may or may not correspond to a release. ;; Note: the 'update-guix-package.scm' script expects this definition to ;; start precisely like this. - (let ((version "1.4.0rc1") - (commit "020184fd39c6244e0336db3c608d3946b8d20490") + (let ((version "1.4.0rc2") + (commit "7866294e32f1e758d06fce4e1b1035eca3a7d772") (revision 0)) (package (name "guix") @@ -182,7 +182,7 @@ (commit commit))) (sha256 (base32 - "1489fdxdb86shx6bnfs8kihhvw44xqiv6fkx3b67cyw1dakxh1m4")) + "0np4fw5kq882nrkfgsvvwgcxqwvm6bzn3dbdf8p48nr7mfrm3rz9")) (file-name (string-append "guix-" version "-checkout")))) (build-system gnu-build-system) (arguments -- cgit 1.4.1