From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: [PATCH] guix: Support authentication when fetching from SVN. Date: Thu, 30 Jun 2016 15:43:23 +0200 Message-ID: <20160630134323.25587-1-ricardo.wurmus@mdc-berlin.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcFm-0000lm-6u for guix-devel@gnu.org; Thu, 30 Jun 2016 09:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bIcFi-0003W3-16 for guix-devel@gnu.org; Thu, 30 Jun 2016 09:43:37 -0400 Received: from pegasus.bbbm.mdc-berlin.de ([141.80.25.20]:48277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bIcFh-0003Vb-JM for guix-devel@gnu.org; Thu, 30 Jun 2016 09:43:33 -0400 Received: from localhost (localhost [127.0.0.1]) by pegasus.bbbm.mdc-berlin.de (Postfix) with ESMTP id D32F23810C0 for ; Thu, 30 Jun 2016 15:43:31 +0200 (CEST) Received: from pegasus.bbbm.mdc-berlin.de ([127.0.0.1]) by localhost (pegasus.bbbm.mdc-berlin.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id trTDHcNOlHeQ for ; Thu, 30 Jun 2016 15:43:25 +0200 (CEST) Received: from HTCATWO.mdc-berlin.net (puck.citx.mdc-berlin.de [141.80.36.101]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pegasus.bbbm.mdc-berlin.de (Postfix) with ESMTPS for ; Thu, 30 Jun 2016 15:43:25 +0200 (CEST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org * guix/svn-download.scm (): Add fields for optional credentials. (svn-fetch): Pass credentials to build-side "svn-fetch". * guix/build/svn.scm (svn-fetch): Pass optional credentials to svn command. --- guix/build/svn.scm | 21 ++++++++++++++------- guix/svn-download.scm | 8 ++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 74fe084..0506e4e 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -29,15 +29,22 @@ ;;; Code: (define* (svn-fetch url revision directory - #:key (svn-command "svn")) + #:key (svn-command "svn") + (username #f) + (password #f)) "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." - (and (zero? (system* svn-command "checkout" "--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) - url directory)) + (and (zero? (apply system* svn-command + "checkout" "--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 username password) + (list (string-append "--username=" username) + (string-append "--password=" password)) + '()) + ,url ,directory))) (with-directory-excursion directory (begin ;; The contents of '.svn' vary as a function of the current status diff --git a/guix/svn-download.scm b/guix/svn-download.scm index d6853ca..b15e3e0 100644 --- a/guix/svn-download.scm +++ b/guix/svn-download.scm @@ -42,7 +42,9 @@ svn-reference make-svn-reference svn-reference? (url svn-reference-url) ; string - (revision svn-reference-revision)) ; number + (revision svn-reference-revision) ; number + (username svn-reference-username (default #f)) + (password svn-reference-password (default #f))) (define (subversion-package) "Return the default Subversion package." @@ -62,7 +64,9 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f." (svn-fetch '#$(svn-reference-url ref) '#$(svn-reference-revision ref) #$output - #:svn-command (string-append #+svn "/bin/svn")))) + #:svn-command (string-append #+svn "/bin/svn") + #:username #$(svn-reference-username ref) + #:password #$(svn-reference-password ref)))) (mlet %store-monad ((guile (package->derivation guile system))) (gexp->derivation (or name "svn-checkout") build -- 2.8.4