genimage.scm 8.1 KB

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