genimage.scm 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  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)
  39. #:use-module (gnu packages textutils)
  40. #:use-module (gnu packages virtualization))
  41. (define-public genimage
  42. (let ((commit "ec44ae086c705e6f0439e742c5a2e9b8f3d6ca82")
  43. (revision "1"))
  44. (package
  45. (name "genimage")
  46. (version (git-version "15" revision commit))
  47. (source (origin
  48. (method git-fetch)
  49. (uri (git-reference
  50. (url "https://github.com/pengutronix/genimage")
  51. (commit commit)))
  52. (file-name (git-file-name name version))
  53. (sha256
  54. (base32
  55. "0amj2vjff58yna6kq959i2gqmbjywqr8j5kr5pjqsvbqam3vgg0r"))
  56. (patches
  57. (search-patches "genimage-mke2fs-test.patch"))))
  58. (build-system gnu-build-system)
  59. (arguments
  60. `(#:modules
  61. ((ice-9 match)
  62. ,@%gnu-build-system-modules)
  63. #:phases
  64. (modify-phases %standard-phases
  65. (add-after 'unpack 'guixify
  66. (lambda* (#:key inputs #:allow-other-keys)
  67. (map (match-lambda
  68. ((input directory regexp)
  69. (substitute* "config.c"
  70. (((format #f "\\.def = \"(~a)\"" regexp) _ command)
  71. (format #f ".def = \"~a/~a/~a\""
  72. (assoc-ref inputs input) directory command)))))
  73. '(("cpio" "bin" "cpio")
  74. ("coreutils" "bin" "dd")
  75. ("e2fsprogs" "sbin" "debugfs|e2fsck|mke2fs|tune2fs")
  76. ("genext2fs" "bin" "genext2fs")
  77. ("cdrkit-libre" "bin" "genisoimage")
  78. ("mtools" "bin" "mcopy|mmd")
  79. ;; mkcramfs is obsolete.
  80. ("dosfstools" "sbin" "mkdosfs")
  81. ("mtd-utils" "sbin" "mkfs.(jffs2|ubifs)|ubinize")
  82. ("squashfs-tools" "bin" "mksquashfs")
  83. ("qemu" "bin" "qemu-img")
  84. ("tar" "bin" "tar")
  85. ("u-boot-tools" "bin" "mkimage")))
  86. (substitute* "util.c"
  87. (("\"/bin/sh\"")
  88. (string-append "\"" (assoc-ref inputs "bash") "/bin/sh\"")))))
  89. (add-before 'check 'fix-failing-tests
  90. (lambda _
  91. ;; We don't have /etc/passwd so uid 0 is not known as "root".
  92. ;; Thus patch it out.
  93. (substitute* '("test/ext2test.0.dump"
  94. "test/ext2test.1.dump"
  95. "test/ext3test.0.dump"
  96. "test/ext3test.1.dump"
  97. "test/ext4test.0.dump"
  98. "test/ext4test.1.dump"
  99. "test/ext2test-percent.0.dump"
  100. "test/ext2test-percent.1.dump"
  101. "test/mke2fs.0.dump")
  102. (("root") "unknown"))))
  103. (add-before 'check 'setenv-check
  104. (lambda _
  105. ;; Our container doesn't provide access to /etc/mtab
  106. (setenv "EXT2FS_NO_MTAB_OK" "1")
  107. ;; Make test reproducible
  108. (setenv "GENIMAGE_MKFJFFS2" "mkfs.jffs2 -U")
  109. (setenv "GENIMAGE_MKE2FS" "mke2fs -E no_copy_xattrs")))
  110. (replace 'check
  111. (lambda _
  112. (invoke "make" "TEST_LOG_COMPILER=" "check"))))))
  113. (native-inputs
  114. (list autoconf
  115. automake
  116. ;;; Note: cramfs is obsolete.
  117. dtc ; for the tests
  118. pkg-config
  119. util-linux)) ; for the tests
  120. (inputs
  121. `(("bash" ,bash)
  122. ("cdrkit-libre" ,cdrkit-libre)
  123. ("cpio" ,cpio)
  124. ;; Note: invoked by final executable.
  125. ("coreutils" ,coreutils) ; chmod, dd
  126. ("dosfstools" ,dosfstools)
  127. ("e2fsprogs" ,e2fsprogs)
  128. ("genext2fs" ,genext2fs)
  129. ("libconfuse" ,libconfuse)
  130. ("mtd-utils" ,mtd-utils)
  131. ("mtools" ,mtools)
  132. ("qemu" ,qemu-minimal)
  133. ("squashfs-tools" ,squashfs-tools)
  134. ("tar" ,tar)
  135. ("u-boot-tools" ,u-boot-tools)))
  136. (synopsis "Create Flash images according to specification")
  137. (description "@command{genimage} creates Flash images according to a
  138. specification file.")
  139. (home-page "https://github.com/pengutronix/genimage")
  140. (license license:gpl2))))