guix build: Factorize 'package-git-url'.
* guix/scripts/build.scm (package-git-url): New procedure. (evaluate-git-replacement-specs): Use it.
This commit is contained in:
parent
f258d88628
commit
0c0ff42a24
1 changed files with 14 additions and 9 deletions
|
@ -275,6 +275,19 @@ (define (replacement-pair old new)
|
||||||
(define %not-equal
|
(define %not-equal
|
||||||
(char-set-complement (char-set #\=)))
|
(char-set-complement (char-set #\=)))
|
||||||
|
|
||||||
|
(define (package-git-url package)
|
||||||
|
"Return the URL of the Git repository for package, or raise an error if
|
||||||
|
the source of PACKAGE is not fetched from a Git repository."
|
||||||
|
(let ((source (package-source package)))
|
||||||
|
(cond ((and (origin? source)
|
||||||
|
(git-reference? (origin-uri source)))
|
||||||
|
(git-reference-url (origin-uri source)))
|
||||||
|
((git-checkout? source)
|
||||||
|
(git-checkout-url source))
|
||||||
|
(else
|
||||||
|
(leave (G_ "the source of ~a is not a Git reference~%")
|
||||||
|
(package-full-name package))))))
|
||||||
|
|
||||||
(define (evaluate-git-replacement-specs specs proc)
|
(define (evaluate-git-replacement-specs specs proc)
|
||||||
"Parse SPECS, a list of strings like \"guile=stable-2.2\", and return a list
|
"Parse SPECS, a list of strings like \"guile=stable-2.2\", and return a list
|
||||||
of package pairs, where (PROC PACKAGE URL BRANCH-OR-COMMIT) returns the
|
of package pairs, where (PROC PACKAGE URL BRANCH-OR-COMMIT) returns the
|
||||||
|
@ -285,15 +298,7 @@ (define (evaluate-git-replacement-specs specs proc)
|
||||||
((name branch-or-commit)
|
((name branch-or-commit)
|
||||||
(let* ((old (specification->package name))
|
(let* ((old (specification->package name))
|
||||||
(source (package-source old))
|
(source (package-source old))
|
||||||
(url (cond ((and (origin? source)
|
(url (package-git-url old)))
|
||||||
(git-reference? (origin-uri source)))
|
|
||||||
(git-reference-url (origin-uri source)))
|
|
||||||
((git-checkout? source)
|
|
||||||
(git-checkout-url source))
|
|
||||||
(else
|
|
||||||
(leave (G_ "the source of ~a is not a Git \
|
|
||||||
reference~%")
|
|
||||||
(package-full-name old))))))
|
|
||||||
(cons old (proc old url branch-or-commit))))
|
(cons old (proc old url branch-or-commit))))
|
||||||
(x
|
(x
|
||||||
(leave (G_ "invalid replacement specification: ~s~%") spec))))
|
(leave (G_ "invalid replacement specification: ~s~%") spec))))
|
||||||
|
|
Loading…
Reference in a new issue