From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 04 07:54:30 2021 Received: (at 48999) by debbugs.gnu.org; 4 Jul 2021 11:54:30 +0000 Received: from localhost ([127.0.0.1]:40461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hi-0000bM-AD for submit@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:30 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:45494 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m00hf-0000as-3V for 48999@debbugs.gnu.org; Sun, 04 Jul 2021 07:54:28 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1625399661; bh=7C7QEzkflnhQc5ic1PfcaX7wJVpYn+YK5wpeZn2hic0=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=J7Q1N3UtN9As2vzxOiPsKCw0BNCLps8E1HumPc9IxX75lYEDBQbj6a6aKcrI3Fyzk ln5mGFVZM2osS1Xmp3YeTa7qnjQUkw9L4teup9sGOvfk+IN4flTbx1/AZiVH1P5pNf z3T8MHciLj4P7t9Pw54RKdd6mpowFLqw5xWYDygM= To: 48999@debbugs.gnu.org Subject: [PATCH v2 3/3] scripts: import: hackage: Add option to import package from local filesystem. In-Reply-To: References: Message-Id: <52f526989b25468210fa05e62580589f2c1cc4ea.1625399149.git.public@yoctocell.xyz> Date: Sun, 04 Jul 2021 13:54:20 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 2.9 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This adds a ‘--path’ option for importing a Haskell package from the local filesystem * guix/scripts/import/hackage.scm (show-help, %options): Add ‘-p’ and ‘--path’ options. (guix-import-hackage): Set the #:port and #:source keywords when the ‘--path’ option is used. --- gu [...] Content analysis details: (2.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps X-Debbugs-Envelope-To: 48999 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , zimoun X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.9 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This adds a ‘--path’ option for importing a Haskell package from the local filesystem * guix/scripts/import/hackage.scm (show-help, %options): Add ‘-p’ and ‘--path’ options. (guix-import-hackage): Set the #:port and #:source keywords when the ‘--path’ option is used. --- gu [...] Content analysis details: (1.9 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 2.0 PDS_OTHER_BAD_TLD Untrustworthy TLDs [URI: yoctocell.xyz (xyz)] -0.0 SPF_PASS SPF: sender matches SPF record 0.5 FROM_SUSPICIOUS_NTLD From abused NTLD 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 0.0 PDS_RDNS_DYNAMIC_FP RDNS_DYNAMIC with FP steps This adds a =E2=80=98--path=E2=80=99 option for importing a Haskell package= from the local filesystem * guix/scripts/import/hackage.scm (show-help, %options): Add =E2=80=98-p=E2= =80=99 and =E2=80=98--path=E2=80=99 options. (guix-import-hackage): Set the #:port and #:source keywords when the =E2=80= =98--path=E2=80=99 option is used. --- guix/scripts/import/hackage.scm | 43 +++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.= scm index 906dca24b1..8728791b52 100644 --- a/guix/scripts/import/hackage.scm +++ b/guix/scripts/import/hackage.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Federico Beffa ;;; Copyright =C2=A9 2018 Ricardo Wurmus +;;; Copyright =C2=A9 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,6 +23,7 @@ #:use-module (guix utils) #:use-module (guix packages) #:use-module (guix scripts) + #:use-module (guix import utils) #:use-module (guix import hackage) #:use-module (guix scripts import) #:use-module (srfi srfi-1) @@ -29,6 +31,7 @@ #:use-module (srfi srfi-37) #:use-module (ice-9 match) #:use-module (ice-9 format) + #:use-module (rnrs io ports) #:export (guix-import-hackage)) =20 @@ -62,6 +65,8 @@ version.\n")) (display (G_ " -s, --stdin read from standard input")) (display (G_ " + -p, --path=3DDIR use local directory as source")) + (display (G_ " -t, --no-test-dependencies don't include test-only dependencies")) (display (G_ " -V, --version display version information and exit")) @@ -87,6 +92,11 @@ version.\n")) (alist-cons 'read-from-stdin? #t (alist-delete 'read-from-stdin? result)))) + (option '(#\p "path") #t #f + (lambda (opt name arg result) + (alist-cons 'read-path arg + (alist-delete 'read-path + result)))) (option '(#\e "cabal-environment") #t #f (lambda (opt name arg result) (alist-cons 'cabal-environment (read/eval arg) @@ -113,22 +123,39 @@ version.\n")) %default-options)) =20 (define (run-importer package-name opts error-fn) - (let* ((arguments (list + (let* ((local-directory (assoc-ref opts 'read-path)) + (arguments (list package-name #:include-test-dependencies? (assoc-ref opts 'include-test-dependencies?) - #:port (if (assoc-ref opts 'read-from-stdin?) - (current-input-port) - #f) + #:port + (cond + ((assoc-ref opts 'read-from-stdin?) + (current-input-port)) + (local-directory + (open-file-input-port + (string-append local-directory + "/" package-name ".cabal"))) + (else #f)) + #:source + `(local-file ,local-directory + ,package-name + #:recursive? #t + #:select? ,(cond + ((git-repository? local-di= rectory) + 'git-predicate) + ((hg-repository? local-dir= ectory) + 'hg-predicate) + (else '(const #t)))) #:cabal-environment (assoc-ref opts 'cabal-environment))) (sexp (if (assoc-ref opts 'recursive) ;; Recursive import (map (match-lambda - ((and ('package ('name name) . rest) pkg) - `(define-public ,(string->symbol name) - ,pkg)) - (_ #f)) + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) (apply hackage-recursive-import arguments)) ;; Single import (apply hackage->guix-package arguments)))) --=20 2.32.0