aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
;;; Copyright © 2022 Timothy Sample <samplet@ngyro.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 build bootloader)
  #:use-module (guix build utils)
  #:use-module (guix utils)
  #:use-module (ice-9 binary-ports)
  #:use-module (ice-9 format)
  #:use-module (rnrs io ports)
  #:use-module (rnrs io simple)
  #:export (write-file-on-device
            install-efi-loader))


;;;
;;; Writing utils.
;;;

(define (write-file-on-device file size device offset)
  "Write SIZE bytes from FILE to DEVICE starting at OFFSET."
  (call-with-input-file file
    (lambda (input)
      (let ((bv (get-bytevector-n input size)))
        (call-with-port
         ;; Do not use "call-with-output-file" that would truncate the file.
         (open-file-output-port device
                                (file-options no-truncate no-fail)
                                (buffer-mode block)
                                ;; Use the binary-friendly ISO-8859-1
                                ;; encoding.
                                (make-transcoder (latin-1-codec)))
         (lambda (output)
           (seek output offset SEEK_SET)
           (put-bytevector output bv)))))))


;;;
;;; EFI bootloader.
;;;

(define* (install-efi grub grub-config esp #:key targets)
  "Write a self-contained GRUB EFI loader to the mounted ESP using
GRUB-CONFIG.

If TARGETS is set, use its car as the GRUB image format and its cdr as
the output filename.  Otherwise, use defaults for the host platform."
  (let* ((system %host-type)
         ;; Hard code the output location to a well-known path recognized by
         ;; compliant firmware. See "3.5.1.1 Removable Media Boot Behaviour":
         ;; http://www.uefi.org/sites/default/files/resources/UEFI%20Spec%202_6.pdf
         (grub-mkstandalone (string-append grub "/bin/grub-mkstandalone"))
         (efi-directory (string-append esp "/EFI/BOOT"))
         ;; Map grub target names to boot file names.
         (efi-targets (or targets
                          (cond ((string-prefix? "x86_64" system)
                                 '("x86_64-efi" . "BOOTX64.EFI"))
                                ((string-prefix? "i686" system)
                                 '("i386-efi" . "BOOTIA32.EFI"))
                                ((string-prefix? "armhf" system)
                                 '("arm-efi" . "BOOTARM.EFI"))
                                ((string-prefix? "aarch64" system)
                                 '("arm64-efi" . "BOOTAA64.EFI"))))))
    ;; grub-mkstandalone requires a TMPDIR to prepare the firmware image.
    (setenv "TMPDIR" esp)

    (mkdir-p efi-directory)
    (invoke grub-mkstandalone "-O" (car efi-targets)
            "-o" (string-append efi-directory "/"
                                (cdr efi-targets))
            ;; Graft the configuration file onto the image.
            (string-append "boot/grub/grub.cfg=" grub-config))))

(define* (install-efi-loader grub-efi esp #:key targets)
  "Install in ESP directory the given GRUB-EFI bootloader.  Configure it to
load the Grub bootloader located in the 'Guix_image' root partition.

If TARGETS is set, use its car as the GRUB image format and its cdr as
the output filename.  Otherwise, use defaults for the host platform."
  (let ((grub-config "grub.cfg"))
    (call-with-output-file grub-config
      (lambda (port)
        ;; Create a tiny configuration file telling the embedded grub where to
        ;; load the real thing.  XXX This is quite fragile, and can prevent
        ;; the image from booting when there's more than one volume with this
        ;; label present.  Reproducible almost-UUIDs could reduce the risk
        ;; (not eliminate it).
        (format port
                "insmod part_msdos~@
               insmod part_gpt~@
               search --set=root --label Guix_image~@
               configfile /boot/grub/grub.cfg~%")))
    (install-efi grub-efi grub-config esp #:targets targets)
    (delete-file grub-config)))

:41 +0200'>2020-09-18gnu: kdenlive: Update to 20.08.1....* gnu/packages/kde.scm (kdenlive): Update to 20.08.1. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Prafulla Giri 2020-09-14gnu: kdenlive: Change source URL to follow permanent redirection....* gnu/packages/kde.scm (kdenlive)[source]: Change url to follow permanent redirection. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Prafulla Giri 2020-09-14gnu: kde: kdenlive: Make breeze theme available at runtime....* gnu/packages/kde.scm (kdenlive): [inputs]: Add breeze. [arguments]: In wrap-program phase, add XDG_DATA_DIRS to include the 'share' sub-directory of the package breeze. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Prafulla Giri 2020-09-05Merge remote-tracking branch 'origin/master' into stagingEfraim Flashner 2020-09-04gnu: kdenlive: Add ffmpeg to input list...* gnu/packages/kde.scm (kdenlive): Add ffmpeg to inputs and wrap the final binary accordingly to have ffmpeg in it's PATH. [inputs]: Add ffmpeg. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Prafulla Giri 2020-08-11gnu: kdenlive: Update to 20.04.1....* gnu/packages/kde.scm (kdenlive): Update to 20.04.1. [propagated-inputs]: Move mlt to ... [inputs]: ... here and add rttr, qtmultimedia, qtquickcontrols2. [arguments]: Add MLT_PREFIX to wrap-program. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Michael Rohleder 2020-07-30gnu: krita: Update to 4.3.0....* gnu/packages/kde.scm (krita): Update to 4.3.0. Signed-off-by: Marius Bakke <marius@gnu.org> Boris A. Dekshteyn 2020-07-24gnu: qtbase: Incorporate bugfix variants....* gnu/packages/qt.scm (qtbase/next, qtbase-for-krita): Remove variables. (qtbase)[source](patches): Add "qtbase-absolute-runpath.patch" and "qtbase-fix-krita-deadlock.patch". (python-pyside-2-tools)[inputs]: Change from QTBASE/NEXT to QTBASE. * gnu/packages/kde.scm (krita)[inputs]: Change from QTBASE-FOR-KRITA to QTBASE. Marius Bakke 2020-07-23gnu: Fix Krita....Fixes <https://bugs.gnu.org/42476>. Reported by linka on #guix. * gnu/packages/patches/qtbase-fix-krita-deadlock.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/qt.scm (qtbase-for-krita): New variable. * gnu/packages/kde.scm (krita)[inputs]: Replace qtbase with qtbase-for-krita. Leo Famulari 2020-07-23Revert "gnu: Fix Krita."...This reverts commit 5f63905096e456097fca206f56ce9257f72faf64. This commit caused `guix pull` to crash like this: ------ Backtrace: In ice-9/boot-9.scm: 222:29 19 (map1 _) 222:29 18 (map1 _) 222:29 17 (map1 _) 222:29 16 (map1 _) 222:17 15 (map1 (((gnu packages kde)) ((gnu packages libevent)) ((gnu packages libidn)) ((gnu packages #)) ((?)) ?)) 3297:17 14 (resolve-interface (gnu packages kde) #:select _ #:hide _ #:prefix _ #:renamer _ #:version _) In ice-9/threads.scm: 390:8 13 (_ _) In ice-9/boot-9.scm: 3223:13 12 (_) In ice-9/threads.scm: 390:8 11 (_ _) In ice-9/boot-9.scm: 3507:20 10 (_) 2806:4 9 (save-module-excursion _) 3527:26 8 (_) In unknown file: 7 (primitive-load-path "gnu/packages/kde" #<procedure 7f68d6fe5da0 at ice-9/boot-9.scm:3514:37 ()>) In ice-9/eval.scm: 626:19 6 (_ #<directory (gnu packages kde) 7f68d6175b40>) 293:34 5 (_ #<directory (gnu packages kde) 7f68d6175b40>) 173:47 4 (_ #(#<directory (gnu packages kde) 7f68d6175b40> #<promise #<procedure 7f68dc5a5d00 at ice-9/eval.sc?>)) 159:9 3 (_ #(#<directory (gnu packages kde) 7f68d6175b40> #<promise #<procedure 7f68dc5a5d00 at ice-9/eval.sc?>)) 191:35 2 (_ #(#<directory (gnu packages kde) 7f68d6175b40> #<promise #<procedure 7f68dc5a5d00 at ice-9/eval.sc?>)) 223:20 1 (proc #(#<directory (gnu packages kde) 7f68d6175b40> #<promise #<procedure 7f68dc5a5d00 at ice-9/eval?>)) In unknown file: 0 (%resolve-variable (7 . qtbase) #<directory (gnu packages kde) 7f68d6175b40>) ERROR: In procedure %resolve-variable: error: qtbase: unbound variable ------ Leo Famulari 2020-07-23gnu: Fix Krita....Fixes <https://bugs.gnu.org/42476>. Reported by linka on #guix. * gnu/packages/patches/qtbase-fix-krita-deadlock.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/kde.scm (qtbase-for-krita): New variable. (krita)[inputs]: Replace qtbase with qtbase-for-krita. Leo Famulari 2020-06-30gnu: kdeconnect: Update to 20.04.2....* gnu/packages/kde.scm (kdeconnect): Update to 20.04.2. Efraim Flashner 2020-06-14gnu: kdeconnect: Update to 20.04.1....* gnu/packages/kde.scm (kdeconnect): Update to 20.04.1. [source]: Update source URI. [arguments]: Adjust configure flags. Efraim Flashner 2020-06-06gnu: kdeconnect: Update to 1.4....* gnu/packages/kde.scm (kdeconnect): Update to 1.4. [arguments]: Add #:phases. [inputs]: Add KIRIGAMI, KPEOPLE, KPEOPLEVCARD, PULSEAUDIO-QT, and QTMULTIMEDIA. Marius Bakke 2020-06-06gnu: KDE: Update to 20.04.1....* gnu/packages/patches/akonadi-paths.patch: Adjust for upstream changes. * gnu/packages/patches/kdepim-runtime-Fix-missing-link-libraries.patch: Delete file. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/kde-internet.scm (kget, kopete, krdc, libgravatar): Update to 20.04.1. [source](uri): Adjust for new upstream location. * gnu/packages/kde-multimedia.scm (audiocd-kio, dragon, ffmpegthumbs, juk, k3b, kamoso, kmix, kwave, libkcddb, libkcompactdisc): Likewise. * gnu/packages/kde-systemtools.scm (dolphin, dolphin-plugins, khelpcenter, konsole, krfb, ksystemlog): Update to 20.04.1. [source](uri): Adjust for new upstream location. * gnu/packages/kde-utils.scm (kate, kmag, kmousetool, kmouth, sweeper): Update to 20.04.1. [source](uri): Adjust for new upstream location. * gnu/packages/kde.scm (baloo-widgets, libkomparediff2, kqtquickcharts, grantleetheme, kcachegrind, libkdegames, zeroconf-ioslave): Update to 20.04.1. [source](uri): Adjust for new upstream location. (grantleetheme)[inputs]: Add KGUIADDONS. * gnu/packages/kde-pim.scm (akonadi, akonadi-calendar, akonadi-contacts, akonadi-mime, akonadi-notes, akonadi-search, kincidenceeditor, kaddressbook, kalarmcal, kblog, kcalendarsupport, kcalutils, kdav, kdepim-apps-libs, kdepim-runtime, keventviews, kgpg, kidentitymanagement, kimap, kldap, kleopatra, kmail, kmailcommon, kmailimporter, kmailtransport, kmbox, kmessagelib, kmime, knotes, kontactinterface, korganizer, kpimcommon, kpimtextedit, ksmtp, ktnef, libkdepim, libkgapi, libkleo, libksieve): Update to 20.04.1. [source](uri): Adjust to current. (akonadi)[inputs]: Remove KDBUSADDONS and KDESIGNERPLUGIN. (akonadi-calendar)[inputs]: Remove KDBUSADDONS. (kdepim-runtime)[source](patches): Remove. [arguments]: Add phase 'extend-CPLUS_INCLUDE_PATH'. [inputs]: Remove KDBUSADDONS and KICONTHEMES. (kmessagelib)[arguments]: Add phase 'extend-CPLUS_INCLUDE_PATH. [inputs]: Add QCA. (kdepim-apps-libs)[inputs]: Remove KDBUSADDONS and KICONTHEMES. (knotes)[inputs]: Remove KDBUSADDONS. (kpimcommon)[inputs]: Remove KDBUSADDONS and KCOMPLETION. (libksieve)[arguments]: Disable one more test. (korganizer)[arguments]: Disable one test. Marius Bakke 2020-06-06gnu: kdevelop: Update to 5.5.2....* gnu/packages/kde.scm (kdevelop): Update to 5.5.2. Marius Bakke 2020-05-18gnu: kcachegrind: Update to 19.08.3....* gnu/packages/kde.scm (kcachegrind): Update to 19.08.3. Marius Bakke 2020-05-18gnu: kqtquickcharts: Update to 19.08.3....* gnu/packages/kde.scm (kqtquickcharts): Update to 19.08.3. Marius Bakke 2020-05-18gnu: kpmcore: Update to 4.1.0....* gnu/packages/patches/kpmcore-fix-tests.patch, gnu/packages/patches/kpmcore-remove-broken-test.patch: Delete files. * gnu/local.mk (dist_patch_DATA): Adjust accordingly. * gnu/packages/kde.scm (kpmcore): Update to 4.1.0. [source](patches): Remove. Marius Bakke 2020-05-18gnu: qca: Update to 2.3.0....* gnu/packages/kde.scm (qca): Update to 2.3.0. Marius Bakke 2020-05-18gnu: libkomparediff2: Update to 19.08.3....* gnu/packages/kde.scm (libkomparediff2): Update to 19.08.3. Marius Bakke 2020-05-18gnu: krita: Update to 4.2.9....* gnu/packages/kde.scm (krita): Update to 4.2.9. [arguments]: Add special configure flag for OPENEXR instead of ILMBASE. Marius Bakke 2020-05-18gnu: kdiagram: Update to 2.7.0....* gnu/packages/kde.scm (kdiagram): Update to 2.7.0. Marius Bakke 2020-05-17gnu: kdeconnect: Fix kdeconnectd path....* gnu/packages/kde.scm (kdeconnect)[arguments]: Add configure-flag to set libexec as a top-level directory in the output. Efraim Flashner 2020-05-13gnu: kdevelop: Update to 5.5.1....* gnu/packages/kde.scm (kdevelop): Update to 5.5.1. Efraim Flashner 2020-05-13gnu: kdevelop-pg-qt: Update to 2.2.1....* gnu/packages/kde.scm (kdevelop-pg-qt): Update to 2.2.1. [source]: Download using git-fetch. Efraim Flashner 2020-03-21Merge branch 'master' into core-updatesMarius Bakke 2020-03-19gnu: Add kdiagram....* gnu/packages/kde.scm (kdiagram): New variable. * packages/patches/kdiagram-Fix-missing-link-libraries.patch: New file. * gnu/local.mk: Add it. Hartmut Goebel