From 12d6628ba30bd85845588e87a92af60ff714d5fa Mon Sep 17 00:00:00 2001 From: AAaronson <6002905-Abcdefp@users.noreply.gitlab.com> Date: Tue, 4 May 2021 12:04:13 +0000 Subject: [PATCH] Replace use of depreciated function 'tmpnam. Fix command line argument nesting. Update comment for usage at comment line. --- nongnu/system/build-image.scm | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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)