From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc6iD-0006FM-Rc for guix-patches@gnu.org; Mon, 31 Jul 2017 05:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc6iA-0002L9-HS for guix-patches@gnu.org; Mon, 31 Jul 2017 05:10:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:60304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dc6iA-0002Ko-E1 for guix-patches@gnu.org; Mon, 31 Jul 2017 05:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dc6i9-0002T7-UN for guix-patches@gnu.org; Mon, 31 Jul 2017 05:10:01 -0400 Subject: [bug#27865] [PATCH 2/3] pull: Fetch source code from Git. Resent-Message-ID: References: <20170728204539.21879-1-ludo@gnu.org> <20170728204539.21879-2-ludo@gnu.org> <87r2wy83rq.fsf@gmail.com> <8760e9fync.fsf@gnu.org> From: Mathieu Othacehe In-reply-to: <8760e9fync.fsf@gnu.org> Date: Mon, 31 Jul 2017 11:09:47 +0200 Message-ID: <87h8xtnfac.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 27865@debbugs.gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Ludo, > In Cuirass you might even assume you have the latest Guile-Git version > available (maybe with a configure check to be on the safe side). We > don’t have to be as cautious there. Would the attached patch be ok ? Thanks, Mathieu --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-base-Report-git-errors.patch >From 6d6b0e48856998251284539e69bbc39e6d21635f Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Mon, 31 Jul 2017 11:08:32 +0200 Subject: [PATCH] base: Report git errors. * src/cuirass/base.scm (report-git-error): New procedure. (with-git-error-handling): New macro. (process-specs): Use with-git-error-handling to catch and report git errors. * build-aux/guix.scm (package)[inputs]: Add guile-git. * configure.ac: Check for (git) module. Also check that (git) exports git-error-message procedure. --- build-aux/guix.scm | 1 + configure.ac | 4 ++++ src/cuirass/base.scm | 58 ++++++++++++++++++++++++++++++++-------------------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/build-aux/guix.scm b/build-aux/guix.scm index 583ef7e..c2f6cdb 100644 --- a/build-aux/guix.scm +++ b/build-aux/guix.scm @@ -80,6 +80,7 @@ '("guile@2.2" "guile-json" "guile-sqlite3" + "guile-git" "guix"))) (native-inputs (map spec+package-list diff --git a/configure.ac b/configure.ac index d7f111c..9c6a597 100644 --- a/configure.ac +++ b/configure.ac @@ -48,9 +48,13 @@ AS_IF([test -z "$ac_cv_path_GUILD"], GUILE_MODULE_REQUIRED([guix]) GUILE_MODULE_REQUIRED([guix git]) +GUILE_MODULE_REQUIRED([git]) GUILE_MODULE_REQUIRED([json]) GUILE_MODULE_REQUIRED([sqlite3]) +# We depend on new Guile-Git errors. +GUILE_MODULE_REQUIRED_EXPORT([(git)], git-error-message) + AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([pre-inst-env:build-aux/pre-inst-env.in], [chmod +x pre-inst-env]) diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm index cc3dd39..f119c45 100644 --- a/src/cuirass/base.scm +++ b/src/cuirass/base.scm @@ -25,6 +25,7 @@ #:use-module (guix derivations) #:use-module (guix store) #:use-module (guix git) + #:use-module (git) #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (ice-9 popen) @@ -92,6 +93,17 @@ values." duration) (acons #:duration duration result))))) +(define (report-git-error error) + "Report the given Guile-Git error." + (format #t "Git error: ~a~%" (git-error-message error))) + +(define-syntax-rule (with-git-error-handling body ...) + (catch 'git-error + (lambda () + body ...) + (lambda (key err) + (report-git-error err)))) + (define (fetch-repository store spec) "Get the latest version of repository specified in SPEC. Return two values: the content of the git repository at URL copied into a store @@ -209,30 +221,32 @@ directory and the sha1 of the top level commit in this directory." (define (process spec) (with-store store (let ((stamp (db-get-stamp db spec))) - (receive (checkout commit) - (fetch-repository store spec) - (when commit - (unless (string=? commit stamp) - (copy-repository-cache checkout spec) + ;; Catch and report git errors. + (with-git-error-handling + (receive (checkout commit) + (fetch-repository store spec) + (when commit + (unless (string=? commit stamp) + (copy-repository-cache checkout spec) - (unless (assq-ref spec #:no-compile?) - (compile (string-append (%package-cachedir) "/" - (assq-ref spec #:name)))) - ;; Always set #:keep-going? so we don't stop on the first build - ;; failure. - (set-build-options store - #:use-substitutes? (%use-substitutes?) - #:fallback? (%fallback?) - #:keep-going? #t) + (unless (assq-ref spec #:no-compile?) + (compile (string-append (%package-cachedir) "/" + (assq-ref spec #:name)))) + ;; Always set #:keep-going? so we don't stop on the first build + ;; failure. + (set-build-options store + #:use-substitutes? (%use-substitutes?) + #:fallback? (%fallback?) + #:keep-going? #t) - (guard (c ((evaluation-error? c) - (format #t "Failed to evaluate ~s specification.~%" - (evaluation-error-spec-name c)) - #f)) - (let* ((spec* (acons #:current-commit commit spec)) - (jobs (evaluate store db spec*))) - (build-packages store db jobs)))) - (db-add-stamp db spec commit)))))) + (guard (c ((evaluation-error? c) + (format #t "Failed to evaluate ~s specification.~%" + (evaluation-error-spec-name c)) + #f)) + (let* ((spec* (acons #:current-commit commit spec)) + (jobs (evaluate store db spec*))) + (build-packages store db jobs)))) + (db-add-stamp db spec commit))))))) (for-each process jobspecs)) -- 2.13.2 --=-=-=--