From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id t3LQBOe/EWR2EQAASxT56A (envelope-from ) for ; Wed, 15 Mar 2023 13:53:59 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id eGcYA+e/EWTyLgEAauVa8A (envelope-from ) for ; Wed, 15 Mar 2023 13:53:59 +0100 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 81AD5FAE2 for ; Wed, 15 Mar 2023 13:53:58 +0100 (CET) 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+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1678884838; h=from:from:sender:sender:reply-to: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; bh=y2vgQzEGvcLSJpaSb532KCccq/Fmm0a6ey2GMQOvgsk=; b=RoaiI1ooGHt9kp1/Z+jyl1pjv2cA+oabgCpAsA/KLB5JRn28HRsCk0rbndKsyxpH5HCZ1q xoBMd0TramAtRj6k2aCdCJCWyuoiopXfKLlxop5oxz/vawsnHY8/3Wos7eOx0wECxJTgQF zaN/kFnMy0FoFLe7hkPIDlsC+mw+60bfR1lPeeU3L/rFjUeq+WWCCgLM78qfnDG8n4CQZi A5FDQZNDBLvNe558vvnqU/yO5f9EA08ASONAgiD8Tayp5uc5t/plDPa8/sCeG4K066NkF2 HT8Qd9sLR7kogQ0404hLehmzO7ji7fbZ5WAsSoSctg368ZyUZr3G7WqD2nklKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1678884838; a=rsa-sha256; cv=none; b=F0YFnijSnJNZCD+5bZPhhd9eH5+gZGRfnt0HJlvrErXQXkmu5eH/UZ3rVnQf8qzPBlFzjD 9akEJaVIy2wF/WxA8FvKv2ECGXCBkdRRt2qj0gmGvIbe2xERZtwNdxM/WKuAibgMZmmVtr HiwQptREnrKiq5h7Fmovub5rNJ17I8GoBA7N6Dc8xJzIsDARagM4J5+88PPl64e2lOwdpf RD4CXM80JaKpFh9n7DbrmCGZDv9crak9OaLH6gkyyHqvEr3HF0C0ZHtLe8UODpg5NNLxna lfpEGKl0vT9/Ux/4AfLl10PDVIrETEE1Rd2lmN1cwVyzJJlXM3K9WOG8xanbAw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcQc0-0003SB-OR; Wed, 15 Mar 2023 08:52:12 -0400 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 1pcQby-0003RC-I1 for guix-patches@gnu.org; Wed, 15 Mar 2023 08:52:10 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcQbv-00039j-L1 for guix-patches@gnu.org; Wed, 15 Mar 2023 08:52:09 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pcQbv-0001Zp-HP for guix-patches@gnu.org; Wed, 15 Mar 2023 08:52:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62202] [PATCH 10/21] import: juliahub: Add functions to parse the git repo for a git tag. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 15 Mar 2023 12:52:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62202 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 62202@debbugs.gnu.org Cc: ngraves@ngraves.fr Received: via spool by 62202-submit@debbugs.gnu.org id=B62202.16788847235982 (code B ref 62202); Wed, 15 Mar 2023 12:52:07 +0000 Received: (at 62202) by debbugs.gnu.org; 15 Mar 2023 12:52:03 +0000 Received: from localhost ([127.0.0.1]:39322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcQbq-0001YB-Rk for submit@debbugs.gnu.org; Wed, 15 Mar 2023 08:52:03 -0400 Received: from 8.mo584.mail-out.ovh.net ([188.165.33.112]:34987) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcQbj-0001X4-OO for 62202@debbugs.gnu.org; Wed, 15 Mar 2023 08:51:57 -0400 Received: from director6.ghost.mail-out.ovh.net (unknown [10.108.20.172]) by mo584.mail-out.ovh.net (Postfix) with ESMTP id 0570F22F69 for <62202@debbugs.gnu.org>; Wed, 15 Mar 2023 12:51:53 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-74llp (unknown [10.110.171.145]) by director6.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 44BFA1FE33; Wed, 15 Mar 2023 12:51:52 +0000 (UTC) Received: from ngraves.fr ([37.59.142.96]) by ghost-submission-6684bf9d7b-74llp with ESMTPSA id FMVkFWi/EWQrNhcA/ww3gA (envelope-from ); Wed, 15 Mar 2023 12:51:52 +0000 X-OVh-ClientIp: 81.67.140.142 Date: Wed, 15 Mar 2023 13:51:19 +0100 Message-Id: <20230315125130.23041-10-ngraves@ngraves.fr> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315125130.23041-1-ngraves@ngraves.fr> References: <20230315125130.23041-1-ngraves@ngraves.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 13792555337731597026 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvddvkedggeegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepudfggeejleevtdffjeetheffvedtheekieeuveehgffggfdthedtfeeigeehuedunecuffhomhgrihhnpehgihhthhhusghushgvrhgtohhnthgvnhhtrdgtohhmpdhjuhhlihgrhhhusgdrohhrghenucfkphepuddvjedrtddrtddruddpfeejrdehledrudegvddrleeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeeivddvtddvseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkeegpdhmohguvgepshhmthhpohhuth 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: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Migadu-Queue-Id: 81AD5FAE2 X-Spam-Score: -3.03 X-Migadu-Spam-Score: -3.03 X-Migadu-Scanner: scn0.migadu.com From: Nicolas Graves via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-TUID: 2g25r6WN/PAc --- guix/import/juliahub.scm | 62 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm index fc25ba1d42..5327e92325 100644 --- a/guix/import/juliahub.scm +++ b/guix/import/juliahub.scm @@ -26,6 +26,7 @@ (define-module (guix import juliahub) #:use-module (srfi srfi-9) #:use-module (srfi srfi-11) #:use-module (guix http-client) + #:use-module (guix git) #:use-module (guix import utils) #:use-module (guix import json) #:use-module (guix base32) @@ -38,6 +39,48 @@ (define-module (guix import juliahub) %juliahub-updater juliahub-recursive-import)) +;; Juliahub may be more up-to-date than the General registry or the actual git +;; tag (it seems around 6 hours pass between the time a commit is supplied to +;; JuliaRegistrator as a release, and the time Julia TagBot Github Action makes +;; the git tag). We have no simple way to get the commit of the latest-version. +;; Thus the best simple thing we can do is get the latest-git-version, and +;; import this version instead. We do this by parsing Package.toml in the General +;; registry, and then getting the refs of the git repo supplied by this +;; file. Parsing this file is also necessary if the package is in a subdir of a +;; git repository, because the information isn't present in Juliahub. +;; There's a last case where some Julia packages are not based on a particular +;; git tag, and where looking for the commit is tedious and artificial. In these +;; cases, we introduce the tree-commit which is available in the Versions.toml +;; file in the General repository. This is equivalent to a commit, since we have +;; a unique hash of the listing of files and directories, thus it can be used to +;; identify the state of a repository. + +(define %general-base-url + "https://raw.githubusercontent.com/JuliaRegistries/General/master/") + +(define (general-url package-name file) + (let ((folder (string-capitalize (string-take package-name 1)))) + (string-append + %general-base-url folder "/" package-name "/" file))) + +(define (ini-list->alist lst) + (match lst + ((attribute '= value ooo ...) + `((,attribute . ,value) ,@(ini-list->alist ooo))) + ('() + '()))) + +(define (ini-fetch url) + (let* ((port (http-fetch url #:text? #t)) + (ini-list (stream->list (port->stream port read)))) + (close-port port) + (ini-list->alist ini-list))) + +(define (latest-git-tag repo) + (let* ((last-ref (last (remote-refs repo #:tags? #t))) + (last-git-tag (last (string-split last-ref #\/)))) + (string-drop last-git-tag 1))) + ;; To update, see file sysimg.jl (define %julia-stdlibs (list "julia" @@ -194,14 +237,21 @@ (define (make-julia-sexp name source home-page synopsis description ((license) (license->symbol license)) (_ `(list ,@(map license->symbol licenses))))))) +;; TODO handle subdir case properly. + (define* (juliahub->guix-package package-name #:key version #:allow-other-keys) "Fetch the metadata for PACKAGE-NAME from juliahub.org, and return the `package' s-expression corresponding to that package, or #f on failure. Optionally include a VERSION string to fetch a specific version juliahub." - (let ((package (if version - (juliahub-fetch package-name version) - (juliahub-fetch package-name)))) + (let* ((package-toml (ini-fetch (general-url name "Package.toml"))) + (subdir (assoc-ref package-toml 'subdir)) + (tag (latest-git-tag (assoc-ref package-toml 'repo))) + (package (if version + (juliahub-fetch package-name version) + (if tag + (juliahub-fetch package-name tag) + (juliahub-fetch package-name))))) (if package (let-values (((source directory) (git->origin+dir @@ -233,13 +283,13 @@ (define* (juliahub->guix-package package-name (define (guix-package->juliahub-name package) (let* ((url (juliahub-package-url package)) - (git-name (car (last-pair (string-split url #\/)))) + (git-name (last (string-split url #\/))) (ungitted-name (if (string-suffix? ".git" git-name) (string-drop-right git-name 4) git-name)) (package-name (if (string-suffix? ".jl" ungitted-name) - (string-drop-right ungitted-name 4) - ungitted-name))) + (string-drop-right ungitted-name 4) + ungitted-name))) package-name)) (define* (import-release package #:key (version #f)) -- 2.39.2