summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-07-25 18:26:18 +0200
committerLudovic Courtès <ludo@gnu.org>2020-07-25 19:11:37 +0200
commitd51bfe242fbe6f3f8f71d723e8fe0c7bbe711ba1 (patch)
tree6d8519ba2ab3e5475ff44dfa3a1c2aa9ec8a50b9 /gnu
parent252a1926bc7d7aa0b39d89a484c0c1b82e945fcd (diff)
Use 'formatted-message' instead of '&message' where appropriate.
* gnu.scm (%try-use-modules): Use 'formatted-message' instead of '&message'. * gnu/machine/digital-ocean.scm (maybe-raise-unsupported-configuration-error): Likewise. * gnu/machine/ssh.scm (machine-check-file-system-availability): Likewise. (machine-check-building-for-appropriate-system): Likewise. (deploy-managed-host): Likewise. (maybe-raise-unsupported-configuration-error): Likewise. * gnu/packages.scm (search-patch): Likewise. * gnu/services.scm (%service-with-default-value): Likewise. (files->etc-directory): Likewise. (fold-services): Likewise. * gnu/system.scm (locale-name->definition*): Likewise. * gnu/system/mapped-devices.scm (check-device-initrd-modules): Likewise. (check-luks-device): Likewise. * guix/channels.scm (latest-channel-instance): Likewise. * guix/cve.scm (json->cve-items): Likewise. * guix/git-authenticate.scm (commit-signing-key): Likewise. (commit-authorized-keys): Likewise. (authenticate-commit): Likewise. (verify-introductory-commit): Likewise. * guix/remote.scm (remote-pipe-for-gexp): Likewise. * guix/scripts/graph.scm (assert-package): Likewise. * guix/scripts/offload.scm (private-key-from-file*): Likewise. * guix/ssh.scm (authenticate-server*): Likewise. (open-ssh-session): Likewise. (remote-inferior): Likewise. * guix/ui.scm (matching-generations): Likewise. * guix/upstream.scm (package-update): Likewise. * tests/channels.scm ("latest-channel-instances, missing introduction for 'guix'"): Catch 'formatted-message?'. ("authenticate-channel, wrong first commit signer"): Likewise. * tests/lint.scm ("patches: not found"): Adjust message string. * tests/packages.scm ("patch not found yields a run-time error"): Catch 'formatted-message?'. * guix/lint.scm (check-patch-file-names): Handle 'formatted-message?'. (check-derivation): Ditto.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/machine/digital-ocean.scm7
-rw-r--r--gnu/machine/ssh.scm36
-rw-r--r--gnu/packages.scm6
-rw-r--r--gnu/services.scm32
-rw-r--r--gnu/system.scm4
-rw-r--r--gnu/system/mapped-devices.scm34
6 files changed, 52 insertions, 67 deletions
diff --git a/gnu/machine/digital-ocean.scm b/gnu/machine/digital-ocean.scm
index 1a91a3a49bb..82383a8c7c2 100644
--- a/gnu/machine/digital-ocean.scm
+++ b/gnu/machine/digital-ocean.scm
@@ -26,6 +26,7 @@
26 #:use-module (guix base32) 26 #:use-module (guix base32)
27 #:use-module (guix derivations) 27 #:use-module (guix derivations)
28 #:use-module (guix i18n) 28 #:use-module (guix i18n)
29 #:use-module ((guix diagnostics) #:select (formatted-message))
29 #:use-module (guix import json) 30 #:use-module (guix import json)
30 #:use-module (guix monads) 31 #:use-module (guix monads)
31 #:use-module (guix records) 32 #:use-module (guix records)
@@ -414,9 +415,7 @@ one procured from https://cloud.digitalocean.com/account/api/tokens.")))))))
414 (let ((config (machine-configuration machine)) 415 (let ((config (machine-configuration machine))
415 (environment (environment-type-name (machine-environment machine)))) 416 (environment (environment-type-name (machine-environment machine))))
416 (unless (and config (digital-ocean-configuration? config)) 417 (unless (and config (digital-ocean-configuration? config))
417 (raise (condition 418 (raise (formatted-message (G_ "unsupported machine configuration '~a' \
418 (&message
419 (message (format #f (G_ "unsupported machine configuration '~a'
420for environment of type '~a'") 419for environment of type '~a'")
421 config 420 config
422 environment)))))))) 421 environment)))))
diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm
index 41486392920..641e8718618 100644
--- a/gnu/machine/ssh.scm
+++ b/gnu/machine/ssh.scm
@@ -179,11 +179,9 @@ exist on the machine."
179 (lambda args 179 (lambda args
180 (system-error-errno args))))) 180 (system-error-errno args)))))
181 (when (number? errno) 181 (when (number? errno)
182 (raise (condition 182 (raise (formatted-message (G_ "device '~a' not found: ~a")
183 (&message
184 (message (format #f (G_ "device '~a' not found: ~a")
185 (file-system-device fs) 183 (file-system-device fs)
186 (strerror errno))))))))) 184 (strerror errno))))))
187 185
188 (define (check-labeled-file-system fs) 186 (define (check-labeled-file-system fs)
189 (define remote-exp 187 (define remote-exp
@@ -196,11 +194,9 @@ exist on the machine."
196 194
197 (remote-let ((result remote-exp)) 195 (remote-let ((result remote-exp))
198 (unless result 196 (unless result
199 (raise (condition 197 (raise (formatted-message (G_ "no file system with label '~a'")
200 (&message
201 (message (format #f (G_ "no file system with label '~a'")
202 (file-system-label->string 198 (file-system-label->string
203 (file-system-device fs)))))))))) 199 (file-system-device fs)))))))
204 200
205 (define (check-uuid-file-system fs) 201 (define (check-uuid-file-system fs)
206 (define remote-exp 202 (define remote-exp
@@ -217,10 +213,8 @@ exist on the machine."
217 213
218 (remote-let ((result remote-exp)) 214 (remote-let ((result remote-exp))
219 (unless result 215 (unless result
220 (raise (condition 216 (raise (formatted-message (G_ "no file system with UUID '~a'")
221 (&message 217 (uuid->string (file-system-device fs)))))))
222 (message (format #f (G_ "no file system with UUID '~a'")
223 (uuid->string (file-system-device fs))))))))))
224 218
225 (append (map check-literal-file-system 219 (append (map check-literal-file-system
226 (filter (lambda (fs) 220 (filter (lambda (fs)
@@ -285,12 +279,10 @@ by MACHINE."
285 (system (remote-system (machine-ssh-session machine)))) 279 (system (remote-system (machine-ssh-session machine))))
286 (when (and (machine-ssh-configuration-build-locally? config) 280 (when (and (machine-ssh-configuration-build-locally? config)
287 (not (string= system (machine-ssh-configuration-system config)))) 281 (not (string= system (machine-ssh-configuration-system config))))
288 (raise (condition 282 (raise (formatted-message (G_ "incorrect target system\
289 (&message
290 (message (format #f (G_ "incorrect target system\
291 ('~a' was given, while the system reports that it is '~a')~%") 283 ('~a' was given, while the system reports that it is '~a')~%")
292 (machine-ssh-configuration-system config) 284 (machine-ssh-configuration-system config)
293 system)))))))) 285 system)))))
294 286
295(define (check-deployment-sanity machine) 287(define (check-deployment-sanity machine)
296 "Raise a '&message' error condition if it is clear that deploying MACHINE's 288 "Raise a '&message' error condition if it is clear that deploying MACHINE's
@@ -402,11 +394,9 @@ environment type of 'managed-host."
402 (when (machine-ssh-configuration-authorize? 394 (when (machine-ssh-configuration-authorize?
403 (machine-configuration machine)) 395 (machine-configuration machine))
404 (unless (file-exists? %public-key-file) 396 (unless (file-exists? %public-key-file)
405 (raise (condition 397 (raise (formatted-message (G_ "no signing key '~a'. \
406 (&message
407 (message (format #f (G_ "no signing key '~a'. \
408have you run 'guix archive --generate-key?'") 398have you run 'guix archive --generate-key?'")
409 %public-key-file)))))) 399 %public-key-file)))
410 (remote-authorize-signing-key (call-with-input-file %public-key-file 400 (remote-authorize-signing-key (call-with-input-file %public-key-file
411 (lambda (port) 401 (lambda (port)
412 (string->canonical-sexp 402 (string->canonical-sexp
@@ -497,9 +487,7 @@ connection to the host.")))
497 (let ((config (machine-configuration machine)) 487 (let ((config (machine-configuration machine))
498 (environment (environment-type-name (machine-environment machine)))) 488 (environment (environment-type-name (machine-environment machine))))
499 (unless (and config (machine-ssh-configuration? config)) 489 (unless (and config (machine-ssh-configuration? config))
500 (raise (condition 490 (raise (formatted-message (G_ "unsupported machine configuration '~a'
501 (&message
502 (message (format #f (G_ "unsupported machine configuration '~a'
503for environment of type '~a'") 491for environment of type '~a'")
504 config 492 config
505 environment)))))))) 493 environment)))))
diff --git a/gnu/packages.scm b/gnu/packages.scm
index d22c992bb1f..4e4282645ad 100644
--- a/gnu/packages.scm
+++ b/gnu/packages.scm
@@ -24,6 +24,7 @@
24 #:use-module (guix packages) 24 #:use-module (guix packages)
25 #:use-module (guix ui) 25 #:use-module (guix ui)
26 #:use-module (guix utils) 26 #:use-module (guix utils)
27 #:use-module (guix diagnostics)
27 #:use-module (guix discovery) 28 #:use-module (guix discovery)
28 #:use-module (guix memoization) 29 #:use-module (guix memoization)
29 #:use-module ((guix build utils) 30 #:use-module ((guix build utils)
@@ -92,9 +93,8 @@
92(define (search-patch file-name) 93(define (search-patch file-name)
93 "Search the patch FILE-NAME. Raise an error if not found." 94 "Search the patch FILE-NAME. Raise an error if not found."
94 (or (search-path (%patch-path) file-name) 95 (or (search-path (%patch-path) file-name)
95 (raise (condition 96 (raise (formatted-message (G_ "~a: patch not found")
96 (&message (message (format #f (G_ "~a: patch not found") 97 file-name))))
97 file-name)))))))
98 98
99(define-syntax-rule (search-patches file-name ...) 99(define-syntax-rule (search-patches file-name ...)
100 "Return the list of absolute file names corresponding to each 100 "Return the list of absolute file names corresponding to each
diff --git a/gnu/services.scm b/gnu/services.scm
index 6509a9014e4..399a432e3f9 100644
--- a/gnu/services.scm
+++ b/gnu/services.scm
@@ -30,7 +30,7 @@
30 #:use-module (guix describe) 30 #:use-module (guix describe)
31 #:use-module (guix sets) 31 #:use-module (guix sets)
32 #:use-module (guix ui) 32 #:use-module (guix ui)
33 #:use-module ((guix utils) #:select (source-properties->location)) 33 #:use-module (guix diagnostics)
34 #:autoload (guix openpgp) (openpgp-format-fingerprint) 34 #:autoload (guix openpgp) (openpgp-format-fingerprint)
35 #:use-module (guix modules) 35 #:use-module (guix modules)
36 #:use-module (gnu packages base) 36 #:use-module (gnu packages base)
@@ -242,13 +242,13 @@ TYPE does not have a default value, an error is raised."
242 (if (eq? default &no-default-value) 242 (if (eq? default &no-default-value)
243 (let ((location (source-properties->location location))) 243 (let ((location (source-properties->location location)))
244 (raise 244 (raise
245 (condition 245 (make-compound-condition
246 (&missing-value-service-error (type type) (location location)) 246 (condition
247 (&message 247 (&missing-value-service-error (type type) (location location)))
248 (message (format #f (G_ "~a: no value specified \ 248 (formatted-message (G_ "~a: no value specified \
249for service of type '~a'") 249for service of type '~a'")
250 (location->string location) 250 (location->string location)
251 (service-type-name type))))))) 251 (service-type-name type)))))
252 (service type default)))) 252 (service type default))))
253 253
254(define-condition-type &service-error &error 254(define-condition-type &service-error &error
@@ -725,10 +725,8 @@ and FILE could be \"/usr/bin/env\"."
725 (() #t) 725 (() #t)
726 (((file _) rest ...) 726 (((file _) rest ...)
727 (when (set-contains? seen file) 727 (when (set-contains? seen file)
728 (raise (condition 728 (raise (formatted-message (G_ "duplicate '~a' entry for /etc")
729 (&message 729 file)))
730 (message (format #f (G_ "duplicate '~a' entry for /etc")
731 file))))))
732 (loop rest (set-insert file seen)))))) 730 (loop rest (set-insert file seen))))))
733 731
734 ;; Detect duplicates early instead of letting them through, eventually 732 ;; Detect duplicates early instead of letting them through, eventually
@@ -1000,12 +998,12 @@ TARGET-TYPE; return the root service adjusted accordingly."
1000 vlist-null)) 998 vlist-null))
1001 (() 999 (()
1002 (raise 1000 (raise
1003 (condition (&missing-target-service-error 1001 (make-compound-condition
1004 (service #f) 1002 (condition (&missing-target-service-error
1005 (target-type target-type)) 1003 (service #f)
1006 (&message 1004 (target-type target-type)))
1007 (message (format #f (G_ "service of type '~a' not found") 1005 (formatted-message (G_ "service of type '~a' not found")
1008 (service-type-name target-type))))))) 1006 (service-type-name target-type)))))
1009 (x 1007 (x
1010 (raise 1008 (raise
1011 (condition (&ambiguous-target-service-error 1009 (condition (&ambiguous-target-service-error
diff --git a/gnu/system.scm b/gnu/system.scm
index 6ae15ab23bd..c8ef641695a 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -1113,9 +1113,7 @@ TYPE (one of 'iso9660 or 'dce). Return a UUID object."
1113 "Variant of 'locale-name->definition' that raises an error upon failure." 1113 "Variant of 'locale-name->definition' that raises an error upon failure."
1114 (match (locale-name->definition name) 1114 (match (locale-name->definition name)
1115 (#f 1115 (#f
1116 (raise (condition 1116 (raise (formatted-message (G_ "~a: invalid locale name") name)))
1117 (&message
1118 (message (format #f (G_ "~a: invalid locale name") name))))))
1119 (def def))) 1117 (def def)))
1120 1118
1121(define (operating-system-locale-directory os) 1119(define (operating-system-locale-directory os)
diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm
index 00f235e6b62..31c50c4e40f 100644
--- a/gnu/system/mapped-devices.scm
+++ b/gnu/system/mapped-devices.scm
@@ -25,6 +25,7 @@
25 #:use-module (guix i18n) 25 #:use-module (guix i18n)
26 #:use-module ((guix diagnostics) 26 #:use-module ((guix diagnostics)
27 #:select (source-properties->location 27 #:select (source-properties->location
28 formatted-message
28 &fix-hint 29 &fix-hint
29 &error-location)) 30 &error-location))
30 #:use-module (gnu services) 31 #:use-module (gnu services)
@@ -132,13 +133,13 @@ DEVICE must be a \"/dev\" file name."
132 ;; "usb_storage"), not file names (e.g., "usb-storage.ko"). This is 133 ;; "usb_storage"), not file names (e.g., "usb-storage.ko"). This is
133 ;; OK because we have machinery that accepts both the hyphen and the 134 ;; OK because we have machinery that accepts both the hyphen and the
134 ;; underscore version. 135 ;; underscore version.
135 (raise (condition 136 (raise (make-compound-condition
136 (&message 137 (formatted-message (G_ "you may need these modules \
137 (message (format #f (G_ "you may need these modules \
138in the initrd for ~a:~{ ~a~}") 138in the initrd for ~a:~{ ~a~}")
139 device missing))) 139 device missing)
140 (&fix-hint 140 (condition
141 (hint (format #f (G_ "Try adding them to the 141 (&fix-hint
142 (hint (format #f (G_ "Try adding them to the
142@code{initrd-modules} field of your @code{operating-system} declaration, along 143@code{initrd-modules} field of your @code{operating-system} declaration, along
143these lines: 144these lines:
144 145
@@ -151,9 +152,10 @@ these lines:
151 152
152If you think this diagnostic is inaccurate, use the @option{--skip-checks} 153If you think this diagnostic is inaccurate, use the @option{--skip-checks}
153option of @command{guix system}.\n") 154option of @command{guix system}.\n")
154 missing))) 155 missing))))
155 (&error-location 156 (condition
156 (location (source-properties->location location))))))) 157 (&error-location
158 (location (source-properties->location location))))))))
157 159
158 160
159;;; 161;;;
@@ -215,13 +217,13 @@ option of @command{guix system}.\n")
215 (if (uuid? source) 217 (if (uuid? source)
216 (match (find-partition-by-luks-uuid (uuid-bytevector source)) 218 (match (find-partition-by-luks-uuid (uuid-bytevector source))
217 (#f 219 (#f
218 (raise (condition 220 (raise (make-compound-condition
219 (&message 221 (formatted-message (G_ "no LUKS partition with UUID '~a'")
220 (message (format #f (G_ "no LUKS partition with UUID '~a'") 222 (uuid->string source))
221 (uuid->string source)))) 223 (condition
222 (&error-location 224 (&error-location
223 (location (source-properties->location 225 (location (source-properties->location
224 (mapped-device-location md))))))) 226 (mapped-device-location md))))))))
225 ((? string? device) 227 ((? string? device)
226 (check-device-initrd-modules device initrd-modules location))) 228 (check-device-initrd-modules device initrd-modules location)))
227 (check-device-initrd-modules source initrd-modules location))))) 229 (check-device-initrd-modules source initrd-modules location)))))