mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-19 14:07:01 +01:00
import: composer: Implement recursive package refresh.
* guix/import/composer.scm (guix-package->composer-name): Simplify. (composer-fetch): Replace reduce by fold to correct version selection logic. (latest-release): Implement recursive package refresh. Rename to import-release. (import-release): New function, formerly known as latest-release. Change-Id: I8f629b4d1da866f5986d39b4e159f2b44af9ee49 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
parent
92e4c0a00d
commit
003366fc96
1 changed files with 21 additions and 13 deletions
|
@ -19,12 +19,14 @@
|
|||
(define-module (guix import composer)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (json)
|
||||
#:use-module (guix hash)
|
||||
#:use-module (guix base32)
|
||||
#:use-module (guix build git)
|
||||
#:use-module (guix build utils)
|
||||
#:use-module (guix build-system)
|
||||
#:use-module (guix build-system composer)
|
||||
#:use-module ((guix diagnostics) #:select (warning))
|
||||
#:use-module (guix hash)
|
||||
#:use-module (guix i18n)
|
||||
#:use-module (guix import json)
|
||||
#:use-module (guix import utils)
|
||||
#:use-module ((guix licenses) #:prefix license:)
|
||||
|
@ -113,7 +115,7 @@ (define* (composer-fetch name #:key (version #f))
|
|||
(if version
|
||||
(assoc-ref packages version)
|
||||
(cdr
|
||||
(reduce
|
||||
(fold
|
||||
(lambda (new cur-max)
|
||||
(match new
|
||||
(((? valid-version? version) . tail)
|
||||
|
@ -217,13 +219,8 @@ (define (guix-name->composer-name name)
|
|||
(define (guix-package->composer-name package)
|
||||
"Given a Composer PACKAGE built from Packagist, return the name of the
|
||||
package in Packagist."
|
||||
(let ((upstream-name (assoc-ref
|
||||
(package-properties package)
|
||||
'upstream-name))
|
||||
(name (package-name package)))
|
||||
(if upstream-name
|
||||
upstream-name
|
||||
(guix-name->composer-name name))))
|
||||
(or (assoc-ref (package-properties package) 'upstream-name)
|
||||
(guix-name->composer-name (package-name package))))
|
||||
|
||||
(define (string->license str)
|
||||
"Convert the string STR into a license object."
|
||||
|
@ -243,8 +240,14 @@ (define (php-package? package)
|
|||
(eq? (package-build-system package) composer-build-system)
|
||||
(string-prefix? "php-" (package-name package))))
|
||||
|
||||
(define* (latest-release package #:key (version #f))
|
||||
"Return an <upstream-source> for the latest release of PACKAGE."
|
||||
(define (dependency->input dependency type)
|
||||
(upstream-input
|
||||
(name dependency)
|
||||
(downstream-name (php-package-name dependency))
|
||||
(type type)))
|
||||
|
||||
(define* (import-release package #:key (version #f))
|
||||
"Return an <upstream-source> for VERSION or the latest release of PACKAGE."
|
||||
(let* ((php-name (guix-package->composer-name package))
|
||||
(composer-package (composer-fetch php-name #:version version)))
|
||||
(if composer-package
|
||||
|
@ -252,7 +255,12 @@ (define* (latest-release package #:key (version #f))
|
|||
(package (composer-package-name composer-package))
|
||||
(version (composer-package-version composer-package))
|
||||
(urls (list (composer-source-url
|
||||
(composer-package-source composer-package)))))
|
||||
(composer-package-source composer-package))))
|
||||
(inputs (append
|
||||
(map (cut dependency->input <> 'regular)
|
||||
(composer-package-require composer-package))
|
||||
(map (cut dependency->input <> 'native)
|
||||
(composer-package-dev-require composer-package)))))
|
||||
(begin
|
||||
(warning (G_ "failed to parse ~a~%") php-name)
|
||||
#f))))
|
||||
|
@ -262,7 +270,7 @@ (define %composer-updater
|
|||
(name 'composer)
|
||||
(description "Updater for Composer packages")
|
||||
(pred php-package?)
|
||||
(import latest-release)))
|
||||
(import import-release)))
|
||||
|
||||
(define* (composer-recursive-import package-name #:optional version)
|
||||
(recursive-import package-name
|
||||
|
|
Loading…
Reference in a new issue