1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Danny Milosavljevic <dannym@scratchpost.org>
4 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
41 (define-public genimage
48 (url "https://github.com/pengutronix/genimage")
49 (commit (string-append "v" version))))
50 (file-name (string-append name "-" version "-checkout"))
53 "15jmh17lvm3jw9c92bjarly7iwhmnfl322d91mprfv10ppb9ip54"))
54 ;; will be shipped with release 14
55 (patches (search-patches "genimage-signedness.patch"))))
56 (build-system gnu-build-system)
59 (modify-phases %standard-phases
60 (add-after 'unpack 'guixify
61 (lambda* (#:key inputs #:allow-other-keys)
62 ;; Note to maintainers: Check ".def =" lines in source.
63 (substitute* "config.c"
64 (("\\.def = \"cpio\"")
65 (string-append ".def = \""
66 (assoc-ref inputs "cpio")
69 (string-append ".def = \""
70 (assoc-ref inputs "coreutils")
72 (("\\.def = \"debugfs\"")
73 (string-append ".def = \""
74 (assoc-ref inputs "e2fsprogs")
76 (("\\.def = \"e2fsck\"")
77 (string-append ".def = \""
78 (assoc-ref inputs "e2fsprogs")
80 (("\\.def = \"genext2fs\"")
81 (string-append ".def = \""
82 (assoc-ref inputs "genext2fs")
84 (("\\.def = \"genisoimage\"")
85 (string-append ".def = \""
86 (assoc-ref inputs "cdrkit-libre")
87 "/bin/genisoimage\""))
88 (("\\.def = \"mcopy\"")
89 (string-append ".def = \""
90 (assoc-ref inputs "mtools")
93 (string-append ".def = \""
94 (assoc-ref inputs "mtools")
96 ;;; Note: mkcramfs is obsolete.
97 (("\\.def = \"mkdosfs\"")
98 (string-append ".def = \""
99 (assoc-ref inputs "dosfstools")
101 (("\\.def = \"mke2fs\"")
102 (string-append ".def = \""
103 (assoc-ref inputs "e2fsprogs")
105 (("\\.def = \"mkfs\\.jffs2\"")
106 (string-append ".def = \""
107 (assoc-ref inputs "mtd-utils")
108 "/sbin/mkfs.jffs2\""))
109 (("\\.def = \"mkfs\\.ubifs\"")
110 (string-append ".def = \""
111 (assoc-ref inputs "mtd-utils")
112 "/sbin/mkfs.ubifs\""))
113 (("\\.def = \"mksquashfs\"")
114 (string-append ".def = \""
115 (assoc-ref inputs "squashfs-tools")
116 "/bin/mksquashfs\""))
117 (("\\.def = \"qemu-img\"")
118 (string-append ".def = \""
119 (assoc-ref inputs "qemu")
121 (("\\.def = \"tar\"")
122 (string-append ".def = \""
123 (assoc-ref inputs "tar")
125 (("\\.def = \"tune2fs\"")
126 (string-append ".def = \""
127 (assoc-ref inputs "e2fsprogs")
129 (("\\.def = \"ubinize\"")
130 (string-append ".def = \""
131 (assoc-ref inputs "mtd-utils")
133 (("\\.def = \"mkimage\"")
134 (string-append ".def = \""
135 (assoc-ref inputs "u-boot-tools")
137 (substitute* "test/basic-images.test"
138 ;; Work around bug in sharness.sh.
141 ;; Work around bug in sharness.sh.
142 (("dd,mkfs\\.fat,mcopy")
144 ;; Should be in the next upstream release.
145 (("qemu_img") "qemu-img"))
146 (substitute* "util.c"
148 (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))
149 ;; We don't have /etc/passwd so uid 0 is not known as "root".
150 ;; Thus patch it out.
151 (substitute* '("test/ext2test.dump"
154 "test/ext2test-percent.dump"
156 (("root") "unknown"))
158 (add-before 'check 'setenv-check
160 ;; Our container doesn't provide access to /etc/mtab
161 (setenv "EXT2FS_NO_MTAB_OK" "1")
162 ;; Make test reproducible
163 (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
164 (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")
168 (invoke "make" "TEST_LOG_COMPILER=" "check"))))))
170 `(("autoconf" ,autoconf)
171 ("automake" ,automake)
172 ;;; Note: cramfs is obsolete.
173 ("dtc" ,dtc) ; for the tests
174 ("pkg-config" ,pkg-config)
175 ("util-linux" ,util-linux))) ; for the tests
178 ("cdrkit-libre" ,cdrkit-libre)
180 ;; Note: invoked by final executable.
181 ("coreutils" ,coreutils) ; chmod, dd
182 ("dosfstools" ,dosfstools)
183 ("e2fsprogs" ,e2fsprogs)
184 ("genext2fs" ,genext2fs)
185 ("libconfuse" ,libconfuse)
186 ("mtd-utils" ,mtd-utils)
188 ("qemu" ,qemu-minimal)
189 ("squashfs-tools" ,squashfs-tools)
191 ("u-boot-tools" ,u-boot-tools)))
192 (synopsis "Create Flash images according to specification")
193 (description "@command{genimage} creates Flash images according to a
194 specification file.")
195 (home-page "https://github.com/pengutronix/genimage")
196 (license license:gpl2)))