From cb9d65923e0b7ccdecf173b73a43b77a7c3b020a Mon Sep 17 00:00:00 2001 From: Alex Griffin Date: Wed, 8 Jan 2020 15:21:44 -0600 Subject: [PATCH] utils: Add 'concatenate-files' function. * nonguix/build/utils.scm (concatenate-files): New function. --- nonguix/build/utils.scm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nonguix/build/utils.scm b/nonguix/build/utils.scm index b520769..a5442ea 100644 --- a/nonguix/build/utils.scm +++ b/nonguix/build/utils.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2019 Pierre Neidhardt +;;; Copyright © 2020 Alex Griffin ;;; ;;; This file is not part of GNU Guix. ;;; @@ -20,9 +21,11 @@ #:use-module (ice-9 match) #:use-module (ice-9 binary-ports) #:use-module (guix build utils) + #:use-module (srfi srfi-26) #:export (64-bit? make-desktop-entry-file - make-wrapper)) + make-wrapper + concatenate-files)) (define (64-bit? file) "Return true if ELF file is in 64-bit format, false otherwise. @@ -183,3 +186,15 @@ contents: (dirname real-file) (canonicalize-path real-file)))) (chmod wrapper #o755)) + +(define (concatenate-files files result) + "Make RESULT the concatenation of all of FILES." + (define (dump file port) + (put-bytevector + port + (call-with-input-file file + get-bytevector-all))) + + (call-with-output-file result + (lambda (port) + (for-each (cut dump <> port) files))))