From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id UIo2A5dvsmCC+wAAgWs5BA (envelope-from ) for ; Sat, 29 May 2021 18:45:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id KBgIOpZvsmA4UAAA1q6Kng (envelope-from ) for ; Sat, 29 May 2021 16:45:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 200921D146 for ; Sat, 29 May 2021 18:45:10 +0200 (CEST) Received: from localhost ([::1]:60470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ln25E-0003lL-T8 for larch@yhetil.org; Sat, 29 May 2021 12:45:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln258-0003l6-Mj for guix-patches@gnu.org; Sat, 29 May 2021 12:45:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46061) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ln258-000339-Fc for guix-patches@gnu.org; Sat, 29 May 2021 12:45:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ln258-0000vG-DM for guix-patches@gnu.org; Sat, 29 May 2021 12:45:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#48697] [PATCH] import: Add CHICKEN egg importer. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 29 May 2021 16:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48697 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Xinglu Chen Cc: 48697@debbugs.gnu.org, raingloom Received: via spool by 48697-submit@debbugs.gnu.org id=B48697.16223066563477 (code B ref 48697); Sat, 29 May 2021 16:45:02 +0000 Received: (at 48697) by debbugs.gnu.org; 29 May 2021 16:44:16 +0000 Received: from localhost ([127.0.0.1]:57607 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln24N-0000u0-OA for submit@debbugs.gnu.org; Sat, 29 May 2021 12:44:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ln24L-0000tj-1J for 48697@debbugs.gnu.org; Sat, 29 May 2021 12:44:14 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47342) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ln24E-0002s8-Px; Sat, 29 May 2021 12:44:06 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=40312 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ln24E-0007ff-HT; Sat, 29 May 2021 12:44:06 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: Date: Sat, 29 May 2021 18:44:04 +0200 In-Reply-To: (Xinglu Chen's message of "Thu, 27 May 2021 14:48:30 +0200") Message-ID: <87zgwd7anf.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1622306710; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=5RMWgT9iYea0R7+/yhWXM6/9sWEGW7fWY/EVINXxgZM=; b=Q9zeCmJgP60Kgoon0oEKpZit9m83qNi4TFABDpoBK+KYBL5IhWbiEk+R7YPM6AMPQ3yPZe nlo5uElG69cIlQVBAoKAoicdybvbLCJJdPl87C7umtb6oMin+KQFGR7L4w6Wmf64bVZAlS zaEkTs0WTQb+6hv5k67vtboO/daTFcLO3PlI4q4aiig2e0DYXCy57foYcl282/cyYMu1g+ ZuyG7eReLBsSTlqg1ZIkEkutJYRMcnXJ27WaUULft6ar2ERss3brzk2jBYiHgPOZYiHqDl O/Nwbk+TDf3tiSynByokZBRTZuFHHuw4INAvITfbcLozfiUXHq7l8AzLI/RLiw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622306710; a=rsa-sha256; cv=none; b=hGyIS6X7WHjF8ka6VUpNGA5d50uU3W610jsYLp6mATGT2UInHA4CkGULTG+HamVxd2qUDd U+FF3bx9a5GqA9JHsgmvd2G7tNWXBwE/k0s2tHKA5J6c9INi7TI1doTonMtD8fX83nxt2l gDm/EI3FVn2E85UGQBWI9nujV2WxSROIP7rdBaFjDK2+C61ZZ+wVIIDT+JCc76Z1biiOxe A5oGHdavT7A2QN0/9eLIAzKqoyYpsIvSzA1x4BB/SFJTamrqzFPCGVUvQSyfYH7Krg9m40 hZupW6Uw8T/GTvlHCbUqm162rIBb1d29+am9m365Bb85hoNnZFmbATA22CqruQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -2.92 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 200921D146 X-Spam-Score: -2.92 X-Migadu-Scanner: scn1.migadu.com X-TUID: Cn8f0CLxMalK Hello! Xinglu Chen skribis: > * guix/import/egg.scm: New file. > * guix/scripts/import/egg.scm: New file. > * tests/egg.scm: New file. > * Makefile.am (MODULES, SCM_TESTS): Register them. > * guix/scripts/import.scm (importers): Add egg importer. > * doc/guix.texi (Invoking guix import, Invoking guix refresh): Document i= t. Woohoo, very nice! > This patch adds recursive importer for CHICKEN eggs, the generated > packages aren=E2=80=99t entirely complete, though. It gets information f= rom The > PACKAGE.egg, which is just a Scheme file that contains a list of lists > that specify the metadata for an egg. However, it doesn=E2=80=99t specif= y a > description, so I have just set the =E2=80=98description=E2=80=99 field t= o #f for now. > The licensing policy for eggs is also a bit vague[1], there is no strict > naming format for licenses, and a lot of eggs just specify =E2=80=98BSD= =E2=80=99 rather > than =E2=80=98BSD-N-Clause=E2=80=99. On IRC, Mario Goulart of CHICKEN fame mentioned that they are working on it, linking to this discussion: https://lists.nongnu.org/archive/html/chicken-hackers/2020-10/msg00003.ht= ml So hopefully it=E2=80=99ll improve soon. In the meantime, what this patch = does (leaving a question mark when licensing is vague) LGTM. > The PACKAGE.egg file can also specify system dependencies, but there is > no consistent format for this, sometimes strings are used, other times > symbols are used, and sometimes the version of the package is also > included. The user will have to double check the names and make sure > they are correct. I am also unsure about whether the system > dependencies should be =E2=80=98propagated-inputs=E2=80=99 or just =E2=80= =98inputs=E2=80=99. Probably just =E2=80=98inputs=E2=80=99, no? Why would they need to be prop= agated? For Guile (and Python, etc.) they have to be propagated because you need .scm and .go files to be in the search path; but with CHICKEN, I believe you end up with .so files, so there=E2=80=99s probably no need for propagat= ion? Not sure actually. > + #:use-module (ice-9 string-fun) Uh, first time I see this one (!). Maybe add #:select to clarify why it=E2=80=99s used for. > +(define %eggs-home-page > + (make-parameter "https://api.call-cc.org/5/doc")) On IRC, Mario suggested that a better value may be "https://wiki.call-cc.org/egg/". > +(define (get-eggs-repository) > + "Update or fetch the latest version of the eggs repository and return = the path > +to the repository." > + (let*-values (((url) "git://code.call-cc.org/eggs-5-latest") > + ((directory commit _) > + (update-cached-checkout url))) > + directory)) I=E2=80=99d call it =E2=80=98eggs-repository=E2=80=99 (without =E2=80=98get= -=E2=80=99). Also, I recommend using srfi-71 instead of srfi-11 in new code. > +(define (find-latest-version name) > + "Get the latest version of the egg NAME." > + (let ((directory (scandir (egg-directory name)))) > + (if directory > + (last directory) > + (begin > + (format #t (G_ "Package not found in eggs repository: ~a~%") n= ame) > + #f)))) This should be rendered with =E2=80=98warning=E2=80=99 from (guix diagnosti= cs). Or maybe it should be raised as a =E2=80=98formatted-message=E2=80=99 excep= tion? > +(define (get-metadata port) > + "Parse the egg metadata from PORT." > + (let ((content (read port))) > + (close-port port) > + content)) > + > +(define (egg-metadata name) > + "Return the package metadata file for the egg NAME." > + (let ((version (find-latest-version name))) > + (if version > + (get-metadata (open-file > + (string-append (egg-directory name) "/" > + version "/" name ".egg") > + "r")) > + #f))) Rather: (call-with-input-file (string-append =E2=80=A6) read) =E2=80=A6 and you can remove =E2=80=98get-metadata=E2=80=99. > +(define (guix-name->egg-name name) > + "Return the CHICKEN egg name corresponding to the Guix package NAME." > + (if (string-prefix? package-name-prefix name) > + (substring name (string-length package-name-prefix)) > + name)) Use =E2=80=98string-drop=E2=80=99 instead of =E2=80=98substring=E2=80=99; I= find it slightly clearer. > +(define (guix-package->egg-name package) > + "Return the CHICKEN egg name of the Guix CHICKEN PACKAGE." > + (let ((upstream-name (assoc-ref > + (package-properties package) > + 'upstream-name)) > + (name (package-name package))) > + (if upstream-name > + upstream-name > + (guix-name->egg-name name)))) This can be simplified a bit: (define (guix-package->egg-name package) (or (assq-ref (package-properties package) 'upstream-name) (guix-name->egg-name (package-name package)))) > +(define (egg-package? package) > + "Check if PACKAGE is an CHICKEN egg package." > + (and (eq? (build-system-name (package-build-system package)) 'chicken) > + (string-prefix? package-name-prefix (package-name package)))) I suggest not relying on build system names; they=E2=80=99re just a debuggi= ng aid. Thus, replace the first =E2=80=98eq?=E2=80=99 with: (eq? (package-build-system package) chicken-build-system) > + (define (safe-append lst1 lst2) > + (match (list lst1 lst2) > + ((#f #f) #f) > + ((lst1 #f) lst1) > + ((#f lst2) lst2) > + (_ (append lst1 lst2)))) This looks like a weird interface. I=E2=80=99d simply ensure you always manipulate lists: empty lists or non-empty lists. > + (define egg-home-page > + (string-append (%eggs-home-page) "/" name)) > + > + (define egg-synopsis > + (let ((synopsis (assoc-ref egg-content 'synopsis))) > + (if (list? synopsis) > + (first synopsis) > + #f))) Rather: (match (assoc-ref egg-content 'synopsis) ((synopsis) synopsis) (_ #f)) > + (define egg-license > + (let ((license (assoc-ref egg-content 'license))) > + (if (list? license) > + ;; Multiple licenses are separated by `/'. > + (string->license (string-split (first license) #\/)) > + #f))) Just make it =E2=80=98egg-licenses=E2=80=99 (plural) since the =E2=80=98lic= ense=E2=80=99 field of can be a list, and then: (match (assoc-ref egg-content 'license) ((license) (map string->license (string-split license #\/))) (#f '())) > + (define (prettify-system-dependency name) > + (let ((name* (if (symbol? name) > + (symbol->string name) > + name))) > + ;; System dependecies sometimes have spaces and/or upper case Typo (=E2=80=9Cdependencies=E2=80=9D). > + ;; letters in them. > + ;; > + ;; There will probably still be some weird edge cases. > + (string-replace-substring (string-downcase name*) " " ""))) How about: (string-map (lambda (chr) (case chr ((#\space) #\-) (else chr))) (string-downcase name)) ? > + (define* (egg-parse-dependency name #:key (system? #f)) > + (let* ((name* (if (list? name) > + (first name) ; (name version) > + name)) > + (name (if system? > + (prettify-system-dependency name*) > + (maybe-symbol->string name*)))) Use =E2=80=98match=E2=80=99. > + (define egg-native-inputs > + (let* ((test-dependencies (assoc-ref egg-content > + 'test-dependencies)) > + (build-dependencies (assoc-ref egg-content > + 'build-dependencies)) > + (test+build-dependencies (safe-append > + test-dependencies > + build-dependencies))) > + (if (list? test+build-dependencies) > + (map egg-parse-dependency > + test+build-dependencies) > + '()))) Use =E2=80=98match=E2=80=99. Arrange so =E2=80=98test-dependencies=E2=80= =99 and =E2=80=98build-dependencies=E2=80=99 are always lists so you don=E2=80=99t need =E2=80=98safe-append=E2=80=99. Last, could you add files that contain translatable strings to =E2=80=98po/guix/POTFILES.in=E2=80=99? Otherwise LGTM. Could you send an updated patch? Thank you! Ludo=E2=80=99.