efi.scm 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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 efi_analyzer
  96. ;; For a short while the package name contained an underscore.
  97. (deprecated-package "efi_analyzer" efi-analyzer))
  98. (define-public sbsigntools
  99. (package
  100. (name "sbsigntools")
  101. (version "0.9.4")
  102. (source
  103. (origin
  104. (method git-fetch)
  105. (uri
  106. (git-reference
  107. (url "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git")
  108. (commit (string-append "v" version))
  109. (recursive? #t)))
  110. (file-name (git-file-name name version))
  111. (sha256
  112. (base32 "1y76wy65y6k10mjl2dm5hb5ms475alr4s080xzj8y833x01xvf3m"))))
  113. (build-system gnu-build-system)
  114. (arguments
  115. `(#:phases
  116. (modify-phases %standard-phases
  117. (add-after 'unpack 'patch-more-shebangs
  118. (lambda* (#:key inputs #:allow-other-keys)
  119. (substitute* "lib/ccan.git/tools/create-ccan-tree"
  120. (("#!/bin/bash")
  121. (string-append "#!"
  122. (assoc-ref inputs "bash")
  123. "/bin/bash")))
  124. #t))
  125. (add-after 'unpack 'patch
  126. (lambda* (#:key inputs outputs #:allow-other-keys)
  127. (substitute* '("configure.ac"
  128. "tests/Makefile.am")
  129. (("/usr/include/efi")
  130. (string-append (assoc-ref inputs "gnu-efi")
  131. "/include/efi"))
  132. (("/usr/lib/gnuefi")
  133. (string-append (assoc-ref inputs "gnu-efi")
  134. "/lib")))
  135. #t))
  136. (add-after 'unpack 'setenv
  137. (lambda _
  138. (setenv "CC" "gcc")
  139. #t)))))
  140. (native-inputs
  141. `(("autoconf" ,autoconf)
  142. ("automake" ,automake)
  143. ("bash" ,bash)
  144. ("help2man" ,help2man)
  145. ("pkg-config" ,pkg-config)
  146. ("util-linux" ,util-linux))) ; getopt
  147. (inputs
  148. `(("gnu-efi" ,gnu-efi)
  149. ("libuuid" ,util-linux "lib")
  150. ("openssl" ,openssl)))
  151. (synopsis "EFI signing tools")
  152. (description "This package provides tools for signing EFI binaries.")
  153. (home-page "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git/")
  154. (license license:gpl3+)))
  155. (define-public efitools
  156. (package
  157. (name "efitools")
  158. (version "1.9.2")
  159. (source
  160. (origin
  161. (method git-fetch)
  162. (uri
  163. (git-reference
  164. (url "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git")
  165. (commit (string-append "v" version))))
  166. (file-name (git-file-name name version))
  167. (sha256
  168. (base32
  169. "0jabgl2pxvfl780yvghq131ylpf82k7banjz0ksjhlm66ik8gb1i"))))
  170. (build-system gnu-build-system)
  171. (arguments
  172. `(#:tests? #f ; No tests exist.
  173. #:make-flags
  174. '("CC=gcc")
  175. #:phases
  176. (modify-phases %standard-phases
  177. (add-after 'unpack 'patch
  178. (lambda* (#:key inputs outputs #:allow-other-keys)
  179. (substitute* "Make.rules"
  180. (("/usr/include/efi")
  181. (string-append (assoc-ref inputs "gnu-efi")
  182. "/include/efi"))
  183. (("\\$\\(DESTDIR\\)/usr")
  184. (string-append (assoc-ref outputs "out")))
  185. (("/usr/lib/gnuefi")
  186. (string-append (assoc-ref inputs "gnu-efi")
  187. "/lib")))
  188. #t))
  189. (add-after 'unpack 'patch-more-shebangs
  190. (lambda* (#:key inputs #:allow-other-keys)
  191. (substitute* "xxdi.pl"
  192. (("#!.*")
  193. (string-append "#!"
  194. (assoc-ref inputs "perl")
  195. "/bin/perl\n")))
  196. #t))
  197. (delete 'configure))))
  198. (native-inputs
  199. `(("help2man" ,help2man)
  200. ("perl" ,perl)
  201. ("perl-file-slurp" ,perl-file-slurp)
  202. ("sbsigntools" ,sbsigntools)))
  203. (inputs
  204. `(("gnu-efi" ,gnu-efi)
  205. ("openssl" ,openssl)))
  206. (synopsis "EFI tools (key management, variable management)")
  207. (description "This package provides EFI tools for EFI key management
  208. and EFI variable management.")
  209. (home-page "https://blog.hansenpartnership.com/efitools-1-4-with-linux-key-manipulation-utilities-released/")
  210. ;; Programs are under GPL 2.
  211. ;; Library routines (in lib/) are under LGPL 2.1.
  212. ;; Compiling/linking/using OpenSSL is permitted.
  213. (license (list license:gpl2
  214. license:lgpl2.1))))
  215. (define-public efilinux
  216. (package
  217. (name "efilinux")
  218. (version "1.1")
  219. (source (origin
  220. (method git-fetch)
  221. (uri (git-reference
  222. (url "https://github.com/mfleming/efilinux")
  223. (commit (string-append "efilinux-" version))))
  224. (file-name (git-file-name name version))
  225. (sha256
  226. (base32
  227. "0b4nxzr3wl5v4b52r79iw1arfgasz26xb38r2blw9v2qz2s1q9w2"))))
  228. (build-system gnu-build-system)
  229. (arguments
  230. `(#:make-flags
  231. (list "CC=gcc"
  232. ,@(match (%current-system)
  233. ("aarch64-linux"
  234. '("ARCH=aarch64"))
  235. ("armhf-linux"
  236. '("ARCH=arm"))
  237. (_ '()))
  238. (string-append "INCDIR=" (assoc-ref %build-inputs "gnu-efi")
  239. "/include")
  240. (string-append "LIBDIR=" (assoc-ref %build-inputs "gnu-efi")
  241. "/lib"))
  242. #:tests? #f ; No tests exist.
  243. #:phases
  244. (modify-phases %standard-phases
  245. (delete 'configure)
  246. (replace 'install
  247. (lambda* (#:key outputs #:allow-other-keys)
  248. (install-file "efilinux.efi"
  249. (string-append (assoc-ref outputs "out")
  250. "/libexec"))
  251. #t)))))
  252. (inputs
  253. `(("gnu-efi" ,gnu-efi)))
  254. (synopsis "Minimal Linux loader for UEFI")
  255. (description "This package provides a minimal Linux loader as an UEFI
  256. program.")
  257. (home-page "https://github.com/mfleming/efilinux")
  258. (license license:bsd-2)))