packages: Gracefully report packages not found.
Fixes a thinko introduced in 1b846da8c3
that would lead to a backtrace when looking for an unknown package.
* gnu/packages.scm (%find-package): Correct logic when checking for
FALLBACK?.
			
			
This commit is contained in:
		
							parent
							
								
									95cd4971d0
								
							
						
					
					
						commit
						efb107e0cd
					
				
					 2 changed files with 12 additions and 1 deletions
				
			
		|  | @ -300,13 +300,15 @@ use NAME@VERSION instead~%"))) | ||||||
|     (_ |     (_ | ||||||
|      (if version |      (if version | ||||||
|          (leave (_ "~A: package not found for version ~a~%") name version) |          (leave (_ "~A: package not found for version ~a~%") name version) | ||||||
|          (or fallback? |          (if (not fallback?) | ||||||
|              ;; XXX: Fallback to the older specification style with an hyphen |              ;; XXX: Fallback to the older specification style with an hyphen | ||||||
|              ;; between NAME and VERSION, for backward compatibility. |              ;; between NAME and VERSION, for backward compatibility. | ||||||
|              (call-with-values |              (call-with-values | ||||||
|                  (lambda () |                  (lambda () | ||||||
|                    (hyphen-separated-name->name+version name)) |                    (hyphen-separated-name->name+version name)) | ||||||
|                (cut %find-package spec <> <> #:fallback? #t)) |                (cut %find-package spec <> <> #:fallback? #t)) | ||||||
|  | 
 | ||||||
|  |              ;; The fallback case didn't find anything either, so bail out. | ||||||
|              (leave (_ "~A: unknown package~%") name)))))) |              (leave (_ "~A: unknown package~%") name)))))) | ||||||
| 
 | 
 | ||||||
| (define (specification->package spec) | (define (specification->package spec) | ||||||
|  |  | ||||||
|  | @ -788,6 +788,15 @@ | ||||||
|                       (guix-package "-p" (derivation->output-path prof) |                       (guix-package "-p" (derivation->output-path prof) | ||||||
|                                     "--search-paths")))))) |                                     "--search-paths")))))) | ||||||
| 
 | 
 | ||||||
|  | (test-equal "specification->package when not found" | ||||||
|  |   'quit | ||||||
|  |   (catch 'quit | ||||||
|  |     (lambda () | ||||||
|  |       ;; This should call 'leave', producing an error message. | ||||||
|  |       (specification->package "this-package-does-not-exist")) | ||||||
|  |     (lambda (key . args) | ||||||
|  |       key))) | ||||||
|  | 
 | ||||||
| (test-end "packages") | (test-end "packages") | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  |  | ||||||
		Reference in a new issue