summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2019-01-31 23:32:56 +0100
committerMarius Bakke <mbakke@fastmail.com>2019-01-31 23:32:56 +0100
commit0747328e317de4bf936fab50e795d1e1523adfc1 (patch)
tree291d4f07a801b147d64faec31e4394c5cd46ce35 /guix
parentdf09e1d6e71f68a8fb44bcc9f13e625f9f9701a5 (diff)
parentff75441fcf0ba1212b0342f933a8999bafe60f03 (diff)
downloadgnu-guix-0747328e317de4bf936fab50e795d1e1523adfc1.tar
gnu-guix-0747328e317de4bf936fab50e795d1e1523adfc1.tar.gz
Merge branch 'master' into staging
Diffstat (limited to 'guix')
-rw-r--r--guix/channels.scm11
-rw-r--r--guix/packages.scm16
-rw-r--r--guix/scripts/pull.scm10
-rw-r--r--guix/self.scm18
-rw-r--r--guix/status.scm157
5 files changed, 175 insertions, 37 deletions
diff --git a/guix/channels.scm b/guix/channels.scm
index 10345c1ce5..96d62ce062 100644
--- a/guix/channels.scm
+++ b/guix/channels.scm
@@ -27,6 +27,7 @@
#:use-module (guix profiles)
#:use-module (guix derivations)
#:use-module (guix combinators)
+ #:use-module (guix deprecation)
#:use-module (guix store)
#:use-module (guix i18n)
#:use-module ((guix utils)
@@ -275,7 +276,12 @@ package modules under SOURCE using CORE, an instance of Guix."
(if (file-exists? script)
(let ((build (save-module-excursion
(lambda ()
- (primitive-load script)))))
+ ;; Disable deprecation warnings; it's OK for SCRIPT to
+ ;; use deprecated APIs and the user doesn't have to know
+ ;; about it.
+ (parameterize ((deprecation-warning-port
+ (%make-void-port "w")))
+ (primitive-load script))))))
;; BUILD must be a monadic procedure of at least one argument: the
;; source tree.
;;
@@ -472,7 +478,8 @@ be used as a profile hook."
(gexp->derivation-in-inferior "guix-package-cache" build
profile
#:properties '((type . profile-hook)
- (hook . package-cache)))))
+ (hook . package-cache))
+ #:local-build? #t)))
(define %channel-profile-hooks
;; The default channel profile hooks.
diff --git a/guix/packages.scm b/guix/packages.scm
index f191327718..8515bb7c6f 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -855,19 +855,27 @@ when CUT? returns true for a given package."
#:optional (rewrite-name identity))
"Return a procedure that, when passed a package, replaces its direct and
indirect dependencies (but not its implicit inputs) according to REPLACEMENTS.
-REPLACEMENTS is a list of package pairs; the first element of each pair is the
-package to replace, and the second one is the replacement.
+REPLACEMENTS is a list of package pairs or a promise thereof; the first
+element of each pair is the package to replace, and the second one is the
+replacement.
Optionally, REWRITE-NAME is a one-argument procedure that takes the name of a
package and returns its new name after rewrite."
(define (rewrite p)
- (match (assq-ref replacements p)
+ (match (assq-ref (if (promise? replacements)
+ (force replacements)
+ replacements)
+ p)
(#f (package
(inherit p)
(name (rewrite-name (package-name p)))))
(new new)))
- (package-mapping rewrite (cut assq <> replacements)))
+ (package-mapping rewrite
+ (lambda (package)
+ (assq package (if (promise? replacements)
+ (force replacements)
+ replacements)))))
(define-syntax-rule (package/inherit p overrides ...)
"Like (package (inherit P) OVERRIDES ...), except that the same
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 41c7fb289a..683ab3f059 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -69,7 +69,7 @@
(multiplexed-build-output? . #t)
(graft? . #t)
(debug . 0)
- (verbosity . 2)))
+ (verbosity . 1)))
(define (show-help)
(display (G_ "Usage: guix pull [OPTION]...
@@ -197,11 +197,13 @@ true, display what would be built without actually building it."
(match (which "guix")
(#f (return #f))
(str
- (let ((command (string-append profile "/bin/guix")))
- (unless (string=? command str)
+ (let ((new (map (cut string-append <> "/bin/guix")
+ (list (user-friendly-profile profile)
+ profile))))
+ (unless (member str new)
(display-hint (format #f (G_ "After setting @code{PATH}, run
@command{hash guix} to make sure your shell refers to @file{~a}.")
- command)))
+ (first new))))
(return #f))))))))
(define (honor-lets-encrypt-certificates! store)
diff --git a/guix/self.scm b/guix/self.scm
index d1b8256802..f028bdbfdd 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -856,13 +856,23 @@ containing MODULE-FILES and possibly other files as well."
(define (report-load file total completed)
(display #\cr)
(format #t
- "loading...\t~5,1f% of ~d files" ;FIXME: i18n
+ "[~3@a/~3@a] loading...\t~5,1f% of ~d files"
+
+ ;; Note: Multiply TOTAL by two to account for the
+ ;; compilation phase that follows.
+ completed (* total 2)
+
(* 100. (/ completed total)) total)
(force-output))
(define (report-compilation file total completed)
(display #\cr)
- (format #t "compiling...\t~5,1f% of ~d files" ;FIXME: i18n
+ (format #t "[~3@a/~3@a] compiling...\t~5,1f% of ~d files"
+
+ ;; Add TOTAL to account for the load phase that came
+ ;; before.
+ (+ total completed) (* total 2)
+
(* 100. (/ completed total)) total)
(force-output))
@@ -874,8 +884,8 @@ containing MODULE-FILES and possibly other files as well."
#:report-load report-load
#:report-compilation report-compilation)))
- (setvbuf (current-output-port) 'none)
- (setvbuf (current-error-port) 'none)
+ (setvbuf (current-output-port) 'line)
+ (setvbuf (current-error-port) 'line)
(set! %load-path (cons #+module-tree %load-path))
(set! %load-path
diff --git a/guix/status.scm b/guix/status.scm
index 93e119bed1..e3375816c5 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -50,6 +50,11 @@
build-status-builds-completed
build-status-downloads-completed
+ build?
+ build
+ build-derivation
+ build-system
+
download?
download
download-item
@@ -85,15 +90,29 @@
;; Builds and substitutions performed by the daemon.
(define-record-type* <build-status> build-status make-build-status
build-status?
- (building build-status-building ;list of drv
+ (building build-status-building ;list of <build>
(default '()))
(downloading build-status-downloading ;list of <download>
(default '()))
- (builds-completed build-status-builds-completed ;list of drv
+ (builds-completed build-status-builds-completed ;list of <build>
(default '()))
- (downloads-completed build-status-downloads-completed ;list of store items
+ (downloads-completed build-status-downloads-completed ;list of <download>
(default '())))
+;; On-going or completed build.
+(define-record-type <build>
+ (%build derivation id system log-file completion)
+ build?
+ (derivation build-derivation) ;string (.drv file name)
+ (id build-id) ;#f | integer
+ (system build-system) ;string
+ (log-file build-log-file) ;#f | string
+ (completion build-completion)) ;#f | integer (percentage)
+
+(define* (build derivation system #:key id log-file completion)
+ "Return a new build."
+ (%build derivation id system log-file completion))
+
;; On-going or completed downloads. Downloads can be stem from substitutes
;; and from "builtin:download" fixed-output derivations.
(define-record-type <download>
@@ -113,11 +132,67 @@
"Return a new download."
(%download item uri size start end transferred))
+(define (matching-build drv)
+ "Return a predicate that matches builds of DRV."
+ (lambda (build)
+ (string=? drv (build-derivation build))))
+
(define (matching-download item)
"Return a predicate that matches downloads of ITEM."
(lambda (download)
(string=? item (download-item download))))
+(define %percentage-line-rx
+ ;; Things like CMake write lines like "[ 10%] gcc -c …". This regexp
+ ;; matches them.
+ (make-regexp "^[[:space:]]*\\[ *([0-9]+)%\\]"))
+
+(define %fraction-line-rx
+ ;; The 'compiled-modules' derivations and Ninja produce reports like
+ ;; "[ 1/32]" at the beginning of each line, while GHC prints "[ 6 of 45]".
+ ;; This regexp matches these.
+ (make-regexp "^[[:space:]]*\\[ *([0-9]+) *(/|of) *([0-9]+)\\]"))
+
+(define (update-build status id line)
+ "Update STATUS based on LINE, a build output line for ID that might contain
+a completion indication."
+ (define (set-completion b %)
+ (build (build-derivation b)
+ (build-system b)
+ #:id (build-id b)
+ #:log-file (build-log-file b)
+ #:completion %))
+
+ (define (find-build)
+ (find (lambda (build)
+ (and (build-id build)
+ (= (build-id build) id)))
+ (build-status-building status)))
+
+ (define (update %)
+ (let ((build (find-build)))
+ (build-status
+ (inherit status)
+ (building (cons (set-completion build %)
+ (delq build (build-status-building status)))))))
+
+ (cond ((string-any #\nul line)
+ ;; Don't try to match a regexp here.
+ status)
+ ((regexp-exec %percentage-line-rx line)
+ =>
+ (lambda (match)
+ (let ((% (string->number (match:substring match 1))))
+ (update %))))
+ ((regexp-exec %fraction-line-rx line)
+ =>
+ (lambda (match)
+ (let ((done (string->number (match:substring match 1)))
+ (total (string->number (match:substring match 3))))
+ (update (* 100. (/ done total))))))
+ (else
+ status)))
+
(define* (compute-status event status
#:key
(current-time current-time)
@@ -126,15 +201,29 @@
"Given EVENT, a tuple like (build-started \"/gnu/store/...-foo.drv\" ...),
compute a new status based on STATUS."
(match event
- (('build-started drv _ ...)
- (build-status
- (inherit status)
- (building (cons drv (build-status-building status)))))
+ (('build-started drv "-" system log-file . rest)
+ (let ((build (build drv system
+ #:id (match rest
+ ((pid . _) (string->number pid))
+ (_ #f))
+ #:log-file (if (string-null? log-file)
+ #f
+ log-file))))
+ (build-status
+ (inherit status)
+ (building (cons build (build-status-building status))))))
(((or 'build-succeeded 'build-failed) drv _ ...)
- (build-status
- (inherit status)
- (building (delete drv (build-status-building status)))
- (builds-completed (cons drv (build-status-builds-completed status)))))
+ (let ((build (find (matching-build drv)
+ (build-status-building status))))
+ ;; If BUILD is #f, this may be because DRV corresponds to a
+ ;; fixed-output derivation that is listed as a download.
+ (if build
+ (build-status
+ (inherit status)
+ (building (delq build (build-status-building status)))
+ (builds-completed
+ (cons build (build-status-builds-completed status))))
+ status)))
;; Note: Ignore 'substituter-started' and 'substituter-succeeded' because
;; they're not as informative as 'download-started' and
@@ -146,10 +235,11 @@ compute a new status based on STATUS."
;; because ITEM is different from DRV's output.
(build-status
(inherit status)
- (building (remove (lambda (drv)
- (equal? (false-if-exception
- (derivation-path->output-path drv))
- item))
+ (building (remove (lambda (build)
+ (let ((drv (build-derivation build)))
+ (equal? (false-if-exception
+ (derivation-path->output-path drv))
+ item)))
(build-status-building status)))
(downloading (cons (download item uri #:size size
#:start (current-time time-monotonic))
@@ -204,6 +294,8 @@ compute a new status based on STATUS."
(current-time time-monotonic))
#:transferred transferred)
downloads)))))
+ (('build-log (? integer? pid) line)
+ (update-build status pid line))
(_
status)))
@@ -349,14 +441,29 @@ addition to build events."
(cut colorize-string <> 'RED 'BOLD)
identity))
+ (define (report-build-progress %)
+ (let ((% (min (max % 0) 100))) ;sanitize
+ (erase-current-line port)
+ (format port "~3d% " (inexact->exact (round %)))
+ (display (progress-bar % (- (current-terminal-columns) 5))
+ port)
+ (force-output port)))
+
(define print-log-line
(if print-log?
(if colorize?
- (lambda (line)
+ (lambda (id line)
(display (colorize-log-line line) port))
- (cut display <> port))
- (lambda (line)
- (spin! port))))
+ (lambda (id line)
+ (display line port)))
+ (lambda (id line)
+ (match (build-status-building status)
+ ((build) ;single job
+ (match (build-completion build)
+ ((? number? %) (report-build-progress %))
+ (_ (spin! port))))
+ (_
+ (spin! port))))))
(unless print-log?
(display "\r" port)) ;erase the spinner
@@ -394,7 +501,7 @@ addition to build events."
(N_ "The following build is still in progress:~%~{ ~a~%~}~%"
"The following builds are still in progress:~%~{ ~a~%~}~%"
(length ongoing))
- ongoing))))
+ (map build-derivation ongoing)))))
(('build-failed drv . _)
(format port (failure (G_ "build of ~a failed")) drv)
(newline port)
@@ -460,7 +567,7 @@ addition to build events."
;; through.
(display line port)
(force-output port))
- (print-log-line line))
+ (print-log-line pid line))
(cond ((string-prefix? "substitute: " line)
;; The daemon prefixes early messages coming with 'guix
;; substitute' with "substitute:". These are useful ("updating
@@ -473,7 +580,7 @@ addition to build events."
(display (info (string-trim-right line)) port)
(newline))
(else
- (print-log-line line)))))
+ (print-log-line pid line)))))
(_
event)))
@@ -570,7 +677,11 @@ The second return value is a thunk to retrieve the current state."
(define (process-line line)
(cond ((string-prefix? "@ " line)
- (match (string-tokenize (string-drop line 2))
+ ;; Note: Drop the trailing \n, and use 'string-split' to preserve
+ ;; spaces (the log file part of 'build-started' events can be the
+ ;; empty string.)
+ (match (string-split (string-drop (string-drop-right line 1) 2)
+ #\space)
(("build-log" (= string->number pid) (= string->number len))
(set! %build-output-pid pid)
(set! %build-output '())