utils: Add helper for invoking programs.
* guix/build/utils.scm (invoke): New variable. Co-authored-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
		
							parent
							
								
									9491227dcb
								
							
						
					
					
						commit
						3f65c190d2
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -84,6 +84,7 @@
 | 
			
		|||
            fold-port-matches
 | 
			
		||||
            remove-store-references
 | 
			
		||||
            wrap-program
 | 
			
		||||
            invoke
 | 
			
		||||
 | 
			
		||||
            locale-category->string))
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -579,6 +580,15 @@ Where every <*-phase-name> is an expression evaluating to a symbol, and
 | 
			
		|||
    ((_ phases (add-after old-phase-name new-phase-name new-phase))
 | 
			
		||||
     (alist-cons-after old-phase-name new-phase-name new-phase phases))))
 | 
			
		||||
 | 
			
		||||
(define (invoke program . args)
 | 
			
		||||
  "Invoke PROGRAM with the given ARGS.  Raise an error if the exit
 | 
			
		||||
code is non-zero; otherwise return #t."
 | 
			
		||||
  (let ((status (apply system* program args)))
 | 
			
		||||
    (unless (zero? status)
 | 
			
		||||
      (error (format #f "program ~s exited with non-zero code" program)
 | 
			
		||||
             status))
 | 
			
		||||
    #t))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
;;;
 | 
			
		||||
;;; Text substitution (aka. sed).
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue