From 5461115e8fd9a3181506307b6090716a0d5c202c Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 17 Mar 2017 22:45:32 +0100 Subject: pack: Add '--target'. * guix/scripts/pack.scm (self-contained-tarball): Add #:target. (docker-image): Add #:target. [build]: Pass it to 'build-docker-image'. (%options, show-help): Add '--target'. (guix-pack): Pass TARGET to 'profile-derivation' and to 'build-image'. * guix/docker.scm (build-docker-image): Add #:system parameter and honor it. * doc/guix.texi (Invoking guix pack): Document '--target'. (Additional Build Options): Refer to the Autoconf manual instead of the obsolete 'configure.info' for cross-compilation. --- guix/scripts/pack.scm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'guix/scripts') diff --git a/guix/scripts/pack.scm b/guix/scripts/pack.scm index ce7613e4a0..626c592e1c 100644 --- a/guix/scripts/pack.scm +++ b/guix/scripts/pack.scm @@ -73,7 +73,8 @@ (define (lookup-compressor name) (leave (_ "~a: compressor not found~%") name))) (define* (self-contained-tarball name profile - #:key deduplicate? + #:key target + deduplicate? (compressor (first %compressors)) localstatedir? (symlinks '()) @@ -184,14 +185,17 @@ (define tar-supports-sort? #:references-graphs `(("profile" ,profile)))) (define* (docker-image name profile - #:key deduplicate? + #:key target + deduplicate? (compressor (first %compressors)) localstatedir? (symlinks '()) (tar tar)) "Return a derivation to construct a Docker image of PROFILE. The image is a tarball conforming to the Docker Image Specification, compressed -with COMPRESSOR. It can be passed to 'docker load'." +with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it +must a be a GNU triplet and it is used to derive the architecture metadata in +the image." ;; FIXME: Honor LOCALSTATEDIR?. (define not-config? (match-lambda @@ -227,6 +231,7 @@ (define build (setenv "PATH" (string-append #$tar "/bin")) (build-docker-image #$output #$profile + #:system (or #$target (utsname:machine (uname))) #:closure "profile" #:symlinks '#$symlinks #:compressor '#$(compressor-command compressor) @@ -278,6 +283,10 @@ (define %options (lambda (opt name arg result) (alist-cons 'system arg (alist-delete 'system result eq?)))) + (option '("target") #t #f + (lambda (opt name arg result) + (alist-cons 'target arg + (alist-delete 'target result eq?)))) (option '(#\C "compression") #t #f (lambda (opt name arg result) (alist-cons 'compressor (lookup-compressor arg) @@ -314,6 +323,8 @@ (define (show-help) -f, --format=FORMAT build a pack in the given FORMAT")) (display (_ " -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\"")) + (display (_ " + --target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\"")) (display (_ " -C, --compression=TOOL compress using TOOL--e.g., \"lzip\"")) (display (_ " @@ -354,6 +365,7 @@ (define opts (pack-format (assoc-ref opts 'format)) (name (string-append (symbol->string pack-format) "-pack")) + (target (assoc-ref opts 'target)) (compressor (assoc-ref opts 'compressor)) (symlinks (assoc-ref opts 'symlinks)) (build-image (match (assq-ref %formats pack-format) @@ -368,8 +380,11 @@ (define opts (run-with-store store (mlet* %store-monad ((profile (profile-derivation - (packages->manifest packages))) + (packages->manifest packages) + #:target target)) (drv (build-image name profile + #:target + target #:compressor compressor #:symlinks -- cgit v1.2.3