diff options
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/offload.scm | 72 | ||||
-rw-r--r-- | guix/scripts/pack.scm | 21 | ||||
-rw-r--r-- | guix/scripts/publish.scm | 16 | ||||
-rw-r--r-- | guix/scripts/system.scm | 10 |
4 files changed, 74 insertions, 45 deletions
diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm index 7e114fa2c9..56d6de6308 100644 --- a/guix/scripts/offload.scm +++ b/guix/scripts/offload.scm @@ -358,25 +358,18 @@ MACHINE." (parameterize ((current-build-output-port (build-log-port))) (build-derivations store (list drv)))) - (retrieve-files* outputs store) - (format (current-error-port) "done with offloaded '~a'~%" - (derivation-file-name drv))) + (retrieve-files* outputs store -(define (retrieve-files* files remote) - "Retrieve FILES from REMOTE and import them using 'restore-file-set'." - (let-values (((port count) - (file-retrieval-port files remote))) - (format #t (N_ "retrieving ~a store item from '~a'...~%" - "retrieving ~a store items from '~a'...~%" count) - count (remote-store-host remote)) + ;; We cannot use the 'import-paths' RPC here because we + ;; already hold the locks for FILES. + #:import + (lambda (port) + (restore-file-set port + #:log-port (current-error-port) + #:lock? #f))) - ;; We cannot use the 'import-paths' RPC here because we already - ;; hold the locks for FILES. - (let ((result (restore-file-set port - #:log-port (current-error-port) - #:lock? #f))) - (close-port port) - result))) + (format (current-error-port) "done with offloaded '~a'~%" + (derivation-file-name drv))) ;;; @@ -407,7 +400,7 @@ allowed on MACHINE. Return +∞ if MACHINE is unreachable." +inf.0 ;MACHINE does not respond, so assume it is infinitely loaded (match (string-tokenize line) ((one five fifteen . x) - (let* ((raw (string->number five)) + (let* ((raw (string->number one)) (jobs (build-machine-parallel-builds machine)) (normalized (/ raw jobs))) (format (current-error-port) "load on machine '~a' is ~s\ @@ -549,8 +542,7 @@ slot (which must later be released with 'release-build-slot'), or #f and #f." "Bail out if NODE is not running Guile." (match (node-guile-version node) (#f - (leave (G_ "Guile could not be started on '~a'~%") - name)) + (report-guile-error name)) ((? string? version) ;; Note: The version string already contains the word "Guile". (info (G_ "'~a' is running ~a~%") @@ -558,18 +550,34 @@ slot (which must later be released with 'release-build-slot'), or #f and #f." (define (assert-node-has-guix node name) "Bail out if NODE lacks the (guix) module, or if its daemon is not running." - (match (node-eval node - '(begin - (use-modules (guix)) - (with-store store - (add-text-to-store store "test" - "Hello, build machine!")))) - ((? string? str) - (info (G_ "Guix is usable on '~a' (test returned ~s)~%") - name str)) - (x - (leave (G_ "failed to use Guix module on '~a' (test returned ~s)~%") - name x)))) + (catch 'node-repl-error + (lambda () + (match (node-eval node + '(begin + (use-modules (guix)) + (and add-text-to-store 'alright))) + ('alright #t) + (_ (report-module-error name)))) + (lambda (key . args) + (report-module-error name))) + + (catch 'node-repl-error + (lambda () + (match (node-eval node + '(begin + (use-modules (guix)) + (with-store store + (add-text-to-store store "test" + "Hello, build machine!")))) + ((? string? str) + (info (G_ "Guix is usable on '~a' (test returned ~s)~%") + name str)) + (x + (leave (G_ "failed to talk to guix-daemon on '~a' (test returned ~s)~%") + name x)))) + (lambda (key . args) + (leave (G_ "remove evaluation on '~a' failed:~{ ~s~}~%") + args)))) (define %random-state (delay diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index a22258d5a6..59dd117edb 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015, 2017 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> +;;; Copyright © 2018 Konrad Hinsen <konrad.hinsen@fastmail.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -292,6 +293,9 @@ the image." (option '(#\e "expression") #t #f (lambda (opt name arg result) (alist-cons 'expression arg result))) + (option '(#\m "manifest") #t #f + (lambda (opt name arg result) + (alist-cons 'manifest arg result))) (option '(#\s "system") #t #f (lambda (opt name arg result) (alist-cons 'system arg @@ -345,6 +349,8 @@ Create a bundle of PACKAGE.\n")) (display (G_ " -S, --symlink=SPEC create symlinks to the profile according to SPEC")) (display (G_ " + -m, --manifest=FILE create a pack with the manifest from FILE")) + (display (G_ " --localstatedir include /var/guix in the resulting pack")) (newline) (display (G_ " @@ -375,10 +381,21 @@ Create a bundle of PACKAGE.\n")) (read/eval-package-expression exp)) (x #f))) + (define (manifest-from-args opts) + (let ((packages (filter-map maybe-package-argument opts)) + (manifest-file (assoc-ref opts 'manifest))) + (cond + ((and manifest-file (not (null? packages))) + (leave (G_ "both a manifest and a package list were given~%"))) + (manifest-file + (let ((user-module (make-user-module '((guix profiles) (gnu))))) + (load* manifest-file user-module))) + (else (packages->manifest packages))))) + (with-error-handling (parameterize ((%graft? (assoc-ref opts 'graft?))) (let* ((dry-run? (assoc-ref opts 'dry-run?)) - (packages (filter-map maybe-package-argument opts)) + (manifest (manifest-from-args opts)) (pack-format (assoc-ref opts 'format)) (name (string-append (symbol->string pack-format) "-pack")) @@ -397,7 +414,7 @@ Create a bundle of PACKAGE.\n")) (run-with-store store (mlet* %store-monad ((profile (profile-derivation - (packages->manifest packages) + manifest #:target target)) (drv (build-image name profile #:target diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm index 1673fb9f33..b5dfdab32f 100644 --- a/guix/scripts/publish.scm +++ b/guix/scripts/publish.scm @@ -672,10 +672,10 @@ example: \"/foo/bar\" yields '(\"foo\" \"bar\")." exp ...) (const #f))) -(define (nar-response-port response) +(define (nar-response-port response compression) "Return a port on which to write the body of RESPONSE, the response of a /nar request, according to COMPRESSION." - (match (assoc-ref (response-headers response) 'x-nar-compression) + (match compression (($ <compression> 'gzip level) ;; Note: We cannot used chunked encoding here because ;; 'make-gzip-output-port' wants a file port. @@ -697,11 +697,13 @@ blocking." (call-with-new-thread (lambda () (set-thread-name "publish nar") - (let* ((response (write-response (sans-content-length response) - client)) - (port (begin - (force-output client) - (nar-response-port response)))) + (let* ((compression (assoc-ref (response-headers response) + 'x-nar-compression)) + (response (write-response (sans-content-length response) + client)) + (port (begin + (force-output client) + (nar-response-port response compression)))) ;; XXX: Given our ugly workaround for <http://bugs.gnu.org/21093> in ;; 'render-nar', BODY here is just the file name of the store item. ;; We call 'write-file' from here because we know that's the only diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index ebcf3e4f3b..999ffb010b 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016 Alex Kost <alezost@gmail.com> ;;; Copyright © 2016, 2017 Chris Marusich <cmmarusich@gmail.com> ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com> @@ -331,7 +331,9 @@ bring the system down." (let ((to-load-names (map shepherd-service-canonical-name to-load)) (to-start (filter shepherd-service-auto-start? to-load))) (info (G_ "loading new services:~{ ~a~}...~%") to-load-names) - (mlet %store-monad ((files (mapm %store-monad shepherd-service-file + (mlet %store-monad ((files (mapm %store-monad + (compose lower-object + shepherd-service-file) to-load))) ;; Here we assume that FILES are exactly those that were computed ;; as part of the derivation that built OS, which is normally the @@ -709,8 +711,8 @@ and TARGET arguments." "Perform ACTION for OS. INSTALL-BOOTLOADER? specifies whether to install bootloader; BOOTLOADER-TAGET is the target for the bootloader; TARGET is the target root directory; IMAGE-SIZE is the size of the image to be built, for -the 'vm-image' and 'disk-image' actions. The root filesystem is created as a -FILE-SYSTEM-TYPE filesystem. FULL-BOOT? is used for the 'vm' action; it +the 'vm-image' and 'disk-image' actions. The root file system is created as a +FILE-SYSTEM-TYPE file system. FULL-BOOT? is used for the 'vm' action; it determines whether to boot directly to the kernel or to the bootloader. When DERIVATIONS-ONLY? is true, print the derivation file name(s) without |