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