* [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error.
@ 2020-10-05 16:35 zimoun
2020-10-05 16:36 ` [bug#43817] [PATCH 1/1] " zimoun
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: zimoun @ 2020-10-05 16:35 UTC (permalink / raw)
To: 43817; +Cc: zimoun
Dear,
This patch allows to gently report failure with 'hg clone'.
For example, let consider the package using 'hg-fetch':
--8<---------------cut here---------------start------------->8---
(define-module (hello)
#:use-module (guix packages)
#:use-module (gnu packages base)
#:use-module (guix hg-download))
(define-public hi-hg
(package
(inherit hello)
(name "hi-hg")
(source (origin
(method hg-fetch)
(uri (hg-reference
(url "https://example.org/hg")
(changeset "314a11282586")))
(sha256
(base32
"1yb0rsrbjg2bwyhfk677crhw0k7ijm6slaq0qq7cd4lznlz2yvji"))))
(home-page "https://example.org/hg")))
--8<---------------cut here---------------end--------------->8---
Then, the current behaviour report an (opinionated: ugly!) backtrace:
--8<---------------cut here---------------start------------->8---
$ guix build -L /tmp/foo/ hi-hg
The following derivations will be built:
/gnu/store/awdr7qhl6hyjgr1m9a40zfnban9ip98x-hi-hg-2.10.drv
/gnu/store/bgdwj7ajkm9xwcyib83wpby1zb9l8si2-hg-checkout.drv
building /gnu/store/bgdwj7ajkm9xwcyib83wpby1zb9l8si2-hg-checkout.drv...
guile: warning: failed to install locale
warning: connection security to example.org is disabled per current settings; communication is susceptible to eavesdropping and tampering
abort: HTTP Error 404: Not Found
Backtrace:
3 (primitive-load "/gnu/store/rf02zx0dscns2bzzics9i93l1xm?")
In ice-9/eval.scm:
293:34 2 (_ #<directory (guile-user) 7ffff5bb8f00>)
In guix/build/hg.scm:
38:2 1 (hg-fetch "https://example.org/hg" "314a11282586" "/gn?" ?)
In guix/build/utils.scm:
654:6 0 (invoke _ . _)
guix/build/utils.scm:654:6: In procedure invoke:
ERROR:
1. &invoke-error:
program: "/gnu/store/0qx1yjfnjn77jag9rmv4z49vfrzk5bgc-mercurial-5.5.1/bin/hg"
arguments: ("clone" "https://example.org/hg" "--rev" "314a11282586" "--insecure" "/gnu/store/6x6hccx9cqpfrcav79inl43ys6frgvw2-hg-checkout")
exit-status: 255
term-signal: #f
stop-signal: #f
builder for `/gnu/store/bgdwj7ajkm9xwcyib83wpby1zb9l8si2-hg-checkout.drv' failed with exit code 1
build of /gnu/store/bgdwj7ajkm9xwcyib83wpby1zb9l8si2-hg-checkout.drv failed
View build log at '/var/log/guix/drvs/bg/dwj7ajkm9xwcyib83wpby1zb9l8si2-hg-checkout.drv.bz2'.
cannot build derivation `/gnu/store/awdr7qhl6hyjgr1m9a40zfnban9ip98x-hi-hg-2.10.drv': 1 dependencies couldn't be built
guix build: error: build of `/gnu/store/awdr7qhl6hyjgr1m9a40zfnban9ip98x-hi-hg-2.10.drv' failed
--8<---------------cut here---------------end--------------->8---
Instead, the proposing patch handles the error and reports:
--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build -L /tmp/foo/ hi-hg
The following derivations will be built:
/gnu/store/zam0r6fvyp9qkzp6kf087iifvnhw140n-hi-hg-2.10.drv
/gnu/store/z4y6xhnaipx0p7sx4ink0bll9i7rww87-hg-checkout.drv
building /gnu/store/z4y6xhnaipx0p7sx4ink0bll9i7rww87-hg-checkout.drv...
guile: warning: failed to install locale
warning: connection security to example.org is disabled per current settings; communication is susceptible to eavesdropping and tampering
abort: HTTP Error 404: Not Found
hg-fetch: '/gnu/store/0qx1yjfnjn77jag9rmv4z49vfrzk5bgc-mercurial-5.5.1/bin/hg clone https://example.org/hg --rev 314a11282586 --insecure /gnu/store/6x6hccx9cqpfrcav79inl43ys6frgvw2-hg-checkout' failed with exit code 255
Trying content-addressed mirror at berlin.guix.gnu.org...
Trying content-addressed mirror at berlin.guix.gnu.org...
builder for `/gnu/store/z4y6xhnaipx0p7sx4ink0bll9i7rww87-hg-checkout.drv' failed to produce output path `/gnu/store/6x6hccx9cqpfrcav79inl43ys6frgvw2-hg-checkout'
build of /gnu/store/z4y6xhnaipx0p7sx4ink0bll9i7rww87-hg-checkout.drv failed
View build log at '/var/log/guix/drvs/z4/y6xhnaipx0p7sx4ink0bll9i7rww87-hg-checkout.drv.bz2'.
cannot build derivation `/gnu/store/zam0r6fvyp9qkzp6kf087iifvnhw140n-hi-hg-2.10.drv': 1 dependencies couldn't be built
guix build: error: build of `/gnu/store/zam0r6fvyp9qkzp6kf087iifvnhw140n-hi-hg-2.10.drv' failed
--8<---------------cut here---------------end--------------->8---
(Note: the code is highly copied from guix/build/git.scm. :-))
All the best,
simon
zimoun (1):
guix: build: hg: Add 'guard' to handle error.
guix/build/hg.scm | 50 +++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 17 deletions(-)
base-commit: 2b73e50c31a61b5dcef35a1e4b9484d9dbcb0fbc
--
2.28.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [bug#43817] [PATCH 1/1] guix: build: hg: Add 'guard' to handle error.
2020-10-05 16:35 [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error zimoun
@ 2020-10-05 16:36 ` zimoun
2020-10-05 16:47 ` [bug#43817] [PATCH 2/2] guix: build: svn: " zimoun
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2020-10-05 16:36 UTC (permalink / raw)
To: 43817; +Cc: zimoun
* guix/build/hg.scm (hg-fetch): Add 'guard' to handle error.
---
guix/build/hg.scm | 50 +++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 17 deletions(-)
diff --git a/guix/build/hg.scm b/guix/build/hg.scm
index b3e3ff7ac3..9245181d8b 100644
--- a/guix/build/hg.scm
+++ b/guix/build/hg.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,6 +21,8 @@
(define-module (guix build hg)
#:use-module (guix build utils)
+ #:use-module (srfi srfi-34)
+ #:use-module (ice-9 format)
#:export (hg-fetch))
;;; Commentary:
@@ -35,22 +38,35 @@
"Fetch CHANGESET from URL into DIRECTORY. CHANGESET must be a valid
Mercurial changeset identifier. Return #t on success, #f otherwise."
- (invoke hg-command
- "clone" url
- "--rev" changeset
- ;; Disable TLS certificate verification. The hash of
- ;; the checkout is known in advance anyway.
- "--insecure"
- directory)
-
- ;; The contents of '.hg' vary as a function of the current
- ;; status of the Mercurial repo. Since we want a fixed
- ;; output, this directory needs to be taken out.
- ;; Since the '.hg' file is also in sub-modules, we have to
- ;; search for it in all sub-directories.
- (for-each delete-file-recursively
- (find-files directory "^\\.hg$" #:directories? #t))
-
- #t)
+ (mkdir-p directory)
+
+ (guard (c ((invoke-error? c)
+ (format (current-error-port)
+ "hg-fetch: '~a~{ ~a~}' failed with exit code ~a~%"
+ (invoke-error-program c)
+ (invoke-error-arguments c)
+ (or (invoke-error-exit-status c) ;XXX: not quite accurate
+ (invoke-error-stop-signal c)
+ (invoke-error-term-signal c)))
+ (delete-file-recursively directory)
+ #f))
+ (with-directory-excursion directory
+ (invoke hg-command
+ "clone" url
+ "--rev" changeset
+ ;; Disable TLS certificate verification. The hash of
+ ;; the checkout is known in advance anyway.
+ "--insecure"
+ directory)
+
+ ;; The contents of '.hg' vary as a function of the current
+ ;; status of the Mercurial repo. Since we want a fixed
+ ;; output, this directory needs to be taken out.
+ ;; Since the '.hg' file is also in sub-modules, we have to
+ ;; search for it in all sub-directories.
+ (for-each delete-file-recursively
+ (find-files directory "^\\.hg$" #:directories? #t))
+
+ #t)))
;;; hg.scm ends here
--
2.28.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#43817] [PATCH 2/2] guix: build: svn: Add 'guard' to handle error.
2020-10-05 16:35 [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error zimoun
2020-10-05 16:36 ` [bug#43817] [PATCH 1/1] " zimoun
@ 2020-10-05 16:47 ` zimoun
2020-10-05 16:49 ` [bug#43817] [PATCH 0/1] guix: build: hg: " zimoun
2020-10-06 8:26 ` bug#43817: " Mathieu Othacehe
3 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2020-10-05 16:47 UTC (permalink / raw)
To: 43817; +Cc: zimoun
* guix/build/svn.scm (svn-fetch): Add 'guard' to handle error.
---
guix/build/svn.scm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/guix/build/svn.scm b/guix/build/svn.scm
index 33783f3056..0afe887487 100644
--- a/guix/build/svn.scm
+++ b/guix/build/svn.scm
@@ -2,6 +2,7 @@
;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -20,6 +21,8 @@
(define-module (guix build svn)
#:use-module (guix build utils)
+ #:use-module (srfi srfi-34)
+ #:use-module (ice-9 format)
#:export (svn-fetch))
;;; Commentary:
@@ -36,7 +39,20 @@
(password #f))
"Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a
valid Subversion revision. Return #t on success, #f otherwise."
- (apply invoke svn-command
+ (mkdir-p directory)
+
+ (guard (c ((invoke-error? c)
+ (format (current-error-port)
+ "svn-fetch: '~a~{ ~a~}' failed with exit code ~a~%"
+ (invoke-error-program c)
+ (invoke-error-arguments c)
+ (or (invoke-error-exit-status c) ;XXX: not quite accurate
+ (invoke-error-stop-signal c)
+ (invoke-error-term-signal c)))
+ (delete-file-recursively directory)
+ #f))
+ (with-directory-excursion directory
+ (apply invoke svn-command
"export" "--non-interactive"
;; Trust the server certificate. This is OK as we
;; verify the checksum later. This can be removed when
@@ -50,6 +66,6 @@ valid Subversion revision. Return #t on success, #f otherwise."
'()
(list "--ignore-externals"))
,url ,directory))
- #t)
+ #t)))
;;; svn.scm ends here
--
2.28.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error.
2020-10-05 16:35 [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error zimoun
2020-10-05 16:36 ` [bug#43817] [PATCH 1/1] " zimoun
2020-10-05 16:47 ` [bug#43817] [PATCH 2/2] guix: build: svn: " zimoun
@ 2020-10-05 16:49 ` zimoun
2020-10-06 8:26 ` bug#43817: " Mathieu Othacehe
3 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2020-10-05 16:49 UTC (permalink / raw)
To: 43817
On Mon, 5 Oct 2020 at 18:35, zimoun <zimon.toutoune@gmail.com> wrote:
> This patch allows to gently report failure with 'hg clone'.
>
> For example, let consider the package using 'hg-fetch':
The patch dealing with 'svn-fetch' is also in this thread.
All the best,
simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#43817: [PATCH 0/1] guix: build: hg: Add 'guard' to handle error.
2020-10-05 16:35 [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error zimoun
` (2 preceding siblings ...)
2020-10-05 16:49 ` [bug#43817] [PATCH 0/1] guix: build: hg: " zimoun
@ 2020-10-06 8:26 ` Mathieu Othacehe
2020-10-07 17:29 ` [bug#43817] " zimoun
3 siblings, 1 reply; 6+ messages in thread
From: Mathieu Othacehe @ 2020-10-06 8:26 UTC (permalink / raw)
To: zimoun; +Cc: 43817-done
Hello zimoun,
> This patch allows to gently report failure with 'hg clone'.
I applied both patches with minor edits.
Thanks,
Mathieu
^ permalink raw reply [flat|nested] 6+ messages in thread
* [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error.
2020-10-06 8:26 ` bug#43817: " Mathieu Othacehe
@ 2020-10-07 17:29 ` zimoun
0 siblings, 0 replies; 6+ messages in thread
From: zimoun @ 2020-10-07 17:29 UTC (permalink / raw)
To: Mathieu Othacehe; +Cc: 43817-done
Hi Mathieu,
On Tue, 6 Oct 2020 at 10:26, Mathieu Othacehe <othacehe@gnu.org> wrote:
> > This patch allows to gently report failure with 'hg clone'.
>
> I applied both patches with minor edits.
Thank you. Paul spotted out an issue that I missed about the patch
tweaking 'svn-fetch'. Now, it is fixed; see patch in [1]. Well, I am
not a Git's guru but "git am --scissors" should do the job.
[1] https://lists.gnu.org/archive/html/guix-commits/2020-10/msg00470.html
Sorry for the annoyance.
Thanks,
simon
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-10-07 17:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-05 16:35 [bug#43817] [PATCH 0/1] guix: build: hg: Add 'guard' to handle error zimoun
2020-10-05 16:36 ` [bug#43817] [PATCH 1/1] " zimoun
2020-10-05 16:47 ` [bug#43817] [PATCH 2/2] guix: build: svn: " zimoun
2020-10-05 16:49 ` [bug#43817] [PATCH 0/1] guix: build: hg: " zimoun
2020-10-06 8:26 ` bug#43817: " Mathieu Othacehe
2020-10-07 17:29 ` [bug#43817] " zimoun
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).