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