unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: 30647@debbugs.gnu.org
Subject: [bug#30647] [PATCH] guix build: Support '--remote-log-file=PACKAGE'.
Date: Wed, 28 Feb 2018 17:19:59 +0300	[thread overview]
Message-ID: <20180228141959.19789-1-go.wigust@gmail.com> (raw)

‘--remote-log-file’ allows to get a URL for a build log file on a substitute
server regardless is it built locally.  ‘--log-file’ returns always local
build log file.

* guix/scripts/build.scm (show-build-log): Split function.
(show-remote-build-log): New function.
(guix-build): Add this.
* doc/guix.texi (Invoking guix build): Document this.
---
 doc/guix.texi          | 18 +++++++++---------
 guix/scripts/build.scm | 31 ++++++++++++++++++++++---------
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 24db16761..782e532ce 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -5812,9 +5812,8 @@ more on GC roots.
 
 @item --log-file
 @cindex build logs, access
-Return the build log file names or URLs for the given
-@var{package-or-derivation}, or raise an error if build logs are
-missing.
+Return the build log file names @var{package-or-derivation}, or raise an
+error if build logs are missing.
 
 This works regardless of how packages or derivations are specified.  For
 instance, the following invocations are equivalent:
@@ -5826,15 +5825,16 @@ guix build --log-file guile
 guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
 @end example
 
-If a log is unavailable locally, and unless @code{--no-substitutes} is
-passed, the command looks for a corresponding log on one of the
-substitute servers (as specified with @code{--substitute-urls}.)
+@item --remote-log-file
+@cindex build logs, access
+
+Same as @code{--log-file} but on one of the substitute servers (as
+specified with @code{--substitute-urls}.
 
-So for instance, imagine you want to see the build log of GDB on MIPS,
-but you are actually on an @code{x86_64} machine:
+For example, you want to see the build log of GDB on MIPS:
 
 @example
-$ guix build --log-file gdb -s mips64el-linux
+$ guix build --remote-log-file gdb -s mips64el-linux
 https://hydra.gnu.org/log/@dots{}-gdb-7.10
 @end example
 
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 57f2d82c5..c45271e50 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -601,6 +601,9 @@ must be one of 'package', 'all', or 'transitive'~%")
          (option '("log-file") #f #f
                  (lambda (opt name arg result)
                    (alist-cons 'log-file? #t result)))
+         (option '("remote-log-file") #f #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'remote-log-file? #t result)))
 
          (append %transformation-options
                  %standard-build-options)))
@@ -691,15 +694,20 @@ package '~a' has no source~%")
                 (map (cut transform store <>)
                      (options->things-to-build opts)))))
 
-(define (show-build-log store file urls)
-  "Show the build log for FILE, falling back to remote logs from URLS if
-needed."
-  (let ((log (or (log-file store file)
-                 (log-url store file #:base-urls urls))))
+(define (show-build-log store file)
+  "Show the build log for FILE."
+  (let ((log (log-file store file)))
     (if log
         (format #t "~a~%" log)
         (leave (G_ "no build log for '~a'~%") file))))
 
+(define (show-remote-build-log store file urls)
+  "Show the remote build log for FILE from URLS."
+  (let ((log (log-url store file #:base-urls urls)))
+    (if log
+        (format #t "~a~%" log)
+        (leave (G_ "no remote build log for '~a'~%") file))))
+
 \f
 ;;;
 ;;; Entry point.
@@ -713,6 +721,9 @@ needed."
   (define quiet?
     (assoc-ref opts 'quiet?))
 
+  (define (derivation-file-names drv items)
+    (delete-duplicates (append (map derivation-file-name drv) items)))
+
   (with-error-handling
     ;; Ask for absolute file names so that .drv file names passed from the
     ;; user to 'read-derivation' are absolute when it returns.
@@ -744,6 +755,7 @@ needed."
                                     opts)))
 
             (unless (or (assoc-ref opts 'log-file?)
+                        (assoc-ref opts 'remote-log-file?)
                         (assoc-ref opts 'derivations-only?))
               (show-what-to-build store drv
                                   #:use-substitutes?
@@ -752,10 +764,11 @@ needed."
                                   #:mode mode))
 
             (cond ((assoc-ref opts 'log-file?)
-                   (for-each (cut show-build-log store <> urls)
-                             (delete-duplicates
-                              (append (map derivation-file-name drv)
-                                      items))))
+                   (for-each (cut show-build-log store <>)
+                             (derivation-file-names drv items)))
+                  ((assoc-ref opts 'remote-log-file?)
+                   (for-each (cut show-remote-build-log store <> urls)
+                             (derivation-file-names drv items)))
                   ((assoc-ref opts 'derivations-only?)
                    (format #t "~{~a~%~}" (map derivation-file-name drv))
                    (for-each (cut register-root store <> <>)
-- 
2.16.1

             reply	other threads:[~2018-02-28 14:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 14:19 Oleg Pykhalov [this message]
2018-02-28 22:13 ` [bug#30647] [PATCH] guix build: Support '--remote-log-file=PACKAGE' Ludovic Courtès
2018-03-01  4:19   ` Oleg Pykhalov
2018-03-01 13:22     ` Ludovic Courtès
2018-03-01 15:40       ` Oleg Pykhalov
2018-03-01 21:30         ` Ludovic Courtès
2018-03-01 15:16   ` Tobias Geerinckx-Rice
2018-03-01 21:23     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180228141959.19789-1-go.wigust@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=30647@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).