mbox

[bug#43817,0/1] guix: build: hg: Add 'guard' to handle error.

Message ID 20201005163544.3947-1-zimon.toutoune@gmail.com
Headers show

Message

Simon Tournier Oct. 5, 2020, 4:35 p.m. UTC
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

Comments

Simon Tournier Oct. 5, 2020, 4:49 p.m. UTC | #1
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
Simon Tournier Oct. 7, 2020, 5:29 p.m. UTC | #2
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