From 2fb12dd1bb725592e1561ac8f4b32fb68accb161 Mon Sep 17 00:00:00 2001 From: zimoun Date: Mon, 5 Oct 2020 18:47:39 +0200 Subject: build: svn: Handle fetch errors. * guix/build/svn.scm (svn-fetch): Add 'guard' to handle errors. Signed-off-by: Mathieu Othacehe --- guix/build/svn.scm | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'guix/build/svn.scm') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 33783f3056..48d28f0327 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver +;;; Copyright © 2020 Simon Tournier ;;; ;;; 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,20 +39,33 @@ (define* (svn-fetch url revision directory (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 - "export" "--non-interactive" - ;; Trust the server certificate. This is OK as we - ;; verify the checksum later. This can be removed when - ;; ca-certificates package is added. - "--trust-server-cert" "-r" (number->string revision) - `(,@(if (and user-name password) - (list (string-append "--username=" user-name) - (string-append "--password=" password)) - '()) - ,@(if recursive? - '() - (list "--ignore-externals")) - ,url ,directory)) - #t) + (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) + (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 + ;; ca-certificates package is added. + "--trust-server-cert" "-r" (number->string revision) + `(,@(if (and user-name password) + (list (string-append "--username=" user-name) + (string-append "--password=" password)) + '()) + ,@(if recursive? + '() + (list "--ignore-externals")) + ,url ,directory)) + #t))) ;;; svn.scm ends here -- cgit v1.2.3 From 1ec67d5220b0ebac20263b44f4fefaf51ba8fdbb Mon Sep 17 00:00:00 2001 From: Paul Garlick Date: Tue, 6 Oct 2020 14:44:09 +0100 Subject: Revert "build: svn: Handle fetch errors." This reverts commit 2fb12dd1bb725592e1561ac8f4b32fb68accb161, which causes the 'svn export' command to fail with: svn: E155000: Destination directory exists; please remove the directory or use --force to overwrite --- guix/build/svn.scm | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'guix/build/svn.scm') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 48d28f0327..33783f3056 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -2,7 +2,6 @@ ;;; Copyright © 2014 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver -;;; Copyright © 2020 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -21,8 +20,6 @@ (define-module (guix build svn) #:use-module (guix build utils) - #:use-module (srfi srfi-34) - #:use-module (ice-9 format) #:export (svn-fetch)) ;;; Commentary: @@ -39,33 +36,20 @@ (define* (svn-fetch url revision directory (password #f)) "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." - (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) - (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 - ;; ca-certificates package is added. - "--trust-server-cert" "-r" (number->string revision) - `(,@(if (and user-name password) - (list (string-append "--username=" user-name) - (string-append "--password=" password)) - '()) - ,@(if recursive? - '() - (list "--ignore-externals")) - ,url ,directory)) - #t))) + (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 + ;; ca-certificates package is added. + "--trust-server-cert" "-r" (number->string revision) + `(,@(if (and user-name password) + (list (string-append "--username=" user-name) + (string-append "--password=" password)) + '()) + ,@(if recursive? + '() + (list "--ignore-externals")) + ,url ,directory)) + #t) ;;; svn.scm ends here -- cgit v1.2.3 From db9e4af0ead4b02e1a70f358de995c43249b8bcf Mon Sep 17 00:00:00 2001 From: zimoun Date: Wed, 7 Oct 2020 01:05:21 +0200 Subject: build: svn: Fix handle fetch errors. This fixes the revert 1ec67d5220b0ebac20263b44f4fefaf51ba8fdbb. * guix/build/svn.scm (svn-fetch): Add 'guard' to handle errors. Signed-off-by: Mathieu Othacehe --- guix/build/svn.scm | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'guix/build/svn.scm') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 33783f3056..f6b4ca0776 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2014 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver +;;; Copyright © 2020 Simon Tournier ;;; ;;; 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,20 +39,29 @@ (define* (svn-fetch url revision directory (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 - "export" "--non-interactive" - ;; Trust the server certificate. This is OK as we - ;; verify the checksum later. This can be removed when - ;; ca-certificates package is added. - "--trust-server-cert" "-r" (number->string revision) - `(,@(if (and user-name password) - (list (string-append "--username=" user-name) - (string-append "--password=" password)) - '()) - ,@(if recursive? - '() - (list "--ignore-externals")) - ,url ,directory)) - #t) + (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) + (invoke-error-stop-signal c) + (invoke-error-term-signal c))) + #f)) + (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 + ;; ca-certificates package is added. + "--trust-server-cert" "-r" (number->string revision) + `(,@(if (and user-name password) + (list (string-append "--username=" user-name) + (string-append "--password=" password)) + '()) + ,@(if recursive? + '() + (list "--ignore-externals")) + ,url ,directory)) + #t)) ;;; svn.scm ends here -- cgit v1.2.3 From b55409b2c0a0cb53f251ceab7746d35805b64ab7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 10 Oct 2020 00:03:57 +0200 Subject: svn-download, hg-download: Use 'report-invoke-error'. * guix/build/hg.scm (hg-fetch): Use 'report-invoke-error' instead of 'format'. * guix/build/svn.scm (svn-fetch): Likewise. --- guix/build/hg.scm | 8 +------- guix/build/svn.scm | 10 ++-------- 2 files changed, 3 insertions(+), 15 deletions(-) (limited to 'guix/build/svn.scm') diff --git a/guix/build/hg.scm b/guix/build/hg.scm index 1cceb63433..0ffad7fa2d 100644 --- a/guix/build/hg.scm +++ b/guix/build/hg.scm @@ -41,13 +41,7 @@ (define* (hg-fetch url changeset directory (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) - (invoke-error-stop-signal c) - (invoke-error-term-signal c))) + (report-invoke-error c) (delete-file-recursively directory) #f)) (with-directory-excursion directory diff --git a/guix/build/svn.scm b/guix/build/svn.scm index f6b4ca0776..44d77a968f 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2014 Ludovic Courtès +;;; Copyright © 2014, 2020 Ludovic Courtès ;;; Copyright © 2014 Sree Harsha Totakura ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2020 Simon Tournier @@ -40,13 +40,7 @@ (define* (svn-fetch url revision directory "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." (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) - (invoke-error-stop-signal c) - (invoke-error-term-signal c))) + (report-invoke-error c) #f)) (apply invoke svn-command "export" "--non-interactive" -- cgit v1.2.3