From patchwork Wed Apr 29 08:47:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mathieu Othacehe X-Patchwork-Id: 21748 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id DD3A427BBE4; Wed, 29 Apr 2020 09:54:19 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:470:142::17]) by mira.cbaines.net (Postfix) with ESMTP id 0A64727BBE1 for ; Wed, 29 Apr 2020 09:54:19 +0100 (BST) Received: from localhost ([::1]:42202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTiTy-0000ZO-Jh for patchwork@mira.cbaines.net; Wed, 29 Apr 2020 04:54:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57096) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTiQN-00075O-DG for guix-patches@gnu.org; Wed, 29 Apr 2020 04:54:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTiOu-0002y0-DZ for guix-patches@gnu.org; Wed, 29 Apr 2020 04:50:35 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTiOt-0002xQ-V6 for guix-patches@gnu.org; Wed, 29 Apr 2020 04:49:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jTiOt-0005Dk-TX for guix-patches@gnu.org; Wed, 29 Apr 2020 04:49:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40955] [PATCH 5/5] vm: Remove obsolete procedures. Resent-From: Mathieu Othacehe Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 29 Apr 2020 08:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40955 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40955@debbugs.gnu.org Cc: Mathieu Othacehe Received: via spool by 40955-submit@debbugs.gnu.org id=B40955.158815010819989 (code B ref 40955); Wed, 29 Apr 2020 08:49:03 +0000 Received: (at 40955) by debbugs.gnu.org; 29 Apr 2020 08:48:28 +0000 Received: from localhost ([127.0.0.1]:42392 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTiOJ-0005CL-SL for submit@debbugs.gnu.org; Wed, 29 Apr 2020 04:48:28 -0400 Received: from mail-wr1-f42.google.com ([209.85.221.42]:37079) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTiO5-0005B8-AJ for 40955@debbugs.gnu.org; Wed, 29 Apr 2020 04:48:26 -0400 Received: by mail-wr1-f42.google.com with SMTP id k1so1491639wrx.4 for <40955@debbugs.gnu.org>; Wed, 29 Apr 2020 01:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sH6JqNzVbU6k8uYPDjZznYmC/UEBhwe8teTdYa05Xhk=; b=Wc6JM4u6qmpP5buu0Sv8hWsi0pSP/wjj8V15/C0u0/tKtAt+90XpKykuMAD2wFhXTY nw5cl8GYXTXfqHxTsiNuvmEExlP70k1Ivljx6jDmRwNwDl1b3+nTqLfEbBW1tb1GaS/L bP8/31y3MICJufzRll9AMORdv/eiTw1gV0RxMJkg3eZFVtOsfS9xN4AgDcw7TsZtuWUE BPQbyFXWziLAM8JgkkfMXwP7fcDCW8uSwgKqL2m6AYqdvF2Zwla3lwUWQXmJv2rj1IU9 EUqFgVALTl+jdWp8GlRqyCrswkt9bg9Wgl1H7MfUCc4P9CsS9JTAnqVexWudmBQ+x4qL fltg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sH6JqNzVbU6k8uYPDjZznYmC/UEBhwe8teTdYa05Xhk=; b=WPfaeTqLh0gqFe4yUSUn9Ef0VQODkHofOhEdGBvFHCMHWE8n0vzAeTG2eTCza59vIX FwD/Cg1V1qPn1WH+VXwCF8ct/TctmoTdVrWaTqVqE1mH4Vrfham3m/0tSaZVHLY0xlTn hwE3/Ox0PqKJ+OiM5JsRoYCA+lMCEDRXmujaUESFURIaUiKn0kOft+rkI+EEVOpMC93j Cl4uviSqTUDo/84xhpPb+YyKCkiSokhBFnWlR9hwHF6DDvPpWocL9vEd46Vd+ExEVLoV Vj9Vt6WxSONJ+EEA2uh5qry7mbJOiQt6g0Ludu9EuC8xZsS+Fs02g5w3jWwYvbzrqL+2 xynA== X-Gm-Message-State: AGi0PuYfHiWg87NeOiICZ59iJSPHNZyKkSBKeBe32X4ot/i6RdxzFIou S4pIy5TtJzZWqxU5Jb6dApLQOBFi X-Google-Smtp-Source: APiQypIi6aITF9UljaUyNNkbbt1oj4alroKOj21WOnayS7FtjUM3tCYZHVz7jpG+kXuhch8yNrlQXQ== X-Received: by 2002:adf:8b1d:: with SMTP id n29mr37084421wra.196.1588150086635; Wed, 29 Apr 2020 01:48:06 -0700 (PDT) Received: from meru.fronius.com ([2a01:cb18:832e:5f00:e9fd:9d65:b691:fcb3]) by smtp.gmail.com with ESMTPSA id x132sm6812621wmg.33.2020.04.29.01.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 01:48:05 -0700 (PDT) From: Mathieu Othacehe Date: Wed, 29 Apr 2020 10:47:56 +0200 Message-Id: <20200429084756.25072-5-m.othacehe@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200429084756.25072-1-m.othacehe@gmail.com> References: <20200429084756.25072-1-m.othacehe@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/build/vm.scm (install-efi, make-iso9660-image): Remove those procedures that are now implemented in (gnu build image) module, (initialize-hard-disk): remove efi support. * gnu/system/vm.scm (iso9660-image): Remove it, (qemu-image): adapt it to remove ISO9660 support. --- gnu/build/vm.scm | 156 +--------------------------------------------- gnu/system/vm.scm | 151 +++++--------------------------------------- 2 files changed, 18 insertions(+), 289 deletions(-) diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index bc6071daa9..1a888b1a51 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -57,8 +57,7 @@ estimated-partition-size root-partition-initializer initialize-partition-table - initialize-hard-disk - make-iso9660-image)) + initialize-hard-disk)) ;;; Commentary: ;;; @@ -417,159 +416,6 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation." (mkdir-p directory) (symlink bootcfg (string-append directory "/bootcfg")))) -(define (install-efi grub esp config-file) - "Write a self-contained GRUB EFI loader to the mounted ESP using CONFIG-FILE." - (let* ((system %host-type) - ;; Hard code the output location to a well-known path recognized by - ;; compliant firmware. See "3.5.1.1 Removable Media Boot Behaviour": - ;; http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%202_6.pdf - (grub-mkstandalone (string-append grub "/bin/grub-mkstandalone")) - (efi-directory (string-append esp "/EFI/BOOT")) - ;; Map grub target names to boot file names. - (efi-targets (cond ((string-prefix? "x86_64" system) - '("x86_64-efi" . "BOOTX64.EFI")) - ((string-prefix? "i686" system) - '("i386-efi" . "BOOTIA32.EFI")) - ((string-prefix? "armhf" system) - '("arm-efi" . "BOOTARM.EFI")) - ((string-prefix? "aarch64" system) - '("arm64-efi" . "BOOTAA64.EFI"))))) - ;; grub-mkstandalone requires a TMPDIR to prepare the firmware image. - (setenv "TMPDIR" esp) - - (mkdir-p efi-directory) - (invoke grub-mkstandalone "-O" (car efi-targets) - "-o" (string-append efi-directory "/" - (cdr efi-targets)) - ;; Graft the configuration file onto the image. - (string-append "boot/grub/grub.cfg=" config-file)))) - -(define* (make-iso9660-image xorriso grub-mkrescue-environment - grub config-file os-drv target - #:key (volume-id "Guix_image") (volume-uuid #f) - register-closures? (closures '())) - "Given a GRUB package, creates an iso image as TARGET, using CONFIG-FILE as -GRUB configuration and OS-DRV as the stuff in it." - (define grub-mkrescue - (string-append grub "/bin/grub-mkrescue")) - - (define grub-mkrescue-sed.sh - (string-append xorriso "/bin/grub-mkrescue-sed.sh")) - - (define target-store - (string-append "/tmp/root" (%store-directory))) - - (define items - ;; The store items to add to the image. - (delete-duplicates - (append-map (lambda (closure) - (map store-info-item - (call-with-input-file (string-append "/xchg/" closure) - read-reference-graph))) - closures))) - - (populate-root-file-system os-drv "/tmp/root") - (mount (%store-directory) target-store "" MS_BIND) - - (when register-closures? - (display "registering closures...\n") - (for-each (lambda (closure) - (register-closure - "/tmp/root" - (string-append "/xchg/" closure) - - ;; TARGET-STORE is a read-only bind-mount so we shouldn't try - ;; to modify it. - #:deduplicate? #f - #:reset-timestamps? #f)) - closures) - (register-bootcfg-root "/tmp/root" config-file)) - - ;; 'grub-mkrescue' calls out to mtools programs to create 'efi.img', a FAT - ;; file system image, and mtools honors SOURCE_DATE_EPOCH for the mtime of - ;; those files. The epoch for FAT is Jan. 1st 1980, not 1970, so choose - ;; that. - (setenv "SOURCE_DATE_EPOCH" - (number->string - (time-second - (date->time-utc (make-date 0 0 0 0 1 1 1980 0))))) - - ;; Our patched 'grub-mkrescue' honors this environment variable and passes - ;; it to 'mformat', which makes it the serial number of 'efi.img'. This - ;; allows for deterministic builds. - (setenv "GRUB_FAT_SERIAL_NUMBER" - (number->string (if volume-uuid - - ;; On 32-bit systems the 2nd argument must be - ;; lower than 2^32. - (string-hash (iso9660-uuid->string volume-uuid) - (- (expt 2 32) 1)) - - #x77777777) - 16)) - - (setenv "MKRESCUE_SED_MODE" "original") - (setenv "MKRESCUE_SED_XORRISO" (string-append xorriso - "/bin/xorriso")) - (setenv "MKRESCUE_SED_IN_EFI_NO_PT" "yes") - (for-each (match-lambda - ((name . value) (setenv name value))) - grub-mkrescue-environment) - - (let ((pipe - (apply open-pipe* OPEN_WRITE - grub-mkrescue - (string-append "--xorriso=" grub-mkrescue-sed.sh) - "-o" target - (string-append "boot/grub/grub.cfg=" config-file) - "etc=/tmp/root/etc" - "var=/tmp/root/var" - "run=/tmp/root/run" - ;; /mnt is used as part of the installation - ;; process, as the mount point for the target - ;; file system, so create it. - "mnt=/tmp/root/mnt" - "-path-list" "-" - "--" - - ;; Set all timestamps to 1. - "-volume_date" "all_file_dates" "=1" - - ;; ‘zisofs’ compression reduces the total image size by ~60%. - "-zisofs" "level=9:block_size=128k" ; highest compression - ;; It's transparent to our Linux-Libre kernel but not to GRUB. - ;; Don't compress the kernel, initrd, and other files read by - ;; grub.cfg, as well as common already-compressed file names. - "-find" "/" "-type" "f" - ;; XXX Even after "--" above, and despite documentation claiming - ;; otherwise, "-or" is stolen by grub-mkrescue which then chokes - ;; on it (as ‘-o …’) and dies. Don't use "-or". - "-not" "-wholename" "/boot/*" - "-not" "-wholename" "/System/*" - "-not" "-name" "unicode.pf2" - "-not" "-name" "bzImage" - "-not" "-name" "*.gz" ; initrd & all man pages - "-not" "-name" "*.png" ; includes grub-image.png - "-exec" "set_filter" "--zisofs" - "--" - - "-volid" (string-upcase volume-id) - (if volume-uuid - `("-volume_date" "uuid" - ,(string-filter (lambda (value) - (not (char=? #\- value))) - (iso9660-uuid->string - volume-uuid))) - `())))) - ;; Pass lines like 'gnu/store/…-x=/gnu/store/…-x' corresponding to the - ;; '-path-list -' option. - (for-each (lambda (item) - (format pipe "~a=~a~%" - (string-drop item 1) item)) - items) - (unless (zero? (close-pipe pipe)) - (error "oh, my! grub-mkrescue failed" grub-mkrescue)))) - (define* (initialize-hard-disk device #:key bootloader-package diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 37840ce355..1cab8997b4 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -269,95 +269,6 @@ substitutable." (eq? (service-kind service) guix-service-type)) (operating-system-services os))))) -(define* (iso9660-image #:key - (name "iso9660-image") - file-system-label - file-system-uuid - (system (%current-system)) - (target (%current-target-system)) - (qemu qemu-minimal) - os - bootcfg-drv - bootloader - (register-closures? (has-guix-service-type? os)) - (inputs '()) - (grub-mkrescue-environment '()) - (substitutable? #t)) - "Return a bootable, stand-alone iso9660 image. - -INPUTS is a list of inputs (as for packages)." - (define schema - (and register-closures? - (local-file (search-path %load-path - "guix/store/schema.sql")))) - - (expression->derivation-in-linux-vm - name - (with-extensions gcrypt-sqlite3&co - (with-imported-modules `(,@(source-module-closure '((gnu build vm) - (guix store database) - (guix build utils)) - #:select? not-config?) - ((guix config) => ,(make-config.scm))) - #~(begin - (use-modules (gnu build vm) - (guix store database) - (guix build utils)) - - (sql-schema #$schema) - - ;; Allow non-ASCII file names--e.g., 'nss-certs'--to be decoded. - (setenv "GUIX_LOCPATH" - #+(file-append glibc-utf8-locales "/lib/locale")) - (setlocale LC_ALL "en_US.utf8") - - (let ((inputs - '#$(append (list parted e2fsprogs dosfstools xorriso) - (map canonical-package - (list sed grep coreutils findutils gawk)))) - - - (graphs '#$(match inputs - (((names . _) ...) - names))) - ;; This variable is unused but allows us to add INPUTS-TO-COPY - ;; as inputs. - (to-register - '#$(map (match-lambda - ((name thing) thing) - ((name thing output) `(,thing ,output))) - inputs))) - - (set-path-environment-variable "PATH" '("bin" "sbin") inputs) - (make-iso9660-image #$xorriso - '#$grub-mkrescue-environment - #$(bootloader-package bootloader) - #$bootcfg-drv - #$os - "/xchg/guixsd.iso" - #:register-closures? #$register-closures? - #:closures graphs - #:volume-id #$file-system-label - #:volume-uuid #$(and=> file-system-uuid - uuid-bytevector)))))) - #:system system - #:target target - - ;; Keep a local file system for /tmp so that we can populate it directly as - ;; root and have files owned by root. See . - #:file-systems (remove (lambda (file-system) - (string=? (file-system-mount-point file-system) - "/tmp")) - %linux-vm-file-systems) - - #:make-disk-image? #f - #:single-file-output? #t - #:references-graphs inputs - #:substitutable? substitutable? - - ;; Xorriso seems to be quite memory-hungry, so increase the VM's RAM size. - #:memory-size 512)) - (define* (qemu-image #:key (name "qemu-image") (system (%current-system)) @@ -618,25 +529,14 @@ to USB sticks meant to be read-only. SUBSTITUTABLE? determines whether the returned derivation should be marked as substitutable." - (define normalize-label - ;; ISO labels are all-caps (case-insensitive), but since - ;; 'find-partition-by-label' is case-sensitive, make it all-caps here. - (if (string=? "iso9660" file-system-type) - string-upcase - identity)) - (define root-label - ;; Volume name of the root file system. - (normalize-label "Guix_image")) + "Guix_image") (define (root-uuid os) ;; UUID of the root file system, computed in a deterministic fashion. ;; This is what we use to locate the root file system so it has to be ;; different from the user's own file system UUIDs. - (operating-system-uuid os - (if (string=? file-system-type "iso9660") - 'iso9660 - 'dce))) + (operating-system-uuid os 'dce)) (define file-systems-to-keep (remove (lambda (fs) @@ -653,11 +553,7 @@ substitutable." #:volatile-root? volatile? rest))) - (bootloader (if (string=? "iso9660" file-system-type) - (bootloader-configuration - (inherit (operating-system-bootloader os)) - (bootloader grub-mkrescue-bootloader)) - (operating-system-bootloader os))) + (bootloader (operating-system-bootloader os)) ;; Force our own root file system. (We need a "/" file system ;; to call 'root-uuid'.) @@ -675,33 +571,20 @@ substitutable." (type file-system-type)) file-systems-to-keep)))) (bootcfg (operating-system-bootcfg os))) - (if (string=? "iso9660" file-system-type) - (iso9660-image #:name name - #:file-system-label root-label - #:file-system-uuid uuid - #:os os - #:bootcfg-drv bootcfg - #:bootloader (bootloader-configuration-bootloader - (operating-system-bootloader os)) - #:inputs `(("system" ,os) - ("bootcfg" ,bootcfg)) - #:grub-mkrescue-environment - '(("MKRESCUE_SED_MODE" . "mbr_hfs")) - #:substitutable? substitutable?) - (qemu-image #:name name - #:os os - #:bootcfg-drv bootcfg - #:bootloader (bootloader-configuration-bootloader - (operating-system-bootloader os)) - #:disk-image-size disk-image-size - #:disk-image-format "raw" - #:file-system-type file-system-type - #:file-system-label root-label - #:file-system-uuid uuid - #:copy-inputs? #t - #:inputs `(("system" ,os) - ("bootcfg" ,bootcfg)) - #:substitutable? substitutable?)))) + (qemu-image #:name name + #:os os + #:bootcfg-drv bootcfg + #:bootloader (bootloader-configuration-bootloader + (operating-system-bootloader os)) + #:disk-image-size disk-image-size + #:disk-image-format "raw" + #:file-system-type file-system-type + #:file-system-label root-label + #:file-system-uuid uuid + #:copy-inputs? #t + #:inputs `(("system" ,os) + ("bootcfg" ,bootcfg)) + #:substitutable? substitutable?))) (define* (system-qemu-image os #:key