gnu: ceph: Install headers to the "lib" output.
[jackhill/guix/guix.git] / gnu / packages / storage.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018 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 check)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages crypto)
35 #:use-module (gnu packages cryptsetup)
36 #:use-module (gnu packages curl)
37 #:use-module (gnu packages databases)
38 #:use-module (gnu packages disk)
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages gnuzilla)
41 #:use-module (gnu packages gperf)
42 #:use-module (gnu packages jemalloc)
43 #:use-module (gnu packages linux)
44 #:use-module (gnu packages lua)
45 #:use-module (gnu packages openldap)
46 #:use-module (gnu packages perl)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages python-xyz)
50 #:use-module (gnu packages tls)
51 #:use-module (gnu packages web)
52 #:use-module (gnu packages xml))
53
54 (define-public ceph
55 (package
56 (name "ceph")
57 (version "13.2.5")
58 (source (origin
59 (method url-fetch)
60 (uri (string-append "https://download.ceph.com/tarballs/ceph-"
61 version ".tar.gz"))
62 (sha256
63 (base32
64 "0jbs6l763clbqnq2s5jksn44yf71rhcnk85cw64fqvmv0r4ch71n"))
65 (patches
66 (search-patches "ceph-skip-unittest_blockdev.patch"
67 "ceph-skip-collect-sys-info-test.patch"
68 "ceph-detect-rocksdb.patch"
69 "ceph-volume-respect-PATH.patch"
70 "ceph-disable-cpu-optimizations.patch"))
71 (modules '((guix build utils)))
72 (snippet
73 '(begin
74 (for-each delete-file-recursively
75 '(;; TODO: Unbundle these:
76 ;"src/isa-l"
77 ;"src/lua"
78 ;"src/googletest"
79 ;"src/xxHash"
80 ;"src/zstd"
81 ;"src/civetweb"
82 "src/test/downloads"
83 "src/rapidjson"
84 "src/spdk"
85 "src/rocksdb"
86 "src/boost"))
87 #t))))
88 (build-system cmake-build-system)
89 (arguments
90 `(#:configure-flags
91 (let* ((out (assoc-ref %outputs "out"))
92 (lib (assoc-ref %outputs "lib"))
93 (libdir (string-append lib "/lib")))
94 (list (string-append "-DCMAKE_INSTALL_PREFIX=" out)
95 (string-append "-DCMAKE_INSTALL_LIBDIR=" libdir)
96 (string-append "-DCMAKE_INSTALL_INCLUDEDIR="
97 lib "/include")
98 ;; We need both libdir and libdir/ceph in RUNPATH.
99 (string-append "-DCMAKE_INSTALL_RPATH="
100 libdir ";" libdir "/ceph")
101 (string-append "-DCMAKE_INSTALL_SYSCONFDIR=" out "/etc")
102 (string-append "-DCMAKE_INSTALL_MANDIR=" out "/share/man")
103 (string-append "-DCMAKE_INSTALL_DOCDIR=" out "/share/ceph/doc")
104 (string-append "-DCMAKE_INSTALL_LIBEXECDIR=" out "/libexec")
105 (string-append "-DKEYUTILS_INCLUDE_DIR="
106 (assoc-ref %build-inputs "keyutils") "/include")
107 "-DCMAKE_INSTALL_LOCALSTATEDIR=/var"
108 "-DENABLE_SHARED=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_XFS=OFF"
118 "-DWITH_XIO=OFF"
119 ;; Use jemalloc instead of tcmalloc.
120 "-DALLOCATOR=jemalloc"))
121 ;; FIXME: Some of the tests leak Btrfs subvolumes on Btrfs. See
122 ;; <https://bugs.gnu.org/29674> for details. Disable tests until
123 ;; resolved.
124 #:tests? #f
125 #:phases
126 (modify-phases %standard-phases
127 (add-after 'unpack 'patch-source
128 (lambda* (#:key outputs #:allow-other-keys)
129 (let ((out (assoc-ref outputs "out"))
130 (lib (assoc-ref outputs "lib")))
131
132 (substitute* "cmake/modules/Distutils.cmake"
133 ;; Prevent creation of Python eggs.
134 (("setup.py install")
135 "setup.py install --single-version-externally-managed --root=/"))
136
137 (substitute* (find-files "src/pybind" "^setup\\.py$")
138 ;; Here we inject an extra line to the `setup.py' of the
139 ;; Python C libraries so RUNPATH gets set up correctly.
140 (("^([[:blank:]]+)extra_compile_args=(.*)$" _ indent args)
141 (string-append indent "extra_compile_args=" args
142 indent "extra_link_args=['-Wl,-rpath="
143 lib "/lib'],\n")))
144
145 (substitute* "src/ceph-disk/tox.ini"
146 ;; Disable flake8 test since it complains about too long lines.
147 (("envlist = flake8,py27") "envlist = py27"))
148
149 (substitute* "src/ceph-detect-init/tox.ini"
150 ;; Disable python3 tests until we at least get py2 working.
151 (("envlist = pep8,py27,py3") "envlist = pep8,py27"))
152
153 (substitute* "src/key_value_store/kv_flat_btree_async.cc"
154 (("/usr/include/") ""))
155
156 (substitute* "src/test/test_subprocess.cc"
157 (("/bin/sh") (which "sh")))
158 (substitute* "qa/standalone/special/ceph_objectstore_tool.py"
159 (("/bin/rm") (which "rm")))
160 (substitute* "src/ceph-disk/ceph_disk/main.py"
161 (("/bin/mount") "mount")
162 (("/bin/umount") "umount")
163 (("/sbin/blkid") (which "blkid"))
164 (("'cryptsetup'") (string-append "'" (which "cryptsetup") "'"))
165 (("'sgdisk'") (string-append "'" (which "sgdisk") "'"))
166 (("'parted'") (string-append "'" (which "parted") "'"))
167 (("'udevadm'") (string-append "'" (which "udevadm") "'")))
168
169 (substitute* "udev/50-rbd.rules"
170 (("/usr/bin/ceph-rbdnamer")
171 (string-append out "/bin/ceph-rbdnamer")))
172 (substitute* "udev/60-ceph-by-parttypeuuid.rules"
173 (("/sbin/blkid") (which "blkid")))
174 (substitute* "udev/95-ceph-osd.rules"
175 (("/usr/sbin/ceph-disk")
176 (string-append out "/bin/ceph-disk")))
177
178 (substitute* "src/test/run-cli-tests"
179 ;; Use our python-cram instead of the (un)bundled one.
180 (("CRAM_BIN=.*$")
181 (string-append "CRAM_BIN=" (which "cram") "\n")))
182
183 ;; Disable tests that are known to fail.
184 ;; TODO: The majority of these fail because
185 ;; 'qa/workunits/ceph-helpers.sh' expects to find
186 ;; /tmp/ceph-disk-virtualenv/bin/ceph-disk, but somehow
187 ;; src/ceph-disk/CMakeLists.txt fails to create it.
188 (substitute* "src/test/CMakeLists.txt"
189 ;; FIXME: These tests fails because `ceph-disk'
190 ;; is not available.
191 (("^add_ceph_test\\(test-ceph-helpers\\.sh.*$") "\n")
192 (("^add_ceph_test\\(test_pidfile\\.sh.*$") "\n")
193 ;; XXX Why does this fail.
194 (("^add_ceph_test\\(cephtool-test-mon\\.sh.*$") "\n")
195 ;; This fails due to missing '/etc/fstab'.
196 (("^add_ceph_test\\(cephtool-test-rados\\.sh.*$") "\n")
197 ;; `Bad messages to stderr: OSD has the store locked'
198 (("^add_ceph_test\\(ceph_objectstore_tool\\.py.*$") "\n")
199 ;; The bundled python-cram fork needs patching to work on
200 ;; guix, and the system version does not support --error-dir.
201 ;; https://bitbucket.org/brodie/cram/issues/9
202 (("^add_ceph_test\\(run-cli-tests.*$") "\n")
203 ;; FIXME: tox/virtualenv/pip does not discover the
204 ;; required packages and tries to go online.
205 (("^add_test\\(NAME run-tox-ceph-disk.*$") "\n")
206 (("^add_test\\(NAME run-tox-ceph-detect-init.*$") "\n")
207 ;; Also remove from the set_property block.
208 (("run-tox-ceph-disk") "")
209 (("run-tox-ceph-detect-init") ""))
210 ;; TODO: This also seems to fail because of /etc/os-release.
211 ;; How to make src/common/util.cc behave without it.
212 (substitute* "src/test/crush/CMakeLists.txt"
213 (("^add_ceph_test\\(crush-classes\\.sh.*$") "\n"))
214 ;; More 'ceph-disk' issues here.. :-(
215 (substitute* "src/test/erasure-code/CMakeLists.txt"
216 (("^add_ceph_test\\(test-erasure-code-plugins\\.sh.*$") "\n")
217 (("^add_ceph_test\\(test-erasure-code\\.sh.*$") "\n")
218 (("^add_ceph_test\\(test-erasure-eio\\.sh.*$") "\n"))
219 (substitute* "src/test/libradosstriper/CMakeLists.txt"
220 (("^add_ceph_test\\(rados-striper\\.sh.*$") "\n"))
221 (substitute* "src/test/mon/CMakeLists.txt"
222 (("^add_ceph_test\\(osd-crush\\.sh.*$") "\n")
223 (("^add_ceph_test\\(test_pool_quota\\.sh.*$") "\n")
224 (("^add_ceph_test\\(osd-pool-create\\.sh.*$") "\n"))
225 (substitute* "src/test/osd/CMakeLists.txt"
226 (("^add_ceph_test\\(osd-bench\\.sh.*$") "\n")
227 (("^add_ceph_test\\(osd-config\\.sh.*$") "\n")
228 (("add_ceph_test\\(osd-dup\\.sh.*$") "\n")
229 (("^add_ceph_test\\(osd-markdown\\.sh.*$") "\n")
230 (("^add_ceph_test\\(osd-reactivate\\.sh.*$") "\n")
231 (("^add_ceph_test\\(osd-reuse-id\\.sh.*$") "\n")
232 (("^add_ceph_test\\(osd-scrub-repair\\.sh.*$") "\n")
233 (("^add_ceph_test\\(osd-scrub-snaps\\.sh.*$") "\n")
234 (("^add_ceph_test\\(osd-copy-from\\.sh.*$") "\n")
235 (("^add_ceph_test\\(osd-fast-mark-down\\.sh.*$") "\n"))
236 #t)))
237 (add-before 'configure 'gcc-workaround
238 (lambda _
239 (unsetenv "C_INCLUDE_PATH")
240 (unsetenv "CPLUS_INCLUDE_PATH")
241 #t))
242 (add-before 'check 'set-check-environment
243 (lambda _
244 ;; Run tests in parallel.
245 (setenv "CTEST_PARALLEL_LEVEL"
246 (number->string (parallel-job-count)))
247 ;; `pip' requires write access in $HOME.
248 (setenv "HOME" "/tmp")
249 #t))
250 (add-before 'install 'set-install-environment
251 (lambda* (#:key outputs #:allow-other-keys)
252 (let* ((out (assoc-ref outputs "out"))
253 (py2sitedir
254 (string-append out "/lib/python2.7/site-packages"))
255 (py3sitedir
256 (string-append out "/lib/python"
257 ,(version-major+minor
258 (package-version python))
259 "/site-packages")))
260 ;; The Python install scripts refuses to function if
261 ;; the install directory is not on PYTHONPATH.
262 (setenv "PYTHONPATH"
263 (string-append py2sitedir ":" py3sitedir ":"
264 (getenv "PYTHONPATH")))
265 #t)))
266 (add-after 'install 'wrap-python-scripts
267 (lambda* (#:key inputs outputs #:allow-other-keys)
268 (let* ((out (assoc-ref outputs "out"))
269 (scripts '("ceph" "ceph-mgr" "ceph-volume"
270 "ceph-detect-init"
271 "ceph-disk")) ;deprecated
272 (prettytable (assoc-ref inputs "python2-prettytable"))
273 (six (assoc-ref inputs "python2-six"))
274 (sitedir (lambda (package)
275 (string-append package
276 "/lib/python2.7/site-packages")))
277 (PYTHONPATH (string-append
278 (sitedir out) ":"
279 (sitedir six) ":"
280 (sitedir prettytable))))
281 (for-each (lambda (executable)
282 (wrap-program (string-append out "/bin/" executable)
283 `("PYTHONPATH" ":" prefix (,PYTHONPATH))))
284 scripts)
285 #t))))))
286 (outputs
287 '("out" "lib"))
288 (native-inputs
289 `(("gcc" ,gcc-7) ;7 or later is required
290 ("gperf" ,gperf)
291 ("pkg-config" ,pkg-config)
292 ("python-cython" ,python-cython)
293 ("python-sphinx" ,python-sphinx)
294 ("yasm" ,yasm)
295
296 ;; For tests.
297 ("inetutils" ,inetutils)
298 ("jq" ,jq)
299 ("perl" ,perl)
300 ("xmlstarlet" ,xmlstarlet)
301 ("python2-cram" ,python2-cram)
302 ("python2-virtualenv" ,python2-virtualenv)
303
304 ;; These dependencies are taken from test-requirements.txt
305 ;; of ceph-disk and ceph-detect-init. The latter can also
306 ;; test against python3, but let's try to get python2 tests
307 ;; working first since that is the default.
308 ("python2-configobj" ,python2-configobj)
309 ("python2-coverage" ,python2-coverage)
310 ("python2-discover" ,python2-discover)
311 ("python2-fixtures" ,python2-fixtures)
312 ("python2-flake8" ,python2-flake8)
313 ("python2-mock" ,python2-mock)
314 ("python2-nose" ,python2-nose)
315 ("python2-pip" ,python2-pip)
316 ("python2-pytest" ,python2-pytest)
317 ("python2-subunit" ,python2-subunit)
318 ("python2-testrepository" ,python2-testrepository)
319 ("python2-testtools" ,python2-testtools)
320 ("python2-tox" ,python2-tox)))
321 (inputs
322 `(("boost" ,boost)
323 ("curl" ,curl)
324 ("cryptsetup" ,cryptsetup)
325 ("expat" ,expat)
326 ("fcgi" ,fcgi)
327 ("fuse" ,fuse)
328 ("gptfdisk" ,gptfdisk)
329 ("jemalloc" ,jemalloc)
330 ("keyutils" ,keyutils)
331 ("leveldb" ,leveldb)
332 ("libaio" ,libaio)
333 ("libatomic-ops" ,libatomic-ops)
334 ("lua" ,lua)
335 ("lz4" ,lz4)
336 ("oath-toolkit" ,oath-toolkit)
337 ("openldap" ,openldap)
338 ("openssl" ,openssl)
339 ("nss" ,nss)
340 ("parted" ,parted)
341 ("python@2" ,python-2)
342 ("python2-prettytable" ,python2-prettytable) ;used by ceph_daemon.py
343 ("python2-six" ,python2-six) ;for ceph-mgr + plugins
344 ("python@3" ,python-3)
345 ("rapidjson" ,rapidjson)
346 ("rocksdb" ,rocksdb)
347 ("snappy" ,snappy)
348 ("udev" ,eudev)
349 ("util-linux" ,util-linux)
350 ("zlib" ,zlib)))
351 (home-page "https://ceph.com/")
352 (synopsis "Distributed object store and file system")
353 (description
354 "Ceph is a distributed storage system designed for reliability and
355 performance. It provides network-based block devices (RBD), a POSIX
356 compliant file system (CephFS), and offers compatibility with various
357 storage protocols (S3, NFS, and others) through the RADOS gateway.")
358 ;; The Ceph libraries are LGPL2.1 and most of the utilities fall under
359 ;; GPL2. The installed erasure code plugins are BSD-3 licensed and do
360 ;; not use the GPL code. The source archive includes a number of files
361 ;; carrying other licenses; consult COPYING for more information. Note
362 ;; that COPYING does not cover third-party bundled software.
363 (license (list license:lgpl2.1 license:gpl2 ;some files are 'or later'
364 license:cc-by-sa3.0 ;documentation
365 license:bsd-3 ;isa-l,jerasure,++
366 license:expat)))) ;civetweb,java bindings