(address . guix-patches@gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
* gnu/packages/flashing-tools.scm (rpi-imager): New variable.
---
gnu/packages/flashing-tools.scm | 88 +++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
Toggle diff (139 lines)
diff --git a/gnu/packages/flashing-tools.scm b/gnu/packages/flashing-tools.scm
index 08300cb860..4bbcd9c4f6 100644
--- a/gnu/packages/flashing-tools.scm
+++ b/gnu/packages/flashing-tools.scm
@@ -10,6 +10,7 @@
;;; Copyright © 2021 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Mathieu Othacehe <othacehe@gnu.org>
;;; Copyright © 2022 Peter Polidoro <peter@polidoro.io>
+;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -29,6 +30,7 @@
(define-module (gnu packages flashing-tools)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix download)
+ #:use-module (guix gexp)
#:use-module (guix git-download)
#:use-module (guix packages)
#:use-module (guix utils)
@@ -36,21 +38,26 @@ (define-module (gnu packages flashing-tools)
#:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
+ #:use-module (guix build-system qt)
#:use-module (gnu packages autotools)
#:use-module (gnu packages admin)
+ #:use-module (gnu packages backup)
#:use-module (gnu packages base)
#:use-module (gnu packages bison)
#:use-module (gnu packages boost)
#:use-module (gnu packages compression)
+ #:use-module (gnu packages curl)
#:use-module (gnu packages elf)
#:use-module (gnu packages flex)
#:use-module (gnu packages ghostscript)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages groff)
+ #:use-module (gnu packages guile)
#:use-module (gnu packages pciutils)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages libusb)
#:use-module (gnu packages libftdi)
+ #:use-module (gnu packages linux)
#:use-module (gnu packages pciutils)
#:use-module (gnu packages qt)
#:use-module (gnu packages tls))
@@ -295,6 +302,87 @@ (define-public rkflashtool
RK3036, RK3066, RK312X, RK3168, RK3188, RK3288, RK3368.")
(license license:bsd-2))))
+(define-public rpi-imager
+ (package
+ (name "rpi-imager")
+ (version "1.7.3")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/raspberrypi/rpi-imager")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (modules '((guix build utils)
+ (ice-9 ftw)
+ (srfi srfi-26)))
+ (snippet '(begin
+ ;; Remove all but the following bundled libraries,
+ ;; which are not yet packaged in Guix.
+ (define keep '("." ".."
+ "drivelist"
+ "mountutils"
+ "sha256crypt"))
+ (with-directory-excursion "src/dependencies"
+ (for-each delete-file-recursively
+ (scandir "." (negate
+ (cut member <> keep)))))))
+ (sha256
+ (base32
+ "0i7r1myhinhlgispq92nzvrjvbc48l87z8xfwc038l44qj1lsq8g"))))
+ (build-system qt-build-system)
+ (arguments
+ (list
+ #:tests? #f ;no test suite
+ #:configure-flags #~(list "-DENABLE_TELEMETRY=OFF")
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'chdir
+ (lambda _
+ (chdir "src")))
+ (add-after 'chdir 'customize-os-list.json
+ ;; The default operating system JSON list contains non-FSDG
+ ;; systems.
+ (lambda _
+ (let* ((datadir (string-append #$output
+ "/share/rpi-imager"))
+ (os-list.json (string-append datadir "/os-list.json")))
+ (mkdir-p datadir)
+ #$(with-extensions (list guile-json-4)
+ #~(begin
+ (use-modules (json))
+ (call-with-output-file os-list.json
+ ;; TODO: Register FSDG and RPi compatible OS
+ ;; images here.
+ (lambda (port)
+ (scm->json '() port)))))
+ (substitute* "config.h"
+ (("#define OSLIST_URL.*")
+ (string-append "#define OSLIST_URL \"file:///"
+ os-list.json "\"\n"))))))
+ (add-after 'chdir 'patch-cmake
+ (lambda _
+ (substitute* "CMakeLists.txt"
+ ;; lsblk expects to have access to /sys/dev/block,
+ ;; which doesn't exist in the build container;
+ ;; prevent the check to fail the build.
+ (("ret EQUAL \"1\"")
+ "FALSE")))))))
+ (inputs
+ (list gnutls
+ curl
+ libarchive
+ qtdeclarative-5
+ qtquickcontrols2-5
+ qtsvg-5
+ qttools-5
+ util-linux))
+ (home-page "https://github.com/raspberrypi/rpi-imager/")
+ (synopsis "Raspberry Pi Imaging Utility")
+ (description "A graphical utility to easily provision and flash a memory
+card with an operating system image suitable for the Raspberry Pi single board
+computer.")
+ (license license:asl2.0)))
+
(define-public heimdall
(package
(name "heimdall")
base-commit: b4be83b6ac7e2139bec5d3eaafcf8af6cbe50856
--
2.38.1