Commit | Line | Data |
---|---|---|
f7c4853a DM |
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) | |
205df739 TGR |
38 | #:use-module (gnu packages textutils) |
39 | #:use-module (gnu packages virtualization)) | |
f7c4853a DM |
40 | |
41 | (define-public genimage | |
42 | (package | |
43 | (name "genimage") | |
44 | (version "10") | |
45 | (source (origin | |
46 | (method git-fetch) | |
47 | (uri (git-reference | |
48 | (url "https://github.com/pengutronix/genimage.git") | |
49 | (commit (string-append "v" version)))) | |
50 | (file-name (string-append name "-" version "-checkout")) | |
51 | (sha256 | |
52 | (base32 | |
53 | "0had00p2why2l1fl14mq7nbhmmfbd3na4qnnpg36akdy05g67jbn")))) | |
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/mke2fs.dump") | |
153 | (("root") "unknown")) | |
154 | #t)) | |
155 | (add-before 'check 'setenv-check | |
156 | (lambda _ | |
157 | ;; Our container doesn't provide access to /etc/mtab | |
158 | (setenv "EXT2FS_NO_MTAB_OK" "1") | |
159 | ;; Make test reproducible | |
160 | (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U") | |
161 | (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs") | |
162 | #t)) | |
163 | (replace 'check | |
164 | (lambda _ | |
165 | (invoke "make" "TEST_LOG_COMPILER=" "check")))))) | |
166 | (native-inputs | |
167 | `(("autoconf" ,autoconf) | |
168 | ("automake" ,automake) | |
169 | ;;; Note: cramfs is obsolete. | |
170 | ("dtc" ,dtc) ; for the tests | |
171 | ("fdisk" ,fdisk) ; for the tests | |
172 | ("pkg-config" ,pkg-config) | |
173 | ("util-linux" ,util-linux))) ; for the tests | |
174 | (inputs | |
175 | `(("bash" ,bash) | |
176 | ("cdrkit-libre" ,cdrkit-libre) | |
177 | ("cpio" ,cpio) | |
178 | ;; Note: invoked by final executable. | |
179 | ("coreutils" ,coreutils) ; chmod, dd | |
180 | ("dosfstools" ,dosfstools) | |
181 | ("e2fsprogs" ,e2fsprogs) | |
182 | ("genext2fs" ,genext2fs) | |
183 | ("libconfuse" ,libconfuse) | |
184 | ("mtd-utils" ,mtd-utils) | |
185 | ("mtools" ,mtools) | |
186 | ("qemu" ,qemu-minimal) | |
187 | ("squashfs-tools" ,squashfs-tools) | |
188 | ("tar" ,tar) | |
189 | ("u-boot-tools" ,u-boot-tools))) | |
190 | (synopsis "Create Flash images according to specification") | |
191 | (description "@command{genimage} creates Flash images according to a | |
192 | specification file.") | |
193 | (home-page "https://github.com/pengutronix/genimage") | |
194 | (license license:gpl2))) |