/* GNU Guix --- Functional package management for GNU Copyright (C) 2018 Ludovic Courtès This file is part of GNU Guix. GNU Guix is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. GNU Guix is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Guix. If not, see . */ /* Make the given @WRAPPED_PROGRAM@ relocatable by executing it in a separate mount namespace where the store is mounted in its right place. We would happily do that in Scheme using 'call-with-container'. However, this very program needs to be relocatable, so it needs to be statically linked, which complicates things (Guile's modules can hardly be "linked" into a single executable.) */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Concatenate DIRECTORY, a slash, and FILE. Return the result, which the caller must eventually free. */ static char * concat (const char *directory, const char *file) { char *result = malloc (strlen (directory) + 2 + strlen (file)); assert (result != NULL); strcpy (result, directory); strcat (result, "/"); strcat (result, file); return result; } static void mkdir_p (const char *di;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016-2023 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017, 2019, 2021 Tobias Geerinckx-Rice <me@tobias.gr> ;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com> ;;; Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org> ;;; Copyright © 2020, 2024 Janneke Nieuwenhuizen <janneke@gnu.org> ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (gnu tests install) #:use-module (gnu) #:use-module (gnu bootloader extlinux) #:use-module (gnu image) #:use-module (gnu tests) #:use-module (gnu tests base) #:use-module (gnu system) #:use-module (gnu system image) #:use-module (gnu system install) #:use-module (gnu system vm) #:use-module ((gnu build marionette) #:select (qemu-command)) #:use-module (gnu packages admin) #:use-module (gnu packages bootloaders) #:use-module (gnu packages commencement) ;for 'guile-final' #:use-module (gnu packages cpio) #:use-module (gnu packages cryptsetup) #:use-module (gnu packages disk) #:use-module (gnu packages emacs) #:use-module (gnu packages emacs-xyz) #:use-module (gnu packages firmware) #:use-module (gnu packages linux) #:use-module (gnu packages ocr) #:use-module (gnu packages openbox) #:use-module (gnu packages package-management) #:use-module (gnu packages ratpoison) #:use-module (gnu packages suckless) #:use-module (gnu packages virtualization) #:use-module (gnu packages wm) #:use-module (gnu packages xorg) #:use-module (gnu services desktop) #:use-module (gnu services networking) #:use-module (gnu services xorg) #:use-module (guix store) #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix grafts) #:use-module (guix gexp) #:use-module (guix utils) #:use-module (srfi srfi-1) #:export (%test-installed-os %test-installed-extlinux-os %test-iso-image-installer %test-separate-store-os %test-separate-home-os %test-raid-root-os %test-encrypted-root-os %test-encrypted-home-os %test-encrypted-home-os-key-file %test-encrypted-root-not-boot-os %test-btrfs-root-os %test-btrfs-root-on-subvolume-os %test-btrfs-raid-root-os %test-btrfs-raid10-root-os %test-btrfs-raid10-root-os-degraded %test-jfs-root-os %test-f2fs-root-os %test-xfs-root-os %test-lvm-separate-home-os %test-gui-installed-os %test-gui-uefi-installed-os %test-gui-installed-os-encrypted %test-gui-installed-desktop-os-encrypted)) ;;; Commentary: ;;; ;;; Test the installation of Guix using the documented approach at the ;;; command line. ;;; ;;; Code: (define-os-with-source (%minimal-os %minimal-os-source) ;; The OS we want to install. (use-modules (gnu) (gnu tests) (srfi srfi-1)) (operating-system (host-name "liberigilo") (timezone "Europe/Paris") (locale "en_US.UTF-8") (bootloader (bootloader-configuration (bootloader grub-bootloader) (targets (list "/dev/vdb")))) (kernel-arguments '("console=ttyS0")) (file-systems (cons (file-system (device (file-system-label "my-root")) (mount-point "/") (type "ext4")) %base-file-systems)) (users (cons (user-account (name "alice") (comment "Bob's sister") (group "users") (supplementary-groups '("wheel" "audio" "video"))) %base-user-accounts)) (services (cons (service marionette-service-type (marionette-configuration (imported-modules '((gnu services herd) (guix build utils) (guix combinators))))) %base-services)))) (define (operating-system-add-packages os packages) "Append PACKAGES to OS packages list." (operating-system (inherit os) (packages (append packages (operating-system-packages os))))) (define-os-with-source (%minimal-extlinux-os %minimal-extlinux-os-source) (use-modules (gnu) (gnu tests) (gnu bootloader extlinux) (srfi srfi-1)) (operating-system (host-name "liberigilo") (timezone "Europe/Paris") (locale "en_US.UTF-8") (bootloader (bootloader-configuration (bootloader extlinux-bootloader-gpt) (targets (list "/dev/vdb")))) (kernel-arguments '("console=ttyS0")) (file-systems (cons (file-system (device (file-system-label "my-root")) (mount-point "/") (type "ext4")) %base-file-systems)) (services (cons (service marionette-service-type (marionette-configuration (imported-modules '((gnu services herd) (guix combinators))))) %base-services)))) (define MiB (expt 2 20)) (define %simple-installation-script ;; Shell script of a simple installation. "\ . /etc/profile set -e -x guix --version export GUIX_BUILD_OPTIONS=--no-grafts guix build isc-dhcp parted --script /dev/vdb mklabel gpt \\ mkpart primary ext2 1M 3M \\ mkpart primary ext2 3M 1.6G \\ set 1 boot on \\ set 1 bios_grub on mkfs.ext4 -L my-root /dev/vdb2 mount /dev/vdb2 /mnt df -h /mnt herd start cow-store /mnt mkdir /mnt/etc cp /