diff --git a/nongnu/system/build-image.scm b/nongnu/system/build-image.scm index 3e4b9e5..541ea0b 100644 --- a/nongnu/system/build-image.scm +++ b/nongnu/system/build-image.scm @@ -19,7 +19,7 @@ ;;; along with this program. If not, see . ;; Generate a bootable image with: -;; $ ./nongnu/system/build-image.scm +;; $ chmod +x build-image.scm && ./build-image.scm ; Searches through Scheme file for 'define and 'define* expressions ; such as (define ... ) or (define ( ...) ...) @@ -37,15 +37,20 @@ exp) (#t (next (read port)))))))) -; Writes channel-list to a tmpfile defined by (tmpnam) +; Writes channel-list to a tmpfile ; 'use-module is assumed to be needed, does not do anything if not used. TODO: remove assumption. +; TODO: get mkstemp! to work (result of using it was a blank file) (define (make-tmp-channel channel-list) - (let ((tmpath (tmpnam))) - (call-with-output-file tmpath - (lambda (port) - (write '(use-modules (guix ci)) port) - (write channel-list port))) - tmpath)) + (let loop ((tmpath (string-append "/tmp/guix-channel" + (number->string (random 1000000))))) + (cond ((file-exists? tmpath) + (loop (string-append "/tmp/guix-channel" + (number->string (random 1000000))))) + (#t (call-with-output-file tmpath + (lambda (port) + (write '(use-modules (guix ci)) port) + (write channel-list port))) + tmpath)))) ; Main function called when run at command line. ; Parses "nongnu/system/install.scm" for channel definition @@ -54,10 +59,10 @@ ; Performs a guix pull using tmpfile as channel file ; Deletes tmpfile ; Builds image (currently iso only) -; supports "--uncompressed" command line argument +; supports "--uncompressed" command line argument ; If "--roll-back" is used as an argument, reverts guix pull ; Returns #t if exit-code is 0, else returns #f -(define (build-image . args) +(define (build-image args) (let* ((image-type 'iso) ; todo: parse args for supported image types (image-label "nonguix-install") (channel-define-name '%channels)