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