From: Alex Griffin via Guix-patches via <guix-patches@gnu.org>
To: 53912@debbugs.gnu.org
Subject: [bug#53912] [PATCH 3/5] system: image: Add wsl-tarball support.
Date: Thu, 10 Feb 2022 06:27:47 +0000 [thread overview]
Message-ID: <87wni3ck2v.fsf@ajgrf.com> (raw)
In-Reply-To: <875ypndznv.fsf@ajgrf.com>
[-- Attachment #1: Type: text/plain, Size: 420 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-system-image-Add-wsl-tarball-support.patch --]
[-- Type: text/x-patch; name=0003-system-image-Add-wsl-tarball-support.patch, Size: 5056 bytes --]
From 27304913a968753f42d06eb2ae7c297873b77cb6 Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
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
next prev parent reply other threads:[~2022-02-10 6:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-10 6:05 [bug#53912] [PATCH 0/5] WIP Add WSL support Alex Griffin via Guix-patches via
2022-02-10 6:12 ` [bug#53912] [PATCH 1/5] scripts: Fix typo Alex Griffin via Guix-patches via
2022-02-10 6:22 ` [bug#53912] [PATCH 2/5] system: image: Add tarball support Alex Griffin via Guix-patches via
2022-04-11 10:34 ` [bug#53912] [PATCH 0/5] WIP Add WSL support Ludovic Courtès
2022-02-10 6:27 ` Alex Griffin via Guix-patches via [this message]
2022-02-15 14:10 ` [bug#53912] [PATCH 3/5] system: image: Add wsl-tarball support Liliana Marie Prikler
2022-02-15 16:28 ` Maxime Devos
2022-02-15 16:31 ` Maxime Devos
2022-02-10 6:31 ` [bug#53912] [PATCH 4/5] system: Add wsl module Alex Griffin via Guix-patches via
2022-02-10 6:35 ` [bug#53912] [PATCH 5/5] image: Add wsl image Alex Griffin via Guix-patches via
2022-04-11 10:41 ` [bug#53912] [PATCH 0/5] WIP Add WSL support Ludovic Courtès
2022-04-26 7:15 ` Mathieu Othacehe
2022-06-04 0:31 ` Christine Lemmer-Webber
2022-09-11 12:23 ` Mathieu Othacehe
2022-09-25 11:56 ` bug#53912: " Mathieu Othacehe
2022-08-11 16:27 ` [bug#53912] " Jacob MacDonald
2022-08-11 21:32 ` [bug#53912] [PATCH 0/5] WIP Add " Stefan via Guix-patches via
2022-08-11 22:31 ` Jacob MacDonald
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wni3ck2v.fsf@ajgrf.com \
--to=guix-patches@gnu.org \
--cc=53912@debbugs.gnu.org \
--cc=a@ajgrf.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).