From 0862b95433cacf91e44248097caa09119fc532a6 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Fri, 14 Jul 2017 20:47:38 +0200 Subject: build, vm: Use a less common label. * gnu/build/vm.scm (initialize-hard-disk): Use "GuixSD_image" as label. * gnu/system/install.scm (installation-os): Likewise. * gnu/system/vm.scm (system-disk-image): Likewise. --- gnu/build/vm.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index d8c53ef37f..086f38ade1 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -354,7 +354,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation." (error "failed to create GRUB EFI image")))) (define* (make-iso9660-image grub config-file os-drv target - #:key (volume-id "GuixSD") (volume-uuid #f)) + #:key (volume-id "GuixSD_image") (volume-uuid #f)) "Given a GRUB package, creates an iso image as TARGET, using CONFIG-FILE as Grub configuration and OS-DRV as the stuff in it." (let ((grub-mkrescue (string-append grub "/bin/grub-mkrescue"))) @@ -440,11 +440,14 @@ passing it a directory name where it is mounted." ;; Create a tiny configuration file telling the embedded grub ;; where to load the real thing. + ;; XXX This is quite fragile, and can prevent the image from booting + ;; when there's more than one volume with this label present. + ;; Reproducible almost-UUIDs could reduce the risk (not eliminate it). (call-with-output-file grub-config (lambda (port) (format port "insmod part_msdos~@ - search --set=root --label GuixSD~@ + search --set=root --label GuixSD_image~@ configfile /boot/grub/grub.cfg~%"))) (display "creating EFI firmware image...") -- cgit v1.2.3 From 21ffcd65c5a3459e939a75eb9151acde6ab53723 Mon Sep 17 00:00:00 2001 From: Tobias Geerinckx-Rice Date: Tue, 18 Jul 2017 16:30:14 +0200 Subject: vm: Increase disk size overhead estimate. * gnu/build/vm.scm (estimated-partition-size): Add 25% to the graph size. --- gnu/build/vm.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 086f38ade1..14bd7851f2 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -157,8 +157,8 @@ the #:references-graphs parameter of 'derivation'." (define (estimated-partition-size graphs) "Return the estimated size of a partition that can store the store items given by GRAPHS, a list of file names produced by #:references-graphs." - ;; Simply add a 20% overhead. - (round (* 1.2 (closure-size graphs)))) + ;; Simply add a 25% overhead. + (round (* 1.25 (closure-size graphs)))) (define* (initialize-partition-table device partitions #:key -- cgit v1.2.3 From 8d033e3e1607d5722ef7288208551d0331c8a853 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 18 Jul 2017 21:38:16 +0200 Subject: vm: 'iso9660-image' produces a single-file output. * gnu/system/vm.scm (expression->derivation-in-linux-vm): Add #:single-file-output? and pass it to 'load-in-linux-vm'. (iso9660-image): Pass #:single-file-output? to 'expression->derivation-in-linux-vm'. * gnu/build/vm.scm (load-in-linux-vm): Add #:single-file-output? and honor it. --- gnu/build/vm.scm | 20 ++++++++++++++++---- gnu/system/vm.scm | 13 +++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 14bd7851f2..727494ad93 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -76,11 +76,14 @@ (qemu (qemu-command)) (memory-size 512) linux initrd make-disk-image? + single-file-output? (disk-image-size (* 100 (expt 2 20))) (disk-image-format "qcow2") (references-graphs '())) "Run BUILDER, a Scheme file, into a VM running LINUX with INITRD, and copy -the result to OUTPUT. +the result to OUTPUT. If SINGLE-FILE-OUTPUT? is true, copy a single file from +/xchg to OUTPUT. Otherwise, copy the contents of /xchg to a new directory +OUTPUT. When MAKE-DISK-IMAGE? is true, OUTPUT will contain a VM image of DISK-IMAGE-SIZE bytes resulting from the execution of BUILDER, which may @@ -137,8 +140,17 @@ the #:references-graphs parameter of 'derivation'." ;; When MAKE-DISK-IMAGE? is true, the image is in OUTPUT already. (unless make-disk-image? - (mkdir output) - (copy-recursively "xchg" output))) + (if single-file-output? + (let ((graph? (lambda (name stat) + (member (basename name) references-graphs)))) + (match (find-files "xchg" (negate graph?)) + ((result) + (copy-file result output)) + (x + (error "did not find a single result file" x)))) + (begin + (mkdir output) + (copy-recursively "xchg" output))))) ;;; @@ -356,7 +368,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation." (define* (make-iso9660-image grub config-file os-drv target #:key (volume-id "GuixSD_image") (volume-uuid #f)) "Given a GRUB package, creates an iso image as TARGET, using CONFIG-FILE as -Grub configuration and OS-DRV as the stuff in it." +GRUB configuration and OS-DRV as the stuff in it." (let ((grub-mkrescue (string-append grub "/bin/grub-mkrescue"))) (mkdir-p "/tmp/root/var/run") (mkdir-p "/tmp/root/run") diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 028649f80b..6f979aee43 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -105,16 +105,19 @@ (guile-for-build (%guile-for-build)) + (single-file-output? #f) (make-disk-image? #f) (references-graphs #f) (memory-size 256) (disk-image-format "qcow2") (disk-image-size 'guess)) "Evaluate EXP in a QEMU virtual machine running LINUX with INITRD (a -derivation). In the virtual machine, EXP has access to all its inputs from the -store; it should put its output files in the `/xchg' directory, which is -copied to the derivation's output when the VM terminates. The virtual machine -runs with MEMORY-SIZE MiB of memory. +derivation). The virtual machine runs with MEMORY-SIZE MiB of memory. In the +virtual machine, EXP has access to all its inputs from the store; it should +put its output file(s) in the '/xchg' directory. + +If SINGLE-FILE-OUTPUT? is true, copy a single file from '/xchg' to OUTPUT. +Otherwise, copy the contents of /xchg to a new directory OUTPUT. When MAKE-DISK-IMAGE? is true, then create a QEMU disk image of type DISK-IMAGE-FORMAT (e.g., 'qcow2' or 'raw'), of DISK-IMAGE-SIZE bytes and @@ -164,6 +167,7 @@ made available under the /xchg CIFS share." #:linux linux #:initrd initrd #:memory-size #$memory-size #:make-disk-image? #$make-disk-image? + #:single-file-output? #$single-file-output? #:disk-image-format #$disk-image-format #:disk-image-size size #:references-graphs graphs))))) @@ -219,6 +223,7 @@ INPUTS is a list of inputs (as for packages)." (reboot)))) #:system system #:make-disk-image? #f + #:single-file-output? #t #:references-graphs inputs)) (define* (qemu-image #:key -- cgit v1.2.3 From 49962b15a1c4e72a55b6cf273806d203906de2ed Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 3 Aug 2017 00:20:05 +0200 Subject: activation: Make sure /etc exists. Fixes . Reported by ng0 . * gnu/build/activation.scm (activate-etc): Add call to 'mkdir-p'. --- gnu/build/activation.scm | 1 + 1 file changed, 1 insertion(+) (limited to 'gnu/build') diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index 299c0728cb..9c58370ec3 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -313,6 +313,7 @@ they already exist." (false-if-exception (delete-file file))) (format #t "populating /etc from ~a...~%" etc) + (mkdir-p "/etc") ;; Create the /etc/ssl -> /run/current-system/profile/etc/ssl symlink. This ;; symlink, to a target outside of the store, probably doesn't belong in the -- cgit v1.2.3 From 9833bcfc08ef009b9e8b4398baa481ef65c80ad7 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Fri, 21 Jul 2017 01:06:46 +0200 Subject: build: Allow mounting of entire disks. * gnu/build/file-systems.scm (disk-partitions): Also return entire drives. --- gnu/build/file-systems.scm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'gnu/build') diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index b6930497d6..203fbdfffb 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -373,15 +373,16 @@ not valid header was found." (define (disk-partitions) "Return the list of device names corresponding to valid disk partitions." - (define (last-character str) - (string-ref str (- (string-length str) 1))) - (define (partition? name major minor) - ;; Select device names that end in a digit, like libblkid's 'probe_all' - ;; function does. Checking for "/sys/dev/block/MAJOR:MINOR/partition" - ;; doesn't work for partitions coming from mapped devices. - (and (char-set-contains? char-set:digit (last-character name)) - (> major 2))) ;ignore RAM disks and floppy disks + ;; grub-mkrescue does some funny things for EFI support which + ;; makes it a lot more difficult than one would expect to support + ;; booting an ISO-9660 image from an USB flash drive. + ;; For example there's a buggy (too small) hidden partition in it + ;; which Linux mounts and then proceeds to fail while trying to + ;; fall off the edge. + ;; In any case, partition tables are supposed to be optional so + ;; here we allow checking entire disks for file systems, too. + (> major 2)) ;ignore RAM disks and floppy disks (call-with-input-file "/proc/partitions" (lambda (port) -- cgit v1.2.3