import: Add updater for rust crates.
* guix/import/crate.scm (crate-package?, latest-release, %crate-updater): New variables. * guix/scripts/refresh.scm (%updaters): Add crate updater. * doc/guix.texi: Add crate updater to table.
This commit is contained in:
parent
3e0c036584
commit
8ac5298786
|
@ -5396,6 +5396,8 @@ the updater for @uref{https://rubygems.org, RubyGems} packages.
|
||||||
the updater for @uref{https://github.com, GitHub} packages.
|
the updater for @uref{https://github.com, GitHub} packages.
|
||||||
@item hackage
|
@item hackage
|
||||||
the updater for @uref{https://hackage.haskell.org, Hackage} packages.
|
the updater for @uref{https://hackage.haskell.org, Hackage} packages.
|
||||||
|
@item crate
|
||||||
|
the updater for @uref{https://crates.io, Crates} packages.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
For instance, the following command only checks for updates of Emacs
|
For instance, the following command only checks for updates of Emacs
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
#:use-module (srfi srfi-2)
|
#:use-module (srfi srfi-2)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:export (crate->guix-package
|
#:export (crate->guix-package
|
||||||
guix-package->crate-name))
|
guix-package->crate-name
|
||||||
|
%crate-updater))
|
||||||
|
|
||||||
(define (crate-fetch crate-name callback)
|
(define (crate-fetch crate-name callback)
|
||||||
"Fetch the metadata for CRATE-NAME from crates.io and call the callback."
|
"Fetch the metadata for CRATE-NAME from crates.io and call the callback."
|
||||||
|
@ -123,3 +124,36 @@ VERSION, INPUTS, NATIVE-INPUTS, HOME-PAGE, SYNOPSIS, DESCRIPTION, and LICENSE."
|
||||||
(define (crate-name->package-name name)
|
(define (crate-name->package-name name)
|
||||||
(string-append "rust-" (string-join (string-split name #\_) "-")))
|
(string-append "rust-" (string-join (string-split name #\_) "-")))
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; Updater
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(define (crate-package? package)
|
||||||
|
"Return true if PACKAGE is a Rust crate from crates.io."
|
||||||
|
(let ((source-url (and=> (package-source package) origin-uri))
|
||||||
|
(fetch-method (and=> (package-source package) origin-method)))
|
||||||
|
(and (eq? fetch-method download:url-fetch)
|
||||||
|
(match source-url
|
||||||
|
((? string?)
|
||||||
|
(crate-url? source-url))
|
||||||
|
((source-url ...)
|
||||||
|
(any crate-url? source-url))))))
|
||||||
|
|
||||||
|
(define (latest-release package)
|
||||||
|
"Return an <upstream-source> for the latest release of PACKAGE."
|
||||||
|
(let* ((crate-name (guix-package->crate-name package))
|
||||||
|
(callback (lambda* (#:key version #:allow-other-keys) version))
|
||||||
|
(version (crate-fetch crate-name callback))
|
||||||
|
(url (crate-uri crate-name version)))
|
||||||
|
(upstream-source
|
||||||
|
(package (package-name package))
|
||||||
|
(version version)
|
||||||
|
(urls (list url)))))
|
||||||
|
|
||||||
|
(define %crate-updater
|
||||||
|
(upstream-updater
|
||||||
|
(name 'crates)
|
||||||
|
(description "Updater for crates.io packages")
|
||||||
|
(pred crate-package?)
|
||||||
|
(latest latest-release)))
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,8 @@ unavailable optional dependencies such as Guile-JSON."
|
||||||
((guix import cpan) => %cpan-updater)
|
((guix import cpan) => %cpan-updater)
|
||||||
((guix import pypi) => %pypi-updater)
|
((guix import pypi) => %pypi-updater)
|
||||||
((guix import gem) => %gem-updater)
|
((guix import gem) => %gem-updater)
|
||||||
((guix import github) => %github-updater)))
|
((guix import github) => %github-updater)
|
||||||
|
((guix import crate) => %crate-updater)))
|
||||||
|
|
||||||
(define (lookup-updater-by-name name)
|
(define (lookup-updater-by-name name)
|
||||||
"Return the updater called NAME."
|
"Return the updater called NAME."
|
||||||
|
|
Loading…
Reference in New Issue