efi.scm 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. ;;;
  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 efi)
  20. #:use-module (gnu packages autotools)
  21. #:use-module (gnu packages bash)
  22. #:use-module (gnu packages linux)
  23. #:use-module (gnu packages man)
  24. #:use-module (gnu packages perl)
  25. #:use-module (gnu packages pkg-config)
  26. #:use-module (gnu packages tls)
  27. #:use-module ((guix licenses) #:prefix license:)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix download)
  30. #:use-module (guix git-download)
  31. #:use-module (guix packages)
  32. #:use-module (guix utils)
  33. #:use-module (ice-9 match))
  34. (define-public gnu-efi
  35. (package
  36. (name "gnu-efi")
  37. (version "3.0.9")
  38. (source
  39. (origin
  40. (method url-fetch)
  41. (uri (string-append "mirror://sourceforge/gnu-efi/"
  42. name "-" version ".tar.bz2"))
  43. (sha256
  44. (base32
  45. "1w3p4aqlc5j93q44la7dc8cr3hky20zvsd0h0k2lyzhwmrzfl5b7"))))
  46. (build-system gnu-build-system)
  47. (arguments
  48. `(#:tests? #f ; None exist.
  49. #:make-flags
  50. (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
  51. #:phases
  52. (modify-phases %standard-phases
  53. (delete 'configure))))
  54. (synopsis "EFI toolchain")
  55. (description "This package provides an EFI (Extensible Firmware
  56. Interface) toolchain for building programs that can run in the
  57. environment presented by Intel's EFI.")
  58. (home-page "https://directory.fsf.org/wiki/GNU_EFI")
  59. ;; Distribution is allowed only when accepting all those licenses.
  60. (license (list license:bsd-2 license:bsd-3 license:bsd-4 license:expat))))
  61. (define-public sbsigntools
  62. (package
  63. (name "sbsigntools")
  64. (version "0.9.2")
  65. (source
  66. (origin
  67. (method git-fetch)
  68. (uri
  69. (git-reference
  70. (url "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git")
  71. (commit (string-append "v" version))
  72. (recursive? #t)))
  73. (file-name (git-file-name name version))
  74. (sha256
  75. (base32
  76. "116649ixr6gvw9fqiljfflxsv4293hgm73bmba5ilxrzn4kpbzvb"))))
  77. (build-system gnu-build-system)
  78. (arguments
  79. `(#:phases
  80. (modify-phases %standard-phases
  81. (add-after 'unpack 'patch-more-shebangs
  82. (lambda* (#:key inputs #:allow-other-keys)
  83. (substitute* "lib/ccan.git/tools/create-ccan-tree"
  84. (("#!/bin/bash")
  85. (string-append "#!"
  86. (assoc-ref inputs "bash")
  87. "/bin/bash")))
  88. #t))
  89. (add-after 'unpack 'patch
  90. (lambda* (#:key inputs outputs #:allow-other-keys)
  91. (substitute* '("configure.ac"
  92. "tests/Makefile.am")
  93. (("/usr/include/efi")
  94. (string-append (assoc-ref inputs "gnu-efi")
  95. "/include/efi"))
  96. (("/usr/lib/gnuefi")
  97. (string-append (assoc-ref inputs "gnu-efi")
  98. "/lib")))
  99. #t))
  100. (add-after 'unpack 'setenv
  101. (lambda _
  102. (setenv "CC" "gcc")
  103. #t)))))
  104. (native-inputs
  105. `(("autoconf" ,autoconf)
  106. ("automake" ,automake)
  107. ("bash" ,bash)
  108. ("help2man" ,help2man)
  109. ("pkg-config" ,pkg-config)
  110. ("util-linux" ,util-linux))) ; getopt
  111. (inputs
  112. `(("gnu-efi" ,gnu-efi)
  113. ("openssl" ,openssl)))
  114. (synopsis "EFI signing tools")
  115. (description "This package provides tools for signing EFI binaries.")
  116. (home-page "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git/")
  117. (license license:gpl3+)))
  118. (define-public efitools
  119. (package
  120. (name "efitools")
  121. (version "1.9.2")
  122. (source
  123. (origin
  124. (method git-fetch)
  125. (uri
  126. (git-reference
  127. (url "https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git")
  128. (commit (string-append "v" version))))
  129. (file-name (git-file-name name version))
  130. (sha256
  131. (base32
  132. "0jabgl2pxvfl780yvghq131ylpf82k7banjz0ksjhlm66ik8gb1i"))))
  133. (build-system gnu-build-system)
  134. (arguments
  135. `(#:tests? #f ; No tests exist.
  136. #:make-flags
  137. '("CC=gcc")
  138. #:phases
  139. (modify-phases %standard-phases
  140. (add-after 'unpack 'patch
  141. (lambda* (#:key inputs outputs #:allow-other-keys)
  142. (substitute* "Make.rules"
  143. (("/usr/include/efi")
  144. (string-append (assoc-ref inputs "gnu-efi")
  145. "/include/efi"))
  146. (("\\$\\(DESTDIR\\)/usr")
  147. (string-append (assoc-ref outputs "out")))
  148. (("/usr/lib/gnuefi")
  149. (string-append (assoc-ref inputs "gnu-efi")
  150. "/lib")))
  151. #t))
  152. (add-after 'unpack 'patch-more-shebangs
  153. (lambda* (#:key inputs #:allow-other-keys)
  154. (substitute* "xxdi.pl"
  155. (("#!.*")
  156. (string-append "#!"
  157. (assoc-ref inputs "perl")
  158. "/bin/perl\n")))
  159. #t))
  160. (delete 'configure))))
  161. (native-inputs
  162. `(("help2man" ,help2man)
  163. ("perl" ,perl)
  164. ("perl-file-slurp" ,perl-file-slurp)
  165. ("sbsigntools" ,sbsigntools)))
  166. (inputs
  167. `(("gnu-efi" ,gnu-efi)
  168. ("openssl" ,openssl)))
  169. (synopsis "EFI tools (key management, variable management)")
  170. (description "This package provides EFI tools for EFI key management
  171. and EFI variable management.")
  172. (home-page "https://blog.hansenpartnership.com/efitools-1-4-with-linux-key-manipulation-utilities-released/")
  173. ;; Programs are under GPL 2.
  174. ;; Library routines (in lib/) are under LGPL 2.1.
  175. ;; Compiling/linking/using OpenSSL is permitted.
  176. (license (list license:gpl2
  177. license:lgpl2.1))))
  178. (define-public efilinux
  179. (package
  180. (name "efilinux")
  181. (version "1.1")
  182. (source (origin
  183. (method git-fetch)
  184. (uri (git-reference
  185. (url "https://github.com/mfleming/efilinux.git")
  186. (commit (string-append "efilinux-" version))))
  187. (file-name (git-file-name name version))
  188. (sha256
  189. (base32
  190. "0b4nxzr3wl5v4b52r79iw1arfgasz26xb38r2blw9v2qz2s1q9w2"))))
  191. (build-system gnu-build-system)
  192. (arguments
  193. `(#:make-flags
  194. (list "CC=gcc"
  195. ,@(match (%current-system)
  196. ("aarch64-linux"
  197. '("ARCH=aarch64"))
  198. ("armhf-linux"
  199. '("ARCH=arm"))
  200. (_ '()))
  201. (string-append "INCDIR=" (assoc-ref %build-inputs "gnu-efi")
  202. "/include")
  203. (string-append "LIBDIR=" (assoc-ref %build-inputs "gnu-efi")
  204. "/lib"))
  205. #:tests? #f ; No tests exist.
  206. #:phases
  207. (modify-phases %standard-phases
  208. (delete 'configure)
  209. (replace 'install
  210. (lambda* (#:key outputs #:allow-other-keys)
  211. (install-file "efilinux.efi"
  212. (string-append (assoc-ref outputs "out")
  213. "/libexec"))
  214. #t)))))
  215. (inputs
  216. `(("gnu-efi" ,gnu-efi)))
  217. (synopsis "Minimal Linux loader for UEFI")
  218. (description "This package provides a minimal Linux loader as an UEFI
  219. program.")
  220. (home-page "https://github.com/mfleming/efilinux")
  221. (license license:bsd-2)))