From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GHrfAchLe18/JgAA0tVLHw (envelope-from ) for ; Mon, 05 Oct 2020 16:37:28 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id YIlGOcdLe1/KJQAA1q6Kng (envelope-from ) for ; Mon, 05 Oct 2020 16:37:27 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6EE359404C5 for ; Mon, 5 Oct 2020 16:37:27 +0000 (UTC) Received: from localhost ([::1]:57792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPTUL-00087q-LE for larch@yhetil.org; Mon, 05 Oct 2020 12:37:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPTTy-00085A-HK for guix-patches@gnu.org; Mon, 05 Oct 2020 12:37:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPTTy-0007zb-7Y for guix-patches@gnu.org; Mon, 05 Oct 2020 12:37:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kPTTy-00057Q-5E for guix-patches@gnu.org; Mon, 05 Oct 2020 12:37:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43817] [PATCH 1/1] guix: build: hg: Add 'guard' to handle error. References: <20201005163544.3947-1-zimon.toutoune@gmail.com> In-Reply-To: <20201005163544.3947-1-zimon.toutoune@gmail.com> Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 05 Oct 2020 16:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43817 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43817@debbugs.gnu.org Cc: zimoun Received: via spool by 43817-submit@debbugs.gnu.org id=B43817.160191580619649 (code B ref 43817); Mon, 05 Oct 2020 16:37:02 +0000 Received: (at 43817) by debbugs.gnu.org; 5 Oct 2020 16:36:46 +0000 Received: from localhost ([127.0.0.1]:50366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kPTTh-00056r-GC for submit@debbugs.gnu.org; Mon, 05 Oct 2020 12:36:46 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41052) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kPTTf-00056d-9H for 43817@debbugs.gnu.org; Mon, 05 Oct 2020 12:36:43 -0400 Received: by mail-wr1-f66.google.com with SMTP id w5so10336319wrp.8 for <43817@debbugs.gnu.org>; Mon, 05 Oct 2020 09:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ViSiot9nFS4O3vLFqRzUsDG7vX57Vv+LsZpAoJJlbqU=; b=nnyYIOnLX5lbjvqrp1prxmqcD9X/xY1vlZY/Dxa5WAveu7yFq5BGLSA1qDUlB/5XIn ehuAUBDWzVYLd2AjZKPyQhwuLOqEpYMk9uwH4QwOp/lgqGKBLwm4eF8CjfZWJALEJJuC Vyha4AQEIANDPjvNI41KwBMMQWHik7BMJ8QZDzqsqAl5yeXtDhY0/6SkBR8ftQUaB/Y6 UBytvLsoFcnRx/44Spzd3Qg/sLMY5AGTtS/CEi8NPf6h54jpjR9L0BeWFYAVjT4TC30j qr7FO3TBazaCkVijqr5GOPmqejxY0qXT02fqUlF0ZPCmFR5wINDYZtJIbSSzP+YBJMkY Yt0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ViSiot9nFS4O3vLFqRzUsDG7vX57Vv+LsZpAoJJlbqU=; b=nB0NG3QC5CE7Y5d4H9QvOzDL/Pxu2uwy+Uhqh6g1CXgPGjVO66GcRDO0jJJJbuW70Q x5vhzpdWVtFCKl+cSHeULLvVcV9Lh3U0QQnpA+tVshi2nG+9ATgmIGP60Df2Lk2uiJeR L6N3w/gu7h3qoPM+Pb6xohaT7eOU9u9Juv1OjqGpmvtL2yn+TvaWaJQA23ljMVr4d7gI sS3ul0NXBHkrRdtQ1T+S2N8fRCxG3GzLxiwFIM2fBESwWk8ar+uydvehd2Hkn805QT5Z vwDr3Crp3tIu+ozSo/c+yVPheeLeGH+x89i+4j2WOlz2mGufwYIOrwhWT81cFJKTOgrC cgHg== X-Gm-Message-State: AOAM53211Wj42BRwbOAmkQCVYOnNMojMvyQut5iA3CiFeX2Ieph6kUfB 2NYVwrHpYWWXbSFvPagWQWmOein/CZ5lEA== X-Google-Smtp-Source: ABdhPJzmIwsfdLA5tAgQg247wRb03H+IS6qxFUU1diTnPrN8M8KWxVcztFIRo0HuweNtNpVBj29MJA== X-Received: by 2002:a5d:50cd:: with SMTP id f13mr214425wrt.211.1601915797070; Mon, 05 Oct 2020 09:36:37 -0700 (PDT) Received: from pfiuh02.univ-paris-diderot.fr ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id n6sm135320wmd.22.2020.10.05.09.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2020 09:36:36 -0700 (PDT) From: zimoun Date: Mon, 5 Oct 2020 18:36:34 +0200 Message-Id: <20201005163634.4300-1-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=gmail.com header.s=20161025 header.b=nnyYIOnL; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: qnxIPkHrUcOV * 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 ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2018 Björn Höfling +;;; Copyright © 2020 Simon Tournier ;;; ;;; 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