From patchwork Thu Feb 10 06:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Griffin X-Patchwork-Id: 37158 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 8971727BBEA; Thu, 10 Feb 2022 06:29:13 +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 CBD5527BBE9 for ; Thu, 10 Feb 2022 06:29:12 +0000 (GMT) Received: from localhost ([::1]:60398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI2x4-0002Zk-Qe for patchwork@mira.cbaines.net; Thu, 10 Feb 2022 01:29:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI2r8-0007Wd-0t for guix-patches@gnu.org; Thu, 10 Feb 2022 01:23:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:59527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI2r7-0002ie-NR for guix-patches@gnu.org; Thu, 10 Feb 2022 01:23:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nI2r7-0003U8-Kp for guix-patches@gnu.org; Thu, 10 Feb 2022 01:23:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53912] [PATCH 2/5] system: image: Add 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:23:01 +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" <53912@debbugs.gnu.org> Received: via spool by 53912-submit@debbugs.gnu.org id=B53912.164447414813336 (code B ref 53912); Thu, 10 Feb 2022 06:23:01 +0000 Received: (at 53912) by debbugs.gnu.org; 10 Feb 2022 06:22:28 +0000 Received: from localhost ([127.0.0.1]:53424 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nI2qZ-0003T2-V8 for submit@debbugs.gnu.org; Thu, 10 Feb 2022 01:22:28 -0500 Received: from mail-4317.proton.ch ([185.70.43.17]:62795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nI2qT-0003Sd-26 for 53912@debbugs.gnu.org; Thu, 10 Feb 2022 01:22:26 -0500 Date: Thu, 10 Feb 2022 06:22:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ajgrf.com; s=protonmail; t=1644474134; bh=kcdPQ7F9u+BG85n0GVA5ib+ZMRLZzQKscfS2GJIyOs4=; h=Date:To:From:Reply-To:Subject:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID; b=ATtNqMZCJU4OhJgwBpGDq46RUD6oTa44xbxYnmu10Botja4SOcqvnaHk7af1tc9rI E8Au3bx0THBWgkgPae8qYNkgQ2J3CX6o8QFPRVrDvJ+kVZ45DAgwOQ0RQHpTCjPLoA yiG+ZrnbpKrFl8VcjJzOYV2umFjNMq05uti0UStEuj1F2ylkawDjlWKp3XMgj3ll0Q rpcWMO4niNiRWqX5NhBiIjYTBYXcF98XGWLeSMEdCB3KwXdNQdTHc7lUkgItjdyXy/ PhCbp/DQecWNhKRPSjffAvCwEp1n95CHzgogl3PHFoZgC8Dxt7F4LkSiNqoSBMqbXL RUoFBX4kPtS6g== Message-ID: 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 support for generating a tarball from operating-system definitions. --- Alex Griffin From ef951ff51bf0e2b2b50c57fbf652b0677c1e6701 Mon Sep 17 00:00:00 2001 From: Alex Griffin 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 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2022 Alex Griffin ;;; ;;; 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?)))) + +;; +;; 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?)))) + ;; ;; 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