efi.scm 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
  3. ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
  4. ;;; Copyright © 2019–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2021 Vincent Legoll <vincent.legoll@gmail.com>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (gnu packages efi)
  22. #:use-module (gnu packages autotools)
  23. #:use-module (gnu packages bash)
  24. #:use-module (gnu packages linux)
  25. #:use-module (gnu packages man)
  26. #:use-module (gnu packages perl)
  27. #:use-module (gnu packages pkg-config)
  28. #:use-module (gnu packages tls)
  29. #:use-module ((guix licenses) #:prefix license:)
  30. #:use-module (guix build-system gnu)
  31. #:use-module (guix download)
  32. #:use-module (guix git-download)
  33. #:use-module (guix packages)
  34. #:use-module (guix utils)
  35. #:use-module (ice-9 match))
  36. (define-public gnu-efi
  37. (package
  38. (name "gnu-efi")
  39. (version "3.0.13")
  40. (source
  41. (origin
  42. (method url-fetch)
  43. (uri (string-append "mirror://sourceforge/gnu-efi/"
  44. "gnu-efi-" version ".tar.bz2"))
  45. (sha256
  46. (base32 "0z9v5pl5pmlw8pjpd66iyh9pml2hh6pqd4c5qilywilw4wazgk1g"))))
  47. (build-system gnu-build-system)
  48. (arguments
  49. `(#:tests? #f ; none exist
  50. #:make-flags
  51. (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
  52. #:phases
  53. (modify-phases %standard-phases
  54. (delete 'configure))))
  55. (synopsis "EFI toolchain")
  56. (description "This package provides an @acronym{EFI, Extensible Firmware
  57. Interface} toolchain for building programs that can run in the
  58. environment presented by Intel's EFI.")
  59. (home-page "https://directory.fsf.org/wiki/GNU_EFI")
  60. ;; Distribution is allowed only when accepting all those licenses.
  61. (license (list license:bsd-2 license:bsd-3 license:bsd-4 license:expat))))
  62. (define-public efi-analyzer
  63. (let ((commit "77c9e3a67cd7c2fca48a4292dad25a5429872f95")
  64. (revision "0"))
  65. (package
  66. (name "efi-analyzer")
  67. (version (git-version "0.0.0" revision commit))
  68. (source
  69. (origin
  70. (method git-fetch)
  71. (uri (git-reference
  72. (url "https://github.com/xypron/efi_analyzer")
  73. (commit commit)))
  74. (file-name (git-file-name name version))
  75. (sha256
  76. (base32 "1izdkzybqyvzpzqz6kx4j7y47j6aa2dsdrychzgs65466x1a4br1"))))
  77. (build-system gnu-build-system)
  78. (arguments
  79. `(#:make-flags
  80. (list (string-append "prefix=" (assoc-ref %outputs "out")))
  81. #:phases
  82. (modify-phases %standard-phases
  83. (add-after 'unpack 'support-cross-compilation
  84. (lambda _
  85. (substitute* "Makefile"
  86. (("gcc") ,(cc-for-target)))
  87. #t))
  88. (delete 'configure)))) ; no configure script
  89. (home-page "https://github.com/xypron/efi_analyzer")
  90. (synopsis "Analyze EFI binaries")
  91. (description
  92. "The EFI Analyzer checks EFI binaries and prints out header and section
  93. information.")
  94. (license license:bsd-2))))
  95. (define-public sbsigntools
  96. (package
  97. (name "sbsigntools")
  98. (version "0.9.4")
  99. (source
  100. (origin
  101. (method git-fetch)
  102. (uri
  103. (git-reference
  104. (url "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git")
  105. (commit (string-append "v" version))
  106. (recursive? #t)))
  107. (file-name (git-file-name name version))
  108. (sha256
  109. (base32 "1y76wy65y6k10mjl2dm5hb5ms475alr4s080xzj8y833x01xvf3m"))))
  110. (build-system gnu-build-system)
  111. (arguments
  112. `(#:phases
  113. (modify-phases %standard-phases
  114. (add-after 'unpack 'patch-more-shebangs
  115. (lambda* (#:key inputs #:allow-other-keys)
  116. (substitute* "lib/ccan.git/tools/create-ccan-tree"
  117. (("#!/bin/bash")
  118. (string-append "#!"
  119. (assoc-ref inputs "bash")
  120. "/bin/bash")))
  121. #t))
  122. (add-after 'unpack 'patch
  123. (lambda* (#:key inputs outputs #:allow-other-keys)
  124. (substitute* '("configure.ac"
  125. "tests/Makefile.am")
  126. (("/usr/include/efi")
  127. (string-append (assoc-ref inputs "gnu-efi")
  128. "/include/efi"))
  129. (("/usr/lib/gnuefi")
  130. (string-append (assoc-ref inputs "gnu-efi")
  131. "/lib")))
  132. #t))
  133. (add-after 'unpack 'setenv
  134. (lambda _
  135. (setenv "CC" "gcc")
  136. #t)))))
  137. (native-inputs
  138. (list autoconf
  139. automake
  140. bash
  141. help2man
  142. pkg-config
  143. util-linux)) ; getopt
  144. (inputs
  145. `(("gnu-efi" ,gnu-efi)
  146. ("libuuid" ,util-linux "lib")
  147. ("openssl" ,openssl)))
  148. (synopsis "EFI signing tools")
  149. (description "This package provides tools for signing EFI binaries.")
  150. (home-page "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git/")
  151. (license license:gpl3+)))
  152. (define-public efitools
  153. (package
  154. (name "efitools")
  155. (version "1.9.2")
  156. (source
  157. (origin
  158. (method git-fetch)
  159. (uri
  160. (git-reference
  161. (url "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git")
  162. (commit (string-append "v" version))))
  163. (file-name (git-file-name name version))
  164. (sha256
  165. (base32
  166. "0jabgl2pxvfl780yvghq131ylpf82k7banjz0ksjhlm66ik8gb1i"))))
  167. (build-system gnu-build-system)
  168. (arguments
  169. `(#:tests? #f ; No tests exist.
  170. #:make-flags
  171. '("CC=gcc")
  172. #:phases
  173. (modify-phases %standard-phases
  174. (add-after 'unpack 'patch
  175. (lambda* (#:key inputs outputs #:allow-other-keys)
  176. (substitute* "Make.rules"
  177. (("/usr/include/efi")
  178. (string-append (assoc-ref inputs "gnu-efi")
  179. "/include/efi"))
  180. (("\\$\\(DESTDIR\\)/usr")
  181. (string-append (assoc-ref outputs "out")))
  182. (("/usr/lib/gnuefi")
  183. (string-append (assoc-ref inputs "gnu-efi")
  184. "/lib")))
  185. #t))
  186. (add-after 'unpack 'patch-more-shebangs
  187. (lambda* (#:key inputs #:allow-other-keys)
  188. (substitute* "xxdi.pl"
  189. (("#!.*")
  190. (string-append "#!"
  191. (assoc-ref inputs "perl")
  192. "/bin/perl\n")))
  193. #t))
  194. (delete 'configure))))
  195. (native-inputs
  196. (list help2man perl perl-file-slurp sbsigntools))
  197. (inputs
  198. (list gnu-efi openssl))
  199. (synopsis "EFI tools (key management, variable management)")
  200. (description "This package provides EFI tools for EFI key management
  201. and EFI variable management.")
  202. (home-page "https://blog.hansenpartnership.com/efitools-1-4-with-linux-key-manipulation-utilities-released/")
  203. ;; Programs are under GPL 2.
  204. ;; Library routines (in lib/) are under LGPL 2.1.
  205. ;; Compiling/linking/using OpenSSL is permitted.
  206. (license (list license:gpl2
  207. license:lgpl2.1))))
  208. (define-public efilinux
  209. (package
  210. (name "efilinux")
  211. (version "1.1")
  212. (source (origin
  213. (method git-fetch)
  214. (uri (git-reference
  215. (url "https://github.com/mfleming/efilinux")
  216. (commit (string-append "efilinux-" version))))
  217. (file-name (git-file-name name version))
  218. (sha256
  219. (base32
  220. "0b4nxzr3wl5v4b52r79iw1arfgasz26xb38r2blw9v2qz2s1q9w2"))))
  221. (build-system gnu-build-system)
  222. (arguments
  223. `(#:make-flags
  224. (list "CC=gcc"
  225. ,@(match (%current-system)
  226. ("aarch64-linux"
  227. '("ARCH=aarch64"))
  228. ("armhf-linux"
  229. '("ARCH=arm"))
  230. (_ '()))
  231. (string-append "INCDIR=" (assoc-ref %build-inputs "gnu-efi")
  232. "/include")
  233. (string-append "LIBDIR=" (assoc-ref %build-inputs "gnu-efi")
  234. "/lib"))
  235. #:tests? #f ; No tests exist.
  236. #:phases
  237. (modify-phases %standard-phases
  238. (delete 'configure)
  239. (replace 'install
  240. (lambda* (#:key outputs #:allow-other-keys)
  241. (install-file "efilinux.efi"
  242. (string-append (assoc-ref outputs "out")
  243. "/libexec"))
  244. #t)))))
  245. (inputs
  246. (list gnu-efi))
  247. (synopsis "Minimal Linux loader for UEFI")
  248. (description "This package provides a minimal Linux loader as an UEFI
  249. program.")
  250. (home-page "https://github.com/mfleming/efilinux")
  251. (license license:bsd-2)))