From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id KCYICVzznWVKngAAkFu2QA (envelope-from ) for ; Wed, 10 Jan 2024 02:31:08 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id qE90AlzznWVY0wAA62LTzQ (envelope-from ) for ; Wed, 10 Jan 2024 02:31:08 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tilde.club header.s=mail header.b=vIF5zPZr; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=tilde.club (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704850267; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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:dkim-signature; bh=XTQAbiA+WfnhRcRyj+MYojLPeC0++mVDa+JoR/1MKGE=; b=uYS4tZprD1BN2le5ThMuz2UTpj+pvNLPcU7z/cLNd2QIvHcRJ/a3GxHfKl71WiQYo7QMjW EiMvty+DJAPcJ9kKNRM7W3lNBhLfeS89BamubNclzN2TEKlnozkiLvwtoZj5EEtmZosgVX gM9820nZTSYzLCa0UNnY8VyARFBZcsF9OZj+ciX1L4GxR4HNIj9pcGLTExSd/GGdm4H0Ms iKn8bIufoUERTgarmRhUSqBxiCRYIzC+TRdnlbyHPrCrHBix10dBaE21XwnJ5FxKYOTior Dz8h6nBFdIcL2uOMYXQGDWiyd3SpSvEx5ZfUH+kpRrLRZUjokN+X7E74JgVOjQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704850268; a=rsa-sha256; cv=none; b=OtR0DH1nd3X2hZGhp14n7bkIziOJwh7MLWWIJRctXUNlWWxocQbUQyX0ZJEpHqglMuif2g W2GMvVmPD62DbpBl9bI5jhnbLwoBdvLXfsbYV4UL5hAeelFIDlAmBV3SYU/m2py1WNOZim M3m+CbNaT/uBBVJxEZZ1geccqZU5TNcLfGdJupoVa/ygg+HEpLBDLDQ/108pSjYDs4JiNe i4rZP/yLxq1t9CNAdkqFwRsYKEyN3Lu1UQQszRrfhT4wNkIhAPls0rNoM1Ynw9w7SFpykz hzUk5AfbVWWB6wD95x6hVB79563wnZjkHZxk2RtITuYaXdXX/rM564XQkKVMuw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tilde.club header.s=mail header.b=vIF5zPZr; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=tilde.club (policy=none) 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 A017B12549 for ; Wed, 10 Jan 2024 02:31:07 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNNQo-0003Id-Aj; Tue, 09 Jan 2024 20:30:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNNQl-0003Gg-MN for guix-patches@gnu.org; Tue, 09 Jan 2024 20:30:55 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNNQl-0007al-Dx; Tue, 09 Jan 2024 20:30:55 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rNNQr-000205-Li; Tue, 09 Jan 2024 20:31:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68358] [PATCH] guix: import: cpan: add recursive References: <1607241d782b7dc97cc5775903c50a81ef3b39ec.1704847312.git.shinyzero0@tilde.club> In-Reply-To: <1607241d782b7dc97cc5775903c50a81ef3b39ec.1704847312.git.shinyzero0@tilde.club> Resent-From: "zero@fedora" Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Wed, 10 Jan 2024 01:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68358 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68358@debbugs.gnu.org Cc: "zero@fedora" , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 68358-submit@debbugs.gnu.org id=B68358.17048502233795 (code B ref 68358); Wed, 10 Jan 2024 01:31:01 +0000 Received: (at 68358) by debbugs.gnu.org; 10 Jan 2024 01:30:23 +0000 Received: from localhost ([127.0.0.1]:41408 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNNQF-0000yO-3b for submit@debbugs.gnu.org; Tue, 09 Jan 2024 20:30:23 -0500 Received: from tilde.club ([142.44.150.184]:49406 ident=postfix) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNNQD-0000sf-5c for 68358@debbugs.gnu.org; Tue, 09 Jan 2024 20:30:22 -0500 Received: from fedora.. (unknown [87.117.56.99]) by tilde.club (Postfix) with ESMTPA id F35B022559F04; Wed, 10 Jan 2024 01:30:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 tilde.club F35B022559F04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.club; s=mail; t=1704850212; bh=/bABb7eOMTNKiWwIePSkKmV0p4NXfZyx1vRNfBT2TuQ=; h=From:To:Cc:Subject:Date:From; b=vIF5zPZrEVTjf3Zww+Rh/L2raAvrLfbSufGfASBTHRvm/4EoQvuIoob+lPpe5JH04 X7clTPQoM5Y1pxFDb334C/qt9bKxk9TnZG62GqdxZ1TaIMmCxp/sXrvKYczL+hJ/m8 F+Vyw9BwDjwUe5JonR/Z1/9X5Hj0GHC70urIusy4= From: "zero@fedora" Date: Wed, 10 Jan 2024 04:29:56 +0300 Message-ID: <7a6b50a5af6f276034ffffcd24ad824fd52df35c.1704850195.git.shinyzero0@tilde.club> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -0.71 X-Spam-Score: -0.71 X-Migadu-Queue-Id: A017B12549 X-Migadu-Scanner: mx12.migadu.com X-TUID: PTNbEaY+8IEf * guix/import/cpan.scm: new function, some changes to make recursive import possible * guix/scripts/import/cpan.scm: add recursive import Change-Id: Id167c7ddd079f4e04650ce7cc1692a9de36cd8fe --- guix/import/cpan.scm | 63 ++++++++++++++++++++++-------------- guix/scripts/import/cpan.scm | 25 +++++++++++--- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm index b87736eef6..2090da275d 100644 --- a/guix/import/cpan.scm +++ b/guix/import/cpan.scm @@ -37,12 +37,13 @@ (define-module (guix import cpan) #:use-module (guix utils) #:use-module (guix base32) #:use-module ((guix download) #:select (download-to-store url-fetch)) - #:use-module ((guix import utils) #:select (factorize-uri)) + #:use-module (guix import utils) #:use-module (guix import json) #:use-module (guix packages) #:use-module (guix upstream) #:use-module (guix derivations) #:export (cpan->guix-package + cpan-recursive-import metacpan-url->mirror-url %cpan-updater @@ -284,35 +285,42 @@ (define (cpan-module->sexp release) upstream-input-downstream-name) inputs))))))) - (let ((tarball (with-store store + (let* ((tarball (with-store store (download-to-store store source-url))) - (inputs (cpan-module-inputs release))) - `(package - (name ,(cpan-name->downstream-name name)) - (version ,version) - (source (origin - (method url-fetch) - (uri (string-append ,@(factorize-uri source-url version))) - (sha256 - (base32 - ,(bytevector->nix-base32-string (file-sha256 tarball)))))) - (build-system perl-build-system) - ,@(maybe-inputs 'native-inputs - (filter (upstream-input-type-predicate 'native) - inputs)) - ,@(maybe-inputs 'propagated-inputs - (filter (upstream-input-type-predicate 'propagated) - inputs)) - (home-page ,(cpan-home name)) - (synopsis ,(cpan-release-abstract release)) - (description fill-in-yourself!) - (license ,(string->license (cpan-release-license release)))))) + (inputs (cpan-module-inputs release)) + (sexp + `(package + (name ,(cpan-name->downstream-name name)) + (version ,version) + (source (origin + (method url-fetch) + (uri (string-append ,@(factorize-uri source-url version))) + (sha256 + (base32 + ,(bytevector->nix-base32-string (file-sha256 tarball)))))) + (build-system perl-build-system) + ,@(maybe-inputs 'native-inputs + (filter (upstream-input-type-predicate 'native) + inputs)) + ,@(maybe-inputs 'propagated-inputs + (filter (upstream-input-type-predicate 'propagated) + inputs)) + (home-page ,(cpan-home name)) + (synopsis ,(cpan-release-abstract release)) + (description fill-in-yourself!) + (license ,(string->license (cpan-release-license release)))))) + (values + sexp + (map upstream-input-name inputs)) + )) -(define (cpan->guix-package module-name) +(define* (cpan->guix-package module-name #:key version #:allow-other-keys) "Fetch the metadata for PACKAGE-NAME from metacpan.org, and return the `package' s-expression corresponding to that package, or #f on failure." (let ((release (cpan-fetch (module->name module-name)))) - (and=> release cpan-module->sexp))) + (if release + (cpan-module->sexp release) + (values #f '())))) (define cpan-package? (let ((cpan-rx (make-regexp (string-append "(" @@ -357,6 +365,11 @@ (define* (latest-release package #:key (version #f)) (urls (list url)) (inputs (cpan-module-inputs release))))))) +(define* (cpan-recursive-import package-name) + (recursive-import package-name + #:repo->guix-package cpan->guix-package + #:guix-name (compose cpan-name->downstream-name module->name))) + (define %cpan-updater (upstream-updater (name 'cpan) diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm index bdf5a1e423..cab6424068 100644 --- a/guix/scripts/import/cpan.scm +++ b/guix/scripts/import/cpan.scm @@ -43,6 +43,9 @@ (define (show-help) Import and convert the CPAN package for PACKAGE-NAME.\n")) (display (G_ " -h, --help display this help and exit")) + (display (G_ " + -r, --recursive generate package expressions for all Gem packages\ + that are not yet in Guix")) (display (G_ " -V, --version display version information and exit")) (newline) @@ -54,6 +57,9 @@ (define %options (lambda args (show-help) (exit 0))) + (option '(#\r "recursive") #f #f + (lambda (opt name arg result) + (alist-cons 'recursive #t result))) (option '(#\V "version") #f #f (lambda args (show-version-and-exit "guix import cpan"))) @@ -78,11 +84,20 @@ (define (guix-import-cpan . args) (reverse opts)))) (match args ((package-name) - (let ((sexp (cpan->guix-package package-name))) - (unless sexp - (leave (G_ "failed to download meta-data for package '~a'~%") - package-name)) - sexp)) + (let ((sexp + (if (assoc-ref opts 'recursive) + (map (match-lambda + ((and ('package ('name name) . rest) pkg) + `(define-public ,(string->symbol name) + ,pkg)) + (_ #f)) + (cpan-recursive-import package-name)) + (let ((sexp (cpan->guix-package package-name))) + sexp)))) + (unless sexp + (leave (G_ "failed to download meta-data for package '~a'~%") + package-name)) + sexp)) (() (leave (G_ "too few arguments~%"))) ((many ...) base-commit: 931d893c550128591018587c90d2491fd66a11a4 -- 2.43.0