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>
5 ;;; This file is part of GNU Guix.
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.
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.
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/>.
20 (define-module (gnu packages cryptsetup)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix build-system gnu)
25 #:use-module (guix utils)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages gnupg)
28 #:use-module (gnu packages popt)
29 #:use-module (gnu packages python)
30 #:use-module (gnu packages linux))
32 (define-public cryptsetup
38 (uri (string-append "mirror://kernel.org/linux/utils/cryptsetup/v"
39 (version-major+minor version)
40 "/" name "-" version ".tar.xz"))
43 "1gail831j826lmpdx2gsc83lp3br6wfnwh3vqwxaa1nn1lfwsc1b"))))
44 (build-system gnu-build-system)
46 `(("libgcrypt" ,libgcrypt)
48 ("util-linux" ,util-linux)
51 `(("python" ,python-wrapper)))
52 (synopsis "Hard disk encryption tool")
54 "LUKS (Linux Unified Key Setup)/Cryptsetup provides a standard on-disk
55 encryption format, which does not only facilitate compatibility among
56 distributions, but which also provides secure management of multiple user
57 passwords. In contrast to existing solutions, LUKS stores all setup necessary
58 setup information in the partition header, enabling the users to transport
59 or migrate their data seamlessly.")
60 (license license:gpl2)
61 (home-page "https://gitlab.com/cryptsetup/cryptsetup")))
63 (define (static-library library)
64 "Return a variant of package LIBRARY that provides static libraries ('.a'
65 files). This assumes LIBRARY uses Libtool."
68 (name (string-append (package-name library) "-static"))
70 (substitute-keyword-arguments (package-arguments library)
71 ((#:configure-flags flags ''())
72 `(append '("--disable-shared" "--enable-static")
75 (define-public cryptsetup-static
76 ;; Stripped-down statically-linked 'cryptsetup' command for use in initrds.
79 (name "cryptsetup-static")
81 '(#:configure-flags '("--disable-shared"
82 "--enable-static-cryptsetup"
84 ;; 'libdevmapper.a' pulls in libpthread, libudev and libm.
85 "LIBS=-ludev -pthread -lm")
87 #:allowed-references () ;this should be self-contained
89 #:modules ((ice-9 ftw)
92 (guix build gnu-build-system))
94 #:phases (modify-phases %standard-phases
95 (add-after 'install 'remove-cruft
96 (lambda* (#:key outputs #:allow-other-keys)
97 ;; Remove everything except the 'cryptsetup' command and
99 (let ((out (assoc-ref outputs "out")))
100 (with-directory-excursion out
101 (let ((dirs (scandir "."
105 (for-each delete-file-recursively
106 (delete "sbin" dirs))
107 (for-each (lambda (file)
108 (rename-file (string-append file
111 (remove-store-references file))
112 '("sbin/cryptsetup" "sbin/veritysetup"))
115 (let ((libgcrypt-static
117 (inherit (static-library libgcrypt))
119 `(("libgpg-error-host" ,(static-library libgpg-error)))))))
120 `(("libgcrypt" ,libgcrypt-static)
121 ("lvm2" ,lvm2-static)
122 ("util-linux" ,util-linux "static")
123 ("util-linux" ,util-linux)
125 (synopsis "Hard disk encryption tool (statically linked)")))