gnu: Add cl-tga.
[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 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages genimage)
20 #:use-module (guix utils)
21 #:use-module (guix packages)
22 #:use-module (guix git-download)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix build-system gnu)
25 #:use-module (guix build utils)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages autotools)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages bash)
30 #:use-module (gnu packages bootloaders)
31 #:use-module (gnu packages cdrom)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages cpio)
34 #:use-module (gnu packages disk)
35 #:use-module (gnu packages linux)
36 #:use-module (gnu packages mtools)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages textutils)
39 #:use-module (gnu packages virtualization))
40
41 (define-public genimage
42 (package
43 (name "genimage")
44 (version "11")
45 (source (origin
46 (method git-fetch)
47 (uri (git-reference
48 (url "https://github.com/pengutronix/genimage")
49 (commit (string-append "v" version))))
50 (file-name (string-append name "-" version "-checkout"))
51 (sha256
52 (base32
53 "15jmh17lvm3jw9c92bjarly7iwhmnfl322d91mprfv10ppb9ip54"))))
54 (build-system gnu-build-system)
55 (arguments
56 `(#:phases
57 (modify-phases %standard-phases
58 (add-after 'unpack 'guixify
59 (lambda* (#:key inputs #:allow-other-keys)
60 ;; Note to maintainers: Check ".def =" lines in source.
61 (substitute* "config.c"
62 (("\\.def = \"cpio\"")
63 (string-append ".def = \""
64 (assoc-ref inputs "cpio")
65 "/bin/cpio\""))
66 (("\\.def = \"dd\"")
67 (string-append ".def = \""
68 (assoc-ref inputs "coreutils")
69 "/bin/dd\""))
70 (("\\.def = \"debugfs\"")
71 (string-append ".def = \""
72 (assoc-ref inputs "e2fsprogs")
73 "/sbin/debugfs\""))
74 (("\\.def = \"e2fsck\"")
75 (string-append ".def = \""
76 (assoc-ref inputs "e2fsprogs")
77 "/sbin/e2fsck\""))
78 (("\\.def = \"genext2fs\"")
79 (string-append ".def = \""
80 (assoc-ref inputs "genext2fs")
81 "/bin/genext2fs\""))
82 (("\\.def = \"genisoimage\"")
83 (string-append ".def = \""
84 (assoc-ref inputs "cdrkit-libre")
85 "/bin/genisoimage\""))
86 (("\\.def = \"mcopy\"")
87 (string-append ".def = \""
88 (assoc-ref inputs "mtools")
89 "/bin/mcopy\""))
90 (("\\.def = \"mmd\"")
91 (string-append ".def = \""
92 (assoc-ref inputs "mtools")
93 "/bin/mmd\""))
94 ;;; Note: mkcramfs is obsolete.
95 (("\\.def = \"mkdosfs\"")
96 (string-append ".def = \""
97 (assoc-ref inputs "dosfstools")
98 "/sbin/mkfs.fat\""))
99 (("\\.def = \"mke2fs\"")
100 (string-append ".def = \""
101 (assoc-ref inputs "e2fsprogs")
102 "/sbin/mke2fs\""))
103 (("\\.def = \"mkfs\\.jffs2\"")
104 (string-append ".def = \""
105 (assoc-ref inputs "mtd-utils")
106 "/sbin/mkfs.jffs2\""))
107 (("\\.def = \"mkfs\\.ubifs\"")
108 (string-append ".def = \""
109 (assoc-ref inputs "mtd-utils")
110 "/sbin/mkfs.ubifs\""))
111 (("\\.def = \"mksquashfs\"")
112 (string-append ".def = \""
113 (assoc-ref inputs "squashfs-tools")
114 "/bin/mksquashfs\""))
115 (("\\.def = \"qemu-img\"")
116 (string-append ".def = \""
117 (assoc-ref inputs "qemu")
118 "/bin/qemu-img\""))
119 (("\\.def = \"tar\"")
120 (string-append ".def = \""
121 (assoc-ref inputs "tar")
122 "/bin/tar\""))
123 (("\\.def = \"tune2fs\"")
124 (string-append ".def = \""
125 (assoc-ref inputs "e2fsprogs")
126 "/sbin/tune2fs\""))
127 (("\\.def = \"ubinize\"")
128 (string-append ".def = \""
129 (assoc-ref inputs "mtd-utils")
130 "/sbin/ubinize\""))
131 (("\\.def = \"mkimage\"")
132 (string-append ".def = \""
133 (assoc-ref inputs "u-boot-tools")
134 "/bin/mkimage\"")))
135 (substitute* "test/basic-images.test"
136 ;; Work around bug in sharness.sh.
137 (("mkdosfs")
138 "mkfs.fat")
139 ;; Work around bug in sharness.sh.
140 (("dd,mkfs\\.fat,mcopy")
141 "dd,mkfs_fat,mcopy")
142 ;; Should be in the next upstream release.
143 (("qemu_img") "qemu-img"))
144 (substitute* "util.c"
145 (("\"/bin/sh\"")
146 (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))
147 ;; We don't have /etc/passwd so uid 0 is not known as "root".
148 ;; Thus patch it out.
149 (substitute* '("test/ext2test.dump"
150 "test/ext3test.dump"
151 "test/ext4test.dump"
152 "test/ext2test-percent.dump"
153 "test/mke2fs.dump")
154 (("root") "unknown"))
155 #t))
156 (add-before 'check 'setenv-check
157 (lambda _
158 ;; Our container doesn't provide access to /etc/mtab
159 (setenv "EXT2FS_NO_MTAB_OK" "1")
160 ;; Make test reproducible
161 (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
162 (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")
163 #t))
164 (replace 'check
165 (lambda _
166 (invoke "make" "TEST_LOG_COMPILER=" "check"))))))
167 (native-inputs
168 `(("autoconf" ,autoconf)
169 ("automake" ,automake)
170 ;;; Note: cramfs is obsolete.
171 ("dtc" ,dtc) ; for the tests
172 ("fdisk" ,fdisk) ; for the tests
173 ("pkg-config" ,pkg-config)
174 ("util-linux" ,util-linux))) ; for the tests
175 (inputs
176 `(("bash" ,bash)
177 ("cdrkit-libre" ,cdrkit-libre)
178 ("cpio" ,cpio)
179 ;; Note: invoked by final executable.
180 ("coreutils" ,coreutils) ; chmod, dd
181 ("dosfstools" ,dosfstools)
182 ("e2fsprogs" ,e2fsprogs)
183 ("genext2fs" ,genext2fs)
184 ("libconfuse" ,libconfuse)
185 ("mtd-utils" ,mtd-utils)
186 ("mtools" ,mtools)
187 ("qemu" ,qemu-minimal)
188 ("squashfs-tools" ,squashfs-tools)
189 ("tar" ,tar)
190 ("u-boot-tools" ,u-boot-tools)))
191 (synopsis "Create Flash images according to specification")
192 (description "@command{genimage} creates Flash images according to a
193 specification file.")
194 (home-page "https://github.com/pengutronix/genimage")
195 (license license:gpl2)))