genimage.scm 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. ;;;
  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. (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. (define-public genimage
  41. (package
  42. (name "genimage")
  43. (version "11")
  44. (source (origin
  45. (method git-fetch)
  46. (uri (git-reference
  47. (url "https://github.com/pengutronix/genimage")
  48. (commit (string-append "v" version))))
  49. (file-name (git-file-name name version))
  50. (sha256
  51. (base32
  52. "15jmh17lvm3jw9c92bjarly7iwhmnfl322d91mprfv10ppb9ip54"))
  53. ;; will be shipped with release 14
  54. (patches (search-patches "genimage-signedness.patch"))))
  55. (build-system gnu-build-system)
  56. (arguments
  57. `(#:phases
  58. (modify-phases %standard-phases
  59. (add-after 'unpack 'guixify
  60. (lambda* (#:key inputs #:allow-other-keys)
  61. ;; Note to maintainers: Check ".def =" lines in source.
  62. (substitute* "config.c"
  63. (("\\.def = \"cpio\"")
  64. (string-append ".def = \""
  65. (assoc-ref inputs "cpio")
  66. "/bin/cpio\""))
  67. (("\\.def = \"dd\"")
  68. (string-append ".def = \""
  69. (assoc-ref inputs "coreutils")
  70. "/bin/dd\""))
  71. (("\\.def = \"debugfs\"")
  72. (string-append ".def = \""
  73. (assoc-ref inputs "e2fsprogs")
  74. "/sbin/debugfs\""))
  75. (("\\.def = \"e2fsck\"")
  76. (string-append ".def = \""
  77. (assoc-ref inputs "e2fsprogs")
  78. "/sbin/e2fsck\""))
  79. (("\\.def = \"genext2fs\"")
  80. (string-append ".def = \""
  81. (assoc-ref inputs "genext2fs")
  82. "/bin/genext2fs\""))
  83. (("\\.def = \"genisoimage\"")
  84. (string-append ".def = \""
  85. (assoc-ref inputs "cdrkit-libre")
  86. "/bin/genisoimage\""))
  87. (("\\.def = \"mcopy\"")
  88. (string-append ".def = \""
  89. (assoc-ref inputs "mtools")
  90. "/bin/mcopy\""))
  91. (("\\.def = \"mmd\"")
  92. (string-append ".def = \""
  93. (assoc-ref inputs "mtools")
  94. "/bin/mmd\""))
  95. ;;; Note: mkcramfs is obsolete.
  96. (("\\.def = \"mkdosfs\"")
  97. (string-append ".def = \""
  98. (assoc-ref inputs "dosfstools")
  99. "/sbin/mkfs.fat\""))
  100. (("\\.def = \"mke2fs\"")
  101. (string-append ".def = \""
  102. (assoc-ref inputs "e2fsprogs")
  103. "/sbin/mke2fs\""))
  104. (("\\.def = \"mkfs\\.jffs2\"")
  105. (string-append ".def = \""
  106. (assoc-ref inputs "mtd-utils")
  107. "/sbin/mkfs.jffs2\""))
  108. (("\\.def = \"mkfs\\.ubifs\"")
  109. (string-append ".def = \""
  110. (assoc-ref inputs "mtd-utils")
  111. "/sbin/mkfs.ubifs\""))
  112. (("\\.def = \"mksquashfs\"")
  113. (string-append ".def = \""
  114. (assoc-ref inputs "squashfs-tools")
  115. "/bin/mksquashfs\""))
  116. (("\\.def = \"qemu-img\"")
  117. (string-append ".def = \""
  118. (assoc-ref inputs "qemu")
  119. "/bin/qemu-img\""))
  120. (("\\.def = \"tar\"")
  121. (string-append ".def = \""
  122. (assoc-ref inputs "tar")
  123. "/bin/tar\""))
  124. (("\\.def = \"tune2fs\"")
  125. (string-append ".def = \""
  126. (assoc-ref inputs "e2fsprogs")
  127. "/sbin/tune2fs\""))
  128. (("\\.def = \"ubinize\"")
  129. (string-append ".def = \""
  130. (assoc-ref inputs "mtd-utils")
  131. "/sbin/ubinize\""))
  132. (("\\.def = \"mkimage\"")
  133. (string-append ".def = \""
  134. (assoc-ref inputs "u-boot-tools")
  135. "/bin/mkimage\"")))
  136. (substitute* "test/basic-images.test"
  137. ;; Work around bug in sharness.sh.
  138. (("mkdosfs")
  139. "mkfs.fat")
  140. ;; Work around bug in sharness.sh.
  141. (("dd,mkfs\\.fat,mcopy")
  142. "dd,mkfs_fat,mcopy")
  143. ;; Should be in the next upstream release.
  144. (("qemu_img") "qemu-img"))
  145. (substitute* "util.c"
  146. (("\"/bin/sh\"")
  147. (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))
  148. ;; We don't have /etc/passwd so uid 0 is not known as "root".
  149. ;; Thus patch it out.
  150. (substitute* '("test/ext2test.dump"
  151. "test/ext3test.dump"
  152. "test/ext4test.dump"
  153. "test/ext2test-percent.dump"
  154. "test/mke2fs.dump")
  155. (("root") "unknown"))
  156. #t))
  157. (add-before 'check 'setenv-check
  158. (lambda _
  159. ;; Our container doesn't provide access to /etc/mtab
  160. (setenv "EXT2FS_NO_MTAB_OK" "1")
  161. ;; Make test reproducible
  162. (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
  163. (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")
  164. #t))
  165. (replace 'check
  166. (lambda _
  167. (invoke "make" "TEST_LOG_COMPILER=" "check"))))))
  168. (native-inputs
  169. `(("autoconf" ,autoconf)
  170. ("automake" ,automake)
  171. ;;; Note: cramfs is obsolete.
  172. ("dtc" ,dtc) ; 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)))