diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-09-06 23:14:07 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-09-06 23:22:10 +0200 |
| commit | 01afdab89c6a91f4cd05d3c4f4ff95a0402703eb (patch) | |
| tree | 7be146245b7b7053532f38476399e5b8f5b2f9c4 | |
| parent | 03763d6473bcd6c7a84bcc3a6aa7bc2d1ee1e44f (diff) | |
packages: Add 'package-superseded' and associated support.
This provides a way to mark a package as superseded by another one.
Upgrades replace superseded packages with their replacement.
* guix/packages.scm (package-superseded, deprecated-package): New
procedures.
* gnu/packages.scm (%find-package): Check for 'package-superseded'.
* guix/scripts/package.scm (transaction-upgrade-entry)[supersede]: New
procedure. Call it when 'package-superseded' is true.
* tests/guix-build.sh: Add test for a superseded package.
* tests/packages.scm ("package-superseded")
("transaction-upgrade-entry, superseded package"): New tests.
| -rw-r--r-- | gnu/packages.scm | 9 | ||||
| -rw-r--r-- | guix/packages.scm | 14 | ||||
| -rw-r--r-- | guix/scripts/package.scm | 46 | ||||
| -rw-r--r-- | tests/guix-build.sh | 6 | ||||
| -rw-r--r-- | tests/packages.scm | 30 |
5 files changed, 89 insertions, 16 deletions
diff --git a/gnu/packages.scm b/gnu/packages.scm index 68a9eef2ad9..5d60423a3ae 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm | |||
| @@ -305,7 +305,14 @@ return its return value." | |||
| 305 | (when fallback? | 305 | (when fallback? |
| 306 | (warning (_ "deprecated NAME-VERSION syntax; \ | 306 | (warning (_ "deprecated NAME-VERSION syntax; \ |
| 307 | use NAME@VERSION instead~%"))) | 307 | use NAME@VERSION instead~%"))) |
| 308 | pkg) | 308 | |
| 309 | (match (package-superseded pkg) | ||
| 310 | ((? package? new) | ||
| 311 | (info (_ "package '~a' has been superseded by '~a'~%") | ||
| 312 | (package-name pkg) (package-name new)) | ||
| 313 | new) | ||
| 314 | (#f | ||
| 315 | pkg))) | ||
| 309 | (_ | 316 | (_ |
| 310 | (if version | 317 | (if version |
| 311 | (leave (_ "~A: package not found for version ~a~%") name version) | 318 | (leave (_ "~A: package not found for version ~a~%") name version) |
diff --git a/guix/packages.scm b/guix/packages.scm index d544c34cf82..afbafc70a7a 100644 --- a/guix/packages.scm +++ b/guix/packages.scm | |||
| @@ -83,6 +83,8 @@ | |||
| 83 | package-location | 83 | package-location |
| 84 | hidden-package | 84 | hidden-package |
| 85 | hidden-package? | 85 | hidden-package? |
| 86 | package-superseded | ||
| 87 | deprecated-package | ||
| 86 | package-field-location | 88 | package-field-location |
| 87 | 89 | ||
| 88 | package-direct-sources | 90 | package-direct-sources |
| @@ -306,6 +308,18 @@ user interfaces, ignores." | |||
| 306 | interfaces." | 308 | interfaces." |
| 307 | (assoc-ref (package-properties p) 'hidden?)) | 309 | (assoc-ref (package-properties p) 'hidden?)) |
| 308 | 310 | ||
| 311 | (define (package-superseded p) | ||
| 312 | "Return the package the supersedes P, or #f if P is still current." | ||
| 313 | (assoc-ref (package-properties p) 'superseded)) | ||
| 314 | |||
| 315 | (define (deprecated-package old-name p) | ||
| 316 | "Return a package called OLD-NAME and marked as superseded by P, a package | ||
| 317 | object." | ||
| 318 | (package | ||
| 319 | (inherit p) | ||
| 320 | (name old-name) | ||
| 321 | (properties `((superseded . ,p))))) | ||
| 322 | |||
| 309 | (define (package-field-location package field) | 323 | (define (package-field-location package field) |
| 310 | "Return the source code location of the definition of FIELD for PACKAGE, or | 324 | "Return the source code location of the definition of FIELD for PACKAGE, or |
| 311 | #f if it could not be determined." | 325 | #f if it could not be determined." |
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index dc5fcba9221..b87aee0be91 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm | |||
| @@ -264,25 +264,41 @@ synopsis or description matches all of REGEXPS." | |||
| 264 | (define (transaction-upgrade-entry entry transaction) | 264 | (define (transaction-upgrade-entry entry transaction) |
| 265 | "Return a variant of TRANSACTION that accounts for the upgrade of ENTRY, a | 265 | "Return a variant of TRANSACTION that accounts for the upgrade of ENTRY, a |
| 266 | <manifest-entry>." | 266 | <manifest-entry>." |
| 267 | (define (supersede old new) | ||
| 268 | (info (_ "package '~a' has been superseded by '~a'~%") | ||
| 269 | (manifest-entry-name old) (package-name new)) | ||
| 270 | (manifest-transaction-install-entry | ||
| 271 | (package->manifest-entry new (manifest-entry-output old)) | ||
| 272 | (manifest-transaction-remove-pattern | ||
| 273 | (manifest-pattern | ||
| 274 | (name (manifest-entry-name old)) | ||
| 275 | (version (manifest-entry-version old)) | ||
| 276 | (output (manifest-entry-output old))) | ||
| 277 | transaction))) | ||
| 278 | |||
| 267 | (match entry | 279 | (match entry |
| 268 | (($ <manifest-entry> name version output (? string? path)) | 280 | (($ <manifest-entry> name version output (? string? path)) |
| 269 | (match (vhash-assoc name (find-newest-available-packages)) | 281 | (match (vhash-assoc name (find-newest-available-packages)) |
| 270 | ((_ candidate-version pkg . rest) | 282 | ((_ candidate-version pkg . rest) |
| 271 | (case (version-compare candidate-version version) | 283 | (match (package-superseded pkg) |
| 272 | ((>) | 284 | ((? package? new) |
| 273 | (manifest-transaction-install-entry | 285 | (supersede entry new)) |
| 274 | (package->manifest-entry pkg output) | 286 | (#f |
| 275 | transaction)) | 287 | (case (version-compare candidate-version version) |
| 276 | ((<) | 288 | ((>) |
| 277 | transaction) | 289 | (manifest-transaction-install-entry |
| 278 | ((=) | 290 | (package->manifest-entry pkg output) |
| 279 | (let ((candidate-path (derivation->output-path | 291 | transaction)) |
| 280 | (package-derivation (%store) pkg)))) | 292 | ((<) |
| 281 | (if (string=? path candidate-path) | 293 | transaction) |
| 282 | transaction | 294 | ((=) |
| 283 | (manifest-transaction-install-entry | 295 | (let ((candidate-path (derivation->output-path |
| 284 | (package->manifest-entry pkg output) | 296 | (package-derivation (%store) pkg)))) |
| 285 | transaction)))))) | 297 | (if (string=? path candidate-path) |
| 298 | transaction | ||
| 299 | (manifest-transaction-install-entry | ||
| 300 | (package->manifest-entry pkg output) | ||
| 301 | transaction)))))))) | ||
| 286 | (#f | 302 | (#f |
| 287 | transaction))))) | 303 | transaction))))) |
| 288 | 304 | ||
diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 6d4f97019ab..9e9788bca01 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh | |||
| @@ -93,6 +93,9 @@ cat > "$module_dir/foo.scm"<<EOF | |||
| 93 | (define-public baz | 93 | (define-public baz |
| 94 | (dummy-package "baz" (replacement foo))) | 94 | (dummy-package "baz" (replacement foo))) |
| 95 | 95 | ||
| 96 | (define-public superseded | ||
| 97 | (deprecated-package "superseded" bar)) | ||
| 98 | |||
| 96 | EOF | 99 | EOF |
| 97 | 100 | ||
| 98 | GUIX_PACKAGE_PATH="$module_dir" | 101 | GUIX_PACKAGE_PATH="$module_dir" |
| @@ -168,6 +171,9 @@ test "$drv1" = "$drv2" | |||
| 168 | if guix build guile --with-input=libunistring=something-really-silly | 171 | if guix build guile --with-input=libunistring=something-really-silly |
| 169 | then false; else true; fi | 172 | then false; else true; fi |
| 170 | 173 | ||
| 174 | # Deprecated/superseded packages. | ||
| 175 | test "`guix build superseded -d`" = "`guix build bar -d`" | ||
| 176 | |||
| 171 | # Parsing package names and versions. | 177 | # Parsing package names and versions. |
| 172 | guix build -n time # PASS | 178 | guix build -n time # PASS |
| 173 | guix build -n time@1.7 # PASS, version found | 179 | guix build -n time@1.7 # PASS, version found |
diff --git a/tests/packages.scm b/tests/packages.scm index 456e6919625..b8e1f111cd0 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -84,6 +84,15 @@ | |||
| 84 | (and (hidden-package? (hidden-package (dummy-package "foo"))) | 84 | (and (hidden-package? (hidden-package (dummy-package "foo"))) |
| 85 | (not (hidden-package? (dummy-package "foo"))))) | 85 | (not (hidden-package? (dummy-package "foo"))))) |
| 86 | 86 | ||
| 87 | (test-assert "package-superseded" | ||
| 88 | (let* ((new (dummy-package "bar")) | ||
| 89 | (old (deprecated-package "foo" new))) | ||
| 90 | (and (eq? (package-superseded old) new) | ||
| 91 | (mock ((gnu packages) find-best-packages-by-name (const (list old))) | ||
| 92 | (specification->package "foo") | ||
| 93 | (and (eq? new (specification->package "foo")) | ||
| 94 | (eq? new (specification->package+output "foo"))))))) | ||
| 95 | |||
| 87 | (test-assert "transaction-upgrade-entry, zero upgrades" | 96 | (test-assert "transaction-upgrade-entry, zero upgrades" |
| 88 | (let* ((old (dummy-package "foo" (version "1"))) | 97 | (let* ((old (dummy-package "foo" (version "1"))) |
| 89 | (tx (mock ((gnu packages) find-newest-available-packages | 98 | (tx (mock ((gnu packages) find-newest-available-packages |
| @@ -112,6 +121,27 @@ | |||
| 112 | (eq? item new))) | 121 | (eq? item new))) |
| 113 | (null? (manifest-transaction-remove tx))))) | 122 | (null? (manifest-transaction-remove tx))))) |
| 114 | 123 | ||
| 124 | (test-assert "transaction-upgrade-entry, superseded package" | ||
| 125 | (let* ((old (dummy-package "foo" (version "1"))) | ||
| 126 | (new (dummy-package "bar" (version "2"))) | ||
| 127 | (dep (deprecated-package "foo" new)) | ||
| 128 | (tx (mock ((gnu packages) find-newest-available-packages | ||
| 129 | (const (vhash-cons "foo" (list "2" dep) vlist-null))) | ||
| 130 | ((@@ (guix scripts package) transaction-upgrade-entry) | ||
| 131 | (manifest-entry | ||
| 132 | (inherit (package->manifest-entry old)) | ||
| 133 | (item (string-append (%store-prefix) "/" | ||
| 134 | (make-string 32 #\e) "-foo-1"))) | ||
| 135 | (manifest-transaction))))) | ||
| 136 | (and (match (manifest-transaction-install tx) | ||
| 137 | ((($ <manifest-entry> "bar" "2" "out" item)) | ||
| 138 | (eq? item new))) | ||
| 139 | (match (manifest-transaction-remove tx) | ||
| 140 | (((? manifest-pattern? pattern)) | ||
| 141 | (and (string=? (manifest-pattern-name pattern) "foo") | ||
| 142 | (string=? (manifest-pattern-version pattern) "1") | ||
| 143 | (string=? (manifest-pattern-output pattern) "out"))))))) | ||
| 144 | |||
| 115 | (test-assert "package-field-location" | 145 | (test-assert "package-field-location" |
| 116 | (let () | 146 | (let () |
| 117 | (define (goto port line column) | 147 | (define (goto port line column) |
