cryptsetup.scm 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
  3. ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
  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 cryptsetup)
  20. #:use-module ((guix licenses) #:prefix license:)
  21. #:use-module (guix packages)
  22. #:use-module (guix download)
  23. #:use-module (guix build-system gnu)
  24. #:use-module (guix utils)
  25. #:use-module (gnu packages)
  26. #:use-module (gnu packages gnupg)
  27. #:use-module (gnu packages popt)
  28. #:use-module (gnu packages python)
  29. #:use-module (gnu packages linux))
  30. (define-public cryptsetup
  31. (package
  32. (name "cryptsetup")
  33. (version "1.7.5")
  34. (source (origin
  35. (method url-fetch)
  36. (uri (string-append "mirror://kernel.org/linux/utils/cryptsetup/v"
  37. (version-major+minor version)
  38. "/" name "-" version ".tar.xz"))
  39. (sha256
  40. (base32
  41. "1gail831j826lmpdx2gsc83lp3br6wfnwh3vqwxaa1nn1lfwsc1b"))))
  42. (build-system gnu-build-system)
  43. (inputs
  44. `(("libgcrypt" ,libgcrypt)
  45. ("lvm2" ,lvm2)
  46. ("util-linux" ,util-linux)
  47. ("popt" ,popt)))
  48. (native-inputs
  49. `(("python" ,python-wrapper)))
  50. (synopsis "Hard disk encryption tool")
  51. (description
  52. "LUKS (Linux Unified Key Setup)/Cryptsetup provides a standard on-disk
  53. encryption format, which does not only facilitate compatibility among
  54. distributions, but which also provides secure management of multiple user
  55. passwords. In contrast to existing solutions, LUKS stores all setup necessary
  56. setup information in the partition header, enabling the users to transport
  57. or migrate their data seamlessly.")
  58. (license license:gpl2)
  59. (home-page "https://gitlab.com/cryptsetup/cryptsetup")))
  60. (define (static-library library)
  61. "Return a variant of package LIBRARY that provides static libraries ('.a'
  62. files). This assumes LIBRARY uses Libtool."
  63. (package
  64. (inherit library)
  65. (name (string-append (package-name library) "-static"))
  66. (arguments
  67. (substitute-keyword-arguments (package-arguments library)
  68. ((#:configure-flags flags ''())
  69. `(append '("--disable-shared" "--enable-static")
  70. ,flags))))))
  71. (define-public cryptsetup-static
  72. ;; Stripped-down statically-linked 'cryptsetup' command for use in initrds.
  73. (package
  74. (inherit cryptsetup)
  75. (name "cryptsetup-static")
  76. (arguments
  77. '(#:configure-flags '("--disable-shared"
  78. "--enable-static-cryptsetup"
  79. ;; 'libdevmapper.a' pulls in libpthread, libudev and libm.
  80. "LIBS=-ludev -pthread -lm")
  81. #:allowed-references () ;this should be self-contained
  82. #:modules ((ice-9 ftw)
  83. (ice-9 match)
  84. (guix build utils)
  85. (guix build gnu-build-system))
  86. #:phases (modify-phases %standard-phases
  87. (add-after 'install 'remove-cruft
  88. (lambda* (#:key outputs #:allow-other-keys)
  89. ;; Remove everything except the 'cryptsetup' command and
  90. ;; its friend.
  91. (let ((out (assoc-ref outputs "out")))
  92. (with-directory-excursion out
  93. (let ((dirs (scandir "."
  94. (match-lambda
  95. ((or "." "..") #f)
  96. (_ #t)))))
  97. (for-each delete-file-recursively
  98. (delete "sbin" dirs))
  99. (for-each (lambda (file)
  100. (rename-file (string-append file
  101. ".static")
  102. file)
  103. (remove-store-references file))
  104. '("sbin/cryptsetup" "sbin/veritysetup"))
  105. #t))))))))
  106. (inputs
  107. (let ((libgcrypt-static
  108. (package
  109. (inherit (static-library libgcrypt))
  110. (propagated-inputs
  111. `(("libgpg-error-host" ,(static-library libgpg-error)))))))
  112. `(("libgcrypt" ,libgcrypt-static)
  113. ("lvm2" ,lvm2-static)
  114. ("util-linux" ,util-linux "static")
  115. ("util-linux" ,util-linux)
  116. ("popt" ,popt))))
  117. (synopsis "Hard disk encryption tool (statically linked)")))