gnu: emacs-helm: Update to 3.8.7.
[jackhill/guix/guix.git] / gnu / packages / genimage.scm
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>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
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.
12 ;;;
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.
17 ;;;
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/>.
20
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))
42
43 (define-public genimage
44 (let ((commit "ec44ae086c705e6f0439e742c5a2e9b8f3d6ca82")
45 (revision "1"))
46 (package
47 (name "genimage")
48 (version (git-version "15" revision commit))
49 (source (origin
50 (method git-fetch)
51 (uri (git-reference
52 (url "https://github.com/pengutronix/genimage")
53 (commit commit)))
54 (file-name (git-file-name name version))
55 (sha256
56 (base32
57 "0amj2vjff58yna6kq959i2gqmbjywqr8j5kr5pjqsvbqam3vgg0r"))
58 (patches
59 (search-patches "genimage-mke2fs-test.patch"))))
60 (build-system gnu-build-system)
61 (arguments
62 `(#:modules
63 ((ice-9 match)
64 ,@%gnu-build-system-modules)
65 #:phases
66 (modify-phases %standard-phases
67 (add-after 'unpack 'guixify
68 (lambda* (#:key inputs #:allow-other-keys)
69 (map (match-lambda
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")
86 ("tar" "bin" "tar")
87 ("u-boot-tools" "bin" "mkimage")))
88 (substitute* "util.c"
89 (("\"/bin/sh\"")
90 (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))))
91 (add-before 'check 'fix-failing-tests
92 (lambda _
93 ;; We don't have /etc/passwd so uid 0 is not known as "root".
94 ;; Thus patch it out.
95 (substitute* '("test/ext2test.0.dump"
96 "test/ext2test.1.dump"
97 "test/ext3test.0.dump"
98 "test/ext3test.1.dump"
99 "test/ext4test.0.dump"
100 "test/ext4test.1.dump"
101 "test/ext2test-percent.0.dump"
102 "test/ext2test-percent.1.dump"
103 "test/mke2fs.0.dump")
104 (("root") "unknown"))))
105 (add-before 'check 'setenv-check
106 (lambda _
107 ;; Our container doesn't provide access to /etc/mtab
108 (setenv "EXT2FS_NO_MTAB_OK" "1")
109 ;; Make test reproducible
110 (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
111 (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")))
112 (replace 'check
113 (lambda _
114 (invoke "make" "TEST_LOG_COMPILER=" "check"))))))
115 (native-inputs
116 (list autoconf
117 automake
118 ;;; Note: cramfs is obsolete.
119 dtc ; for the tests
120 pkg-config
121 util-linux)) ; for the tests
122 (inputs
123 `(("bash" ,bash)
124 ("cdrkit-libre" ,cdrkit-libre)
125 ("cpio" ,cpio)
126 ;; Note: invoked by final executable.
127 ("coreutils" ,coreutils) ; chmod, dd
128 ("dosfstools" ,dosfstools)
129 ("e2fsprogs" ,e2fsprogs)
130 ("genext2fs" ,genext2fs)
131 ("libconfuse" ,libconfuse)
132 ("mtd-utils" ,mtd-utils)
133 ("mtools" ,mtools)
134 ("qemu" ,qemu-minimal)
135 ("squashfs-tools" ,squashfs-tools)
136 ("tar" ,tar)
137 ("u-boot-tools" ,u-boot-tools)))
138 (synopsis "Create Flash images according to specification")
139 (description "@command{genimage} creates Flash images according to a
140 specification file.")
141 (home-page "https://github.com/pengutronix/genimage")
142 (license license:gpl2))))