diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2023-12-02 12:04:23 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2023-12-04 22:26:36 +0100 |
| commit | 06b9c1260c72935806957bf302c40c1db6101a63 (patch) | |
| tree | 2db1f47c7085c947001719fee6cddfc5eb55ebc4 | |
| parent | d83d4488da5c3bb65867bffa2b8587a7c7b056cc (diff) | |
substitute: Do not exit when failing to find a nar.
Fixes <https://issues.guix.gnu.org/67575>.
* guix/scripts/substitute.scm (process-substitution/fallback): Use
‘report-error’ instead of ‘leave’. Write status line to PORT.
* tests/substitute.scm ("substitute, narinfo is available but nar is
missing"): Adjust accordingly.
Change-Id: Ic7297dbd563c007111ec2167c8d52505a07d4822
| -rwxr-xr-x | guix/scripts/substitute.scm | 5 | ||||
| -rw-r--r-- | tests/substitute.scm | 47 |
2 files changed, 28 insertions, 24 deletions
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm index 126f0f9c692..37cd08e2895 100755 --- a/guix/scripts/substitute.scm +++ b/guix/scripts/substitute.scm | |||
| @@ -635,8 +635,9 @@ way to download the nar." | |||
| 635 | (let loop ((cache-urls cache-urls)) | 635 | (let loop ((cache-urls cache-urls)) |
| 636 | (match cache-urls | 636 | (match cache-urls |
| 637 | (() | 637 | (() |
| 638 | (leave (G_ "failed to find alternative substitute for '~a'~%") | 638 | (report-error (G_ "failed to find alternative substitute for '~a'~%") |
| 639 | (narinfo-path narinfo))) | 639 | (narinfo-path narinfo)) |
| 640 | (display "not-found\n" port)) | ||
| 640 | ((cache-url rest ...) | 641 | ((cache-url rest ...) |
| 641 | (match (lookup-narinfos cache-url | 642 | (match (lookup-narinfos cache-url |
| 642 | (list (narinfo-path narinfo)) | 643 | (list (narinfo-path narinfo)) |
diff --git a/tests/substitute.scm b/tests/substitute.scm index 7246ed82d51..33a6d6040ae 100644 --- a/tests/substitute.scm +++ b/tests/substitute.scm | |||
| @@ -662,28 +662,31 @@ System: mips64el-linux\n"))) | |||
| 662 | (lambda () | 662 | (lambda () |
| 663 | (false-if-exception (delete-file "substitute-retrieved"))))))) | 663 | (false-if-exception (delete-file "substitute-retrieved"))))))) |
| 664 | 664 | ||
| 665 | (test-quit "substitute, narinfo is available but nar is missing" | 665 | (test-equal "substitute, narinfo is available but nar is missing" |
| 666 | "failed to find alternative substitute" | 666 | "not-found\n" |
| 667 | (with-narinfo* | 667 | (let ((port (open-output-string))) |
| 668 | (string-append %narinfo "Signature: " | 668 | (parameterize ((current-output-port port)) |
| 669 | (signature-field | 669 | (with-narinfo* |
| 670 | %narinfo | 670 | (string-append %narinfo "Signature: " |
| 671 | #:public-key %wrong-public-key)) | 671 | (signature-field |
| 672 | %main-substitute-directory | 672 | %narinfo |
| 673 | 673 | #:public-key %wrong-public-key)) | |
| 674 | (with-http-server `((200 ,(string-append %narinfo "Signature: " | 674 | %main-substitute-directory |
| 675 | (signature-field %narinfo))) | 675 | |
| 676 | (404 "Sorry, nar is missing!")) | 676 | (with-http-server `((200 ,(string-append %narinfo "Signature: " |
| 677 | (parameterize ((substitute-urls | 677 | (signature-field %narinfo))) |
| 678 | (list (%local-url) | 678 | (404 "Sorry, nar is missing!")) |
| 679 | (string-append "file://" | 679 | (parameterize ((substitute-urls |
| 680 | %main-substitute-directory)))) | 680 | (list (%local-url) |
| 681 | (delete-file (string-append %main-substitute-directory | 681 | (string-append "file://" |
| 682 | "/example.nar")) | 682 | %main-substitute-directory)))) |
| 683 | (request-substitution (string-append (%store-prefix) | 683 | (delete-file (string-append %main-substitute-directory |
| 684 | "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") | 684 | "/example.nar")) |
| 685 | "substitute-retrieved") | 685 | (request-substitution (string-append (%store-prefix) |
| 686 | (not (file-exists? "substitute-retrieved")))))) | 686 | "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-foo") |
| 687 | "substitute-retrieved") | ||
| 688 | (and (not (file-exists? "substitute-retrieved")) | ||
| 689 | (get-output-string port)))))))) | ||
| 687 | 690 | ||
| 688 | (test-equal "substitute, first narinfo is unsigned and has wrong hash" | 691 | (test-equal "substitute, first narinfo is unsigned and has wrong hash" |
| 689 | "Substitutable data." | 692 | "Substitutable data." |
