2015-10-21 05:11:25 -04:00
|
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
upstream: Replace 'input-changes' field by 'inputs'.
Returning the expected list of inputs rather than changes relative to
the current package definition is less ambiguous and offers more
possibilities for further processing.
* guix/upstream.scm (<upstream-source>)[input-changes]: Remove.
[inputs]: New field.
(<upstream-input>): New record type.
* guix/upstream.scm (upstream-input-type-predicate)
(input-type-filter, upstream-source-regular-inputs)
(upstream-source-native-inputs, upstream-source-propagated-inputs): New
procedures.
(changed-inputs): Expect an <upstream-source> as its second argument.
Adjust accordingly.
* guix/import/pypi.scm (distribution-sha256): New procedure.
(maybe-inputs): Expect a list of <upstream-input>.
(compute-inputs): Rewrite to return a list of <upstream-input>.
(pypi-package-inputs, pypi-package->upstream-source): New procedures.
(make-pypi-sexp): Use it.
* guix/import/stackage.scm (latest-lts-release): Define 'cabal'.
Replace 'input-changes' field by 'inputs'.
* guix/scripts/refresh.scm (update-package): Use 'changed-inputs'
instead of 'upstream-source-input-changes'.
* tests/cran.scm ("description->package"): Adjust order of inputs.
* tests/pypi.scm (default-sha256, default-sha256/base32): New variables.
(foo-json): Add 'digests' entry.
("pypi->guix-package, no wheel"): Check HASH against DEFAULT-SHA256/BASE32.
("pypi->guix-package, wheels"): Likewise.
("pypi->guix-package, no usable requirement file."): Likewise.
("pypi->guix-package, package name contains \"-\" followed by digits"):
Likewise.
("package-latest-release"): New test.
* tests/upstream.scm (test-package-sexp): Remove.
("changed-inputs returns no changes"): Rewrite to use <upstream-source>.
(test-new-package-sexp): Remove.
("changed-inputs returns changes to plain input list"): Rewrite.
("changed-inputs returns changes to all plain input lists"): Likewise.
("changed-inputs returns changes to labelled input list")
("changed-inputs returns changes to all labelled input lists"): Remove.
* guix/import/cran.scm (maybe-inputs): Expect PACKAGE-INPUTS to be a
list of <upstream-input>.
(source-dir->dependencies): Return a list of <upstream-input>.
(vignette-builders): Likewise.
(uri-helper, cran-package-source-url)
(cran-package-propagated-inputs, cran-package-inputs): New procedures.
(description->package): Use them instead of local definitions.
(latest-cran-release): Replace 'input-changes' field by 'inputs'.
(latest-bioconductor-release): Likewise.
(format-inputs): Remove.
* guix/import/hackage.scm (cabal-package-inputs): New procedure.
(hackage-module->sexp): Use it.
[maybe-inputs]: Expect a list of <upstream-input>.
2023-05-15 16:37:25 -04:00
|
|
|
|
;;; Copyright © 2010-2023 Ludovic Courtès <ludo@gnu.org>
|
2015-10-26 14:24:53 -04:00
|
|
|
|
;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
|
2024-02-19 05:44:47 -05:00
|
|
|
|
;;; Copyright © 2019, 2022-2024 Ricardo Wurmus <rekado@elephly.net>
|
2022-01-05 09:07:50 -05:00
|
|
|
|
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
|
|
|
|
|
;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
|
2022-06-24 16:36:38 -04:00
|
|
|
|
;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
|
2015-10-21 05:11:25 -04:00
|
|
|
|
;;;
|
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
|
;;; your option) any later version.
|
|
|
|
|
;;;
|
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
|
;;;
|
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
(define-module (guix upstream)
|
|
|
|
|
#:use-module (guix records)
|
|
|
|
|
#:use-module (guix utils)
|
2017-07-06 02:13:31 -04:00
|
|
|
|
#:use-module (guix discovery)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:use-module ((guix download)
|
2019-03-08 17:13:56 -05:00
|
|
|
|
#:select (download-to-store url-fetch))
|
2022-01-05 09:07:50 -05:00
|
|
|
|
#:use-module (guix git-download)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:use-module (guix gnupg)
|
|
|
|
|
#:use-module (guix packages)
|
2020-07-20 15:16:17 -04:00
|
|
|
|
#:use-module (guix diagnostics)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:use-module (guix ui)
|
|
|
|
|
#:use-module (guix base32)
|
2016-11-30 11:30:12 -05:00
|
|
|
|
#:use-module (guix gexp)
|
2022-01-05 09:07:50 -05:00
|
|
|
|
#:autoload (guix git) (latest-repository-commit git-reference->git-checkout)
|
|
|
|
|
#:use-module (guix hash)
|
2016-11-30 11:30:12 -05:00
|
|
|
|
#:use-module (guix store)
|
2021-01-07 04:00:50 -05:00
|
|
|
|
#:use-module ((guix derivations) #:select (built-derivations derivation->output-path))
|
2023-05-17 10:52:54 -04:00
|
|
|
|
#:autoload (guix read-print) (object->string*)
|
2021-01-07 04:00:50 -05:00
|
|
|
|
#:autoload (gcrypt hash) (port-sha256)
|
2016-11-30 11:30:12 -05:00
|
|
|
|
#:use-module (guix monads)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
|
#:use-module (srfi srfi-9)
|
|
|
|
|
#:use-module (srfi srfi-11)
|
|
|
|
|
#:use-module (srfi srfi-26)
|
2019-03-08 17:13:56 -05:00
|
|
|
|
#:use-module (srfi srfi-34)
|
|
|
|
|
#:use-module (srfi srfi-35)
|
2019-03-27 09:56:23 -04:00
|
|
|
|
#:use-module (rnrs bytevectors)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
|
#:export (upstream-source
|
|
|
|
|
upstream-source?
|
|
|
|
|
upstream-source-package
|
|
|
|
|
upstream-source-version
|
|
|
|
|
upstream-source-urls
|
|
|
|
|
upstream-source-signature-urls
|
2015-11-02 18:59:28 -05:00
|
|
|
|
upstream-source-archive-types
|
upstream: Replace 'input-changes' field by 'inputs'.
Returning the expected list of inputs rather than changes relative to
the current package definition is less ambiguous and offers more
possibilities for further processing.
* guix/upstream.scm (<upstream-source>)[input-changes]: Remove.
[inputs]: New field.
(<upstream-input>): New record type.
* guix/upstream.scm (upstream-input-type-predicate)
(input-type-filter, upstream-source-regular-inputs)
(upstream-source-native-inputs, upstream-source-propagated-inputs): New
procedures.
(changed-inputs): Expect an <upstream-source> as its second argument.
Adjust accordingly.
* guix/import/pypi.scm (distribution-sha256): New procedure.
(maybe-inputs): Expect a list of <upstream-input>.
(compute-inputs): Rewrite to return a list of <upstream-input>.
(pypi-package-inputs, pypi-package->upstream-source): New procedures.
(make-pypi-sexp): Use it.
* guix/import/stackage.scm (latest-lts-release): Define 'cabal'.
Replace 'input-changes' field by 'inputs'.
* guix/scripts/refresh.scm (update-package): Use 'changed-inputs'
instead of 'upstream-source-input-changes'.
* tests/cran.scm ("description->package"): Adjust order of inputs.
* tests/pypi.scm (default-sha256, default-sha256/base32): New variables.
(foo-json): Add 'digests' entry.
("pypi->guix-package, no wheel"): Check HASH against DEFAULT-SHA256/BASE32.
("pypi->guix-package, wheels"): Likewise.
("pypi->guix-package, no usable requirement file."): Likewise.
("pypi->guix-package, package name contains \"-\" followed by digits"):
Likewise.
("package-latest-release"): New test.
* tests/upstream.scm (test-package-sexp): Remove.
("changed-inputs returns no changes"): Rewrite to use <upstream-source>.
(test-new-package-sexp): Remove.
("changed-inputs returns changes to plain input list"): Rewrite.
("changed-inputs returns changes to all plain input lists"): Likewise.
("changed-inputs returns changes to labelled input list")
("changed-inputs returns changes to all labelled input lists"): Remove.
* guix/import/cran.scm (maybe-inputs): Expect PACKAGE-INPUTS to be a
list of <upstream-input>.
(source-dir->dependencies): Return a list of <upstream-input>.
(vignette-builders): Likewise.
(uri-helper, cran-package-source-url)
(cran-package-propagated-inputs, cran-package-inputs): New procedures.
(description->package): Use them instead of local definitions.
(latest-cran-release): Replace 'input-changes' field by 'inputs'.
(latest-bioconductor-release): Likewise.
(format-inputs): Remove.
* guix/import/hackage.scm (cabal-package-inputs): New procedure.
(hackage-module->sexp): Use it.
[maybe-inputs]: Expect a list of <upstream-input>.
2023-05-15 16:37:25 -04:00
|
|
|
|
upstream-source-inputs
|
|
|
|
|
|
|
|
|
|
upstream-input-type-predicate
|
|
|
|
|
upstream-source-regular-inputs
|
|
|
|
|
upstream-source-native-inputs
|
|
|
|
|
upstream-source-propagated-inputs
|
|
|
|
|
|
|
|
|
|
upstream-input
|
|
|
|
|
upstream-input?
|
|
|
|
|
upstream-input-name
|
|
|
|
|
upstream-input-downstream-name
|
|
|
|
|
upstream-input-type
|
|
|
|
|
upstream-input-min-version
|
|
|
|
|
upstream-input-max-version
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2020-07-03 16:45:21 -04:00
|
|
|
|
url-predicate
|
2017-09-25 11:34:26 -04:00
|
|
|
|
url-prefix-predicate
|
2015-10-21 05:11:25 -04:00
|
|
|
|
coalesce-sources
|
|
|
|
|
|
|
|
|
|
upstream-updater
|
|
|
|
|
upstream-updater?
|
|
|
|
|
upstream-updater-name
|
2015-10-26 14:24:53 -04:00
|
|
|
|
upstream-updater-description
|
2015-10-21 05:11:25 -04:00
|
|
|
|
upstream-updater-predicate
|
upstream-updater: Rename record field.
The next commits will make the functions, which are currently importing the
latest version of a package, change into importing the latest or a given
version of the package (for those updaters supporting specifying a version).
Thus the name ‘latest‘ is no longer appropriate.
* guix/upstream.scm (upstream-updater) Rename field [latest] to
[import]. (lookup-updater, package-latest-release) Adjust fieldname
accordingly.
* guix/gnu-maintenance.scm (%gnu-updater, %gnu-ftp-updater,
%savannah-updater, %sourceforge-updater, %xorg-updater,
%kernel.org-updater, %generic-html-updater),
guix/import/cpan.scm (%cpan-updater),
guix/import/cran.scm (%cran-updater, %bioconductor-updater),
guix/import/crate.scm (%crate-updater),
guix/import/egg.scm (%egg-updater),
guix/import/elpa.scm (%elpa-updater),
guix/import/gem.scm (%gem-updater),
guix/import/git.scm (%generic-git-updater),
guix/import/github.scm (%github-updater),
guix/import/gnome.scm (%gnome-updater),
guix/import/hackage.scm (%hackage-updater),
guix/import/hexpm.scm (%hexpm-updater),
guix/import/kde.scm (%kde-updater),
guix/import/launchpad.scm (%launchpad-updater),
guix/import/minetest.scm (%minetest-updater),
guix/import/opam.scm (%opam-updater),
guix/import/pypi.scm (%pypi-updater),
guix/import/stackage.scm (%stackage-updater),
tests/import-github.scm (found-sexp)
tests/transformations.scm ("options->transformation, with-latest"):
Adjust fieldname accordingly.
2022-08-27 07:05:33 -04:00
|
|
|
|
upstream-updater-import
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2017-07-06 02:13:31 -04:00
|
|
|
|
%updaters
|
2016-11-29 09:07:07 -05:00
|
|
|
|
lookup-updater
|
|
|
|
|
|
2015-10-21 05:11:25 -04:00
|
|
|
|
download-tarball
|
2022-11-11 06:25:52 -05:00
|
|
|
|
package-archive-type
|
2016-11-29 09:07:07 -05:00
|
|
|
|
package-latest-release
|
|
|
|
|
package-latest-release*
|
2015-10-21 05:11:25 -04:00
|
|
|
|
package-update
|
|
|
|
|
update-package-source))
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;;
|
|
|
|
|
;;; This module provides tools to represent and manipulate a upstream source
|
|
|
|
|
;;; code, and to auto-update package recipes.
|
|
|
|
|
;;;
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
;; Representation of upstream's source. There can be several URLs--e.g.,
|
|
|
|
|
;; tar.gz, tar.gz, etc. There can be correspond signature URLs, one per
|
|
|
|
|
;; source URL.
|
|
|
|
|
(define-record-type* <upstream-source>
|
|
|
|
|
upstream-source make-upstream-source
|
|
|
|
|
upstream-source?
|
|
|
|
|
(package upstream-source-package) ;string
|
|
|
|
|
(version upstream-source-version) ;string
|
2022-01-05 09:07:50 -05:00
|
|
|
|
(urls upstream-source-urls) ;list of strings|git-reference
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(signature-urls upstream-source-signature-urls ;#f | list of strings
|
2019-01-11 03:26:44 -05:00
|
|
|
|
(default #f))
|
upstream: Replace 'input-changes' field by 'inputs'.
Returning the expected list of inputs rather than changes relative to
the current package definition is less ambiguous and offers more
possibilities for further processing.
* guix/upstream.scm (<upstream-source>)[input-changes]: Remove.
[inputs]: New field.
(<upstream-input>): New record type.
* guix/upstream.scm (upstream-input-type-predicate)
(input-type-filter, upstream-source-regular-inputs)
(upstream-source-native-inputs, upstream-source-propagated-inputs): New
procedures.
(changed-inputs): Expect an <upstream-source> as its second argument.
Adjust accordingly.
* guix/import/pypi.scm (distribution-sha256): New procedure.
(maybe-inputs): Expect a list of <upstream-input>.
(compute-inputs): Rewrite to return a list of <upstream-input>.
(pypi-package-inputs, pypi-package->upstream-source): New procedures.
(make-pypi-sexp): Use it.
* guix/import/stackage.scm (latest-lts-release): Define 'cabal'.
Replace 'input-changes' field by 'inputs'.
* guix/scripts/refresh.scm (update-package): Use 'changed-inputs'
instead of 'upstream-source-input-changes'.
* tests/cran.scm ("description->package"): Adjust order of inputs.
* tests/pypi.scm (default-sha256, default-sha256/base32): New variables.
(foo-json): Add 'digests' entry.
("pypi->guix-package, no wheel"): Check HASH against DEFAULT-SHA256/BASE32.
("pypi->guix-package, wheels"): Likewise.
("pypi->guix-package, no usable requirement file."): Likewise.
("pypi->guix-package, package name contains \"-\" followed by digits"):
Likewise.
("package-latest-release"): New test.
* tests/upstream.scm (test-package-sexp): Remove.
("changed-inputs returns no changes"): Rewrite to use <upstream-source>.
(test-new-package-sexp): Remove.
("changed-inputs returns changes to plain input list"): Rewrite.
("changed-inputs returns changes to all plain input lists"): Likewise.
("changed-inputs returns changes to labelled input list")
("changed-inputs returns changes to all labelled input lists"): Remove.
* guix/import/cran.scm (maybe-inputs): Expect PACKAGE-INPUTS to be a
list of <upstream-input>.
(source-dir->dependencies): Return a list of <upstream-input>.
(vignette-builders): Likewise.
(uri-helper, cran-package-source-url)
(cran-package-propagated-inputs, cran-package-inputs): New procedures.
(description->package): Use them instead of local definitions.
(latest-cran-release): Replace 'input-changes' field by 'inputs'.
(latest-bioconductor-release): Likewise.
(format-inputs): Remove.
* guix/import/hackage.scm (cabal-package-inputs): New procedure.
(hackage-module->sexp): Use it.
[maybe-inputs]: Expect a list of <upstream-input>.
2023-05-15 16:37:25 -04:00
|
|
|
|
(inputs upstream-source-inputs ;#f | list of <upstream-input>
|
|
|
|
|
(delayed) (default #f))) ;delayed because optional and costly
|
|
|
|
|
|
|
|
|
|
;; Representation of a dependency as expressed by upstream.
|
|
|
|
|
(define-record-type* <upstream-input>
|
|
|
|
|
upstream-input make-upstream-input
|
|
|
|
|
upstream-input?
|
|
|
|
|
(name upstream-input-name) ;upstream package name
|
|
|
|
|
(downstream-name upstream-input-downstream-name) ;Guix package name
|
|
|
|
|
(type upstream-input-type ;'regular | 'native | 'propagated
|
|
|
|
|
(default 'regular))
|
|
|
|
|
(min-version upstream-input-min-version
|
|
|
|
|
(default 'any))
|
|
|
|
|
(max-version upstream-input-max-version
|
|
|
|
|
(default 'any)))
|
|
|
|
|
|
|
|
|
|
(define (upstream-input-type-predicate type)
|
|
|
|
|
"Return a predicate that returns true when passed an <upstream-input> record
|
|
|
|
|
of the given TYPE (a symbol such as 'propagated)."
|
|
|
|
|
(lambda (source)
|
|
|
|
|
(eq? type (upstream-input-type source))))
|
|
|
|
|
|
|
|
|
|
(define (input-type-filter type)
|
|
|
|
|
"Return a procedure that, given an <upstream-source>, returns the subset of
|
|
|
|
|
its inputs that have the given TYPE (a symbol such as 'native)."
|
|
|
|
|
(lambda (source)
|
|
|
|
|
"Return the subset of inputs of SOURCE that have the given TYPE."
|
|
|
|
|
(filter (lambda (input)
|
|
|
|
|
(eq? type (upstream-input-type input)))
|
|
|
|
|
(upstream-source-inputs source))))
|
|
|
|
|
|
|
|
|
|
(define upstream-source-regular-inputs (input-type-filter 'regular))
|
|
|
|
|
(define upstream-source-native-inputs (input-type-filter 'native))
|
|
|
|
|
(define upstream-source-propagated-inputs (input-type-filter 'propagated))
|
2019-01-11 03:26:44 -05:00
|
|
|
|
|
2020-07-03 16:45:21 -04:00
|
|
|
|
(define* (url-predicate matching-url?)
|
|
|
|
|
"Return a predicate that returns true when passed a package whose source is
|
|
|
|
|
an <origin> with the URL-FETCH method, and one of its URLs passes
|
|
|
|
|
MATCHING-URL?."
|
2017-09-25 11:34:26 -04:00
|
|
|
|
(lambda (package)
|
|
|
|
|
(match (package-source package)
|
|
|
|
|
((? origin? origin)
|
2020-07-03 16:45:21 -04:00
|
|
|
|
(and (eq? (origin-method origin) url-fetch)
|
|
|
|
|
(match (origin-uri origin)
|
|
|
|
|
((? string? url)
|
|
|
|
|
(matching-url? url))
|
|
|
|
|
(((? string? urls) ...)
|
|
|
|
|
(any matching-url? urls))
|
|
|
|
|
(_
|
|
|
|
|
#f))))
|
2017-09-25 11:34:26 -04:00
|
|
|
|
(_ #f))))
|
|
|
|
|
|
2020-07-03 16:45:21 -04:00
|
|
|
|
(define (url-prefix-predicate prefix)
|
|
|
|
|
"Return a predicate that returns true when passed a package where one of its
|
|
|
|
|
source URLs starts with PREFIX."
|
|
|
|
|
(url-predicate (cut string-prefix? prefix <>)))
|
|
|
|
|
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(define (upstream-source-archive-types release)
|
|
|
|
|
"Return the available types of archives for RELEASE---a list of strings such
|
|
|
|
|
as \"gz\" or \"xz\"."
|
|
|
|
|
(map file-extension (upstream-source-urls release)))
|
|
|
|
|
|
|
|
|
|
(define (coalesce-sources sources)
|
|
|
|
|
"Coalesce the elements of SOURCES, a list of <upstream-source>, that
|
|
|
|
|
correspond to the same version."
|
|
|
|
|
(define (same-version? r1 r2)
|
|
|
|
|
(string=? (upstream-source-version r1) (upstream-source-version r2)))
|
|
|
|
|
|
|
|
|
|
(define (release>? r1 r2)
|
|
|
|
|
(version>? (upstream-source-version r1) (upstream-source-version r2)))
|
|
|
|
|
|
|
|
|
|
(fold (lambda (release result)
|
|
|
|
|
(match result
|
|
|
|
|
((head . tail)
|
|
|
|
|
(if (same-version? release head)
|
|
|
|
|
(cons (upstream-source
|
|
|
|
|
(inherit release)
|
|
|
|
|
(urls (append (upstream-source-urls release)
|
|
|
|
|
(upstream-source-urls head)))
|
|
|
|
|
(signature-urls
|
2015-12-07 17:54:35 -05:00
|
|
|
|
(let ((one (upstream-source-signature-urls release))
|
2016-03-09 09:08:00 -05:00
|
|
|
|
(two (upstream-source-signature-urls head)))
|
2015-12-07 17:54:35 -05:00
|
|
|
|
(and one two (append one two)))))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
tail)
|
|
|
|
|
(cons release result)))
|
|
|
|
|
(()
|
|
|
|
|
(list release))))
|
|
|
|
|
'()
|
|
|
|
|
(sort sources release>?)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;
|
|
|
|
|
;;; Auto-update.
|
|
|
|
|
;;;
|
|
|
|
|
|
2015-10-26 14:24:53 -04:00
|
|
|
|
(define-record-type* <upstream-updater>
|
|
|
|
|
upstream-updater make-upstream-updater
|
2015-10-21 05:11:25 -04:00
|
|
|
|
upstream-updater?
|
2015-10-26 14:24:53 -04:00
|
|
|
|
(name upstream-updater-name)
|
|
|
|
|
(description upstream-updater-description)
|
|
|
|
|
(pred upstream-updater-predicate)
|
upstream-updater: Rename record field.
The next commits will make the functions, which are currently importing the
latest version of a package, change into importing the latest or a given
version of the package (for those updaters supporting specifying a version).
Thus the name ‘latest‘ is no longer appropriate.
* guix/upstream.scm (upstream-updater) Rename field [latest] to
[import]. (lookup-updater, package-latest-release) Adjust fieldname
accordingly.
* guix/gnu-maintenance.scm (%gnu-updater, %gnu-ftp-updater,
%savannah-updater, %sourceforge-updater, %xorg-updater,
%kernel.org-updater, %generic-html-updater),
guix/import/cpan.scm (%cpan-updater),
guix/import/cran.scm (%cran-updater, %bioconductor-updater),
guix/import/crate.scm (%crate-updater),
guix/import/egg.scm (%egg-updater),
guix/import/elpa.scm (%elpa-updater),
guix/import/gem.scm (%gem-updater),
guix/import/git.scm (%generic-git-updater),
guix/import/github.scm (%github-updater),
guix/import/gnome.scm (%gnome-updater),
guix/import/hackage.scm (%hackage-updater),
guix/import/hexpm.scm (%hexpm-updater),
guix/import/kde.scm (%kde-updater),
guix/import/launchpad.scm (%launchpad-updater),
guix/import/minetest.scm (%minetest-updater),
guix/import/opam.scm (%opam-updater),
guix/import/pypi.scm (%pypi-updater),
guix/import/stackage.scm (%stackage-updater),
tests/import-github.scm (found-sexp)
tests/transformations.scm ("options->transformation, with-latest"):
Adjust fieldname accordingly.
2022-08-27 07:05:33 -04:00
|
|
|
|
(import upstream-updater-import))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2017-07-06 02:13:31 -04:00
|
|
|
|
(define (importer-modules)
|
|
|
|
|
"Return the list of importer modules."
|
|
|
|
|
(cons (resolve-interface '(guix gnu-maintenance))
|
|
|
|
|
(all-modules (map (lambda (entry)
|
|
|
|
|
`(,entry . "guix/import"))
|
2018-03-26 17:42:59 -04:00
|
|
|
|
%load-path)
|
|
|
|
|
#:warn warn-about-load-error)))
|
2017-07-06 02:13:31 -04:00
|
|
|
|
|
|
|
|
|
(define %updaters
|
2022-07-18 07:16:04 -04:00
|
|
|
|
;; The list of publically-known updaters, alphabetically sorted.
|
|
|
|
|
(delay
|
|
|
|
|
(sort (fold-module-public-variables (lambda (obj result)
|
|
|
|
|
(if (upstream-updater? obj)
|
|
|
|
|
(cons obj result)
|
|
|
|
|
result))
|
|
|
|
|
'()
|
|
|
|
|
(importer-modules))
|
|
|
|
|
(lambda (updater1 updater2)
|
|
|
|
|
(string<? (symbol->string (upstream-updater-name updater1))
|
|
|
|
|
(symbol->string (upstream-updater-name updater2)))))))
|
2017-07-06 02:13:31 -04:00
|
|
|
|
|
2021-01-07 04:00:50 -05:00
|
|
|
|
;; Tests need to mock this variable so mark it as "non-declarative".
|
|
|
|
|
(set! %updaters %updaters)
|
|
|
|
|
|
2021-01-06 12:37:52 -05:00
|
|
|
|
(define* (lookup-updater package
|
|
|
|
|
#:optional (updaters (force %updaters)))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
"Return an updater among UPDATERS that matches PACKAGE, or #f if none of
|
|
|
|
|
them matches."
|
2019-09-09 04:33:42 -04:00
|
|
|
|
(find (match-lambda
|
upstream-updater: Rename record field.
The next commits will make the functions, which are currently importing the
latest version of a package, change into importing the latest or a given
version of the package (for those updaters supporting specifying a version).
Thus the name ‘latest‘ is no longer appropriate.
* guix/upstream.scm (upstream-updater) Rename field [latest] to
[import]. (lookup-updater, package-latest-release) Adjust fieldname
accordingly.
* guix/gnu-maintenance.scm (%gnu-updater, %gnu-ftp-updater,
%savannah-updater, %sourceforge-updater, %xorg-updater,
%kernel.org-updater, %generic-html-updater),
guix/import/cpan.scm (%cpan-updater),
guix/import/cran.scm (%cran-updater, %bioconductor-updater),
guix/import/crate.scm (%crate-updater),
guix/import/egg.scm (%egg-updater),
guix/import/elpa.scm (%elpa-updater),
guix/import/gem.scm (%gem-updater),
guix/import/git.scm (%generic-git-updater),
guix/import/github.scm (%github-updater),
guix/import/gnome.scm (%gnome-updater),
guix/import/hackage.scm (%hackage-updater),
guix/import/hexpm.scm (%hexpm-updater),
guix/import/kde.scm (%kde-updater),
guix/import/launchpad.scm (%launchpad-updater),
guix/import/minetest.scm (%minetest-updater),
guix/import/opam.scm (%opam-updater),
guix/import/pypi.scm (%pypi-updater),
guix/import/stackage.scm (%stackage-updater),
tests/import-github.scm (found-sexp)
tests/transformations.scm ("options->transformation, with-latest"):
Adjust fieldname accordingly.
2022-08-27 07:05:33 -04:00
|
|
|
|
(($ <upstream-updater> name description pred import)
|
2019-09-09 04:33:42 -04:00
|
|
|
|
(pred package)))
|
|
|
|
|
updaters))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2021-01-06 12:37:52 -05:00
|
|
|
|
(define* (package-latest-release package
|
|
|
|
|
#:optional
|
2022-06-24 16:36:38 -04:00
|
|
|
|
(updaters (force %updaters))
|
|
|
|
|
#:key (version #f))
|
2016-04-14 15:40:20 -04:00
|
|
|
|
"Return an upstream source to update PACKAGE, a <package> object, or #f if
|
2021-04-04 16:44:41 -04:00
|
|
|
|
none of UPDATERS matches PACKAGE. When several updaters match PACKAGE, try
|
|
|
|
|
them until one of them returns an upstream source. It is the caller's
|
|
|
|
|
responsibility to ensure that the returned source is newer than the current
|
|
|
|
|
one."
|
|
|
|
|
(any (match-lambda
|
upstream-updater: Rename record field.
The next commits will make the functions, which are currently importing the
latest version of a package, change into importing the latest or a given
version of the package (for those updaters supporting specifying a version).
Thus the name ‘latest‘ is no longer appropriate.
* guix/upstream.scm (upstream-updater) Rename field [latest] to
[import]. (lookup-updater, package-latest-release) Adjust fieldname
accordingly.
* guix/gnu-maintenance.scm (%gnu-updater, %gnu-ftp-updater,
%savannah-updater, %sourceforge-updater, %xorg-updater,
%kernel.org-updater, %generic-html-updater),
guix/import/cpan.scm (%cpan-updater),
guix/import/cran.scm (%cran-updater, %bioconductor-updater),
guix/import/crate.scm (%crate-updater),
guix/import/egg.scm (%egg-updater),
guix/import/elpa.scm (%elpa-updater),
guix/import/gem.scm (%gem-updater),
guix/import/git.scm (%generic-git-updater),
guix/import/github.scm (%github-updater),
guix/import/gnome.scm (%gnome-updater),
guix/import/hackage.scm (%hackage-updater),
guix/import/hexpm.scm (%hexpm-updater),
guix/import/kde.scm (%kde-updater),
guix/import/launchpad.scm (%launchpad-updater),
guix/import/minetest.scm (%minetest-updater),
guix/import/opam.scm (%opam-updater),
guix/import/pypi.scm (%pypi-updater),
guix/import/stackage.scm (%stackage-updater),
tests/import-github.scm (found-sexp)
tests/transformations.scm ("options->transformation, with-latest"):
Adjust fieldname accordingly.
2022-08-27 07:05:33 -04:00
|
|
|
|
(($ <upstream-updater> name description pred import)
|
2021-04-04 16:44:41 -04:00
|
|
|
|
(and (pred package)
|
2022-06-24 16:36:38 -04:00
|
|
|
|
(import package #:version version))))
|
2021-04-04 16:44:41 -04:00
|
|
|
|
updaters))
|
2016-11-29 09:07:07 -05:00
|
|
|
|
|
2021-01-06 12:37:52 -05:00
|
|
|
|
(define* (package-latest-release* package
|
|
|
|
|
#:optional
|
|
|
|
|
(updaters (force %updaters)))
|
2016-11-29 09:07:07 -05:00
|
|
|
|
"Like 'package-latest-release', but ensure that the return source is newer
|
|
|
|
|
than that of PACKAGE."
|
|
|
|
|
(match (package-latest-release package updaters)
|
|
|
|
|
((and source ($ <upstream-source> name version))
|
|
|
|
|
(and (version>? version (package-version package))
|
|
|
|
|
source))
|
|
|
|
|
(_
|
|
|
|
|
#f)))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2016-11-30 11:30:12 -05:00
|
|
|
|
(define (uncompressed-tarball name tarball)
|
|
|
|
|
"Return a derivation that decompresses TARBALL."
|
|
|
|
|
(define (ref package)
|
|
|
|
|
(module-ref (resolve-interface '(gnu packages compression))
|
|
|
|
|
package))
|
|
|
|
|
|
|
|
|
|
(define compressor
|
|
|
|
|
(cond ((or (string-suffix? ".gz" tarball)
|
|
|
|
|
(string-suffix? ".tgz" tarball))
|
|
|
|
|
(file-append (ref 'gzip) "/bin/gzip"))
|
|
|
|
|
((string-suffix? ".bz2" tarball)
|
|
|
|
|
(file-append (ref 'bzip2) "/bin/bzip2"))
|
|
|
|
|
((string-suffix? ".xz" tarball)
|
|
|
|
|
(file-append (ref 'xz) "/bin/xz"))
|
|
|
|
|
((string-suffix? ".lz" tarball)
|
|
|
|
|
(file-append (ref 'lzip) "/bin/lzip"))
|
|
|
|
|
(else
|
|
|
|
|
(error "unknown archive type" tarball))))
|
|
|
|
|
|
|
|
|
|
(gexp->derivation (file-sans-extension name)
|
|
|
|
|
#~(begin
|
|
|
|
|
(copy-file #+tarball #+name)
|
|
|
|
|
(and (zero? (system* #+compressor "-d" #+name))
|
|
|
|
|
(copy-file #+(file-sans-extension name)
|
|
|
|
|
#$output)))))
|
|
|
|
|
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(define* (download-tarball store url signature-url
|
2023-05-17 10:19:20 -04:00
|
|
|
|
#:key (key-download 'interactive) key-server)
|
2015-10-21 05:11:25 -04:00
|
|
|
|
"Download the tarball at URL to the store; check its OpenPGP signature at
|
|
|
|
|
SIGNATURE-URL, unless SIGNATURE-URL is false. On success, return the tarball
|
2016-05-17 07:41:07 -04:00
|
|
|
|
file name; return #f on failure (network failure or authentication failure).
|
2023-05-17 10:19:20 -04:00
|
|
|
|
|
2016-05-17 07:41:07 -04:00
|
|
|
|
KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed
|
2023-05-17 10:19:20 -04:00
|
|
|
|
values: 'interactive' (default), 'always', and 'never'; KEY-SERVER specifies
|
|
|
|
|
the OpenPGP key server where the key should be looked up."
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(let ((tarball (download-to-store store url)))
|
|
|
|
|
(if (not signature-url)
|
|
|
|
|
tarball
|
2016-11-30 11:30:12 -05:00
|
|
|
|
(let* ((sig (download-to-store store signature-url))
|
|
|
|
|
|
|
|
|
|
;; Sometimes we get a signature over the uncompressed tarball.
|
|
|
|
|
;; In that case, decompress the tarball in the store so that we
|
|
|
|
|
;; can check the signature.
|
|
|
|
|
(data (if (string-prefix? (basename url)
|
|
|
|
|
(basename signature-url))
|
|
|
|
|
tarball
|
|
|
|
|
(run-with-store store
|
|
|
|
|
(mlet %store-monad ((drv (uncompressed-tarball
|
|
|
|
|
(basename url) tarball)))
|
|
|
|
|
(mbegin %store-monad
|
|
|
|
|
(built-derivations (list drv))
|
2019-12-20 15:49:43 -05:00
|
|
|
|
(return (derivation->output-path drv))))))))
|
|
|
|
|
(let-values (((status data)
|
2020-07-21 06:30:24 -04:00
|
|
|
|
(if sig
|
|
|
|
|
(gnupg-verify* sig data
|
2023-05-17 10:19:20 -04:00
|
|
|
|
#:server key-server
|
2020-07-21 06:30:24 -04:00
|
|
|
|
#:key-download key-download)
|
|
|
|
|
(values 'missing-signature data))))
|
2019-12-20 15:49:43 -05:00
|
|
|
|
(match status
|
|
|
|
|
('valid-signature
|
|
|
|
|
tarball)
|
2020-07-21 06:30:24 -04:00
|
|
|
|
('missing-signature
|
|
|
|
|
(warning (G_ "failed to download detached signature from ~a~%")
|
|
|
|
|
signature-url)
|
|
|
|
|
#f)
|
2019-12-20 15:49:43 -05:00
|
|
|
|
('invalid-signature
|
|
|
|
|
(warning (G_ "signature verification failed for '~a' (key: ~a)~%")
|
|
|
|
|
url data)
|
|
|
|
|
#f)
|
|
|
|
|
('missing-key
|
|
|
|
|
(warning (G_ "missing public key ~a for '~a'~%")
|
|
|
|
|
data url)
|
|
|
|
|
#f)))))))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2022-01-05 09:07:50 -05:00
|
|
|
|
(define (upstream-source-compiler/url-fetch source system)
|
|
|
|
|
"Lower SOURCE, an <upstream-source> pointing to a tarball, as a
|
|
|
|
|
fixed-output derivation that would fetch it, and verify its authenticity."
|
2021-01-07 04:00:50 -05:00
|
|
|
|
(mlet* %store-monad ((url -> (first (upstream-source-urls source)))
|
|
|
|
|
(signature
|
|
|
|
|
-> (and=> (upstream-source-signature-urls source)
|
|
|
|
|
first))
|
|
|
|
|
(tarball ((store-lift download-tarball) url signature)))
|
|
|
|
|
(unless tarball
|
|
|
|
|
(raise (formatted-message (G_ "failed to fetch source from '~a'")
|
|
|
|
|
url)))
|
|
|
|
|
|
|
|
|
|
;; Instead of returning TARBALL, return a fixed-output derivation that
|
|
|
|
|
;; would be able to re-download it. In practice, since TARBALL is already
|
|
|
|
|
;; in the store, no extra download will happen, but having the derivation
|
|
|
|
|
;; in store improves provenance tracking.
|
|
|
|
|
(let ((hash (call-with-input-file tarball port-sha256)))
|
|
|
|
|
(url-fetch url 'sha256 hash (store-path-package-name tarball)
|
|
|
|
|
#:system system))))
|
|
|
|
|
|
2022-01-05 09:07:50 -05:00
|
|
|
|
(define (upstream-source-compiler/git-fetch source system)
|
|
|
|
|
"Lower SOURCE, an <upstream-source> using git, as a fixed-output
|
|
|
|
|
derivation that would fetch it."
|
|
|
|
|
(mlet* %store-monad ((reference -> (upstream-source-urls source))
|
|
|
|
|
(checkout
|
|
|
|
|
(lower-object
|
|
|
|
|
(git-reference->git-checkout reference)
|
|
|
|
|
system)))
|
|
|
|
|
;; Like in 'upstream-source-compiler/url-fetch', return a fixed-output
|
|
|
|
|
;; derivation instead of CHECKOUT.
|
|
|
|
|
(git-fetch reference 'sha256
|
|
|
|
|
(file-hash* checkout #:recursive? #true #:select? (const #true))
|
|
|
|
|
(git-file-name (upstream-source-package source)
|
|
|
|
|
(upstream-source-version source))
|
|
|
|
|
#:system system)))
|
|
|
|
|
|
|
|
|
|
(define-gexp-compiler (upstream-source-compiler (source <upstream-source>)
|
|
|
|
|
system target)
|
|
|
|
|
"Download SOURCE, lower it as a fixed-output derivation that would fetch it,
|
|
|
|
|
and verify its authenticity if possible."
|
|
|
|
|
(if (git-reference? (upstream-source-urls source))
|
|
|
|
|
(upstream-source-compiler/git-fetch source system)
|
|
|
|
|
(upstream-source-compiler/url-fetch source system)))
|
|
|
|
|
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(define (find2 pred lst1 lst2)
|
|
|
|
|
"Like 'find', but operate on items from both LST1 and LST2. Return two
|
|
|
|
|
values: the item from LST1 and the item from LST2 that match PRED."
|
|
|
|
|
(let loop ((lst1 lst1) (lst2 lst2))
|
|
|
|
|
(match lst1
|
|
|
|
|
((head1 . tail1)
|
|
|
|
|
(match lst2
|
|
|
|
|
((head2 . tail2)
|
|
|
|
|
(if (pred head1 head2)
|
|
|
|
|
(values head1 head2)
|
|
|
|
|
(loop tail1 tail2)))))
|
|
|
|
|
(()
|
|
|
|
|
(values #f #f)))))
|
|
|
|
|
|
2022-11-11 06:25:52 -05:00
|
|
|
|
(define (package-archive-type package)
|
|
|
|
|
"If PACKAGE's source is a tarball or zip archive, return its archive type--a
|
|
|
|
|
string such as \"xz\". Otherwise return #f."
|
|
|
|
|
(match (and=> (package-source package) origin-actual-file-name)
|
|
|
|
|
(#f #f)
|
|
|
|
|
(file
|
|
|
|
|
(let ((extension (file-extension file)))
|
|
|
|
|
;; FILE might be "example-1.2-checkout", in which case we want to
|
|
|
|
|
;; ignore the extension.
|
|
|
|
|
(and (or (string-contains extension "z")
|
|
|
|
|
(string-contains extension "tar"))
|
|
|
|
|
extension)))))
|
|
|
|
|
|
2019-03-08 17:13:56 -05:00
|
|
|
|
(define* (package-update/url-fetch store package source
|
2023-05-17 10:19:20 -04:00
|
|
|
|
#:key key-download key-server)
|
2019-03-27 09:42:07 -04:00
|
|
|
|
"Return the version, tarball, and SOURCE, to update PACKAGE to
|
2019-03-08 17:13:56 -05:00
|
|
|
|
SOURCE, an <upstream-source>."
|
|
|
|
|
(match source
|
2019-03-27 09:42:07 -04:00
|
|
|
|
(($ <upstream-source> _ version urls signature-urls)
|
2019-03-08 17:13:56 -05:00
|
|
|
|
(let*-values (((archive-type)
|
2022-11-11 06:25:52 -05:00
|
|
|
|
(package-archive-type package))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
((url signature-url)
|
2019-08-17 16:50:58 -04:00
|
|
|
|
;; Try to find a URL that matches ARCHIVE-TYPE.
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(find2 (lambda (url sig-url)
|
2016-09-28 10:17:07 -04:00
|
|
|
|
;; Some URIs lack a file extension, like
|
|
|
|
|
;; 'https://crates.io/???/0.1/download'. In that
|
|
|
|
|
;; case, pick the first URL.
|
|
|
|
|
(or (not archive-type)
|
|
|
|
|
(string-suffix? archive-type url)))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
urls
|
|
|
|
|
(or signature-urls (circular-list #f)))))
|
2019-08-17 16:50:58 -04:00
|
|
|
|
;; If none of URLS matches ARCHIVE-TYPE, then URL is #f; in that case,
|
|
|
|
|
;; pick up the first element of URLS.
|
|
|
|
|
(let ((tarball (download-tarball store
|
|
|
|
|
(or url (first urls))
|
|
|
|
|
(and (pair? signature-urls)
|
|
|
|
|
(or signature-url
|
|
|
|
|
(first signature-urls)))
|
2023-05-17 10:19:20 -04:00
|
|
|
|
#:key-server key-server
|
2015-10-21 05:11:25 -04:00
|
|
|
|
#:key-download key-download)))
|
2019-03-27 09:42:07 -04:00
|
|
|
|
(values version tarball source))))))
|
2019-03-08 17:13:56 -05:00
|
|
|
|
|
2022-03-04 13:32:32 -05:00
|
|
|
|
|
2023-05-17 10:19:20 -04:00
|
|
|
|
(define* (package-update/git-fetch store package source
|
|
|
|
|
#:key key-download key-server)
|
2022-01-05 09:07:50 -05:00
|
|
|
|
"Return the version, checkout, and SOURCE, to update PACKAGE to
|
|
|
|
|
SOURCE, an <upstream-source>."
|
|
|
|
|
;; TODO: it would be nice to authenticate commits, e.g. with
|
|
|
|
|
;; "guix git authenticate" or a list of permitted signing keys.
|
|
|
|
|
(define ref (upstream-source-urls source)) ; a <git-reference>
|
|
|
|
|
(values (upstream-source-version source)
|
|
|
|
|
(latest-repository-commit
|
|
|
|
|
store
|
|
|
|
|
(git-reference-url ref)
|
|
|
|
|
#:ref `(tag-or-commit . ,(git-reference-commit ref))
|
|
|
|
|
#:recursive? (git-reference-recursive? ref))
|
|
|
|
|
source))
|
|
|
|
|
|
2019-03-08 17:13:56 -05:00
|
|
|
|
(define %method-updates
|
|
|
|
|
;; Mapping of origin methods to source update procedures.
|
2022-01-05 09:07:50 -05:00
|
|
|
|
`((,url-fetch . ,package-update/url-fetch)
|
|
|
|
|
(,git-fetch . ,package-update/git-fetch)))
|
2019-03-08 17:13:56 -05:00
|
|
|
|
|
2021-01-06 12:37:52 -05:00
|
|
|
|
(define* (package-update store package
|
|
|
|
|
#:optional (updaters (force %updaters))
|
2023-05-17 10:19:20 -04:00
|
|
|
|
#:key (version #f)
|
|
|
|
|
(key-download 'interactive) key-server)
|
2019-03-08 17:13:56 -05:00
|
|
|
|
"Return the new version, the file name of the new version tarball, and input
|
2022-06-15 17:01:26 -04:00
|
|
|
|
changes for PACKAGE; return #f (three values) when PACKAGE is up-to-date;
|
|
|
|
|
raise an error when the updater could not determine available releases.
|
2019-03-08 17:13:56 -05:00
|
|
|
|
KEY-DOWNLOAD specifies a download policy for missing OpenPGP keys; allowed
|
2022-12-27 16:53:10 -05:00
|
|
|
|
values: 'always', 'never', and 'interactive' (default).
|
|
|
|
|
|
|
|
|
|
When VERSION is specified, update PACKAGE to that version, even if that is a
|
|
|
|
|
downgrade."
|
2022-06-24 16:36:38 -04:00
|
|
|
|
(match (package-latest-release package updaters #:version version)
|
2019-03-08 17:13:56 -05:00
|
|
|
|
((? upstream-source? source)
|
2022-12-27 16:53:10 -05:00
|
|
|
|
(if (or (version>? (upstream-source-version source)
|
|
|
|
|
(package-version package))
|
|
|
|
|
(and version
|
|
|
|
|
(begin
|
|
|
|
|
(warning (package-location package)
|
|
|
|
|
(G_ "downgrading '~a' from ~a to ~a~%")
|
|
|
|
|
(package-name package)
|
|
|
|
|
(package-version package)
|
|
|
|
|
(upstream-source-version source))
|
|
|
|
|
#t)))
|
2022-06-15 17:01:26 -04:00
|
|
|
|
(let ((method (match (package-source package)
|
|
|
|
|
((? origin? origin)
|
|
|
|
|
(origin-method origin))
|
|
|
|
|
(_
|
|
|
|
|
#f))))
|
|
|
|
|
(match (assq method %method-updates)
|
|
|
|
|
(#f
|
|
|
|
|
(raise (make-compound-condition
|
|
|
|
|
(formatted-message (G_ "cannot download for \
|
2019-03-08 17:13:56 -05:00
|
|
|
|
this method: ~s")
|
2022-06-15 17:01:26 -04:00
|
|
|
|
method)
|
|
|
|
|
(condition
|
|
|
|
|
(&error-location
|
|
|
|
|
(location (package-location package)))))))
|
|
|
|
|
((_ . update)
|
|
|
|
|
(update store package source
|
2023-05-17 10:19:20 -04:00
|
|
|
|
#:key-server key-server
|
2022-06-15 17:01:26 -04:00
|
|
|
|
#:key-download key-download))))
|
|
|
|
|
(values #f #f #f)))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(#f
|
2022-07-01 10:24:03 -04:00
|
|
|
|
;; Warn rather than abort so that other updates can still take place.
|
2022-06-24 16:36:38 -04:00
|
|
|
|
(if version
|
|
|
|
|
(warning (G_ "updater failed to find release ~a@~a~%")
|
|
|
|
|
(package-name package) version)
|
|
|
|
|
(warning (G_ "updater failed to determine available releases for ~a~%")
|
|
|
|
|
(package-name package)))
|
2022-07-01 10:24:03 -04:00
|
|
|
|
(values #f #f #f))))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(define (update-package-inputs package source)
|
|
|
|
|
"Update the input fields of the definition of PACKAGE according to those
|
|
|
|
|
specified in SOURCE, an <upstream-source>."
|
|
|
|
|
(define (update-field field source-inputs package-inputs)
|
|
|
|
|
(define loc
|
|
|
|
|
(package-field-location package field))
|
|
|
|
|
|
|
|
|
|
(define new
|
|
|
|
|
(map (compose string->symbol upstream-input-downstream-name)
|
|
|
|
|
(source-inputs source)))
|
|
|
|
|
|
|
|
|
|
(define old
|
|
|
|
|
(match (package-inputs package)
|
|
|
|
|
(((labels (? package? packages)) ...)
|
2023-09-13 08:06:19 -04:00
|
|
|
|
labels
|
|
|
|
|
(map string->symbol labels))
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(_
|
|
|
|
|
'())))
|
|
|
|
|
|
|
|
|
|
(define unchanged?
|
|
|
|
|
(equal? new old))
|
|
|
|
|
|
|
|
|
|
(if (and loc (not unchanged?))
|
|
|
|
|
(edit-expression (location->source-properties
|
|
|
|
|
(absolute-location loc))
|
|
|
|
|
(lambda (str)
|
|
|
|
|
(object->string* `(list ,@new)
|
|
|
|
|
(location-column loc))))
|
|
|
|
|
(unless unchanged?
|
|
|
|
|
;; XXX: Bail out when FIELD isn't already present in the source.
|
|
|
|
|
;; TODO: Add the field if it's missing.
|
|
|
|
|
(warning (package-location package)
|
|
|
|
|
(G_ "~a: '~a' field not found; leaving it unchanged~%")
|
|
|
|
|
(package-name package) field)
|
|
|
|
|
(warning (package-location package)
|
|
|
|
|
(G_ "~a: expected '~a' value: ~s~%")
|
|
|
|
|
(package-name package) field new))))
|
|
|
|
|
|
2023-05-28 16:44:52 -04:00
|
|
|
|
(define (filtered-inputs source-inputs extra-property ignore-property)
|
|
|
|
|
;; Return a procedure that behaves like SOURCE-INPUTS but additionally
|
|
|
|
|
;; honors EXTRA-PROPERTY and IGNORE-PROPERTY from PACKAGE.
|
|
|
|
|
(lambda (source)
|
|
|
|
|
(let* ((inputs (source-inputs source))
|
|
|
|
|
(properties (package-properties package))
|
|
|
|
|
(ignore (or (assoc-ref properties ignore-property) '()))
|
|
|
|
|
(extra (or (assoc-ref properties extra-property) '())))
|
2024-02-19 05:44:47 -05:00
|
|
|
|
(sort
|
|
|
|
|
(append (if (null? ignore)
|
|
|
|
|
inputs
|
|
|
|
|
(remove (lambda (input)
|
|
|
|
|
(member (upstream-input-downstream-name input)
|
|
|
|
|
ignore))
|
|
|
|
|
inputs))
|
|
|
|
|
(map (lambda (name)
|
|
|
|
|
(upstream-input
|
|
|
|
|
(name name)
|
|
|
|
|
(downstream-name name)))
|
|
|
|
|
extra))
|
|
|
|
|
(lambda (a b)
|
|
|
|
|
(string-ci<? (upstream-input-downstream-name a)
|
|
|
|
|
(upstream-input-downstream-name b)))))))
|
2023-05-28 16:44:52 -04:00
|
|
|
|
|
|
|
|
|
(define regular-inputs
|
|
|
|
|
(filtered-inputs upstream-source-regular-inputs
|
|
|
|
|
'updater-extra-inputs
|
|
|
|
|
'updater-ignored-inputs))
|
|
|
|
|
(define native-inputs
|
|
|
|
|
(filtered-inputs upstream-source-native-inputs
|
|
|
|
|
'updater-extra-native-inputs
|
|
|
|
|
'updater-ignored-native-inputs))
|
|
|
|
|
(define propagated-inputs
|
|
|
|
|
(filtered-inputs upstream-source-propagated-inputs
|
|
|
|
|
'updater-extra-propagated-inputs
|
|
|
|
|
'updater-ignored-propagated-inputs))
|
|
|
|
|
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(for-each update-field
|
|
|
|
|
'(inputs native-inputs propagated-inputs)
|
2023-05-28 16:44:52 -04:00
|
|
|
|
(list regular-inputs
|
|
|
|
|
native-inputs
|
|
|
|
|
propagated-inputs)
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(list package-inputs
|
|
|
|
|
package-native-inputs
|
|
|
|
|
package-propagated-inputs)))
|
|
|
|
|
|
2019-03-27 09:56:23 -04:00
|
|
|
|
(define* (update-package-source package source hash)
|
|
|
|
|
"Modify the source file that defines PACKAGE to refer to SOURCE, an
|
|
|
|
|
<upstream-source> whose tarball has SHA256 HASH (a bytevector). Return the
|
|
|
|
|
new version string if an update was made, and #f otherwise."
|
|
|
|
|
(define (update-expression expr replacements)
|
|
|
|
|
;; Apply REPLACEMENTS to package expression EXPR, a string. REPLACEMENTS
|
|
|
|
|
;; must be a list of replacement pairs, either bytevectors or strings.
|
|
|
|
|
(fold (lambda (replacement str)
|
|
|
|
|
(match replacement
|
|
|
|
|
(((? bytevector? old-bv) . (? bytevector? new-bv))
|
|
|
|
|
(string-replace-substring
|
|
|
|
|
str
|
|
|
|
|
(bytevector->nix-base32-string old-bv)
|
|
|
|
|
(bytevector->nix-base32-string new-bv)))
|
|
|
|
|
((old . new)
|
|
|
|
|
(string-replace-substring str old new))))
|
|
|
|
|
expr
|
|
|
|
|
replacements))
|
2016-04-06 06:32:20 -04:00
|
|
|
|
|
|
|
|
|
(let ((name (package-name package))
|
2019-03-27 09:56:23 -04:00
|
|
|
|
(version (upstream-source-version source))
|
2016-04-06 06:32:20 -04:00
|
|
|
|
(version-loc (package-field-location package 'version)))
|
|
|
|
|
(if version-loc
|
|
|
|
|
(let* ((loc (package-location package))
|
|
|
|
|
(old-version (package-version package))
|
2020-05-21 18:24:35 -04:00
|
|
|
|
(old-hash (content-hash-value
|
|
|
|
|
(origin-hash (package-source package))))
|
2019-03-27 09:56:23 -04:00
|
|
|
|
(old-url (match (origin-uri (package-source package))
|
|
|
|
|
((? string? url) url)
|
2022-01-05 09:07:50 -05:00
|
|
|
|
((? git-reference? ref)
|
|
|
|
|
(git-reference-url ref))
|
2019-03-27 09:56:23 -04:00
|
|
|
|
(_ #f)))
|
|
|
|
|
(new-url (match (upstream-source-urls source)
|
2022-01-05 09:07:50 -05:00
|
|
|
|
((first _ ...) first)
|
|
|
|
|
((? git-reference? ref)
|
|
|
|
|
(git-reference-url ref))
|
|
|
|
|
(_ #f)))
|
|
|
|
|
(old-commit (match (origin-uri (package-source package))
|
|
|
|
|
((? git-reference? ref)
|
|
|
|
|
(git-reference-commit ref))
|
|
|
|
|
(_ #f)))
|
|
|
|
|
(new-commit (match (upstream-source-urls source)
|
|
|
|
|
((? git-reference? ref)
|
|
|
|
|
(git-reference-commit ref))
|
|
|
|
|
(_ #f)))
|
2016-04-06 06:32:20 -04:00
|
|
|
|
(file (and=> (location-file loc)
|
|
|
|
|
(cut search-path %load-path <>))))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(if file
|
2019-03-27 09:56:23 -04:00
|
|
|
|
;; Be sure to use absolute filename. Replace the URL directory
|
|
|
|
|
;; when OLD-URL is available; this is useful notably for
|
|
|
|
|
;; mirror://cpan/ URLs where the directory may change as a
|
|
|
|
|
;; function of the person who uploads the package. Note that
|
|
|
|
|
;; package definitions usually concatenate fragments of the URL,
|
|
|
|
|
;; which is why we only attempt to replace a subset of the URL.
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(let ((replacements `((,old-version . ,version)
|
2019-03-27 09:56:23 -04:00
|
|
|
|
(,old-hash . ,hash)
|
2022-01-05 09:07:50 -05:00
|
|
|
|
,@(if (and old-commit new-commit)
|
|
|
|
|
`((,old-commit . ,new-commit))
|
|
|
|
|
'())
|
2019-03-27 09:56:23 -04:00
|
|
|
|
,@(if (and old-url new-url)
|
|
|
|
|
`((,(dirname old-url) .
|
|
|
|
|
,(dirname new-url)))
|
|
|
|
|
'()))))
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(and (edit-expression (location->source-properties
|
|
|
|
|
(absolute-location loc))
|
2019-03-27 09:56:23 -04:00
|
|
|
|
(cut update-expression <> replacements))
|
2023-05-17 10:52:54 -04:00
|
|
|
|
(or (not (upstream-source-inputs source))
|
|
|
|
|
(update-package-inputs package source))
|
2019-03-27 09:56:23 -04:00
|
|
|
|
version))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(begin
|
ui: Rename '_' to 'G_'.
This avoids collisions with '_' when the latter is used as a 'match'
pattern for instance. See
<https://lists.gnu.org/archive/html/guix-devel/2017-04/msg00464.html>.
* guix/ui.scm: Rename '_' to 'G_'.
* po/guix/Makevars (XGETTEXT_OPTIONS): Adjust accordingly.
* build-aux/compile-all.scm (warnings): Remove 'format'.
* gnu/packages.scm,
gnu/services.scm,
gnu/services/shepherd.scm,
gnu/system.scm,
gnu/system/shadow.scm,
guix/gnupg.scm,
guix/http-client.scm,
guix/import/cpan.scm,
guix/import/elpa.scm,
guix/import/pypi.scm,
guix/nar.scm,
guix/scripts.scm,
guix/scripts/archive.scm,
guix/scripts/authenticate.scm,
guix/scripts/build.scm,
guix/scripts/challenge.scm,
guix/scripts/container.scm,
guix/scripts/container/exec.scm,
guix/scripts/copy.scm,
guix/scripts/download.scm,
guix/scripts/edit.scm,
guix/scripts/environment.scm,
guix/scripts/gc.scm,
guix/scripts/graph.scm,
guix/scripts/hash.scm,
guix/scripts/import.scm,
guix/scripts/import/cpan.scm,
guix/scripts/import/cran.scm,
guix/scripts/import/crate.scm,
guix/scripts/import/elpa.scm,
guix/scripts/import/gem.scm,
guix/scripts/import/gnu.scm,
guix/scripts/import/hackage.scm,
guix/scripts/import/nix.scm,
guix/scripts/import/pypi.scm,
guix/scripts/import/stackage.scm,
guix/scripts/lint.scm,
guix/scripts/offload.scm,
guix/scripts/pack.scm,
guix/scripts/package.scm,
guix/scripts/perform-download.scm,
guix/scripts/publish.scm,
guix/scripts/pull.scm,
guix/scripts/refresh.scm,
guix/scripts/size.scm,
guix/scripts/substitute.scm,
guix/scripts/system.scm,
guix/ssh.scm,
guix/upstream.scm: Use 'G_' instead of '_'. Most of this change was
obtained by running: "sed -i -e's/(_ "/(G_ "/g' `find -name \*.scm`".
2017-05-03 09:57:02 -04:00
|
|
|
|
(warning (G_ "~a: could not locate source file")
|
2015-10-21 05:11:25 -04:00
|
|
|
|
(location-file loc))
|
|
|
|
|
#f)))
|
2020-07-20 15:16:17 -04:00
|
|
|
|
(warning (package-location package)
|
|
|
|
|
(G_ "~a: no `version' field in source; skipping~%")
|
|
|
|
|
name))))
|
2015-10-21 05:11:25 -04:00
|
|
|
|
|
|
|
|
|
;;; upstream.scm ends here
|