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