aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 David Craven <david@craven.ch>
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2022 Reza Alizadeh Majd <r.majd@pantherx.org>
;;;
;;; 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 bootloader extlinux)
  #:use-module (gnu bootloader)
  #:use-module (gnu packages bootloaders)
  #:use-module (guix gexp)
  #:use-module (guix utils)
  #:export (extlinux-bootloader
            extlinux-bootloader-gpt))

(define* (extlinux-configuration-file config entries
                                      #:key
                                      (system (%current-system))
                                      (old-entries '())
                                      #:allow-other-keys)
  "Return the U-Boot configuration file corresponding to CONFIG, a
<u-boot-configuration> object, and where the store is available at STORE-FS, a
<file-system> object.  OLD-ENTRIES is taken to be a list of menu entries
corresponding to old generations of the system."

  (define all-entries
    (append entries (bootloader-configuration-menu-entries config)))

  (define with-fdtdir?
    (bootloader-configuration-device-tree-support? config))

  (define (menu-entry->gexp entry)
    (let ((label (menu-entry-label entry))
          (kernel (menu-entry-linux entry))
          (kernel-arguments (menu-entry-linux-arguments entry))
          (initrd (menu-entry-initrd entry)))
      #~(format port "LABEL ~a
  MENU LABEL ~a
  KERNEL ~a
  ~a
  INITRD ~a
  APPEND ~a
~%"
                #$label #$label
                #$kernel
                (if #$with-fdtdir?
                    (string-append "FDTDIR " (dirname #$kernel) "/lib/dtbs")
                    "")
                #$initrd
                (string-join (list #$@kernel-arguments)))))

  (define builder
    #~(call-with-output-file #$output
        (lambda (port)
          (let ((timeout #$(bootloader-configuration-timeout config)))
            (format port "# This file was generated from your Guix configuration.  Any changes
# will be lost upon reconfiguration.
UI menu.c32
MENU TITLE GNU Guix Boot Options
PROMPT ~a
TIMEOUT ~a~%"
                    (if (> timeout 0) 1 0)
                    ;; timeout is expressed in 1/10s of seconds.
                    (* 10 timeout))
            #$@(map menu-entry->gexp all-entries)

            #$@(if (pair? old-entries)
                   #~((format port "~%")
                      #$@(map menu-entry->gexp old-entries)
                      (format port "~%"))
                   #~())))))

  (computed-file "extlinux.conf" builder
                 #:options '(#:local-build? #t
                             #:substitutable? #f)))




;;;
;;; Install procedures.
;;;

(define (install-extlinux mbr)
  #~(lambda (bootloader device mount-point)
      (let ((extlinux (string-append bootloader "/sbin/extlinux"))
            (install-dir (string-append mount-point "/boot/extlinux"))
            (syslinux-dir (string-append bootloader "/share/syslinux")))
        (for-each (lambda (file)
                    (install-file file install-dir))
                  (find-files syslinux-dir "\\.c32$"))
        (invoke/quiet extlinux "--install" install-dir)
        (write-file-on-device (string-append syslinux-dir "/" #$mbr)
                              440 device 0))))

(define install-extlinux-mbr
  (install-extlinux "mbr.bin"))

(define install-extlinux-gpt
  (install-extlinux "gptmbr.bin"))



;;;
;;; Bootloader definitions.
;;;

(define extlinux-bootloader
  (bootloader
   (name 'extlinux)
   (package syslinux)
   (installer install-extlinux-mbr)
   (configuration-file "/boot/extlinux/extlinux.conf")
   (configuration-file-generator extlinux-configuration-file)))

(define extlinux-bootloader-gpt
  (bootloader
   (inherit extlinux-bootloader)
   (installer install-extlinux-gpt)))
: Build hurd-barebones-qcow2-image.Mathieu Othacehe Build hurd-barebones-qcow2-image instead of hurd-barebones-disk-image to speed downloads. * gnu/ci.scm (%guix-system-images): Build 'hurd-barebones-qcow2-image instead of 'hurd-barebones-disk-image. 2020-09-25ci: Remove native-system restriction from "hello" and "list" jobsets.Jan (janneke) Nieuwenhuizen * gnu/ci.scm (hydra-jobs): Remove restriction for system to equal (%current-system). Co-authored-by: Ludovic Courtès <ludo@gnu.org> 2020-09-03ci: In the 'core' subset, build GCC >= 7.Ludovic Courtès Suggested by Jan Nieuwenhuizen <janneke@gnu.org>. * gnu/ci.scm (%core-packages): Keep only GCC >= 7. 2020-09-03gnu: ci: Truncate git commit in ISO label.Julien Lepiller * gnu/ci.scm (image-jobs): Keep only 7 characters from git commit in ISO label. 2020-08-31gnu: ci: Set label in iso9660 jobs.Julien Lepiller * gnu/ci.scm (image-jobs): Set label of generated ISOs. 2020-06-29ci: Do not limit disk-image size.Mathieu Othacehe Installation tests are already checking the disk-image size. Do not set another limit here. * gnu/ci.scm (image-jobs): Do not limit disk-image size. 2020-06-25ci: Build Guix System images.Mathieu Othacehe Build a list of Guix System images. For now, this list only contains the Hurd barebones Guix System image. * gnu/ci.scm (%guixsd-supported-systems): Remove "armhf-linux", (%u-boot-systems): remove unused variable, (%guix-system-images): new variable (qemu-jobs): rename to "image-jobs" and build the Guix Systems listed in the new "%guix-system-images" variable, (system-test-jobs): adapt accordingly, (hydra-jobs): ditto. 2020-06-25Revert "ci: Build Guix System images."Ludovic Courtès This reverts commit eda3fcfb46586710fff876ce6254b300795ef543. This change broke evaluations on CI: @ build-succeeded /gnu/store/991738x97ff1f8181a7p1pflqwkgagm8-profile.drv - ERROR: In procedure read: In procedure scm_lreadr: #<unknown port>:16:144: Unknown # object: #\< 2020-06-24ci: Build Guix System images.Mathieu Othacehe 2020-05-29image: Do not use VM to create disk-images.Mathieu Othacehe Now that installing Grub on raw disk-images is supported, we do not need to rely on (gnu system vm) module. * gnu/system/image.scm (make-system-image): Rename to ... (system-image): ... this, and remove the compatibility wrapper. (find-image): Turn to a monadic procedure. This will become useful when introducing Hurd support, to be able to detect the target system. * gnu/ci.scm (qemu-jobs): Use lower-object now that system-image returns a file-like object. * gnu/tests/install.scm (run-install): Ditto. * guix/scripts/system.scm (system-derivation-for-action): Add a 'base-image' argument, (perform-action): adapt accordingly. 2020-05-05Merge branch 'master' into core-updatesMarius Bakke 2020-05-05image: Add a new API.Mathieu Othacehe Raw disk-images and ISO9660 images are created in a Qemu virtual machine. This is quite fragile, very slow, and almost unusable without KVM. For all these reasons, add support for host image generation. This implies the use new image generation mechanisms. - Raw disk images: images of partitions are created using tools such as mke2fs and mkdosfs depending on the partition file-system type. The partition images are then assembled into a final image using genimage. - ISO9660 images: the ISO root directory is populated within the store. GNU xorriso is then called on that directory, in the exact same way as this is done in (gnu build vm) module. Those mechanisms are built upon the new (gnu image) module. * gnu/image.scm: New file. * gnu/system/image.scm: New file. * gnu/build/image: New file. * gnu/local.mk: Add them. * gnu/system/vm.scm (system-disk-image): Rename to system-disk-image-in-vm. * gnu/ci.scm (qemu-jobs): Adapt to new API. * gnu/tests/install.scm (run-install): Ditto. * guix/scripts/system.scm (system-derivation-for-action): Ditto. 2020-04-08Merge branch 'master' into core-updatesMarius Bakke Conflicts: etc/news.scm gnu/local.mk gnu/packages/check.scm gnu/packages/cross-base.scm gnu/packages/gimp.scm gnu/packages/java.scm gnu/packages/mail.scm gnu/packages/sdl.scm gnu/packages/texinfo.scm gnu/packages/tls.scm gnu/packages/version-control.scm 2020-04-07ci: Remove "mips64el-linux-gnuabi64" from '%cross-targets'.Ludovic Courtès The N64 ABI has always been a niche, it seems. * gnu/ci.scm (%cross-targets): Remove "mips64el-linux-gnuabi64". 2020-03-14Merge branch 'master' into core-updatesMarius Bakke 2020-03-13maint: Add 'etc/release-manifest.scm'.Ludovic Courtès * etc/release-manifest.scm: New file. * gnu/ci.scm (%cross-targets): Export. * build-aux/check-available-binaries.scm: Remove. * Makefile.am (EXTRA_DIST): Add 'etc/release-manifest.scm' and remove 'build-aux/check-available-binaries.scm'. (assert-binaries-available): Rewrite using 'guix weather -m'. 2020-03-10Merge branch 'master' into core-updatesMarius Bakke 2020-03-05ci: Adjust 'channel-build-system' for when the source is a file name.Ludovic Courtès Fixes an evaluation error introduced in dd1ee160be8ba4e211432c08e161c24901cd670e: when invoked via 'build-aux/cuirass/gnu-system.scm', SOURCE is a store file name, not a <local-file> as it is when invoked via 'etc/system-tests.scm'. * gnu/ci.scm (channel-build-system)[build]: Call 'lower-object' only when SOURCE is not a string. 2020-03-05tests: "make check-system" no longer interns source upfront.Ludovic Courtès * gnu/ci.scm (channel-build-system)[build, lower]: Honor #:source. (channel-source->package): New procedure. (system-test-jobs): Remove 'instance' and call to 'checkout->channel-instance'. Use 'channel-source->package'. * build-aux/run-system-tests.scm (tests-for-channel-instance): Rename to... (tests-for-current-guix): ... this. Change 'instance' to 'source'. (run-system-tests): Use 'local-file' instead of 'interned-file' for SOURCE. 2020-03-05ci: Move 'cross-jobs' procedure to the top level.Ludovic Courtès * gnu/ci.scm (cross-jobs): New procedure. Moved from... (hydra-jobs): ... here. 2020-02-24ci: Don't cross build bootstrap tarballs to MinGW.Ludovic Courtès This makes little sense and it broke in commit 8bd2b15b06f6306e37cc72995b76a7f0754cf1a6 since the mingw libc doesn't have a "static" output. * gnu/ci.scm (%packages-to-cross-build): Remove. (packages-to-cross-build): New procedure. (hydra-jobs)[cross-jobs]: Use it. 2020-01-31ci: Cross-build for riscv64-linux-gnu.Ludovic Courtès * gnu/ci.scm (%cross-targets): Add "riscv64-linux-gnu". 2019-12-01ci: Make sure the Guix checkout is the one providing Cuirass proc.Clément Lassieur Fixes <https://bugs.gnu.org/36378>. Reported by Reza Alizadeh Majd <r.majd@pantherx.org>. * build-aux/hydra/gnu-system.scm (find-current-checkout): New procedure. (hydra-jobs): Use FIND-CURRENT-CHECKOUT to define CHECKOUT. Pass it to the inferior Guix as an extra argument whose key is 'superior-guix-checkout'. * gnu/ci.scm (find-current-checkout): New procedure. (hydra-jobs): Use FIND-CURRENT-CHECKOUT to define CHECKOUT. This will return '#f' if the current Guix is an inferior. In that case, use the 'superior-guix-checkout' argument provided by the superior Guix. 2019-11-13tests: "make check-system" uses Guix built with (guix self).Ludovic Courtès This is a followup to 7e6d8d366a61f951936ed83371877ce006f679f6. It means that "make check-system" can run tests from (gnu tests install) much faster because it does not need to build a full 'guix' package. * gnu/ci.scm (channel-instance->package): Export. * build-aux/run-system-tests.scm (tests-for-channel-instance): New procedure, with code formerly in 'run-system-tests'. (run-system-tests): Call 'interned-file' for SOURCE, and add call to 'tests-for-channel-instance'.