[PATCH v2 12/23] DRAFT import: juliahub: Add functions to parse the git repo for a git tag.

  • Done
  • quality assurance status badge
Details
One participant
  • Simon Tournier
Owner
unassigned
Submitted by
Simon Tournier
Severity
normal
Merged with

Debbugs page

Simon Tournier wrote 1 years ago
(address . 62202@debbugs.gnu.org)
e42032f4db1c8b76ff5ba94805deba47992a7c39.1695060058.git.zimon.toutoune@gmail.com
From: Nicolas Graves via Guix-patches via <guix-patches@gnu.org>

Signed-off-by: Simon Tournier <zimon.toutoune@gmail.com>
---
guix/import/juliahub.scm | 62 ++++++++++++++++++++++++++++++++++++----
1 file changed, 56 insertions(+), 6 deletions(-)

Toggle diff (105 lines)
diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm
index fc25ba1d4220..5327e923251d 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.38.1
Simon Tournier wrote 1 years ago
control message for bug #66083
(address . control@debbugs.gnu.org)
86v8c7mc88.fsf@gmail.com
close 66083
quit
Simon Tournier wrote 1 years ago
control message for bug #66075
(address . control@debbugs.gnu.org)
86a5tjmc4o.fsf@gmail.com
merge 66075 66089 66088 66087 66086 66085 66084 66083 66082
quit
Simon Tournier wrote 1 years ago
(address . control@debbugs.gnu.org)
868r93mc3w.fsf@gmail.com
merge 66075 66092 66091 66090
quit
?
Your comment

This issue is archived.

To comment on this conversation send an email to 66083@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 66083
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help