storage.scm 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (gnu packages storage)
  22. #:use-module (guix download)
  23. #:use-module ((guix licenses) #:prefix license:)
  24. #:use-module (guix packages)
  25. #:use-module (guix utils)
  26. #:use-module (guix build-system cmake)
  27. #:use-module (gnu packages)
  28. #:use-module (gnu packages admin)
  29. #:use-module (gnu packages assembly)
  30. #:use-module (gnu packages authentication)
  31. #:use-module (gnu packages bdw-gc)
  32. #:use-module (gnu packages boost)
  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 gperf)
  40. #:use-module (gnu packages jemalloc)
  41. #:use-module (gnu packages linux)
  42. #:use-module (gnu packages lua)
  43. #:use-module (gnu packages ncurses)
  44. #:use-module (gnu packages networking)
  45. #:use-module (gnu packages nss)
  46. #:use-module (gnu packages openldap)
  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 sphinx)
  51. #:use-module (gnu packages tls)
  52. #:use-module (gnu packages web)
  53. #:use-module (gnu packages xml))
  54. (define-public ceph
  55. (package
  56. (name "ceph")
  57. (version "14.2.16")
  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. "0lmdri415hqczc9565s5m5568pnj97ipqxgnw6085kps0flwq5zh"))
  65. (patches
  66. (search-patches
  67. "ceph-disable-cpu-optimizations.patch"
  68. "ceph-fix-snappy-breaking-change.patch"))
  69. (modules '((guix build utils)))
  70. (snippet
  71. '(begin
  72. (for-each delete-file-recursively
  73. '(;; TODO: Unbundle these:
  74. ;"src/isa-l"
  75. ;"src/lua"
  76. ;"src/xxHash"
  77. ;"src/zstd"
  78. ;"src/civetweb"
  79. ;"src/seastar/fmt"
  80. "src/test/downloads"
  81. "src/c-ares"
  82. "src/googletest"
  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_DATADIR=" lib "/share")
  103. (string-append "-DCMAKE_INSTALL_MANDIR=" out "/share/man")
  104. (string-append "-DCMAKE_INSTALL_DOCDIR=" out "/share/ceph/doc")
  105. (string-append "-DCMAKE_INSTALL_LIBEXECDIR=" out "/libexec")
  106. (string-append "-DKEYUTILS_INCLUDE_DIR="
  107. (assoc-ref %build-inputs "keyutils") "/include")
  108. (string-append "-DXFS_INCLUDE_DIR="
  109. (assoc-ref %build-inputs "xfsprogs") "/include")
  110. "-DCMAKE_INSTALL_LOCALSTATEDIR=/var"
  111. "-DBUILD_SHARED_LIBS=ON"
  112. "-DWITH_SYSTEM_ROCKSDB=ON"
  113. "-DWITH_SYSTEM_BOOST=ON"
  114. "-DWITH_PYTHON3=ON"
  115. ;; TODO: Enable these when available in Guix.
  116. "-DWITH_MGR_DASHBOARD_FRONTEND=OFF" ;requires node + nodeenv
  117. "-DWITH_BABELTRACE=OFF"
  118. "-DWITH_LTTNG=OFF"
  119. "-DWITH_SPDK=OFF"
  120. "-DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
  121. ;; Use jemalloc instead of tcmalloc.
  122. "-DALLOCATOR=jemalloc"
  123. ;; Do not bother building the tests; we are not currently running
  124. ;; them, and they do not build with system googletest as of 14.2.5.
  125. "-DWITH_TESTS=OFF"))
  126. ;; FIXME: Some of the tests leak Btrfs subvolumes on Btrfs. See
  127. ;; <https://bugs.gnu.org/29674> for details. Disable tests until
  128. ;; resolved.
  129. #:tests? #f
  130. #:phases
  131. (modify-phases %standard-phases
  132. (add-after 'unpack 'patch-source
  133. (lambda* (#:key outputs #:allow-other-keys)
  134. (let ((out (assoc-ref outputs "out"))
  135. (lib (assoc-ref outputs "lib")))
  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. (substitute* (find-files "src/pybind" "^setup\\.py$")
  141. ;; Here we inject an extra line to the `setup.py' of the
  142. ;; Python C libraries so RUNPATH gets set up correctly.
  143. (("^([[:blank:]]+)extra_compile_args=(.*)$" _ indent args)
  144. (string-append indent "extra_compile_args=" args
  145. indent "extra_link_args=['-Wl,-rpath="
  146. lib "/lib'],\n")))
  147. ;; Statically link libcrc32 because it does not get installed,
  148. ;; yet several libraries end up referring to it.
  149. (substitute* "src/common/CMakeLists.txt"
  150. (("add_library\\(crc32")
  151. "add_library(crc32 STATIC"))
  152. (substitute* "udev/50-rbd.rules"
  153. (("/usr/bin/ceph-rbdnamer")
  154. (string-append out "/bin/ceph-rbdnamer")))
  155. #t)))
  156. (add-before 'install 'set-install-environment
  157. (lambda* (#:key outputs #:allow-other-keys)
  158. (let* ((out (assoc-ref outputs "out"))
  159. (py3sitedir
  160. (string-append out "/lib/python"
  161. ,(version-major+minor
  162. (package-version python))
  163. "/site-packages")))
  164. ;; The Python install scripts refuses to function if
  165. ;; the install directory is not on PYTHONPATH.
  166. (setenv "PYTHONPATH" py3sitedir))))
  167. (add-after 'install 'wrap-python-scripts
  168. (lambda* (#:key inputs outputs #:allow-other-keys)
  169. (let* ((out (assoc-ref outputs "out"))
  170. (scripts '("ceph" "ceph-mgr" "ceph-volume"))
  171. (prettytable (assoc-ref inputs "python-prettytable"))
  172. (six (assoc-ref inputs "python-six"))
  173. (sitedir (lambda (package)
  174. (string-append package
  175. "/lib/python"
  176. ,(version-major+minor
  177. (package-version python))
  178. "/site-packages")))
  179. (PYTHONPATH (string-append
  180. (sitedir out) ":"
  181. (sitedir six) ":"
  182. (sitedir prettytable))))
  183. (for-each (lambda (executable)
  184. (wrap-program (string-append out "/bin/" executable)
  185. `("GUIX_PYTHONPATH" ":" prefix (,PYTHONPATH))))
  186. scripts)
  187. #t))))))
  188. (outputs
  189. '("out" "lib"))
  190. (native-inputs
  191. `(("gperf" ,gperf)
  192. ("pkg-config" ,pkg-config)
  193. ("python-cython" ,python-cython)
  194. ("python-sphinx" ,python-sphinx)
  195. ("yasm" ,yasm)))
  196. (inputs
  197. `(("boost" ,boost)
  198. ("curl" ,curl)
  199. ("cryptsetup" ,cryptsetup)
  200. ("expat" ,expat)
  201. ("fcgi" ,fcgi)
  202. ("fuse" ,fuse)
  203. ("jemalloc" ,jemalloc)
  204. ("keyutils" ,keyutils)
  205. ("leveldb" ,leveldb)
  206. ("libaio" ,libaio)
  207. ("libatomic-ops" ,libatomic-ops)
  208. ("libcap-ng" ,libcap-ng)
  209. ("libnl" ,libnl)
  210. ("librdkafka" ,librdkafka)
  211. ("lua" ,lua)
  212. ("lz4" ,lz4)
  213. ("oath-toolkit" ,oath-toolkit)
  214. ("openldap" ,openldap)
  215. ("openssl" ,openssl)
  216. ("ncurses" ,ncurses)
  217. ("nss" ,nss)
  218. ("python-prettytable" ,python-prettytable) ;used by ceph_daemon.py
  219. ("python-six" ,python-six) ;for ceph-mgr + plugins
  220. ("python" ,python-wrapper)
  221. ("rapidjson" ,rapidjson)
  222. ("rdma-core" ,rdma-core)
  223. ("rocksdb" ,rocksdb)
  224. ("snappy" ,snappy)
  225. ("udev" ,eudev)
  226. ("util-linux" ,util-linux)
  227. ("util-linux:lib" ,util-linux "lib")
  228. ("xfsprogs" ,xfsprogs)
  229. ("zlib" ,zlib)))
  230. (home-page "https://ceph.com/")
  231. (synopsis "Distributed object store and file system")
  232. (description
  233. "Ceph is a distributed storage system designed for reliability and
  234. performance. It provides network-based block devices (RBD), a POSIX
  235. compliant file system (CephFS), and offers compatibility with various
  236. storage protocols (S3, NFS, and others) through the RADOS gateway.")
  237. ;; The Ceph libraries are LGPL2.1 and most of the utilities fall under
  238. ;; GPL2. The installed erasure code plugins are BSD-3 licensed and do
  239. ;; not use the GPL code. The source archive includes a number of files
  240. ;; carrying other licenses; consult COPYING for more information. Note
  241. ;; that COPYING does not cover third-party bundled software.
  242. (license (list license:lgpl2.1 license:gpl2 ;some files are 'or later'
  243. license:cc-by-sa3.0 ;documentation
  244. license:bsd-3 ;isa-l,jerasure,++
  245. license:expat)))) ;civetweb,java bindings