1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
3 ;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
4 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages genimage)
22 #:use-module (guix utils)
23 #:use-module (guix packages)
24 #:use-module (guix git-download)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build utils)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages autotools)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bash)
32 #:use-module (gnu packages bootloaders)
33 #:use-module (gnu packages cdrom)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages cpio)
36 #:use-module (gnu packages disk)
37 #:use-module (gnu packages linux)
38 #:use-module (gnu packages mtools)
39 #:use-module (gnu packages pkg-config)
40 #:use-module (gnu packages textutils)
41 #:use-module (gnu packages virtualization))
43 (define-public genimage
44 (let ((commit "11bb04455eaf5434f0723c91a2224918ebd0a196")
48 (version (git-version "14" revision commit))
52 (url "https://github.com/pengutronix/genimage")
54 (file-name (git-file-name name version))
57 "1dq3lk0awk12v2aidry35gvrci5a3nr6rzcq0j9hyyf0w1z1rn0l"))
59 (search-patches "genimage-mke2fs-test.patch"))))
60 (build-system gnu-build-system)
64 ,@%gnu-build-system-modules)
66 (modify-phases %standard-phases
67 (add-after 'unpack 'guixify
68 (lambda* (#:key inputs #:allow-other-keys)
70 ((input directory regexp)
71 (substitute* "config.c"
72 (((format #f "\\.def = \"(~a)\"" regexp) _ command)
73 (format #f ".def = \"~a/~a/~a\""
74 (assoc-ref inputs input) directory command)))))
75 '(("cpio" "bin" "cpio")
76 ("coreutils" "bin" "dd")
77 ("e2fsprogs" "sbin" "debugfs|e2fsck|mke2fs|tune2fs")
78 ("genext2fs" "bin" "genext2fs")
79 ("cdrkit-libre" "bin" "genisoimage")
80 ("mtools" "bin" "mcopy|mmd")
81 ;; mkcramfs is obsolete.
82 ("dosfstools" "sbin" "mkdosfs")
83 ("mtd-utils" "sbin" "mkfs.(jffs2|ubifs)|ubinize")
84 ("squashfs-tools" "bin" "mksquashfs")
85 ("qemu" "bin" "qemu-img")
87 ("u-boot-tools" "bin" "mkimage")))
90 (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))))
91 (add-before 'check 'fix-failing-tests
93 ;; We don't have /etc/passwd so uid 0 is not known as "root".
95 (substitute* '("test/ext2test.0.dump"
96 "test/ext3test.0.dump"
97 "test/ext4test.0.dump"
98 "test/ext2test-percent.0.dump"
100 (("root") "unknown"))))
101 (add-before 'check 'setenv-check
103 ;; Our container doesn't provide access to /etc/mtab
104 (setenv "EXT2FS_NO_MTAB_OK" "1")
105 ;; Make test reproducible
106 (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
107 (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")))
110 (invoke "make" "TEST_LOG_COMPILER=" "check"))))))
112 `(("autoconf" ,autoconf)
113 ("automake" ,automake)
114 ;;; Note: cramfs is obsolete.
115 ("dtc" ,dtc) ; for the tests
116 ("pkg-config" ,pkg-config)
117 ("util-linux" ,util-linux))) ; for the tests
120 ("cdrkit-libre" ,cdrkit-libre)
122 ;; Note: invoked by final executable.
123 ("coreutils" ,coreutils) ; chmod, dd
124 ("dosfstools" ,dosfstools)
125 ("e2fsprogs" ,e2fsprogs)
126 ("genext2fs" ,genext2fs)
127 ("libconfuse" ,libconfuse)
128 ("mtd-utils" ,mtd-utils)
130 ("qemu" ,qemu-minimal)
131 ("squashfs-tools" ,squashfs-tools)
133 ("u-boot-tools" ,u-boot-tools)))
134 (synopsis "Create Flash images according to specification")
135 (description "@command{genimage} creates Flash images according to a
136 specification file.")
137 (home-page "https://github.com/pengutronix/genimage")
138 (license license:gpl2))))