storage.scm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
  6. ;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages storage)
  23. #:use-module (guix download)
  24. #:use-module ((guix licenses) #:prefix license:)
  25. #:use-module (guix packages)
  26. #:use-module (guix utils)
  27. #:use-module (guix build-system cmake)
  28. #:use-module (gnu packages)
  29. #:use-module (gnu packages admin)
  30. #:use-module (gnu packages assembly)
  31. #:use-module (gnu packages authentication)
  32. #:use-module (gnu packages bdw-gc)
  33. #:use-module (gnu packages boost)
  34. #:use-module (gnu packages compression)
  35. #:use-module (gnu packages crypto)
  36. #:use-module (gnu packages cryptsetup)
  37. #:use-module (gnu packages curl)
  38. #:use-module (gnu packages databases)
  39. #:use-module (gnu packages disk)
  40. #:use-module (gnu packages gperf)
  41. #:use-module (gnu packages jemalloc)
  42. #:use-module (gnu packages icu4c)
  43. #:use-module (gnu packages linux)
  44. #:use-module (gnu packages lua)
  45. #:use-module (gnu packages ncurses)
  46. #:use-module (gnu packages networking)
  47. #:use-module (gnu packages nss)
  48. #:use-module (gnu packages openldap)
  49. #:use-module (gnu packages pkg-config)
  50. #:use-module (gnu packages pretty-print)
  51. #:use-module (gnu packages python)
  52. #:use-module (gnu packages python-xyz)
  53. #:use-module (gnu packages rpc)
  54. #:use-module (gnu packages sphinx)
  55. #:use-module (gnu packages sqlite)
  56. #:use-module (gnu packages textutils)
  57. #:use-module (gnu packages tls)
  58. #:use-module (gnu packages web)
  59. #:use-module (gnu packages xml))
  60. (define-public ceph
  61. (package
  62. (name "ceph")
  63. (version "17.2.5")
  64. (source (origin
  65. (method url-fetch)
  66. (uri (string-append "https://download.ceph.com/tarballs/ceph-"
  67. version ".tar.gz"))
  68. (sha256
  69. (base32
  70. "16mjj6cyrpdn49ig82mmrv984vqfdf24d6i4n9sghfli8z0nj8in"))
  71. (patches
  72. (search-patches
  73. "ceph-disable-cpu-optimizations.patch"))
  74. (modules '((guix build utils)))
  75. (snippet
  76. '(for-each delete-file-recursively
  77. '(;; TODO: Unbundle these:
  78. "src/arrow"
  79. ;;"src/isa-l"
  80. ;;"src/lua"
  81. ;;"src/xxHash"
  82. ;;"src/zstd"
  83. ;;"src/civetweb"
  84. "src/c-ares"
  85. "src/fmt"
  86. "src/googletest"
  87. "src/rapidjson"
  88. "src/spdk"
  89. "src/rocksdb"
  90. "src/boost"
  91. "src/utf8proc")))))
  92. (build-system cmake-build-system)
  93. (arguments
  94. (list
  95. #:parallel-build? #f ;because mgr_legacy_options.h is not built in time
  96. #:configure-flags
  97. '(let* ((out (assoc-ref %outputs "out"))
  98. (lib (assoc-ref %outputs "lib"))
  99. (libdir (string-append lib "/lib")))
  100. (list (string-append "-DCMAKE_INSTALL_PREFIX=" out)
  101. (string-append "-DCMAKE_INSTALL_LIBDIR=" libdir)
  102. (string-append "-DCMAKE_INSTALL_INCLUDEDIR="
  103. lib "/include")
  104. ;; We need both libdir and libdir/ceph in RUNPATH.
  105. (string-append "-DCMAKE_INSTALL_RPATH="
  106. libdir ";" libdir "/ceph")
  107. (string-append "-DCMAKE_INSTALL_SYSCONFDIR=" out "/etc")
  108. (string-append "-DCMAKE_INSTALL_DATADIR=" lib "/share")
  109. (string-append "-DCMAKE_INSTALL_MANDIR=" out "/share/man")
  110. (string-append "-DCMAKE_INSTALL_DOCDIR=" out "/share/ceph/doc")
  111. (string-append "-DCMAKE_INSTALL_LIBEXECDIR=" out "/libexec")
  112. (string-append "-DKEYUTILS_INCLUDE_DIR="
  113. (assoc-ref %build-inputs "keyutils") "/include")
  114. (string-append "-DXFS_INCLUDE_DIR="
  115. (assoc-ref %build-inputs "xfsprogs") "/include")
  116. "-DCMAKE_INSTALL_LOCALSTATEDIR=/var"
  117. "-DBUILD_SHARED_LIBS=ON"
  118. "-DWITH_SYSTEM_ARROW=ON"
  119. "-DWITH_SYSTEM_BOOST=ON"
  120. "-DWITH_SYSTEM_ROCKSDB=ON"
  121. "-DWITH_SYSTEM_UTF8PROC=ON"
  122. ;; TODO: Enable these when available in Guix.
  123. "-DWITH_MGR_DASHBOARD_FRONTEND=OFF" ;requires node + nodeenv
  124. "-DWITH_BABELTRACE=OFF"
  125. "-DWITH_LTTNG=OFF"
  126. "-DWITH_SPDK=OFF"
  127. "-DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
  128. ;; Use jemalloc instead of tcmalloc.
  129. "-DALLOCATOR=jemalloc"
  130. ;; Don't install systemd unit files.
  131. "-DWITH_SYSTEMD=OFF"
  132. ;; Do not bother building the tests; we are not currently running
  133. ;; them, and they do not build with system googletest as of 14.2.5.
  134. "-DWITH_TESTS=OFF"))
  135. ;; FIXME: Some of the tests leak Btrfs subvolumes on Btrfs. See
  136. ;; <https://bugs.gnu.org/29674> for details. Disable tests until
  137. ;; resolved.
  138. #:tests? #f
  139. #:phases
  140. `(modify-phases %standard-phases
  141. (add-after 'unpack 'patch-source
  142. (lambda* (#:key outputs #:allow-other-keys)
  143. (let ((out (assoc-ref outputs "out"))
  144. (lib (assoc-ref outputs "lib")))
  145. (substitute* "src/rgw/store/dbstore/sqlite/CMakeLists.txt"
  146. (("add_library\\(sqlite_db \\$")
  147. "add_library(sqlite_db STATIC $"))
  148. (substitute* "src/rgw/store/dbstore/CMakeLists.txt"
  149. (("add_library\\(dbstore \\$")
  150. "add_library(dbstore STATIC $")
  151. (("add_library\\(dbstore_lib \\$")
  152. "add_library(dbstore_lib STATIC $"))
  153. (substitute* "cmake/modules/Distutils.cmake"
  154. ;; Prevent creation of Python eggs.
  155. (("setup.py install")
  156. "setup.py install --single-version-externally-managed --root=/")
  157. ;; Inject the -rpath linker argument when linking
  158. ;; Python C libraries so RUNPATH gets set up correctly.
  159. (("LDFLAGS=(.*)\n" _ flags)
  160. (string-append "LDFLAGS=\\\"" flags
  161. " -Wl,-rpath=" lib "/lib\\\"\n")))
  162. ;; Statically link libcrc32 because it does not get installed,
  163. ;; yet several libraries end up referring to it.
  164. (substitute* "src/common/CMakeLists.txt"
  165. (("add_library\\(crc32")
  166. "add_library(crc32 STATIC"))
  167. (substitute* "udev/50-rbd.rules"
  168. (("/usr/bin/ceph-rbdnamer")
  169. (string-append out "/bin/ceph-rbdnamer"))))))
  170. (add-before 'install 'set-install-environment
  171. (lambda* (#:key outputs #:allow-other-keys)
  172. (let* ((out (assoc-ref outputs "out"))
  173. (py3sitedir
  174. (string-append out "/lib/python"
  175. ,(version-major+minor
  176. (package-version python))
  177. "/site-packages")))
  178. ;; The Python install scripts refuses to function if
  179. ;; the install directory is not on PYTHONPATH.
  180. (setenv "PYTHONPATH" py3sitedir))))
  181. (add-after 'install 'wrap-python-scripts
  182. (lambda* (#:key inputs outputs #:allow-other-keys)
  183. (let* ((out (assoc-ref outputs "out"))
  184. (scripts '("bin/ceph" "bin/cephfs-top" "sbin/ceph-volume"))
  185. (dependencies (map (lambda (input)
  186. (assoc-ref inputs input))
  187. '("python-prettytable" "python-pyyaml")))
  188. (sitedir (lambda (package)
  189. (string-append package
  190. "/lib/python"
  191. ,(version-major+minor
  192. (package-version python))
  193. "/site-packages")))
  194. (PYTHONPATH (string-join (map sitedir (cons out dependencies))
  195. ":")))
  196. (for-each (lambda (executable)
  197. (wrap-program (string-append out "/" executable)
  198. `("GUIX_PYTHONPATH" ":" prefix (,PYTHONPATH))))
  199. scripts)))))))
  200. (outputs
  201. '("out" "lib"))
  202. (native-inputs
  203. (list gperf pkg-config python-cython python-sphinx yasm))
  204. (inputs
  205. (list `(,apache-thrift "lib")
  206. `(,apache-thrift "include")
  207. `(,apache-arrow-for-ceph "lib")
  208. boost
  209. curl
  210. cryptsetup
  211. eudev
  212. expat
  213. fcgi
  214. fmt-8
  215. fuse
  216. icu4c
  217. jemalloc
  218. keyutils
  219. leveldb
  220. libaio
  221. libatomic-ops
  222. libcap-ng
  223. libnl
  224. librdkafka
  225. lua
  226. lz4
  227. oath-toolkit
  228. openldap
  229. openssl
  230. ncurses
  231. nss
  232. python-prettytable ;used by ceph_daemon.py
  233. python-pyyaml ;from python-common/setup.py
  234. python
  235. rapidjson
  236. rdma-core
  237. rocksdb
  238. snappy
  239. sqlite
  240. utf8proc
  241. util-linux
  242. `(,util-linux "lib")
  243. xfsprogs
  244. zlib))
  245. (home-page "https://ceph.com/")
  246. (synopsis "Distributed object store and file system")
  247. (description
  248. "Ceph is a distributed storage system designed for reliability and
  249. performance. It provides network-based block devices (RBD), a POSIX
  250. compliant file system (CephFS), and offers compatibility with various
  251. storage protocols (S3, NFS, and others) through the RADOS gateway.")
  252. ;; The Ceph libraries are LGPL2.1 and most of the utilities fall under
  253. ;; GPL2. The installed erasure code plugins are BSD-3 licensed and do
  254. ;; not use the GPL code. The source archive includes a number of files
  255. ;; carrying other licenses; consult COPYING for more information. Note
  256. ;; that COPYING does not cover third-party bundled software.
  257. (license (list license:lgpl2.1 license:gpl2 ;some files are 'or later'
  258. license:cc-by-sa3.0 ;documentation
  259. license:bsd-3 ;isa-l,jerasure,++
  260. license:expat)))) ;civetweb,java bindings