Replace use of depreciated function 'tmpnam.

Fix command line argument nesting.
Update comment for usage at comment line.
This commit is contained in:
AAaronson 2021-05-04 12:04:13 +00:00
parent 389e355f91
commit 12d6628ba3

View File

@ -19,7 +19,7 @@
;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;; 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 <name> ... ) or (define (<name> ...) ...)
@ -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
(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))
tmpath))))
; Main function called when run at command line.
; Parses "nongnu/system/install.scm" for channel definition
@ -57,7 +62,7 @@
; 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)