From: Alex Griffin via Guix-patches via <guix-patches@gnu.org>
To: "53912@debbugs.gnu.org" <53912@debbugs.gnu.org>
Subject: [bug#53912] [PATCH 2/5] system: image: Add tarball support.
Date: Thu, 10 Feb 2022 06:22:10 +0000 [thread overview]
Message-ID: <SUzGTg5w2gbywISnUpFqNjuIslmQ9Sr0-0mjc2lBJf4GW_veZ--jJntAFbvYXNR2BtjM-SHj6lkJo_F5KOq5GhGJpYgiPtGRHs4duzMg4aQ=@ajgrf.com> (raw)
In-Reply-To: <875ypndznv.fsf@ajgrf.com>
[-- Attachment #1: Type: text/plain, Size: 103 bytes --]
This patch adds support for generating a tarball from operating-system definitions.
--
Alex Griffin
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-system-image-Add-tarball-support.patch --]
[-- Type: text/x-patch; name=0002-system-image-Add-tarball-support.patch, Size: 6106 bytes --]
From ef951ff51bf0e2b2b50c57fbf652b0677c1e6701 Mon Sep 17 00:00:00 2001
From: Alex Griffin <a@ajgrf.com>
Date: Sun, 6 Feb 2022 16:29:47 -0600
Subject: [PATCH 2/5] system: image: Add tarball support.
* gnu/system/image.scm (tarball-image, tarball-image-type): New variables.
(system-tarball-image): New procedure.
(image->root-file-system): Add tarball image support.
(system-image): Ditto.
---
gnu/system/image.scm | 82 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
diff --git a/gnu/system/image.scm b/gnu/system/image.scm
index 42e215f614..33c9c23225 100644
--- a/gnu/system/image.scm
+++ b/gnu/system/image.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2020, 2021 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;; Copyright © 2022 Alex Griffin <a@ajgrf.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -24,6 +25,7 @@ (define-module (gnu system image)
#:use-module (guix modules)
#:use-module (guix monads)
#:use-module (guix records)
+ #:use-module (guix scripts pack)
#:use-module (guix store)
#:use-module (guix ui)
#:use-module (guix utils)
@@ -70,6 +72,7 @@ (define-module (gnu system image)
efi-disk-image
iso9660-image
docker-image
+ tarball-image
raw-with-offset-disk-image
image-with-os
@@ -78,6 +81,7 @@ (define-module (gnu system image)
iso-image-type
uncompressed-iso-image-type
docker-image-type
+ tarball-image-type
raw-with-offset-image-type
image-with-label
@@ -135,6 +139,10 @@ (define docker-image
(image
(format 'docker)))
+(define tarball-image
+ (image
+ (format 'tarball)))
+
(define* (raw-with-offset-disk-image #:optional (offset root-offset))
(image
(format 'disk-image)
@@ -192,6 +200,11 @@ (define docker-image-type
(name 'docker)
(constructor (cut image-with-os docker-image <>))))
+(define tarball-image-type
+ (image-type
+ (name 'tarball)
+ (constructor (cut image-with-os tarball-image <>))))
+
(define raw-with-offset-image-type
(image-type
(name 'raw-with-offset)
@@ -631,6 +644,71 @@ (define builder
#:options `(#:references-graphs ((,graph ,os))
#:substitutable? ,substitutable?))))
+\f
+;;
+;; Tarball image.
+;;
+
+(define* (system-tarball-image image
+ #:key
+ (name "image")
+ (compressor (srfi-1:first %compressors)))
+ "Build a tarball of IMAGE. NAME is the base name to use for the
+output file."
+ (let* ((shared-network? (image-shared-network? image))
+ (os (image-operating-system image))
+ (substitutable? (image-substitutable? image))
+ (schema (local-file (search-path %load-path
+ "guix/store/schema.sql")))
+ (name (string-append name ".tar" (compressor-extension compressor)))
+ (graph "system-graph"))
+ (define builder
+ (with-extensions gcrypt-sqlite3&co ;for (guix store database)
+ (with-imported-modules `(,@(source-module-closure
+ '((guix build pack)
+ (guix build store-copy)
+ (guix build utils)
+ (guix store database)
+ (gnu build image))
+ #:select? not-config?)
+ ((guix config) => ,(make-config.scm)))
+ #~(begin
+ (use-modules (guix build pack)
+ (guix build store-copy)
+ (guix build utils)
+ (guix store database)
+ (gnu build image))
+
+ ;; Set the SQL schema location.
+ (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 ((image-root (string-append (getcwd) "/tmp-root"))
+ (tar #+(file-append tar "/bin/tar")))
+
+ (mkdir-p image-root)
+ (initialize-root-partition image-root
+ #:references-graphs '(#$graph)
+ #:deduplicate? #f
+ #:system-directory #$os)
+
+ (with-directory-excursion image-root
+ (apply invoke tar "-cvf" #$output "."
+ (tar-base-options
+ #:tar tar
+ #:compressor #+(and=> compressor compressor-command)))))))))
+
+ (computed-file name builder
+ ;; Allow offloading so that this I/O-intensive process
+ ;; doesn't run on the build farm's head node.
+ #:local-build? #f
+ #:options `(#:references-graphs ((,graph ,os))
+ #:substitutable? ,substitutable?))))
+
\f
;;
;; Image creation.
@@ -640,7 +718,7 @@ (define (image->root-file-system image)
"Return the IMAGE root partition file-system type."
(case (image-format image)
((iso9660) "iso9660")
- ((docker) "dummy")
+ ((docker tarball) "dummy")
(else
(partition-file-system (find-root-partition image)))))
@@ -778,6 +856,8 @@ (define target (cond
("bootcfg" ,bootcfg))))
((memq image-format '(docker))
(system-docker-image image*))
+ ((memq image-format '(tarball))
+ (system-tarball-image image*))
((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 ` Alex Griffin via Guix-patches via [this message]
2022-04-11 10:34 ` [bug#53912] [PATCH 0/5] WIP Add WSL support Ludovic Courtès
2022-02-10 6:27 ` [bug#53912] [PATCH 3/5] system: image: Add wsl-tarball support Alex Griffin via Guix-patches via
2022-02-15 14:10 ` 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='SUzGTg5w2gbywISnUpFqNjuIslmQ9Sr0-0mjc2lBJf4GW_veZ--jJntAFbvYXNR2BtjM-SHj6lkJo_F5KOq5GhGJpYgiPtGRHs4duzMg4aQ=@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).