diff options
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build/compile.scm | 56 | ||||
-rw-r--r-- | guix/deprecation.scm | 24 | ||||
-rw-r--r-- | guix/derivations.scm | 2 | ||||
-rw-r--r-- | guix/grafts.scm | 2 | ||||
-rw-r--r-- | guix/import/github.scm | 67 | ||||
-rw-r--r-- | guix/inferior.scm | 12 | ||||
-rw-r--r-- | guix/records.scm | 20 | ||||
-rw-r--r-- | guix/scripts/challenge.scm | 2 | ||||
-rw-r--r-- | guix/scripts/graph.scm | 2 | ||||
-rw-r--r-- | guix/scripts/lint.scm | 4 | ||||
-rw-r--r-- | guix/scripts/offload.scm | 43 | ||||
-rw-r--r-- | guix/scripts/pull.scm | 1 | ||||
-rw-r--r-- | guix/self.scm | 19 | ||||
-rw-r--r-- | guix/serialization.scm | 2 | ||||
-rw-r--r-- | guix/ssh.scm | 12 | ||||
-rw-r--r-- | guix/store.scm | 232 | ||||
-rw-r--r-- | guix/tests.scm | 2 | ||||
-rw-r--r-- | guix/ui.scm | 10 |
18 files changed, 307 insertions, 205 deletions
diff --git a/guix/build/compile.scm b/guix/build/compile.scm index 215489f136..9e31be93ff 100644 --- a/guix/build/compile.scm +++ b/guix/build/compile.scm @@ -97,8 +97,7 @@ (report-load file total completed) (format debug-port "~%loading '~a'...~%" file) - (parameterize ((current-warning-port debug-port)) - (resolve-interface (file-name->module-name file))) + (resolve-interface (file-name->module-name file)) (loop files (+ 1 completed))))))) @@ -158,37 +157,38 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"." ;; Exit as soon as something goes wrong. (exit-on-exception - (with-fluids ((*current-warning-prefix* "")) - (with-target host - (lambda () - (let ((relative (relative-file source-directory file))) - (compile-file file - #:output-file (string-append build-directory "/" - (scm->go relative)) - #:opts (append warning-options - (optimization-options relative)))))))) + (with-target host + (lambda () + (let ((relative (relative-file source-directory file))) + (compile-file file + #:output-file (string-append build-directory "/" + (scm->go relative)) + #:opts (append warning-options + (optimization-options relative))))))) (with-mutex progress-lock (set! completed (+ 1 completed)))) (with-augmented-search-path %load-path source-directory (with-augmented-search-path %load-compiled-path build-directory - ;; FIXME: To work around <https://bugs.gnu.org/15602>, we first load all - ;; of FILES. - (load-files source-directory files - #:report-load report-load - #:debug-port debug-port) - - ;; Make sure compilation related modules are loaded before starting to - ;; compile files in parallel. - (compile #f) - - ;; XXX: Don't use too many workers to work around the insane memory - ;; requirements of the compiler in Guile 2.2.2: - ;; <https://lists.gnu.org/archive/html/guile-devel/2017-05/msg00033.html>. - (n-par-for-each (min workers 8) build files) - - (unless (zero? total) - (report-compilation #f total total))))) + (with-fluids ((*current-warning-prefix* "")) + + ;; FIXME: To work around <https://bugs.gnu.org/15602>, we first load all + ;; of FILES. + (load-files source-directory files + #:report-load report-load + #:debug-port debug-port) + + ;; Make sure compilation related modules are loaded before starting to + ;; compile files in parallel. + (compile #f) + + ;; XXX: Don't use too many workers to work around the insane memory + ;; requirements of the compiler in Guile 2.2.2: + ;; <https://lists.gnu.org/archive/html/guile-devel/2017-05/msg00033.html>. + (n-par-for-each (min workers 8) build files) + + (unless (zero? total) + (report-compilation #f total total)))))) (eval-when (eval load) (when (and (string=? "2" (major-version)) diff --git a/guix/deprecation.scm b/guix/deprecation.scm index 453aad7106..2f7c058940 100644 --- a/guix/deprecation.scm +++ b/guix/deprecation.scm @@ -20,7 +20,7 @@ #:use-module (guix i18n) #:use-module (ice-9 format) #:export (define-deprecated - without-deprecation-warnings + define-deprecated/alias deprecation-warning-port)) ;;; Commentary: @@ -33,7 +33,7 @@ (define deprecation-warning-port ;; Port where deprecation warnings go. - (make-parameter (current-warning-port))) + (make-parameter (current-error-port))) (define (source-properties->location-string properties) "Return a human-friendly, GNU-standard representation of PROPERTIES, a @@ -87,3 +87,23 @@ This will write a deprecation warning to DEPRECATION-WARNING-PORT." (id (identifier? #'id) #'real)))))))))) + +(define-syntax-rule (define-deprecated/alias deprecated replacement) + "Define as an alias a deprecated variable, procedure, or macro, along +these lines: + + (define-deprecated/alias nix-server? store-connection?) + +where 'nix-server?' is the deprecated name for 'store-connection?'. + +This will write a deprecation warning to DEPRECATION-WARNING-PORT." + (define-syntax deprecated + (lambda (s) + (warn-about-deprecation 'deprecated (syntax-source s) + #:replacement 'replacement) + (syntax-case s () + ((_ args (... ...)) + #'(replacement args (... ...))) + (id + (identifier? #'id) + #'replacement))))) diff --git a/guix/derivations.scm b/guix/derivations.scm index f6176a78fd..fb2fa177be 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -113,7 +113,7 @@ ;;; Error conditions. ;;; -(define-condition-type &derivation-error &nix-error +(define-condition-type &derivation-error &store-error derivation-error? (derivation derivation-error-derivation)) diff --git a/guix/grafts.scm b/guix/grafts.scm index db9c6854fd..a3e12f6efd 100644 --- a/guix/grafts.scm +++ b/guix/grafts.scm @@ -189,7 +189,7 @@ available." items))) (define (references* items) - (guard (c ((nix-protocol-error? c) + (guard (c ((store-protocol-error? c) ;; As a last resort, build DRV and query the references of the ;; build result. diff --git a/guix/import/github.scm b/guix/import/github.scm index b287313d98..4d12339204 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -98,7 +98,9 @@ false if none is recognized" (updated-url source-uri)) ((source-uri ...) (find updated-url source-uri)))) - ((eq? fetch-method download:git-fetch) + ((and (eq? fetch-method download:git-fetch) + (string-prefix? "https://github.com/" + (download:git-reference-url source-uri))) (download:git-reference-url source-uri)) (else #f)))) @@ -169,6 +171,9 @@ empty list." "Return a string of the newest released version name given a string URL like 'https://github.com/arq5x/bedtools2/archive/v2.24.0.tar.gz' and the name of the package e.g. 'bedtools2'. Return #f if there is no releases" + (define (pre-release? x) + (hash-ref x "prerelease")) + (let* ((json (fetch-releases-or-tags url))) (if (eq? json #f) (if (%github-token) @@ -178,40 +183,32 @@ API when using a GitHub token") API. This may be fixed by using an access token and setting the environment variable GUIX_GITHUB_TOKEN, for instance one procured from https://github.com/settings/tokens")) - (let loop ((releases - (filter - (lambda (x) - ;; example pre-release: - ;; https://github.com/wwood/OrfM/releases/tag/v0.5.1 - ;; or an all-prerelease set - ;; https://github.com/powertab/powertabeditor/releases - (not (hash-ref x "prerelease"))) - json))) - (match releases - (() ;empty release list - #f) - ((release . rest) ;one or more releases - (let ((tag (or (hash-ref release "tag_name") ;a "release" - (hash-ref release "name"))) ;a tag - (name-length (string-length package-name))) - ;; some tags include the name of the package e.g. "fdupes-1.51" - ;; so remove these - (if (and (< name-length (string-length tag)) - (string=? (string-append package-name "-") - (substring tag 0 (+ name-length 1)))) - (substring tag (+ name-length 1)) - ;; some tags start with a "v" e.g. "v0.25.0" - ;; where some are just the version number - (if (string-prefix? "v" tag) - (substring tag 1) - - ;; Finally, reject tags that don't start with a digit: - ;; they may not represent a release. - (if (and (not (string-null? tag)) - (char-set-contains? char-set:digit - (string-ref tag 0))) - tag - (loop rest))))))))))) + (any + (lambda (release) + (let ((tag (or (hash-ref release "tag_name") ;a "release" + (hash-ref release "name"))) ;a tag + (name-length (string-length package-name))) + (cond + ;; some tags include the name of the package e.g. "fdupes-1.51" + ;; so remove these + ((and (< name-length (string-length tag)) + (string=? (string-append package-name "-") + (substring tag 0 (+ name-length 1)))) + (substring tag (+ name-length 1))) + ;; some tags start with a "v" e.g. "v0.25.0" + ;; where some are just the version number + ((string-prefix? "v" tag) + (substring tag 1)) + ;; Finally, reject tags that don't start with a digit: + ;; they may not represent a release. + ((and (not (string-null? tag)) + (char-set-contains? char-set:digit + (string-ref tag 0))) + tag) + (else #f)))) + (match (remove pre-release? json) + (() json) ; keep everything + (releases releases)))))) (define (latest-release pkg) "Return an <upstream-source> for the latest release of PKG." diff --git a/guix/inferior.scm b/guix/inferior.scm index 9f19e7d316..6cfa146029 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -26,9 +26,9 @@ version>? version-prefix? cache-directory)) #:use-module ((guix store) - #:select (nix-server-socket - nix-server-major-version - nix-server-minor-version + #:select (store-connection-socket + store-connection-major-version + store-connection-minor-version store-lift)) #:use-module ((guix derivations) #:select (read-derivation-from-file)) @@ -424,8 +424,8 @@ thus be the code of a one-argument procedure that accepts a store." (chmod directory #o700) (let* ((name (string-append directory "/inferior")) (socket (socket AF_UNIX SOCK_STREAM 0)) - (major (nix-server-major-version store)) - (minor (nix-server-minor-version store)) + (major (store-connection-major-version store)) + (minor (store-connection-minor-version store)) (proto (logior major minor))) (bind socket AF_UNIX name) (listen socket 1024) @@ -451,7 +451,7 @@ thus be the code of a one-argument procedure that accepts a store." inferior) (match (accept socket) ((client . address) - (proxy client (nix-server-socket store)))) + (proxy client (store-connection-socket store)))) (close-port socket) (read-inferior-response inferior))))) diff --git a/guix/records.scm b/guix/records.scm index 98f3c8fef0..6b3c25cefa 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2018 Mark H Weaver <mhw@netris.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -52,6 +53,22 @@ ((weird _ ...) ;weird! (syntax-violation name "invalid field specifier" #'weird))))) +(define (report-duplicate-field-specifier name ctor) + "Report the first duplicate identifier among the bindings in CTOR." + (syntax-case ctor () + ((_ bindings ...) + (let loop ((bindings #'(bindings ...)) + (seen '())) + (syntax-case bindings () + (((field value) rest ...) + (not (memq (syntax->datum #'field) seen)) + (loop #'(rest ...) (cons (syntax->datum #'field) seen))) + ((duplicate rest ...) + (syntax-violation name "duplicate field initializer" + #'duplicate)) + (() + #t)))))) + (eval-when (expand load eval) ;; The procedures below are needed both at run time and at expansion time. @@ -169,6 +186,9 @@ of TYPE matches the expansion-time ABI." #'(field (... ...))) (wrap-field-value f (field-default-value f)))) + ;; Pass S to make sure source location info is preserved. + (report-duplicate-field-specifier 'name s) + (let ((fields (append fields (map car default-values)))) (cond ((lset= eq? fields '(expected ...)) #`(let* #,(field-bindings diff --git a/guix/scripts/challenge.scm b/guix/scripts/challenge.scm index f0693ed8df..65de42053d 100644 --- a/guix/scripts/challenge.scm +++ b/guix/scripts/challenge.scm @@ -109,7 +109,7 @@ "Return the hash of ITEM, a store item, if ITEM was built locally. Otherwise return #f." (lambda (store) - (guard (c ((nix-protocol-error? c) + (guard (c ((store-protocol-error? c) (values #f store))) (if (locally-built? store item) (values (query-path-hash store item) store) diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm index 145a574dba..8efeef3274 100644 --- a/guix/scripts/graph.scm +++ b/guix/scripts/graph.scm @@ -299,7 +299,7 @@ this type of graph"))))))) information available in the local store or using information about substitutes." (lambda (store) - (guard (c ((nix-protocol-error? c) + (guard (c ((store-protocol-error? c) (match (substitutable-path-info store (list item)) ((info) (values (substitutable-references info) store)) diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 665adcfb8d..ddad5b7fd0 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -833,11 +833,11 @@ descriptions maintained upstream." (define (try system) (catch #t (lambda () - (guard (c ((nix-protocol-error? c) + (guard (c ((store-protocol-error? c) (emit-warning package (format #f (G_ "failed to create ~a derivation: ~a") system - (nix-protocol-error-message c)))) + (store-protocol-error-message c)))) ((message-condition? c) (emit-warning package (format #f (G_ "failed to create ~a derivation: ~a") diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 30fe69ad6d..eb02672dbf 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> ;;; ;;; This file is part of GNU Guix. @@ -358,12 +358,12 @@ MACHINE." (format (current-error-port) "@ build-remote ~a ~a~%" (derivation-file-name drv) (build-machine-name machine)) - (guard (c ((nix-protocol-error? c) + (guard (c ((store-protocol-error? c) (format (current-error-port) (G_ "derivation '~a' offloaded to '~a' failed: ~a~%") (derivation-file-name drv) (build-machine-name machine) - (nix-protocol-error-message c)) + (store-protocol-error-message c)) (let* ((inferior (false-if-exception (remote-inferior session))) (space (false-if-exception (node-free-disk-space inferior)))) @@ -712,18 +712,31 @@ machine." (warning (G_ "failed to run 'guix repl' on machine '~a'~%") (build-machine-name machine))) ((? inferior? inferior) - (let ((uts (inferior-eval '(uname) inferior)) - (load (node-load inferior)) - (free (node-free-disk-space inferior))) - (close-inferior inferior) - (format #t "~a~% kernel: ~a ~a~% architecture: ~a~%\ - host name: ~a~% normalized load: ~a~% free disk space: ~,2f MiB~%" - (build-machine-name machine) - (utsname:sysname uts) (utsname:release uts) - (utsname:machine uts) - (utsname:nodename uts) - (normalized-load machine load) - (/ free (expt 2 20) 1.))))) + (let ((now (car (gettimeofday)))) + (match (inferior-eval '(list (uname) + (car (gettimeofday))) + inferior) + ((uts time) + (when (< time now) + ;; Build machine clocks must not be behind as this + ;; could cause timestamp issues. + (warning (G_ "machine '~a' is ~a seconds behind~%") + (build-machine-name machine) + (- now time))) + + (let ((load (node-load inferior)) + (free (node-free-disk-space inferior))) + (close-inferior inferior) + (format #t "~a~% kernel: ~a ~a~% architecture: ~a~%\ + host name: ~a~% normalized load: ~a~% free disk space: ~,2f MiB~%\ + time difference: ~a s~%" + (build-machine-name machine) + (utsname:sysname uts) (utsname:release uts) + (utsname:machine uts) + (utsname:nodename uts) + (normalized-load machine load) + (/ free (expt 2 20) 1.) + (- time now)))))))) (disconnect! session)) machines))) diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm index d3a4401a01..41c7fb289a 100644 --- a/guix/scripts/pull.scm +++ b/guix/scripts/pull.scm @@ -46,6 +46,7 @@ #:use-module ((gnu packages certs) #:select (le-certs)) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (srfi srfi-37) #:use-module (ice-9 match) diff --git a/guix/self.scm b/guix/self.scm index fa78015a41..d1b8256802 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -36,8 +36,7 @@ #:export (make-config.scm whole-package ;for internal use in 'guix pull' compiled-guix - guix-derivation - reload-guix)) + guix-derivation)) ;;; @@ -613,10 +612,6 @@ Info manual." (append (file-imports source "gnu/system/examples" (const #t)) - ;; Need so we get access system tests from an - ;; inferior. - (file-imports source "gnu/tests" (const #t)) - ;; All the installer code is on the build-side. (file-imports source "gnu/installer/" (const #t)) @@ -636,6 +631,17 @@ Info manual." #:extensions dependencies #:guile-for-build guile-for-build)) + (define *system-test-modules* + ;; Ship these modules mostly so (gnu ci) can discover them. + (scheme-node "guix-system-tests" + `((gnu tests) + ,@(scheme-modules* source "gnu/tests")) + (list *core-package-modules* *package-modules* + *extra-modules* *system-modules* *core-modules* + *cli-modules*) ;for (guix scripts pack), etc. + #:extensions dependencies + #:guile-for-build guile-for-build)) + (define *config* (scheme-node "guix-config" '() @@ -664,6 +670,7 @@ Info manual." ;; comes with *CORE-MODULES*. (list *config* *cli-modules* + *system-test-modules* *system-modules* *package-modules* *core-package-modules* diff --git a/guix/serialization.scm b/guix/serialization.scm index 7c0fea552d..e14b7d1b9f 100644 --- a/guix/serialization.scm +++ b/guix/serialization.scm @@ -59,7 +59,7 @@ ;; Similar to serialize.cc in Nix. -(define-condition-type &nar-error &error ; XXX: inherit from &nix-error ? +(define-condition-type &nar-error &error ; XXX: inherit from &store-error ? nar-error? (file nar-error-file) ; file we were restoring, or #f (port nar-error-port)) ; port from which we read diff --git a/guix/ssh.scm b/guix/ssh.scm index d90cb77be0..2b286a67b2 100644 --- a/guix/ssh.scm +++ b/guix/ssh.scm @@ -180,7 +180,7 @@ right away." (socket-name "/var/guix/daemon-socket/socket")) "Connect to the remote build daemon listening on SOCKET-NAME over SESSION, -an SSH session. Return a <nix-server> object." +an SSH session. Return a <store-connection> object." (open-connection #:port (remote-daemon-channel session socket-name))) @@ -288,7 +288,7 @@ REMOTE, a remote store. When RECURSIVE? is true, send the closure of FILES. Return the list of store items actually sent." ;; Compute the subset of FILES missing on SESSION and send them. (let* ((files (if recursive? (requisites local files) files)) - (session (channel-get-session (nix-server-socket remote))) + (session (channel-get-session (store-connection-socket remote))) (missing (inferior-remote-eval `(begin (use-modules (guix) @@ -328,24 +328,24 @@ Return the list of store items actually sent." missing) (('protocol-error message) (raise (condition - (&nix-protocol-error (message message) (status 42))))) + (&store-protocol-error (message message) (status 42))))) (('error key args ...) (raise (condition - (&nix-protocol-error + (&store-protocol-error (message (call-with-output-string (lambda (port) (print-exception port #f key args)))) (status 43))))) (_ (raise (condition - (&nix-protocol-error + (&store-protocol-error (message "unknown error while sending files over SSH") (status 44))))))))) (define (remote-store-session remote) "Return the SSH channel beneath REMOTE, a remote store as returned by 'connect-to-remote-daemon', or #f." - (channel-get-session (nix-server-socket remote))) + (channel-get-session (store-connection-socket remote))) (define (remote-store-host remote) "Return the name of the host REMOTE is connected to, where REMOTE is a diff --git a/guix/store.scm b/guix/store.scm index 1f88eb2b33..d079147529 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -20,6 +20,7 @@ (define-module (guix store) #:use-module (guix utils) #:use-module (guix config) + #:use-module (guix deprecation) #:use-module (guix memoization) #:use-module (guix serialization) #:use-module (guix monads) @@ -51,14 +52,31 @@ %gc-roots-directory %default-substitute-urls + store-connection? + store-connection-version + store-connection-major-version + store-connection-minor-version + store-connection-socket + + ;; Deprecated forms for 'store-connection'. nix-server? nix-server-version nix-server-major-version nix-server-minor-version nix-server-socket + current-store-protocol-version ;for internal use mcached + &store-error store-error? + &store-connection-error store-connection-error? + store-connection-error-file + store-connection-error-code + &store-protocol-error store-protocol-error? + store-protocol-error-message + store-protocol-error-status + + ;; Deprecated forms for '&store-error' et al. &nix-error nix-error? &nix-connection-error nix-connection-error? nix-connection-error-file @@ -335,59 +353,83 @@ ;; remote-store.cc -(define-record-type* <nix-server> nix-server %make-nix-server - nix-server? - (socket nix-server-socket) - (major nix-server-major-version) - (minor nix-server-minor-version) +(define-record-type* <store-connection> store-connection %make-store-connection + store-connection? + (socket store-connection-socket) + (major store-connection-major-version) + (minor store-connection-minor-version) - (buffer nix-server-output-port) ;output port - (flush nix-server-flush-output) ;thunk + (buffer store-connection-output-port) ;output port + (flush store-connection-flush-output) ;thunk ;; Caches. We keep them per-connection, because store paths build ;; during the session are temporary GC roots kept for the duration of ;; the session. - (ats-cache nix-server-add-to-store-cache) - (atts-cache nix-server-add-text-to-store-cache) - (object-cache nix-server-object-cache + (ats-cache store-connection-add-to-store-cache) + (atts-cache store-connection-add-text-to-store-cache) + (object-cache store-connection-object-cache (default vlist-null))) ;vhash -(set-record-type-printer! <nix-server> +(set-record-type-printer! <store-connection> (lambda (obj port) - (format port "#<build-daemon ~a.~a ~a>" - (nix-server-major-version obj) - (nix-server-minor-version obj) + (format port "#<store-connection ~a.~a ~a>" + (store-connection-major-version obj) + (store-connection-minor-version obj) (number->string (object-address obj) 16)))) -(define-condition-type &nix-error &error - nix-error?) +(define-deprecated/alias nix-server? store-connection?) +(define-deprecated/alias nix-server-major-version + store-connection-major-version) +(define-deprecated/alias nix-server-minor-version + store-connection-minor-version) +(define-deprecated/alias nix-server-socket store-connection-socket) + + +(define-condition-type &store-error &error + store-error?) + +(define-condition-type &store-connection-error &store-error + store-connection-error? + (file store-connection-error-file) + (errno store-connection-error-code)) + +(define-condition-type &store-protocol-error &store-error + store-protocol-error? + (message store-protocol-error-message) + (status store-protocol-error-status)) + +(define-deprecated/alias &nix-error &store-error) +(define-deprecated/alias nix-error? store-error?) +(define-deprecated/alias &nix-connection-error &store-connection-error) +(define-deprecated/alias nix-connection-error? store-connection-error?) +(define-deprecated/alias nix-connection-error-file + store-connection-error-file) +(define-deprecated/alias nix-connection-error-code + store-connection-error-code) +(define-deprecated/alias &nix-protocol-error &store-protocol-error) +(define-deprecated/alias nix-protocol-error? store-protocol-error?) +(define-deprecated/alias nix-protocol-error-message + store-protocol-error-message) +(define-deprecated/alias nix-protocol-error-status + store-protocol-error-status) -(define-condition-type &nix-connection-error &nix-error - nix-connection-error? - (file nix-connection-error-file) - (errno nix-connection-error-code)) - -(define-condition-type &nix-protocol-error &nix-error - nix-protocol-error? - (message nix-protocol-error-message) - (status nix-protocol-error-status)) (define-syntax-rule (system-error-to-connection-error file exp ...) "Catch 'system-error' exceptions and translate them to -'&nix-connection-error'." +'&store-connection-error'." (catch 'system-error (lambda () exp ...) (lambda args (let ((errno (system-error-errno args))) - (raise (condition (&nix-connection-error + (raise (condition (&store-connection-error (file file) (errno errno)))))))) (define (open-unix-domain-socket file) "Connect to the Unix-domain socket at FILE and return it. Raise a -'&nix-connection-error' upon error." +'&store-connection-error' upon error." (let ((s (with-fluids ((%default-port-encoding #f)) ;; This trick allows use of the `scm_c_read' optimization. (socket PF_UNIX SOCK_STREAM 0))) @@ -403,7 +445,7 @@ (define (open-inet-socket host port) "Connect to the Unix-domain socket at HOST:PORT and return it. Raise a -'&nix-connection-error' upon error." +'&store-connection-error' upon error." (let ((sock (with-fluids ((%default-port-encoding #f)) ;; This trick allows use of the `scm_c_read' optimization. (socket PF_UNIX SOCK_STREAM 0)))) @@ -435,7 +477,7 @@ ;; Connection failed, so try one of the other addresses. (close s) (if (null? rest) - (raise (condition (&nix-connection-error + (raise (condition (&store-connection-error (file host) (errno (system-error-errno args))))) (loop rest)))))))))) @@ -444,7 +486,7 @@ "Connect to the daemon at URI, a string that may be an actual URI or a file name." (define (not-supported) - (raise (condition (&nix-connection-error + (raise (condition (&store-connection-error (file uri) (errno ENOTSUP))))) @@ -493,8 +535,8 @@ for this connection will be pinned. Return a server object." ;; One of the 'write-' or 'read-' calls below failed, but this is ;; really a connection error. (raise (condition - (&nix-connection-error (file (or port uri)) - (errno EPROTO)) + (&store-connection-error (file (or port uri)) + (errno EPROTO)) (&message (message "build daemon handshake failed")))))) (let*-values (((port) (or port (connect-to-daemon uri))) @@ -515,13 +557,13 @@ for this connection will be pinned. Return a server object." (write-int cpu-affinity port))) (when (>= (protocol-minor v) 11) (write-int (if reserve-space? 1 0) port)) - (let ((conn (%make-nix-server port - (protocol-major v) - (protocol-minor v) - output flush - (make-hash-table 100) - (make-hash-table 100) - vlist-null))) + (let ((conn (%make-store-connection port + (protocol-major v) + (protocol-minor v) + output flush + (make-hash-table 100) + (make-hash-table 100) + vlist-null))) (let loop ((done? (process-stderr conn))) (or done? (process-stderr conn))) conn))))))))) @@ -536,27 +578,29 @@ already taken place on PORT and that we're just continuing on this established connection. Use with care." (let-values (((output flush) (buffering-output-port port (make-bytevector 8192)))) - (%make-nix-server port - (protocol-major version) - (protocol-minor version) - output flush - (make-hash-table 100) - (make-hash-table 100) - vlist-null))) - -(define (nix-server-version store) + (%make-store-connection port + (protocol-major version) + (protocol-minor version) + output flush + (make-hash-table 100) + (make-hash-table 100) + vlist-null))) + +(define (store-connection-version store) "Return the protocol version of STORE as an integer." - (protocol-version (nix-server-major-version store) - (nix-server-minor-version store))) + (protocol-version (store-connection-major-version store) + (store-connection-minor-version store))) + +(define-deprecated/alias nix-server-version store-connection-version) (define (write-buffered-output server) "Flush SERVER's output port." - (force-output (nix-server-output-port server)) - ((nix-server-flush-output server))) + (force-output (store-connection-output-port server)) + ((store-connection-flush-output server))) (define (close-connection server) "Close the connection to SERVER." - (close (nix-server-socket server))) + (close (store-connection-socket server))) (define-syntax-rule (with-store store exp ...) "Bind STORE to an open connection to the store and evaluate EXPs; @@ -566,7 +610,7 @@ automatically close the store when the dynamic extent of EXP is left." (const #f) (lambda () (parameterize ((current-store-protocol-version - (nix-server-version store))) + (store-connection-version store))) exp) ...) (lambda () (false-if-exception (close-connection store)))))) @@ -622,7 +666,7 @@ Since the build process's output cannot be assumed to be UTF-8, we conservatively consider it to be Latin-1, thereby avoiding possible encoding conversion errors." (define p - (nix-server-socket server)) + (store-connection-socket server)) ;; magic cookies from worker-protocol.hh (define %stderr-next #x6f6c6d67) ; "olmg", build log @@ -666,18 +710,18 @@ encoding conversion errors." (let ((error (read-maybe-utf8-string p)) ;; Currently the daemon fails to send a status code for early ;; errors like DB schema version mismatches, so check for EOF. - (status (if (and (>= (nix-server-minor-version server) 8) + (status (if (and (>= (store-connection-minor-version server) 8) (not (eof-object? (lookahead-u8 p)))) (read-int p) 1))) - (raise (condition (&nix-protocol-error + (raise (condition (&store-protocol-error (message error) (status status)))))) ((= k %stderr-last) ;; The daemon is done (see `stopWork' in `nix-worker.cc'.) #t) (else - (raise (condition (&nix-protocol-error + (raise (condition (&store-protocol-error (message "invalid error code") (status k)))))))) @@ -734,7 +778,7 @@ encoding conversion errors." ;; Must be called after `open-connection'. (define socket - (nix-server-socket server)) + (store-connection-socket server)) (let-syntax ((send (syntax-rules () ((_ (type option) ...) @@ -744,22 +788,22 @@ encoding conversion errors." (write-int (operation-id set-options) socket) (send (boolean keep-failed?) (boolean keep-going?) (boolean fallback?) (integer verbosity)) - (when (< (nix-server-minor-version server) #x61) + (when (< (store-connection-minor-version server) #x61) (let ((max-build-jobs (or max-build-jobs 1)) (max-silent-time (or max-silent-time 3600))) (send (integer max-build-jobs) (integer max-silent-time)))) - (when (>= (nix-server-minor-version server) 2) + (when (>= (store-connection-minor-version server) 2) (send (boolean use-build-hook?))) - (when (>= (nix-server-minor-version server) 4) + (when (>= (store-connection-minor-version server) 4) (send (integer build-verbosity) (integer log-type) (boolean print-build-trace))) - (when (and (>= (nix-server-minor-version server) 6) - (< (nix-server-minor-version server) #x61)) + (when (and (>= (store-connection-minor-version server) 6) + (< (store-connection-minor-version server) #x61)) (let ((build-cores (or build-cores (current-processor-count)))) (send (integer build-cores)))) - (when (>= (nix-server-minor-version server) 10) + (when (>= (store-connection-minor-version server) 10) (send (boolean use-substitutes?))) - (when (>= (nix-server-minor-version server) 12) + (when (>= (store-connection-minor-version server) 12) (let ((pairs `(;; This option is honored by 'guix substitute' et al. ,@(if print-build-trace `(("print-extended-build-trace" @@ -884,8 +928,8 @@ bytevector) as its internal buffer, and a thunk to flush this output port." ((_ (name (type arg) ...) docstring return ...) (lambda (server arg ...) docstring - (let* ((s (nix-server-socket server)) - (buffered (nix-server-output-port server))) + (let* ((s (store-connection-socket server)) + (buffered (store-connection-output-port server))) (record-operation 'name) (write-int (operation-id name) buffered) (write-arg type arg buffered) @@ -907,7 +951,7 @@ bytevector) as its internal buffer, and a thunk to flush this output port." invalid item may exist on disk but still be invalid, for instance because it is the result of an aborted or failed build.) -A '&nix-protocol-error' condition is raised if PATH is not prefixed by the +A '&store-protocol-error' condition is raised if PATH is not prefixed by the store directory (/gnu/store)." boolean) @@ -944,7 +988,7 @@ string). Raise an error if no such path exists." REFERENCES is the list of store paths referred to by the resulting store path." (let* ((args `(,bytes ,name ,references)) - (cache (nix-server-add-text-to-store-cache server))) + (cache (store-connection-add-text-to-store-cache server))) (or (hash-ref cache args) (let ((path (add-text-to-store server name bytes references))) (hash-set! cache args path) @@ -973,7 +1017,7 @@ path." ;; We don't use the 'operation' macro so we can pass SELECT? to ;; 'write-file'. (record-operation 'add-to-store) - (let ((port (nix-server-socket server))) + (let ((port (store-connection-socket server))) (write-int (operation-id add-to-store) port) (write-string basename port) (write-int 1 port) ;obsolete, must be #t @@ -999,7 +1043,7 @@ where FILE is the entry's absolute file name and STAT is the result of ;; Note: We don't stat FILE-NAME at each call, and thus we assume that ;; the file remains unchanged for the lifetime of SERVER. (let* ((args `(,file-name ,basename ,recursive? ,hash-algo ,select?)) - (cache (nix-server-add-to-store-cache server))) + (cache (store-connection-add-to-store-cache server))) (or (hash-ref cache args) (let ((path (add-to-store server basename recursive? hash-algo file-name @@ -1078,14 +1122,14 @@ an arbitrary directory layout in the store without creating a derivation." ((_ 'directory (names . _) ...) names))) (define cache - (nix-server-add-to-store-cache server)) + (store-connection-add-to-store-cache server)) (or (hash-ref cache tree) (begin ;; We don't use the 'operation' macro so we can use 'write-file-tree' ;; instead of 'write-file'. (record-operation 'add-to-store/tree) - (let ((port (nix-server-socket server))) + (let ((port (store-connection-socket server))) (write-int (operation-id add-to-store) port) (write-string basename port) (write-int 1 port) ;obsolete, must be #t @@ -1117,12 +1161,12 @@ outputs, and return when the worker is done building them. Elements of THINGS that are not derivations can only be substituted and not built locally. Return #t on success." (parameterize ((current-store-protocol-version - (nix-server-version store))) - (if (>= (nix-server-minor-version store) 15) + (store-connection-version store))) + (if (>= (store-connection-minor-version store) 15) (build store things mode) (if (= mode (build-mode normal)) (build/old store things) - (raise (condition (&nix-protocol-error + (raise (condition (&store-protocol-error (message "unsupported build mode") (status 1)))))))))) @@ -1182,12 +1226,12 @@ error if there is no such root." (define (references/substitutes store items) "Return the list of list of references of ITEMS; the result has the same length as ITEMS. Query substitute information for any item missing from the -store at once. Raise a '&nix-protocol-error' exception if reference +store at once. Raise a '&store-protocol-error' exception if reference information for one of ITEMS is missing." (let* ((requested items) (local-refs (map (lambda (item) (or (hash-ref %reference-cache item) - (guard (c ((nix-protocol-error? c) #f)) + (guard (c ((store-protocol-error? c) #f)) (references store item)))) items)) (missing (fold-right (lambda (item local-ref result) @@ -1203,7 +1247,7 @@ information for one of ITEMS is missing." '() (substitutable-path-info store missing)))) (when (< (length substs) (length missing)) - (raise (condition (&nix-protocol-error + (raise (condition (&store-protocol-error (message "cannot determine \ the list of references") (status 1))))) @@ -1334,9 +1378,9 @@ supported by STORE." ;; derivation builders in general, which appeared in Guix > 0.11.0. ;; Return the empty list if it doesn't. Note that this RPC does not ;; exist in 'nix-daemon'. - (if (or (> (nix-server-major-version store) #x100) - (and (= (nix-server-major-version store) #x100) - (>= (nix-server-minor-version store) #x60))) + (if (or (> (store-connection-major-version store) #x100) + (and (= (store-connection-major-version store) #x100) + (>= (store-connection-minor-version store) #x60))) (builders store) '())))) @@ -1366,14 +1410,14 @@ the list of store paths to delete. IGNORE-LIVENESS? should always be #f. MIN-FREED is the minimum amount of disk space to be freed, in bytes, before the GC can stop. Return the list of store paths delete, and the number of bytes freed." - (let ((s (nix-server-socket server))) + (let ((s (store-connection-socket server))) (write-int (operation-id collect-garbage) s) (write-int action s) (write-store-path-list to-delete s) (write-arg boolean #f s) ; ignore-liveness? (write-long-long min-freed s) (write-int 0 s) ; obsolete - (when (>= (nix-server-minor-version server) 5) + (when (>= (store-connection-minor-version server) 5) ;; Obsolete `use-atime' and `max-atime' parameters. (write-int 0 s) (write-int 0 s)) @@ -1389,8 +1433,8 @@ and the number of bytes freed." ;; To be on the safe side, completely invalidate both caches. ;; Otherwise we could end up returning store paths that are no longer ;; valid. - (hash-clear! (nix-server-add-to-store-cache server)) - (hash-clear! (nix-server-add-text-to-store-cache server))) + (hash-clear! (store-connection-add-to-store-cache server)) + (hash-clear! (store-connection-add-text-to-store-cache server))) (values paths freed)))) @@ -1425,7 +1469,7 @@ collected, and the number of bytes freed." "Import the set of store paths read from PORT into SERVER's store. An error is raised if the set of paths read from PORT is not signed (as per 'export-path #:sign? #t'.) Return the list of store paths imported." - (let ((s (nix-server-socket server))) + (let ((s (store-connection-socket server))) (write-int (operation-id import-paths) s) (let loop ((done? (process-stderr server port))) (or done? (loop (process-stderr server port)))) @@ -1433,7 +1477,7 @@ is raised if the set of paths read from PORT is not signed (as per (define* (export-path server path port #:key (sign? #t)) "Export PATH to PORT. When SIGN? is true, sign it." - (let ((s (nix-server-socket server))) + (let ((s (store-connection-socket server))) (write-int (operation-id export-path) s) (write-store-path path s) (write-arg boolean sign? s) @@ -1502,10 +1546,10 @@ OBJECT is typically a high-level object such as a <package> or an <origin>, and RESULT is typically its derivation." (lambda (store) (values result - (nix-server + (store-connection (inherit store) (object-cache (vhash-consq object (cons result keys) - (nix-server-object-cache store))))))) + (store-connection-object-cache store))))))) (define record-cache-lookup! (if (profiled? "object-cache") @@ -1540,7 +1584,7 @@ and KEYS. KEYS is a list of additional keys to match against, and which are compared with 'equal?'. Return #f on failure and the cached result otherwise." (lambda (store) - (let* ((cache (nix-server-object-cache store)) + (let* ((cache (store-connection-object-cache store)) ;; Escape as soon as we find the result. This avoids traversing ;; the whole vlist chain and significantly reduces the number of @@ -1654,7 +1698,7 @@ where FILE is the entry's absolute file name and STAT is the result of "Monadic version of 'query-path-info' that returns #f when ITEM is not in the store." (lambda (store) - (guard (c ((nix-protocol-error? c) + (guard (c ((store-protocol-error? c) ;; ITEM is not in the store; return #f. (values #f store))) (values (query-path-info store item) store)))) diff --git a/guix/tests.scm b/guix/tests.scm index f4948148c4..16a426c4f9 100644 --- a/guix/tests.scm +++ b/guix/tests.scm @@ -64,7 +64,7 @@ (define* (open-connection-for-tests #:optional (uri (%daemon-socket-uri))) "Open a connection to the build daemon for tests purposes and return it." - (guard (c ((nix-error? c) + (guard (c ((store-error? c) (format (current-error-port) "warning: build daemon error: ~s~%" c) #f)) diff --git a/guix/ui.scm b/guix/ui.scm index 1e089753e1..9ff56ea85c 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -684,14 +684,14 @@ or remove one of them from the profile.") file (or (port-filename* port) port)) (leave (G_ "corrupt input while restoring archive from ~s~%") (or (port-filename* port) port))))) - ((nix-connection-error? c) + ((store-connection-error? c) (leave (G_ "failed to connect to `~a': ~a~%") - (nix-connection-error-file c) - (strerror (nix-connection-error-code c)))) - ((nix-protocol-error? c) + (store-connection-error-file c) + (strerror (store-connection-error-code c)))) + ((store-protocol-error? c) ;; FIXME: Server-provided error messages aren't i18n'd. (leave (G_ "build failed: ~a~%") - (nix-protocol-error-message c))) + (store-protocol-error-message c))) ((derivation-missing-output-error? c) (leave (G_ "reference to invalid output '~a' of derivation '~a'~%") (derivation-missing-output c) |