From patchwork Mon Nov 1 10:55:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 34199 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0D23D27BBE3; Mon, 1 Nov 2021 10:56:17 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 6FA8D27BBE1 for ; Mon, 1 Nov 2021 10:56:16 +0000 (GMT) Received: from localhost ([::1]:55306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhUz9-0008Ml-FM for patchwork@mira.cbaines.net; Mon, 01 Nov 2021 06:56:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhUyw-0008LC-3P for guix-patches@gnu.org; Mon, 01 Nov 2021 06:56:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mhUyv-0007mf-Rc for guix-patches@gnu.org; Mon, 01 Nov 2021 06:56:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mhUyv-00027T-Oa for guix-patches@gnu.org; Mon, 01 Nov 2021 06:56:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#51545] [PATCH] import: egg: Allow imports of a specific version. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 01 Nov 2021 10:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 51545 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 51545@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16357641388102 (code B ref -1); Mon, 01 Nov 2021 10:56:01 +0000 Received: (at submit) by debbugs.gnu.org; 1 Nov 2021 10:55:38 +0000 Received: from localhost ([127.0.0.1]:33810 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mhUyX-00026b-TB for submit@debbugs.gnu.org; Mon, 01 Nov 2021 06:55:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:55988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mhUyV-00026T-Px for submit@debbugs.gnu.org; Mon, 01 Nov 2021 06:55:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhUyV-0007hm-IM for guix-patches@gnu.org; Mon, 01 Nov 2021 06:55:35 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:60976 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhUyR-0007dy-RQ for guix-patches@gnu.org; Mon, 01 Nov 2021 06:55:35 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1635764127; bh=0oDjpkc19By7A3Uekc5v6hJRq3JGcqQBejqgDEoMT3o=; h=From:To:Subject:Date; b=DvAcnsAegqcRzU8/y9Gn1oxp2P74XQ/qOEUgHL4PA0i2IREaQGkeF9nD2GL80DLdp x25BXm+mNhRxLlAIILRKLglAYcyAam9nESZIMd7nCRp5PjzwOeiegaW4edveW7ArqM kvHiPAXoUg0krRZP7QW6Ora0VHda3plbzGnq2vdA= Message-Id: Date: Mon, 01 Nov 2021 11:55:26 +0100 MIME-Version: 1.0 Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.001, FROM_SUSPICIOUS_NTLD_FP=1.824, PDS_OTHER_BAD_TLD=0.001, PDS_RDNS_DYNAMIC_FP=0.001, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TO_NO_BRKTS_DYNIP=0.248 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/import/egg.scm (eggs-repository): Change URL. (egg-metadata): Accept optional #:version keyword argument. (egg->guix-package): Accept ‘version’ argument. (egg-recursive-import): Add ‘version’ argument and honor it. * guix/scripts/import/egg.scm (guix-import-egg): Parse a specification instead of just a package name. * doc/guix.texi (Invoking guix import): Document it. --- doc/guix.texi | 8 +++++++- guix/import/egg.scm | 37 ++++++++++++++++++++----------------- guix/scripts/import/egg.scm | 34 +++++++++++++++++++--------------- 3 files changed, 46 insertions(+), 33 deletions(-) base-commit: e1370ea8fa41417bedb437b2fc3a066b19f82c52 diff --git a/doc/guix.texi b/doc/guix.texi index ea1973f02c..5432612009 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12166,7 +12166,7 @@ @cindex egg Import metadata for @uref{https://wiki.call-cc.org/eggs, CHICKEN eggs}. The information is taken from @file{PACKAGE.egg} files found in the -@uref{git://code.call-cc.org/eggs-5-latest, eggs-5-latest} Git +@uref{git://code.call-cc.org/eggs-5-all, eggs-5-all} Git repository. However, it does not provide all the information that we need, there is no ``description'' field, and the licenses used are not always precise (BSD is often used instead of BSD-N). @@ -12175,6 +12175,12 @@ guix import egg sourcehut @end example +You can also ask for a specific version + +@example +guix import egg array@@1.0 +@end example + Additional options include: @table @code @item --recursive diff --git a/guix/import/egg.scm b/guix/import/egg.scm index 89e7a9160d..ff9f5a0247 100644 --- a/guix/import/egg.scm +++ b/guix/import/egg.scm @@ -51,10 +51,10 @@ (define-module (guix import egg) ;;; ;;; The following happens under the hood: ;;; -;;; * is a Git repository that contains -;;; the latest version of all CHICKEN eggs. We look clone this repository -;;; and retrieve the latest version number, and the PACKAGE.egg file, which -;;; contains a list of lists containing metadata about the egg. +;;; * is a Git repository that contains +;;; all versions of all CHICKEN eggs. We look clone this repository and, by +;;; default, retrieve the latest version number, and the PACKAGE.egg file, +;;; which contains a list of lists containing metadata about the egg. ;;; ;;; * All the eggs are stored as tarballs at ;;; , so we grab the tarball for @@ -96,7 +96,7 @@ (define (egg-name->guix-name name) (define (eggs-repository) "Update or fetch the latest version of the eggs repository and return the path to the repository." - (let* ((url "git://code.call-cc.org/eggs-5-latest") + (let* ((url "git://code.call-cc.org/eggs-5-all") (directory commit _ (update-cached-checkout url))) directory)) @@ -112,12 +112,13 @@ (define (find-latest-version name) (last directory) #f))) -(define* (egg-metadata name #:optional file) - "Return the package metadata file for the egg NAME, or if FILE is specified, -return the package metadata in FILE." +(define* (egg-metadata name #:key (version #f) (file #f)) + "Return the package metadata file for the egg NAME at version VERSION, or if +FILE is specified, return the package metadata in FILE." (call-with-input-file (or file (string-append (egg-directory name) "/" - (find-latest-version name) + (or version + (find-latest-version name)) "/" name ".egg")) read)) @@ -173,10 +174,11 @@ (define string->license ;;; Egg importer. ;;; -(define* (egg->guix-package name #:key (file #f) (source #f)) - "Import a CHICKEN egg called NAME from either the given .egg FILE, or from -the latest NAME metadata downloaded from the official repository if FILE is #f. -Return a record or #f on failure. +(define* (egg->guix-package name version #:key (file #f) (source #f)) + "Import a CHICKEN egg called NAME from either the given .egg FILE, or from the +latest NAME metadata downloaded from the official repository if FILE is #f. +Return a record or #f on failure. If VERSION is specified, import +the particular version from the egg repository. SOURCE is a ``file-like'' object containing the source code corresponding to the egg. If SOURCE is not specified, the latest tarball for egg NAME will be @@ -186,8 +188,8 @@ (define* (egg->guix-package name #:key (file #f) (source #f)) locally. Note that if FILE and SOURCE are specified, recursive import will not work." (define egg-content (if file - (egg-metadata name file) - (egg-metadata name))) + (egg-metadata name #:file file) + (egg-metadata name #:version version))) (if (not egg-content) (values #f '()) ; egg doesn't exist (let* ((version* (or (assoc-ref egg-content 'version) @@ -326,10 +328,11 @@ (define (maybe-inputs input-type inputs) (define egg->guix-package/m ;memoized variant (memoize egg->guix-package)) -(define (egg-recursive-import package-name) +(define* (egg-recursive-import package-name #:optional version) (recursive-import package-name + #:version version #:repo->guix-package (lambda* (name #:key version repo) - (egg->guix-package/m name)) + (egg->guix-package/m name version)) #:guix-name egg-name->guix-name)) diff --git a/guix/scripts/import/egg.scm b/guix/scripts/import/egg.scm index 829cdc2ca0..6a9657d12c 100644 --- a/guix/scripts/import/egg.scm +++ b/guix/scripts/import/egg.scm @@ -26,6 +26,7 @@ (define-module (guix scripts import egg) #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-37) + #:use-module (srfi srfi-71) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (guix-import-egg)) @@ -83,21 +84,24 @@ (define (parse-options) (_ #f)) (reverse opts)))) (match args - ((package-name) - (if (assoc-ref opts 'recursive) - ;; Recursive import - (map (match-lambda - ((and ('package ('name name) . rest) pkg) - `(define-public ,(string->symbol name) - ,pkg)) - (_ #f)) - (egg-recursive-import package-name)) - ;; Single import - (let ((sexp (egg->guix-package package-name))) - (unless sexp - (leave (G_ "failed to download meta-data for package '~a'~%") - package-name)) - sexp))) + ((spec) + (let ((name version (package-name->name+version spec))) + (if (assoc-ref opts 'recursive) + ;; Recursive import + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (egg-recursive-import name version)) + ;; Single import + (let ((sexp (egg->guix-package name version))) + (unless sexp + (leave (G_ "failed to download meta-data for package '~a'~%") + (if version + (string-append name "@" version) + name))) + sexp)))) (() (leave (G_ "too few arguments~%"))) ((many ...)