From patchwork Thu Feb 10 06:27:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Griffin X-Patchwork-Id: 37159 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 4CAC927BBEA; Thu, 10 Feb 2022 06:29:40 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B9B2927BBE9 for ; Thu, 10 Feb 2022 06:29:39 +0000 (GMT) Received: from localhost ([::1]:32874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI2xW-00032K-SP for patchwork@mira.cbaines.net; Thu, 10 Feb 2022 01:29:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI2vy-00024R-Km for guix-patches@gnu.org; Thu, 10 Feb 2022 01:28:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59540) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI2vy-0004HC-B1 for guix-patches@gnu.org; Thu, 10 Feb 2022 01:28:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nI2vy-0003d0-8m for guix-patches@gnu.org; Thu, 10 Feb 2022 01:28:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53912] [PATCH 3/5] system: image: Add wsl-tarball support. References: <875ypndznv.fsf@ajgrf.com> In-Reply-To: <875ypndznv.fsf@ajgrf.com> Resent-From: Alex Griffin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Feb 2022 06:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53912 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53912@debbugs.gnu.org Received: via spool by 53912-submit@debbugs.gnu.org id=B53912.164447448113939 (code B ref 53912); Thu, 10 Feb 2022 06:28:02 +0000 Received: (at 53912) by debbugs.gnu.org; 10 Feb 2022 06:28:01 +0000 Received: from localhost ([127.0.0.1]:53437 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nI2vx-0003cl-99 for submit@debbugs.gnu.org; Thu, 10 Feb 2022 01:28:01 -0500 Received: from mail-4022.proton.ch ([185.70.40.22]:18612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nI2vv-0003cV-Cg for 53912@debbugs.gnu.org; Thu, 10 Feb 2022 01:28:00 -0500 Date: Thu, 10 Feb 2022 06:27:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajgrf.com; s=protonmail; t=1644474472; bh=c3zsOYlfNFw2RJqbnZGRw69TC5R+qQMsh6IcIkdbCGQ=; h=Date:To:From:Reply-To:Subject:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID; b=VxticU2ohSEHHykGeuxmsyxvH0kO6VsZ9SBDfa6qbmWdPIvTl8l4CSAVBww3aMuvR 9tNw5Sfa9VJNidU+i3rsy9S+yECNIFezWz9tMBjikUM+cpLCJU8cuf2y7O8d48/TsE oz+pNsovLuPIpfUO7EQZ95601kLy9kijSBsos1hx7BNHOE9KOPKnst6bOxd/zo6V65 6wiW/NwpN0A5b1eiKSqek3yQGiC7/bFJahSbbmy5IWeVEXeuh2mSXm5DgiZMb2KVZL iaFMboEXet9UHXjM0shM9rSOCBHZFRpuz6HH4A8QBpZOWZi2WzLlERppuN0zOGimjx ljgncmBAyytbw== Message-ID: <87wni3ck2v.fsf@ajgrf.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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" Reply-to: Alex Griffin X-ACL-Warn: , Alex Griffin via Guix-patches X-Patchwork-Original-From: Alex Griffin via Guix-patches via From: Alex Griffin X-getmail-retrieved-from-mailbox: Patches This patch adds the wsl-tarball image type. The difference between this and the plain tarball type is the creation of the symlinks at /bin/sh and /bin/mount. These are necessary for the first boot to work after importing. We can’t rely on special-files-service-type for this because the system is not activated yet, and the /bin/sh symlink initiates the first system activation. Thanks, – Alex Griffin From 27304913a968753f42d06eb2ae7c297873b77cb6 Mon Sep 17 00:00:00 2001 From: Alex Griffin Date: Mon, 7 Feb 2022 18:37:25 -0600 Subject: [PATCH 3/5] system: image: Add wsl-tarball support. * gnu/system/image.scm (wsl-tarball-image, wsl-tarball-image-type): New variables. (image->root-file-system): Add wsl-tarball image support. (system-image): Ditto. --- gnu/system/image.scm | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 33c9c23225..83a2a76a9c 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -37,12 +37,14 @@ (define-module (gnu system image) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu system) + #:use-module (gnu system accounts) #:use-module (gnu system file-systems) #:use-module (gnu system linux-container) #:use-module (gnu system uuid) #:use-module (gnu system vm) #:use-module (guix packages) #:use-module (gnu packages base) + #:use-module (gnu packages bash) #:use-module (gnu packages bootloaders) #:use-module (gnu packages cdrom) #:use-module (gnu packages compression) @@ -73,6 +75,7 @@ (define-module (gnu system image) iso9660-image docker-image tarball-image + wsl-tarball-image raw-with-offset-disk-image image-with-os @@ -82,6 +85,7 @@ (define-module (gnu system image) uncompressed-iso-image-type docker-image-type tarball-image-type + wsl-tarball-image-type raw-with-offset-image-type image-with-label @@ -143,6 +147,10 @@ (define tarball-image (image (format 'tarball))) +(define wsl-tarball-image + (image + (format 'wsl-tarball))) + (define* (raw-with-offset-disk-image #:optional (offset root-offset)) (image (format 'disk-image) @@ -205,6 +213,11 @@ (define tarball-image-type (name 'tarball) (constructor (cut image-with-os tarball-image <>)))) +(define wsl-tarball-image-type + (image-type + (name 'wsl-tarball) + (constructor (cut image-with-os wsl-tarball-image <>)))) + (define raw-with-offset-image-type (image-type (name 'raw-with-offset) @@ -652,7 +665,8 @@ (define builder (define* (system-tarball-image image #:key (name "image") - (compressor (srfi-1:first %compressors))) + (compressor (srfi-1:first %compressors)) + (wsl? #f)) "Build a tarball of IMAGE. NAME is the base name to use for the output file." (let* ((shared-network? (image-shared-network? image)) @@ -661,7 +675,12 @@ (define* (system-tarball-image image (schema (local-file (search-path %load-path "guix/store/schema.sql"))) (name (string-append name ".tar" (compressor-extension compressor))) - (graph "system-graph")) + (graph "system-graph") + (root (srfi-1:find (lambda (user) + (and=> (user-account-uid user) zero?)) + (operating-system-users os))) + (root-shell (or (and=> root user-account-shell) + (file-append bash "/bin/bash")))) (define builder (with-extensions gcrypt-sqlite3&co ;for (guix store database) (with-imported-modules `(,@(source-module-closure @@ -697,6 +716,15 @@ (define builder #:system-directory #$os) (with-directory-excursion image-root + (when #$wsl? + ;; WSL requires /bin/sh. Will be overwritten by system + ;; activation. + (symlink #$root-shell "./bin/sh") + + ;; WSL requires /bin/mount to access the host fs. + (symlink #+(file-append util-linux "/bin/mount") + "./bin/mount")) + (apply invoke tar "-cvf" #$output "." (tar-base-options #:tar tar @@ -718,7 +746,7 @@ (define (image->root-file-system image) "Return the IMAGE root partition file-system type." (case (image-format image) ((iso9660) "iso9660") - ((docker tarball) "dummy") + ((docker tarball wsl-tarball) "dummy") (else (partition-file-system (find-root-partition image))))) @@ -858,6 +886,8 @@ (define target (cond (system-docker-image image*)) ((memq image-format '(tarball)) (system-tarball-image image*)) + ((memq image-format '(wsl-tarball)) + (system-tarball-image image* #:wsl? #t)) ((memq image-format '(iso9660)) (system-iso9660-image image* -- 2.34.0