Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / storage.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020 Marius Bakke <mbakke@fastmail.com>
3 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
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 storage)
21 #:use-module (guix download)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix utils)
25 #:use-module (guix build-system cmake)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages admin)
28 #:use-module (gnu packages assembly)
29 #:use-module (gnu packages authentication)
30 #:use-module (gnu packages bdw-gc)
31 #:use-module (gnu packages boost)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages crypto)
34 #:use-module (gnu packages cryptsetup)
35 #:use-module (gnu packages curl)
36 #:use-module (gnu packages databases)
37 #:use-module (gnu packages disk)
38 #:use-module (gnu packages gperf)
39 #:use-module (gnu packages jemalloc)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages lua)
42 #:use-module (gnu packages ncurses)
43 #:use-module (gnu packages nss)
44 #:use-module (gnu packages openldap)
45 #:use-module (gnu packages pkg-config)
46 #:use-module (gnu packages python)
47 #:use-module (gnu packages python-xyz)
48 #:use-module (gnu packages sphinx)
49 #:use-module (gnu packages tls)
50 #:use-module (gnu packages web)
51 #:use-module (gnu packages xml))
52
53 (define-public ceph
54 (package
55 (name "ceph")
56 (version "14.2.8")
57 (source (origin
58 (method url-fetch)
59 (uri (string-append "https://download.ceph.com/tarballs/ceph-"
60 version ".tar.gz"))
61 (sha256
62 (base32
63 "0p7pjycqhxqg1mmix8ykx3xqq01d560p54iiidxps0rcvwfkyyki"))
64 (patches
65 (search-patches "ceph-disable-cpu-optimizations.patch"))
66 (modules '((guix build utils)))
67 (snippet
68 '(begin
69 (for-each delete-file-recursively
70 '(;; TODO: Unbundle these:
71 ;"src/isa-l"
72 ;"src/lua"
73 ;"src/xxHash"
74 ;"src/zstd"
75 ;"src/civetweb"
76 "src/seastar/fmt"
77 "src/test/downloads"
78 "src/c-ares"
79 "src/googletest"
80 "src/rapidjson"
81 "src/spdk"
82 "src/rocksdb"
83 "src/boost"))
84 #t))))
85 (build-system cmake-build-system)
86 (arguments
87 `(#:configure-flags
88 (let* ((out (assoc-ref %outputs "out"))
89 (lib (assoc-ref %outputs "lib"))
90 (libdir (string-append lib "/lib")))
91 (list (string-append "-DCMAKE_INSTALL_PREFIX=" out)
92 (string-append "-DCMAKE_INSTALL_LIBDIR=" libdir)
93 (string-append "-DCMAKE_INSTALL_INCLUDEDIR="
94 lib "/include")
95 ;; We need both libdir and libdir/ceph in RUNPATH.
96 (string-append "-DCMAKE_INSTALL_RPATH="
97 libdir ";" libdir "/ceph")
98 (string-append "-DCMAKE_INSTALL_SYSCONFDIR=" out "/etc")
99 (string-append "-DCMAKE_INSTALL_DATADIR=" lib "/share")
100 (string-append "-DCMAKE_INSTALL_MANDIR=" out "/share/man")
101 (string-append "-DCMAKE_INSTALL_DOCDIR=" out "/share/ceph/doc")
102 (string-append "-DCMAKE_INSTALL_LIBEXECDIR=" out "/libexec")
103 (string-append "-DKEYUTILS_INCLUDE_DIR="
104 (assoc-ref %build-inputs "keyutils") "/include")
105 (string-append "-DXFS_INCLUDE_DIR="
106 (assoc-ref %build-inputs "xfsprogs") "/include")
107 "-DCMAKE_INSTALL_LOCALSTATEDIR=/var"
108 "-DBUILD_SHARED_LIBS=ON"
109 "-DWITH_SYSTEM_ROCKSDB=ON"
110 "-DWITH_SYSTEM_BOOST=ON"
111 "-DWITH_PYTHON3=ON"
112 ;; TODO: Enable these when available in Guix.
113 "-DWITH_MGR_DASHBOARD_FRONTEND=OFF" ;requires node + nodeenv
114 "-DWITH_BABELTRACE=OFF"
115 "-DWITH_LTTNG=OFF"
116 "-DWITH_SPDK=OFF"
117 "-DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
118
119 ;; Use jemalloc instead of tcmalloc.
120 "-DALLOCATOR=jemalloc"
121
122 ;; Do not bother building the tests; we are not currently running
123 ;; them, and they do not build with system googletest as of 14.2.5.
124 "-DWITH_TESTS=OFF"))
125 ;; FIXME: Some of the tests leak Btrfs subvolumes on Btrfs. See
126 ;; <https://bugs.gnu.org/29674> for details. Disable tests until
127 ;; resolved.
128 #:tests? #f
129 #:phases
130 (modify-phases %standard-phases
131 (add-after 'unpack 'patch-source
132 (lambda* (#:key outputs #:allow-other-keys)
133 (let ((out (assoc-ref outputs "out"))
134 (lib (assoc-ref outputs "lib")))
135
136 (substitute* "cmake/modules/Distutils.cmake"
137 ;; Prevent creation of Python eggs.
138 (("setup.py install")
139 "setup.py install --single-version-externally-managed --root=/"))
140
141 (substitute* (find-files "src/pybind" "^setup\\.py$")
142 ;; Here we inject an extra line to the `setup.py' of the
143 ;; Python C libraries so RUNPATH gets set up correctly.
144 (("^([[:blank:]]+)extra_compile_args=(.*)$" _ indent args)
145 (string-append indent "extra_compile_args=" args
146 indent "extra_link_args=['-Wl,-rpath="
147 lib "/lib'],\n")))
148
149 ;; Statically link libcrc32 because it does not get installed,
150 ;; yet several libraries end up referring to it.
151 (substitute* "src/common/CMakeLists.txt"
152 (("add_library\\(crc32")
153 "add_library(crc32 STATIC"))
154
155 (substitute* "udev/50-rbd.rules"
156 (("/usr/bin/ceph-rbdnamer")
157 (string-append out "/bin/ceph-rbdnamer")))
158 #t)))
159 (add-before 'install 'set-install-environment
160 (lambda* (#:key outputs #:allow-other-keys)
161 (let* ((out (assoc-ref outputs "out"))
162 (py3sitedir
163 (string-append out "/lib/python"
164 ,(version-major+minor
165 (package-version python))
166 "/site-packages")))
167 ;; The Python install scripts refuses to function if
168 ;; the install directory is not on PYTHONPATH.
169 (setenv "PYTHONPATH"
170 (string-append py3sitedir ":"
171 (getenv "PYTHONPATH")))
172 #t)))
173 (add-after 'install 'wrap-python-scripts
174 (lambda* (#:key inputs outputs #:allow-other-keys)
175 (let* ((out (assoc-ref outputs "out"))
176 (scripts '("ceph" "ceph-mgr" "ceph-volume"))
177 (prettytable (assoc-ref inputs "python-prettytable"))
178 (six (assoc-ref inputs "python-six"))
179 (sitedir (lambda (package)
180 (string-append package
181 "/lib/python"
182 ,(version-major+minor
183 (package-version python))
184 "/site-packages")))
185 (PYTHONPATH (string-append
186 (sitedir out) ":"
187 (sitedir six) ":"
188 (sitedir prettytable))))
189 (for-each (lambda (executable)
190 (wrap-program (string-append out "/bin/" executable)
191 `("PYTHONPATH" ":" prefix (,PYTHONPATH))))
192 scripts)
193 #t))))))
194 (outputs
195 '("out" "lib"))
196 (native-inputs
197 `(("gperf" ,gperf)
198 ("pkg-config" ,pkg-config)
199 ("python-cython" ,python-cython)
200 ("python-sphinx" ,python-sphinx)
201 ("yasm" ,yasm)))
202 (inputs
203 `(("boost" ,boost)
204 ("curl" ,curl)
205 ("cryptsetup" ,cryptsetup)
206 ("expat" ,expat)
207 ("fcgi" ,fcgi)
208 ("fuse" ,fuse)
209 ("jemalloc" ,jemalloc)
210 ("keyutils" ,keyutils)
211 ("leveldb" ,leveldb)
212 ("libaio" ,libaio)
213 ("libatomic-ops" ,libatomic-ops)
214 ("libcap-ng" ,libcap-ng)
215 ("libnl" ,libnl)
216 ("lua" ,lua)
217 ("lz4" ,lz4)
218 ("oath-toolkit" ,oath-toolkit)
219 ("openldap" ,openldap)
220 ("openssl" ,openssl)
221 ("ncurses" ,ncurses)
222 ("nss" ,nss)
223 ("python-prettytable" ,python-prettytable) ;used by ceph_daemon.py
224 ("python-six" ,python-six) ;for ceph-mgr + plugins
225 ("python" ,python-wrapper)
226 ("rapidjson" ,rapidjson)
227 ("rdma-core" ,rdma-core)
228 ("rocksdb" ,rocksdb)
229 ("snappy" ,snappy)
230 ("udev" ,eudev)
231 ("util-linux" ,util-linux)
232 ("util-linux:lib" ,util-linux "lib")
233 ("xfsprogs" ,xfsprogs)
234 ("zlib" ,zlib)))
235 (home-page "https://ceph.com/")
236 (synopsis "Distributed object store and file system")
237 (description
238 "Ceph is a distributed storage system designed for reliability and
239 performance. It provides network-based block devices (RBD), a POSIX
240 compliant file system (CephFS), and offers compatibility with various
241 storage protocols (S3, NFS, and others) through the RADOS gateway.")
242 ;; The Ceph libraries are LGPL2.1 and most of the utilities fall under
243 ;; GPL2. The installed erasure code plugins are BSD-3 licensed and do
244 ;; not use the GPL code. The source archive includes a number of files
245 ;; carrying other licenses; consult COPYING for more information. Note
246 ;; that COPYING does not cover third-party bundled software.
247 (license (list license:lgpl2.1 license:gpl2 ;some files are 'or later'
248 license:cc-by-sa3.0 ;documentation
249 license:bsd-3 ;isa-l,jerasure,++
250 license:expat)))) ;civetweb,java bindings