1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2018 Konrad Hinsen <konrad.hinsen@fastmail.net>
5 ;;; Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
6 ;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (guix scripts pack)
24 #:use-module (guix scripts)
25 #:use-module (guix ui)
26 #:use-module (guix gexp)
27 #:use-module (guix utils)
28 #:use-module (guix store)
29 #:use-module ((guix status) #:select (with-status-verbosity))
30 #:use-module (guix grafts)
31 #:autoload (guix inferior) (inferior-package?)
32 #:use-module (guix monads)
33 #:use-module (guix modules)
34 #:use-module (guix packages)
35 #:use-module (guix profiles)
36 #:use-module (guix describe)
37 #:use-module (guix derivations)
38 #:use-module (guix search-paths)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix scripts build)
41 #:use-module ((guix self) #:select (make-config.scm))
42 #:use-module (gnu packages)
43 #:use-module (gnu packages bootstrap)
44 #:use-module ((gnu packages compression) #:hide (zip))
45 #:use-module (gnu packages guile)
46 #:use-module (gnu packages base)
47 #:autoload (gnu packages package-management) (guix)
48 #:autoload (gnu packages gnupg) (guile-gcrypt)
49 #:autoload (gnu packages guile) (guile2.0-json guile-json)
50 #:use-module (srfi srfi-1)
51 #:use-module (srfi srfi-9)
52 #:use-module (srfi srfi-26)
53 #:use-module (srfi srfi-37)
54 #:use-module (ice-9 match)
57 self-contained-tarball
63 ;; Type of a compression tool.
64 (define-record-type <compressor>
65 (compressor name extension command)
67 (name compressor-name) ;string (e.g., "gzip")
68 (extension compressor-extension) ;string (e.g., ".lz")
69 (command compressor-command)) ;gexp (e.g., #~("/gnu/store/…/gzip" "-9n"))
72 ;; Available compression tools.
73 (list (compressor "gzip" ".gz"
74 #~(#+(file-append gzip "/bin/gzip") "-9n"))
75 (compressor "lzip" ".lz"
76 #~(#+(file-append lzip "/bin/lzip") "-9"))
77 (compressor "xz" ".xz"
78 #~(#+(file-append xz "/bin/xz") "-e"))
79 (compressor "bzip2" ".bz2"
80 #~(#+(file-append bzip2 "/bin/bzip2") "-9"))
81 (compressor "none" "" #f)))
83 ;; This one is only for use in this module, so don't put it in %compressors.
85 (compressor "bootstrap-xz" ".xz"
86 #~(#+(file-append %bootstrap-coreutils&co "/bin/xz") "-e")))
88 (define (lookup-compressor name)
89 "Return the compressor object called NAME. Error out if it could not be
91 (or (find (match-lambda
92 (($ <compressor> name*)
93 (string=? name* name)))
95 (leave (G_ "~a: compressor not found~%") name)))
98 ;; Select (guix …) and (gnu …) modules, except (guix config).
105 (define gcrypt-sqlite3&co
106 ;; Guile-Gcrypt, Guile-SQLite3, and their propagated inputs.
107 (append-map (lambda (package)
109 (match (package-transitive-propagated-inputs package)
110 (((labels packages) ...)
112 (list guile-gcrypt guile-sqlite3)))
114 (define (store-database items)
115 "Return a directory containing a store database where all of ITEMS and their
116 dependencies are registered."
118 (local-file (search-path %load-path
119 "guix/store/schema.sql")))
124 (string-append "closure" (number->string n)))
125 (iota (length items))))
128 (with-extensions gcrypt-sqlite3&co
129 (with-imported-modules (source-module-closure
130 '((guix build store-copy)
131 (guix store database)))
133 (use-modules (guix store database)
134 (guix build store-copy)
137 (define (read-closure closure)
138 (call-with-input-file closure read-reference-graph))
140 (let ((items (append-map read-closure '#$labels)))
141 (register-items items
142 #:state-directory #$output
144 #:reset-timestamps? #f
145 #:registration-time %epoch
146 #:schema #$schema))))))
148 (computed-file "store-database" build
149 #:options `(#:references-graphs ,(zip labels items))))
151 (define* (self-contained-tarball name profile
153 (profile-name "guix-profile")
156 (compressor (first %compressors))
160 "Return a self-contained tarball containing a store initialized with the
161 closure of PROFILE, a derivation. The tarball contains /gnu/store; if
162 LOCALSTATEDIR? is true, it also contains /var/guix, including /var/guix/db
163 with a properly initialized store database.
165 SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be
169 (file-append (store-database (list profile))
173 (with-imported-modules (source-module-closure
177 #:select? not-config?)
179 (use-modules (guix build utils)
180 ((guix build union) #:select (relative-file-name))
186 (define %root "root")
188 (define symlink->directives
189 ;; Return "populate directives" to make the given symlink and its
190 ;; parent directories.
193 (let ((target (string-append #$profile "/" target))
194 (parent (dirname source)))
195 ;; Never add a 'directory' directive for "/" so as to
196 ;; preserve its ownnership when extracting the archive (see
197 ;; below), and also because this would lead to adding the
198 ;; same entries twice in the tarball.
199 `(,@(if (string=? parent "/")
201 `((directory ,parent)))
203 -> ,(relative-file-name parent target)))))))
206 ;; Fully-qualified symlinks.
207 (append-map symlink->directives '#$symlinks))
209 ;; The --sort option was added to GNU tar in version 1.28, released
210 ;; 2014-07-28. For testing, we use the bootstrap tar, which is
211 ;; older and doesn't support it.
212 (define tar-supports-sort?
213 (zero? (system* (string-append #+archiver "/bin/tar")
214 "cf" "/dev/null" "--files-from=/dev/null"
217 ;; Add 'tar' to the search path.
218 (setenv "PATH" #+(file-append archiver "/bin"))
220 ;; Note: there is not much to gain here with deduplication and there
221 ;; is the overhead of the '.links' directory, so turn it off.
222 ;; Furthermore GNU tar < 1.30 sometimes fails to extract tarballs
224 ;; <http://lists.gnu.org/archive/html/bug-tar/2017-11/msg00009.html>.
225 (populate-single-profile-directory %root
227 #:profile-name #$profile-name
229 #:database #+database)
232 (for-each (cut evaluate-populate-directive <> %root)
235 ;; Create the tarball. Use GNU format so there's no file name
236 ;; length limitation.
237 (with-directory-excursion %root
239 (zero? (apply system* "tar"
240 #+@(if (compressor-command compressor)
243 '#+(compressor-command compressor)))
247 ;; Avoid non-determinism in the archive. Use
248 ;; mtime = 1, not zero, because that is what the
249 ;; daemon does for files in the store (see the
250 ;; 'mtimeStore' constant in local-store.cc.)
251 (if tar-supports-sort? "--sort=name" "--mtime=@1")
252 "--mtime=@1" ;for files in /var/guix
258 ;; Avoid adding / and /var to the tarball, so
259 ;; that the ownership and permissions of those
260 ;; directories will not be overwritten when
261 ;; extracting the archive. Do not include /root
262 ;; because the root account might have a
263 ;; different home directory.
264 #$@(if localstatedir?
268 (string-append "." (%store-directory))
271 (filter-map (match-lambda
272 (('directory directory)
273 (string-append "." directory))
275 (string-append "." source))
280 (warning (G_ "entry point not supported in the '~a' format~%")
283 (gexp->derivation (string-append name ".tar"
284 (compressor-extension compressor))
286 #:references-graphs `(("profile" ,profile))))
288 (define* (squashfs-image name profile
290 (profile-name "guix-profile")
291 (compressor (first %compressors))
295 (archiver squashfs-tools-next))
296 "Return a squashfs image containing a store initialized with the closure of
297 PROFILE, a derivation. The image contains a subset of /gnu/store, empty mount
298 points for virtual file systems (like procfs), and optional symlinks.
300 SYMLINKS must be a list of (SOURCE -> TARGET) tuples denoting symlinks to be
304 (file-append (store-database (list profile))
308 (with-imported-modules (source-module-closure
310 (guix build store-copy)
313 #:select? not-config?)
315 (use-modules (guix build utils)
316 (guix build store-copy)
317 ((guix build union) #:select (relative-file-name))
323 (define database #+database)
324 (define entry-point #$entry-point)
326 (setenv "PATH" (string-append #$archiver "/bin"))
328 ;; We need an empty file in order to have a valid file argument when
329 ;; we reparent the root file system. Read on for why that's
331 (with-output-to-file ".empty" (lambda () (display "")))
333 ;; Create the squashfs image in several steps.
334 ;; Add all store items. Unfortunately mksquashfs throws away all
335 ;; ancestor directories and only keeps the basename. We fix this
336 ;; in the following invocations of mksquashfs.
337 (apply invoke "mksquashfs"
338 `(,@(map store-info-item
339 (call-with-input-file "profile"
340 read-reference-graph))
343 ;; Do not perform duplicate checking because we
344 ;; don't have any dupes.
347 ,#+(compressor-name compressor)))
349 ;; Here we reparent the store items. For each sub-directory of
350 ;; the store prefix we need one invocation of "mksquashfs".
351 (for-each (lambda (dir)
352 (apply invoke "mksquashfs"
355 "-root-becomes" ,dir)))
356 (reverse (string-tokenize (%store-directory)
357 (char-set-complement (char-set #\/)))))
359 ;; Add symlinks and mount points.
360 (apply invoke "mksquashfs"
363 ;; Create SYMLINKS via pseudo file definitions.
367 ;; Create relative symlinks to work around a bug in
369 ;; https://bugs.gnu.org/34913
370 ;; https://github.com/sylabs/singularity/issues/1487
371 (let ((target (string-append #$profile "/" target)))
374 ;; name s mode uid gid symlink
377 (relative-file-name (dirname source)
381 ;; Create /.singularity.d/actions, and optionally the 'run'
382 ;; script, used by 'singularity run'.
383 "-p" "/.singularity.d d 555 0 0"
384 "-p" "/.singularity.d/actions d 555 0 0"
386 `(;; This one if for Singularity 2.x.
389 "/.singularity.d/actions/run s 777 0 0 "
390 (relative-file-name "/.singularity.d/actions"
391 (string-append #$profile "/"
394 ;; This one is for Singularity 3.x.
397 "/.singularity.d/runscript s 777 0 0 "
398 (relative-file-name "/.singularity.d"
399 (string-append #$profile "/"
403 ;; Create empty mount points.
404 "-p" "/proc d 555 0 0"
405 "-p" "/sys d 555 0 0"
406 "-p" "/dev d 555 0 0"
407 "-p" "/home d 555 0 0"))
410 ;; Initialize /var/guix.
411 (install-database-and-gc-roots "var-etc" database #$profile)
412 (invoke "mksquashfs" "var-etc" #$output)))))
414 (gexp->derivation (string-append name
415 (compressor-extension compressor)
418 #:references-graphs `(("profile" ,profile))))
420 (define* (docker-image name profile
422 (profile-name "guix-profile")
423 (compressor (first %compressors))
428 "Return a derivation to construct a Docker image of PROFILE. The
429 image is a tarball conforming to the Docker Image Specification, compressed
430 with COMPRESSOR. It can be passed to 'docker load'. If TARGET is true, it
431 must a be a GNU triplet and it is used to derive the architecture metadata in
435 (file-append (store-database (list profile))
438 (define defmod 'define-module) ;trick Geiser
441 ;; Guile-JSON and Guile-Gcrypt are required by (guix docker).
442 (with-extensions (list guile-json guile-gcrypt)
443 (with-imported-modules (source-module-closure '((guix docker)
444 (guix build store-copy))
445 #:select? not-config?)
447 (use-modules (guix docker) (srfi srfi-19) (guix build store-copy))
449 (setenv "PATH" (string-append #$archiver "/bin"))
451 (build-docker-image #$output
453 (call-with-input-file "profile"
454 read-reference-graph))
456 #:database #+database
457 #:system (or #$target (utsname:machine (uname)))
458 #:entry-point #$(and entry-point
459 #~(string-append #$profile "/"
461 #:symlinks '#$symlinks
462 #:compressor '#$(compressor-command compressor)
463 #:creation-time (make-time time-utc 0 1))))))
465 (gexp->derivation (string-append name ".tar"
466 (compressor-extension compressor))
468 #:references-graphs `(("profile" ,profile))))
472 ;;; Compiling C programs.
475 ;; A C compiler. That lowers to a single program that can be passed typical C
476 ;; compiler flags, and it makes sure the whole toolchain is available.
477 (define-record-type <c-compiler>
478 (%c-compiler toolchain guile)
480 (toolchain c-compiler-toolchain)
481 (guile c-compiler-guile))
483 (define* (c-compiler #:optional inputs
484 #:key (guile (default-guile)))
485 (%c-compiler inputs guile))
487 (define (bootstrap-c-compiler)
488 "Return the C compiler that uses the bootstrap toolchain. This is used only
489 by '--bootstrap', for testing purposes."
490 (define bootstrap-toolchain
491 (list (first (assoc-ref %bootstrap-inputs "gcc"))
492 (first (assoc-ref %bootstrap-inputs "binutils"))
493 (first (assoc-ref %bootstrap-inputs "libc"))))
495 (c-compiler bootstrap-toolchain
496 #:guile %bootstrap-guile))
498 (define-gexp-compiler (c-compiler-compiler (compiler <c-compiler>) system target)
499 "Lower COMPILER to a single script that does the right thing."
501 (or (c-compiler-toolchain compiler)
502 (list (first (assoc-ref (standard-packages) "gcc"))
503 (first (assoc-ref (standard-packages) "ld-wrapper"))
504 (first (assoc-ref (standard-packages) "binutils"))
505 (first (assoc-ref (standard-packages) "libc"))
506 (gexp-input (first (assoc-ref (standard-packages) "libc"))
510 (match (append-map package-propagated-inputs
511 (filter package? toolchain))
512 (((labels things . _) ...)
513 (append toolchain things))))
517 (append-map package-native-search-paths
518 (filter package? inputs))))
521 (with-imported-modules (source-module-closure
523 (guix search-paths)))
525 (use-modules (guix build utils) (guix search-paths)
528 (define (output-file args)
529 (let loop ((args args))
532 (("-o" file _ ...) file)
533 ((head rest ...) (loop rest)))))
535 (set-search-paths (map sexp->search-path-specification
536 '#$(map search-path-specification->sexp
540 (let ((output (output-file (command-line))))
541 (apply invoke "gcc" (cdr (command-line)))
542 (invoke "strip" output)))))
545 ;; TODO: Yep, we'll have to do it someday!
546 (leave (G_ "cross-compilation not implemented here;
547 please email '~a'~%")
548 (@ (guix config) %guix-bug-report-address)))
550 (gexp->script "c-compiler" run
551 #:guile (c-compiler-guile compiler)))
558 (define* (wrapped-package package
559 #:optional (compiler (c-compiler))
562 (local-file (search-auxiliary-file "run-in-namespace.c")))
565 (specification->package "proot-static"))
568 (with-imported-modules (source-module-closure
572 (use-modules (guix build utils)
573 ((guix build union) #:select (relative-file-name))
577 (define (strip-store-prefix file)
578 ;; Given a file name like "/gnu/store/…-foo-1.2/bin/foo", return
580 (let* ((len (string-length (%store-directory)))
581 (base (string-drop file (+ 1 len))))
582 (match (string-index base #\/)
584 (index (string-drop base index)))))
586 (define (build-wrapper program)
587 ;; Build a user-namespace wrapper for PROGRAM.
588 (format #t "building wrapper for '~a'...~%" program)
589 (copy-file #$runner "run.c")
592 (("@WRAPPED_PROGRAM@") program)
593 (("@STORE_DIRECTORY@") (%store-directory)))
595 (let* ((base (strip-store-prefix program))
596 (result (string-append #$output "/" base))
599 #$(file-append (proot) "/bin/proot")
600 (+ (string-length (%store-directory))
602 (mkdir-p (dirname result))
603 (apply invoke #$compiler "-std=gnu99" "-static" "-Os" "-g0" "-Wall"
606 (list (string-append "-DPROOT_PROGRAM=\""
609 (delete-file "run.c")))
611 (setvbuf (current-output-port) 'line)
613 ;; Link the top-level files of PACKAGE so that search paths are
614 ;; properly defined in PROFILE/etc/profile.
616 (for-each (lambda (file)
617 (unless (member file '("." ".." "bin" "sbin" "libexec"))
618 (let ((file* (string-append #$package "/" file)))
619 (symlink (relative-file-name #$output file*)
620 (string-append #$output "/" file)))))
623 (for-each build-wrapper
624 (append (find-files #$(file-append package "/bin"))
625 (find-files #$(file-append package "/sbin"))
626 (find-files #$(file-append package "/libexec")))))))
628 (computed-file (string-append
629 (cond ((package? package)
630 (package-full-name package "-"))
631 ((inferior-package? package)
632 (string-append (inferior-package-name package)
634 (inferior-package-version package)))
639 (define (map-manifest-entries proc manifest)
640 "Apply PROC to all the entries of MANIFEST and return a new manifest."
645 (item (proc (manifest-entry-item entry)))))
646 (manifest-entries manifest))))
650 ;;; Command-line options.
653 (define %default-options
654 ;; Alist of default option values.
656 (profile-name . "guix-profile")
657 (system . ,(%current-system))
661 (print-build-trace? . #t)
662 (print-extended-build-trace? . #t)
663 (multiplexed-build-output? . #t)
667 (compressor . ,(first %compressors))))
670 ;; Supported pack formats.
671 `((tarball . ,self-contained-tarball)
672 (squashfs . ,squashfs-image)
673 (docker . ,docker-image)))
675 (define (show-formats)
676 ;; Print the supported pack formats.
677 (display (G_ "The supported formats for 'guix pack' are:"))
680 tarball Self-contained tarball, ready to run on another machine"))
682 squashfs Squashfs image suitable for Singularity"))
684 docker Tarball ready for 'docker load'"))
688 ;; Specifications of the command-line options.
689 (cons* (option '(#\h "help") #f #f
693 (option '(#\V "version") #f #f
695 (show-version-and-exit "guix pack")))
697 (option '(#\n "dry-run") #f #f
698 (lambda (opt name arg result)
699 (alist-cons 'dry-run? #t (alist-cons 'graft? #f result))))
700 (option '(#\f "format") #t #f
701 (lambda (opt name arg result)
702 (alist-cons 'format (string->symbol arg) result)))
703 (option '("list-formats") #f #f
707 (option '(#\R "relocatable") #f #f
708 (lambda (opt name arg result)
709 (match (assq-ref result 'relocatable?)
711 (alist-cons 'relocatable? #t result))
713 (alist-cons 'relocatable? 'proot
714 (alist-delete 'relocatable? result))))))
715 (option '(#\e "expression") #t #f
716 (lambda (opt name arg result)
717 (alist-cons 'expression arg result)))
718 (option '(#\m "manifest") #t #f
719 (lambda (opt name arg result)
720 (alist-cons 'manifest arg result)))
721 (option '(#\s "system") #t #f
722 (lambda (opt name arg result)
723 (alist-cons 'system arg
724 (alist-delete 'system result eq?))))
725 (option '("entry-point") #t #f
726 (lambda (opt name arg result)
727 (alist-cons 'entry-point arg result)))
728 (option '("target") #t #f
729 (lambda (opt name arg result)
730 (alist-cons 'target arg
731 (alist-delete 'target result eq?))))
732 (option '(#\C "compression") #t #f
733 (lambda (opt name arg result)
734 (alist-cons 'compressor (lookup-compressor arg)
736 (option '(#\S "symlink") #t #f
737 (lambda (opt name arg result)
738 ;; Note: Using 'string-split' allows us to handle empty
739 ;; TARGET (as in "/opt/guile=", meaning that /opt/guile is
740 ;; a symlink to the profile) correctly.
741 (match (string-split arg (char-set #\=))
743 (let ((symlinks (assoc-ref result 'symlinks)))
744 (alist-cons 'symlinks
745 `((,source -> ,target) ,@symlinks)
746 (alist-delete 'symlinks result eq?))))
748 (leave (G_ "~a: invalid symlink specification~%")
750 (option '("save-provenance") #f #f
751 (lambda (opt name arg result)
752 (alist-cons 'save-provenance? #t result)))
753 (option '("localstatedir") #f #f
754 (lambda (opt name arg result)
755 (alist-cons 'localstatedir? #t result)))
756 (option '("profile-name") #t #f
757 (lambda (opt name arg result)
759 ((or "guix-profile" "current-guix")
760 (alist-cons 'profile-name arg result))
762 (leave (G_ "~a: unsupported profile name~%") arg)))))
763 (option '(#\r "root") #t #f
764 (lambda (opt name arg result)
765 (alist-cons 'gc-root arg result)))
767 (option '(#\v "verbosity") #t #f
768 (lambda (opt name arg result)
769 (let ((level (string->number* arg)))
770 (alist-cons 'verbosity level
771 (alist-delete 'verbosity result)))))
772 (option '("bootstrap") #f #f
773 (lambda (opt name arg result)
774 (alist-cons 'bootstrap? #t result)))
776 (append %transformation-options
777 %standard-build-options)))
780 (display (G_ "Usage: guix pack [OPTION]... PACKAGE...
781 Create a bundle of PACKAGE.\n"))
782 (show-build-options-help)
784 (show-transformation-options-help)
787 -f, --format=FORMAT build a pack in the given FORMAT"))
789 --list-formats list the formats available"))
791 -R, --relocatable produce relocatable executables"))
793 -e, --expression=EXPR consider the package EXPR evaluates to"))
795 -s, --system=SYSTEM attempt to build for SYSTEM--e.g., \"i686-linux\""))
797 --target=TRIPLET cross-build for TRIPLET--e.g., \"armel-linux-gnu\""))
799 -C, --compression=TOOL compress using TOOL--e.g., \"lzip\""))
801 -S, --symlink=SPEC create symlinks to the profile according to SPEC"))
803 -m, --manifest=FILE create a pack with the manifest from FILE"))
805 --entry-point=PROGRAM
806 use PROGRAM as the entry point of the pack"))
808 --save-provenance save provenance information"))
810 --localstatedir include /var/guix in the resulting pack"))
813 populate /var/guix/profiles/.../NAME"))
815 -r, --root=FILE make FILE a symlink to the result, and register it
816 as a garbage collector root"))
818 -v, --verbosity=LEVEL use the given verbosity LEVEL"))
820 --bootstrap use the bootstrap binaries to build the pack"))
823 -h, --help display this help and exit"))
825 -V, --version display version information and exit"))
827 (show-bug-report-information))
834 (define (guix-pack . args)
836 (parse-command-line args %options (list %default-options)))
838 (define maybe-package-argument
839 ;; Given an option pair, return a package, a package/output tuple, or #f.
844 (specification->package+output spec))
847 (read/eval-package-expression exp))
850 (define (manifest-from-args store opts)
851 (let* ((transform (options->transformation opts))
852 (packages (map (match-lambda
853 (((? package? package) output)
854 (list (transform store package) output))
855 ((? package? package)
856 (list (transform store package) "out")))
857 (filter-map maybe-package-argument opts)))
858 (manifest-file (assoc-ref opts 'manifest)))
860 (if (assoc-ref opts 'save-provenance?)
862 (match (package-provenance package)
864 (warning (G_ "could not determine provenance of package ~a~%")
865 (package-full-name package))
868 `((provenance . ,sexp)))))
872 ((and manifest-file (not (null? packages)))
873 (leave (G_ "both a manifest and a package list were given~%")))
875 (let ((user-module (make-user-module '((guix profiles) (gnu)))))
876 (load* manifest-file user-module)))
881 (package->manifest-entry package output
883 (properties package))))
888 (with-status-verbosity (assoc-ref opts 'verbosity)
889 ;; Set the build options before we do anything else.
890 (set-build-options-from-command-line store opts)
892 (parameterize ((%graft? (assoc-ref opts 'graft?))
893 (%guile-for-build (package-derivation
895 (if (assoc-ref opts 'bootstrap?)
897 (canonical-package guile-2.2))
898 (assoc-ref opts 'system)
899 #:graft? (assoc-ref opts 'graft?))))
900 (let* ((dry-run? (assoc-ref opts 'dry-run?))
901 (relocatable? (assoc-ref opts 'relocatable?))
902 (proot? (eq? relocatable? 'proot))
903 (manifest (let ((manifest (manifest-from-args store opts)))
904 ;; Note: We cannot honor '--bootstrap' here because
905 ;; 'glibc-bootstrap' lacks 'libc.a'.
907 (map-manifest-entries
908 (cut wrapped-package <> #:proot? proot?)
911 (pack-format (assoc-ref opts 'format))
912 (name (string-append (symbol->string pack-format)
914 (target (assoc-ref opts 'target))
915 (bootstrap? (assoc-ref opts 'bootstrap?))
916 (compressor (if bootstrap?
918 (assoc-ref opts 'compressor)))
919 (archiver (if (equal? pack-format 'squashfs)
922 %bootstrap-coreutils&co
924 (symlinks (assoc-ref opts 'symlinks))
925 (build-image (match (assq-ref %formats pack-format)
926 ((? procedure? proc) proc)
928 (leave (G_ "~a: unknown pack format~%")
930 (localstatedir? (assoc-ref opts 'localstatedir?))
931 (entry-point (assoc-ref opts 'entry-point))
932 (profile-name (assoc-ref opts 'profile-name))
933 (gc-root (assoc-ref opts 'gc-root)))
934 (when (null? (manifest-entries manifest))
935 (warning (G_ "no packages specified; building an empty pack~%")))
937 (run-with-store store
938 (mlet* %store-monad ((profile (profile-derivation
941 ;; Always produce relative
942 ;; symlinks for Singularity (see
943 ;; <https://bugs.gnu.org/34913>).
946 (eq? 'squashfs pack-format))
948 #:hooks (if bootstrap?
950 %default-profile-hooks)
951 #:locales? (not bootstrap?)
953 (drv (build-image name profile
969 (show-what-to-build* (list drv)
971 (assoc-ref opts 'substitutes?)
974 (built-derivations (list drv))
976 (register-root* (match (derivation->output-paths drv)
977 (((names . items) ...)
980 (return (format #t "~a~%"
981 (derivation->output-path drv))))))
982 #:system (assoc-ref opts 'system))))))))