summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d2701de9c99d5e4e569c93109d264ddc158d0930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
# Maintainer: Paul Stemmet <aur@luxolus.com>
# Contributor: Thore Bödecker <foxxx0@archlinux.org>
# Contributor: SĂ©bastien "Seblu" Luttringer <seblu@archlinux.org>

pkgbase='ceph'
pkgname=('ceph') ; package_ceph() { : ; } ;
pkgver=17.2.6
pkgrel=4
pkgdesc='Distributed, fault-tolerant storage platform delivering object, block, and file system'
arch=('x86_64')
url='https://ceph.com/'
license=('GPL')
makedepends=('zstd' 'bash' 'bc' 'boost' 'boost-libs' 'bzip2' 'c-ares' 'cmake' 'coreutils' 'coffeescript'
             'cpio' 'crypto++' 'cryptsetup' 'cunit' 'curl' 'cython' 'expat'
             'fcgi' 'fontconfig' 'fuse2' 'fuse3' 'fmt' 'gcc' 'gcc-libs' 'git' 'glibc' 'gmock' 'gnutls'
             'gperf' 'gperftools' 'gptfdisk' 'gtest' 'hwloc' 'inetutils' 'java-runtime'
             'jq' 'jre11-openjdk-headless' 'junit' 'keyutils' 'leveldb' 'libaio'
             'libatomic_ops' 'libcap' 'libcap-ng' 'libcroco' 'libcurl-compat'
             'libedit' 'libgudev' 'libnl' 'librabbitmq-c' 'libtool' 'util-linux'
             'libuv' 'libxml2' 'librdkafka' 'libpciaccess' 'lsb-release' 'lua' 'lz4' 'ncurses'
             'nss' 'numactl' 'oath-toolkit' 'openssl' 'parted' 'pcre' 'pcre2' 'pkgconf' 'protobuf'
             'procps-ng' 'python-astroid' 'python-attrs' 'python-bcrypt'
             'python-cheroot' 'python-cherrypy' 'python-coverage' 'python-dateutil'
             'python-elasticsearch' 'python-flask' 'python-flask-restful'
             'python-google-api-python-client' 'python-google-auth'
             'python-google-auth-httplib2' 'python-grpcio' 'python-isort'
             'python-jinja' 'python-lazy-object-proxy' 'python-mccabe'
             'python-isodate' 'python-defusedxml' 'python-pkgconfig' 'python-protobuf'
             'python-lxml' 'python-xmlsec' 'python-yaml'
             'python-more-itertools' 'python-numpy' 'python-pbr' 'python-pecan'
             'python-pip' 'python-pluggy' 'python-portend' 'python-prettytable'
             'python-prometheus_client' 'python-py' 'python-pycparser'
             'python-pyjwt' 'python-pyopenssl' 'python-pytz' 'python-requests'
             'python-routes' 'python-scikit-learn' 'python-scipy'
             'python-setuptools' 'python-six' 'python-sphinx' 'python-tempora'
             'python-virtualenv' 'python-werkzeug' 'python-wrapt' 'rabbitmq'
             'sed' 'snappy' 'socat' 'systemd' 'systemd-libs' 'valgrind'
             'xfsprogs' 'xmlstarlet' 'xmlsec' 'xxhash' 'yaml-cpp' 'yasm' 'zlib' )
checkdepends=('python-mock' 'python-nose' 'python-pycodestyle' 'python-pylint'
              'python-pytest' 'python-pytest-cov')
# Despite the upstream suggesting that LTO is now possible, I still am unable
# to set this. I get SEGVs in tests, and repeated mentions of C++ One Definition Rule
# violations in builds -- probably causing the segfaults. Need to look into this some
# more before I enable it.
# See: https://github.com/ceph/ceph/pull/42602
options=('emptydirs' '!lto')
source=(
  "https://download.ceph.com/tarballs/${pkgbase}-${pkgver}.tar.gz"
  'ceph.sysusers'
  'ceph.sudoers'
  'ceph-13.2.2-dont-install-sysvinit-script.patch'
  'disable-empty-readable.sh-test.patch'

  # Avoid spurious failures in logrotate when duplicate rule files exist,
  # typically around cephadm auto-generated rotate rules
  'ceph-17.2.5-logrotate-ignore-dups.patch'

  # Test improperly creates librados::async_write templates, in boost 1.80
  # not sure why yet, need to ask upstream for help
  'ceph-16.2.7-delete-test-librados-asio.patch'

  # Test wants to use `git ls-files`, and is sad when it finds itself not running in a
  # git repo
  'ceph-17.2.4-tox-flake8-git-ls-files.patch'

  # A problem with mypy versions <= 0.981 causes a false postive around numpy imports.
  # See: https://github.com/python/mypy/issues/13627
  'ceph-17.2.4-tox-mypy-false-postive.patch'

  # Cephadm tests rely on some mock fs abstraction which dies in the build chroot,
  # so disable them
  'ceph-17.2.4-tox-cephadm-rm.patch'

  # Split up a very IO heavy test suite, as otherwise test is liable to timeout
  # NOTE: this is a very large patchset and will guarrented break if/when the upstream
  # touches anything in src/test/objectstore
  'ceph-17.2.4-test-bluefs-split.patch'

  # pybind cython modules seem to have a longstanding issue with incorrectly mocking
  # cythonize calls in setup.py when 'egg_info' is a provided directive
  'ceph-17.2.4-pybind-unmock-cythonize.patch'

  # fixes the few usages of std::iterator which has been deprecated in c++17, quieting
  # a lot of _GLIBCXX17_DEPRECATED line noise during builds
  'ceph-17.2.5-fix-iterator-depreciations.patch'

  # Fixes API changes to boost::beast string_view type def in 1.81
  # https://github.com/boostorg/beast/issues/2594
  'ceph-17.2.5-rgw-client-boost-string-view.patch'

  # Fix missing includes from gcc 13 changes
  'ceph-17.2.6-rocksdb-gcc13-includes.patch'
  'ceph-17.2.6-ceph-gcc13-includes.patch'

  # Fixes node-gyp errors due to py3.11 incompatibilities
  'ceph-17.2.6-mgr-dashboard-node-version.patch'

  # Fixes inspect.getargspec errors due to removal in py3.11
  'ceph-17.2.6-mgr-dashboard-cherrypy-18.patch'

  # Fixes inspect.formatargspec errors in pylint2.6->wrapt due to removal in py3.11
  'ceph-17.2.6-mgr-dashboard-pylint-217.patch'

  # Backports a cmake opt to allow us to use the bundled fmtlib rather than system
  # Should be removed before v18
  'ceph-17.2.6-backport-with-fmt-version.patch'

  # Fixes a couple breaking changes from cython v3.0.0
  'ceph-17.2.6-cython-fixes.patch'
)
sha512sums=('dca9aea2ce210c15fcc34cb06a5dc5b4488ffa36d684166d47ebd87e48b54b6fee0882e1c67007a780e1c25754e9bc6e760cc10f60ea1183263f8504ef2dbd9b'
            '4354001c1abd9a0c385ba7bd529e3638fb6660b6a88d4e49706d4ac21c81b8e829303a20fb5445730bdac18c4865efb10bc809c1cd56d743c12aa9a52e160049'
            '41dbc1c395cdf9b3edf5c5d91bbc90f416b4338ad964fa3471f26a4312d3ec2a5dcebbc351a1640dc4b047b4f71aa134ac7486747e5f62980092b0176e7567f5'
            'ea069b75b786c22166c609b127b512802cc5c6e9512d792d7b7b34d276f5b86d57c8c35cfc7b5c855a59c0ba87ba1aabe2ca26da72b26bff46b6ba8410ddb27e'
            '2234d005df71b3b6013e6b76ad07a5791e3af7efec5f41c78eb1a9c92a22a67f0be9560be59b52534e90bfe251bcf32c33d5d40163f3f8f7e7420691f0f4a222'
            'b12cabda7184721c494edd22250fd05019694d2bc445722d100cdefab5385bd25c2267a029d2f6053932fa6717e38c4314385afd986969ee2744d745b53c8b58'
            '66770a80ba4e05ea72d4809cb5819cce7499ea7523b85b1a57370df68de1d7f6f94b1c10d0f9f9a3c8e6a86d0419434c70778c568cd06a0dd2e6126631a3355c'
            '31e578b240ceaaf1216b56cdce654661eed6529ef642ecad164a02669e850100a49a85dc70f3d744671e2c5dad10aee64be7d091fa33007cb8fc6788a4336799'
            '85c0a00419c292204be03e8962b0d4bc67c5dc21eb19e74897ec88168f19ac93fc2e38c405b212421c419a74923ec8c5c10844e23269225c52937fd2ad40d817'
            '6b53e3a2b1941f8dfdb4b83cafc4c500e818dd3a0736d7061f0ebcdfb514094b217e4688384c5b428288181ef6fff0ca73895c65a046e2d6ae2b834375164216'
            '81f540c8312972887a7cb43b8a4e29bfc6f24d5774787a4a8edfe65cca7d3b08faa08ecd09066d7ea67111769a5aec7385fe9a969546626f58874dd8aff5b664'
            '781a01e622a70d56bf1948bdc0b427ffa95a86cec7dd9d26c6007a9ec024a942a8ca55f2acc3d37344862f1d6bf11cae998d8071754cd841a66bfba4ec9c58bf'
            '2a6f33791760e14543c90077bfc6bf1b6b82ee2996e80b4762eadb887a0d9a67c221b6f10832ddf780dc6abaed246a1e2ee7680c9c861c4ff70e61b752a37b36'
            '02ca1a9bf15f9cd6f474f264ba2bf66ae725bac990a7cac315dabe377c66935a7afd8117f18a1f82c78bdf9ab2c3e5a2a227f2ffc166974dd7bb99b290f1f233'
            '1897ddfcd21fbbd1f18f304db6fddb5ba9336bbe2be365ece57a3ae8195f075ceb66f40fc37a4b5bf6481e8a87561383108493aa88cb01d78a904c9da28bb36c'
            '2971475ed43480802d6053e259e8540475b3da0d2a84edc9df05e822d51f31b25de450f387fb33e1f7034d3139e502e8da1b0b00ccbb066d01091055e880804b'
            'd9729c33f2b8c03ab918919e3b62cbc0825314ad09596dc12984ac5964f8b421db3376b84fa26e0952e0781deb218f8aff6ba32f9c8e5a22bd27afac8dcaf6d3'
            '79be1630ae4a599509e5d789d4aefe412ce47e67ad482f853664fa4b01e063c20593e3da668e6a776ad038fb07606ae948eea41bab20776c33c87f9ab49505e0'
            'c767a8e6fd02ea2ab88e99b50b206d0f825acdf177136ded38d93594fc7663b7c9612af7195b85e0b2b501d8ee482af5e088e9abb5ebee7b8a69e0153ce89782'
            '6b4d829c9ecacdc8fbbc6d36eb59bcd844544b728121f75101d5078fd87f6531aeafff5de636c325ebcb88eb0da49f9f62f947bf7d7db4be426ab8ddb02996f6'
            '0c5124693bd317a73707dfd34b17664cc05233aec08e07739fe08fc9a73be7a1f4446052b1addde832cba141a382c35f45e60c89a00bb7dab81cee7ed6be07e1')
__version="${pkgver}-${pkgrel}"

# -fno-plt causes linker errors (undefined reference to internal methods)
# similar issue: https://bugs.archlinux.org/task/54845
# https://github.com/intel/media-driver/commit/d95d8f7ab7ac94a2e0f4ee6a4b4794898dc2d3b7
# as of today (2019-07-12) the upstream maintainers do not consider this a bug in their code
# (IMHO rightfully so) and thus we strip the option here
export CFLAGS="${CFLAGS/-fno-plt/}"
export CXXFLAGS="${CXXFLAGS/-fno-plt/}"


prepare() {
  cd "${srcdir}/${pkgbase}-${pkgver}"

  # apply patches from the source array
  local filename
  for filename in "${source[@]%%::*}"; do
    if [[ "${filename}" =~ \.patch$ ]]; then
      echo "Applying patch ${filename##*/}"
      patch -p1 -N -i "${srcdir}/${filename##*/}"
    fi
  done

  # fix boost stuff for system-boost
  find . -name '*.cmake' -or -name 'CMakeLists.txt' -print0 | xargs --null \
    sed -r \
    -e 's|Boost::|boost_|g' \
    -e 's|Boost_|boost_|g' \
    -e 's|[Bb]oost_boost|boost_system|g' -i || exit 1

  # remove tests that require root privileges
  rm src/test/cli/ceph-authtool/cap*.t
  sed -i '/add_ceph_test(mgr-dashboard-smoke.sh/d' src/test/mgr/CMakeLists.txt

  # disable/remove broken tests
  sed -i '/add_ceph_test(smoke.sh/d' src/test/CMakeLists.txt
  sed -i '/add_ceph_test(safe-to-destroy.sh/d' src/test/osd/CMakeLists.txt
}

build() {
  cd "${srcdir}/${pkgbase}-${pkgver}"

  # 2022-09-27 fmt>9 has deprecated an API that is used extensively throughout
  # the code base. See:
  # Upstream: https://tracker.ceph.com/issues/56610
  # Debian: https://salsa.debian.org/ceph-team/ceph/-/merge_requests/9
  CPPFLAGS+=' -DFMT_DEPRECATED_OSTREAM'

  export CFLAGS+=" ${CPPFLAGS}"
  export CXXFLAGS+=" ${CPPFLAGS}"
  export CMAKE_BUILD_TYPE='RelWithDebInfo'
  export CMAKE_WARN_UNUSED_CLI=no

  cmake \
    -B build \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_SYSCONFDIR=/etc \
    -DCMAKE_INSTALL_SBINDIR=/usr/bin \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib \
    -DCEPH_SYSTEMD_ENV_DIR=/etc/default \
    -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    -DENABLE_GIT_VERSION=ON \
    -DWITH_BABELTRACE=OFF \
    -DWITH_LTTNG=OFF \
    -DWITH_FIO=OFF \
    -DWITH_OPENLDAP=OFF \
    -DWITH_RDMA=OFF \
    -DWITH_OCF=OFF \
    -DWITH_DPDK=OFF \
    -DWITH_SPDK=OFF \
    -DWITH_CEPHFS=ON \
    -DWITH_CEPHFS_JAVA=ON \
    -DWITH_CEPHFS_SHELL=ON \
    -DWITH_FUSE=ON \
    -DWITH_LZ4=ON \
    -DWITH_XFS=ON \
    -DWITH_MGR=ON \
    -DWITH_MGR_DASHBOARD_FRONTEND=ON \
    -DDASHBOARD_FRONTEND_LANGS="en-US" \
    -DWITH_RADOSGW=ON \
    -DWITH_RADOSGW_BEAST_OPENSSL=ON \
    -DWITH_RADOSGW_AMQP_ENDPOINT=ON \
    -DWITH_RADOSGW_KAFKA_ENDPOINT=ON \
    -DWITH_RADOSGW_LUA_PACKAGES=ON \
    -DWITH_RADOSGW_DBSTORE=OFF \
    -DWITH_RADOSGW_SELECT_PARQUET=OFF \
    -DWITH_SYSTEMD=ON \
    -DWITH_SYSTEM_BOOST=ON \
    -DWITH_SYSTEM_ZSTD=ON \
    -DWITH_SYSTEM_GTEST=OFF \
    -DWITH_SYSTEM_NPM=OFF \
    -DWITH_FMT_VERSION="9.0.0" \
    -DENABLE_SHARED=ON \
    -DWITH_TESTS=ON \
    -Wno-dev

  VERBOSE=1 make -C build legacy-option-headers
  VERBOSE=1 make -C build all
}

check() {
  cd "${srcdir}/${pkgbase}-${pkgver}"

  export CTEST_PARALLEL_LEVEL=7
  export CTEST_OUTPUT_ON_FAILURE=1
  VERBOSE=1 make -C build check || true

  # sometimes processes are not properly terminated...
  for process in ceph-mon ceph-mgr ceph-osd; do
    pkill -9 "${process}" || true
  done
}

_package() {
  local p="$1" f d; shift
  for f in "$@"; do
    d="$srcdir/__pkg__/$p/${f#${_staging}/}"
    mkdir -p "$(dirname "$d")"
    mv -v "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

_print() {
  (
    cd "$pkgdir" && \
    find . -type f,l -print0 \
      | xargs --null -I@ echo '    > @'
  )
}

# Real packaging function, make sure to call this in the *first*
# package_() function makepkg calls
#
# Keep in mind that adding _package lines here does nothing unless
# that package is:
# 1. Referenced in pkgname=()
# 2. Has a package_<name>() function defined for it
_make_ceph_packages() {

  # Main install
  local install="${pkgdir}/staging" ; mkdir "${install}"
  make DESTDIR="${install}" -C "${srcdir}/${pkgbase}-${pkgver}/build" install

  # Clear _package cache
  rm -rf "${srcdir}/__pkg__" || :

  (
    cd "${install}"

    pyv=$(python -c 'import sys ; v = sys.version_info ; print("%d.%d" %(v[0], v[1]))')

    lib=usr/lib
    inc=usr/include
    bin=usr/bin
    sbin=usr/sbin
    share=usr/share
    etc=etc
    python=$lib/python${pyv}/site-packages
    systemd=$lib/systemd/system
    man=$share/man

    ###############################################
    #         Print install files                 #
    ###############################################

    printf '##### CEPH INSTALL ' ; printf '%0.s#' {1..29} ; printf '\n'
    find . | sed -e 's|^\./||'
    printf '##### CEPH INSTALL ' ; printf '%0.s#' {1..29} ; printf '\n'

    ###############################################
    #         Install pruning                     #
    ###############################################

    # Remove 'tests' directories
    find . -depth -type d -name 'tests' -exec rm -vr '{}' \+

    # Remove most common test bins/scripts
    find . -depth -type f,l -name '*test*' -exec rm -v '{}' \+

    # $share/ceph/mgr/test_orchestrator
    find . -depth -type d -name 'test_orchestrator' -exec rm -vr '{}' \+

    # Live test tools
    rm -v  $bin/ceph_scratchtool{,pp}
    rm -rv $bin/ceph_psim
    rm -rv $bin/ceph-run $man/man8/ceph-run.8
    rm -rv $bin/ceph_multi_stress_watch
    rm -rv $bin/ceph-coverage

    # Old ssh key stuff
    rm -vf $share/ceph/*drop.ceph*

    # TODO: Move this into a patch
    # Fix EnvironmentFile location in systemd service files
    sed -i -e 's|/etc/sysconfig/|/etc/conf.d/|g' $systemd/*.service

    # Fix bash completions path
    install -d -m 755 "$share/bash-completion"
    mv -v $etc/bash_completion.d $share/bash-completion/completions

    # TODO: Move this into a patch
    # Fix sbin dir (cmake opt seems to have no effect)
    mv -v $sbin/* $bin/
    rm -vrf $sbin

    ###############################################
    #         Ceph core libraries                 #
    ###############################################

    _package ceph-compressor \
      $lib/ceph/compressor/*

    _package ceph-crypto \
      $lib/ceph/crypto/*

    _package ceph-erasure \
      $lib/ceph/erasure-code/*

    _package ceph-common \
      $bin/crushtool \
      $bin/ceph-authtool \
      $bin/ceph-conf \
      $lib/ceph/ceph_common.sh \
      $lib/ceph/libceph-common.so.2 \
      $lib/ceph/denc/* \
      $share/doc/ceph/sample.ceph.conf \
      $man/man8/crushtool.8 \
      $man/man8/ceph-{conf,authtool}.8

    _package librados \
      $inc/rados/* \
      $inc/radosstriper/* \
      $lib/librados.so{,.2,.2.0.0} \
      $lib/libradosstriper.so{,.1,.1.0.0} \
      $lib/rados-classes/* \
      $bin/librados-config \
      $bin/ceph-clsinfo \
      $man/man8/librados-config.8 \
      $man/man8/ceph-clsinfo.8

    _package ceph-rados \
      $bin/rados \
      $bin/ceph_radosacl \
      $share/bash-completion/completions/rados \
      $man/man8/rados.8

    _package libcephsqlite \
      $inc/libcephsqlite.h \
      $lib/libcephsqlite.so

    ###############################################
    #         Ceph clients / applications         #
    ###############################################

    _package librbd \
      $inc/rbd/* \
      $lib/librbd.so{,.1,.1.17.0} \
      $lib/ceph/librbd/*

    _package ceph-rbd \
      $bin/ceph-rbdnamer \
      $bin/rbd{,map,-{fuse,mirror,nbd,replay,replay-many}} \
      $bin/ceph-immutable-object-cache \
      $systemd/ceph-rbd-mirror{.target,@.service} \
      $systemd/ceph-immutable-object-cache{.target,@.service} \
      $systemd/rbdmap.service \
      $share/bash-completion/completions/rbd \
      $man/man8/ceph-rbdnamer.8 \
      $man/man8/ceph-immutable-object-cache.8 \
      $man/man8/rbd*

    _package libcephfs \
      $inc/cephfs/* \
      $lib/libcephfs.so{,.2,.2.0.0}

    _package ceph-cephfs \
      $bin/cephfs-{data-scan,{journal,table}-tool,mirror} \
      $bin/ceph-fuse \
      $bin/mount.{ceph,fuse.ceph} \
      $bin/ceph-client-debug \
      $systemd/cephfs-mirror{.target,@.service} \
      $systemd/ceph-fuse{.target,@.service} \
      $man/man8/ceph-fuse.8 \
      $man/man8/mount.{ceph,fuse.ceph}.8 \
      $man/man8/cephfs-*

    _package librgw \
      $lib/libradosgw.so{,.2,.2.0.0} \
      $lib/librgw.so{,.2,.2.0.0}
  )

  local -i _ret=$(find "${install}" -type f,l | wc -l)
  if (( _ret > 0 )) ; then
    echo "[ERROR] Files were found after packaging! Bailing out!"
    echo "        Please ensure all files are either moved or"
    echo "        deleted before package_ceph-common() completes."
    ( cd "${install}" && find . -type f,l | sed -e 's|^\./||' )
    return 1
  else
    rm -rf "${install}"
  fi

  return 0
}

###############################################
#         Ceph core libraries                 #
###############################################

package_ceph-common() {
  pkgdesc='Ceph Storage common libraries and dependencies'
  depends=(
    "ceph-compressor=${__version}"   "ceph-crypto=${__version}"   "ceph-erasure=${__version}"

    'boost-libs'   'curl'           'glibc'    'keyutils'     'libutil-linux'
    'nss'          'systemd-libs'   'bash'     'fmt'          'cryptsetup'
    'libxcrypt'    'libaio'         'libcap'   'gperftools'
  )
  provides=(
    'libceph-common.so'    'libceph_ebd_vdo.so'
  )

  #============================================#
  # This section needs to be run in the first  #
  # package function makepkg calls to populate #
  # the contents of each package function.     #
  _make_ceph_packages
  #============================================#

  mv __pkg__/$pkgname/* "$pkgdir"

  # sysusers
  install -Dm644 "${srcdir}/ceph.sysusers" \
    "${pkgdir}/usr/lib/sysusers.d/${pkgbase}.conf"

  # Prepare conf dir
  install -D -d -m755 -o   0 -g 340 "${pkgdir}/etc/ceph"

  _print
}

package_ceph-compressor() {
  pkgdesc='Ceph Storage compressor libs'
  depends=(
    'gcc-libs' 'lz4' 'snappy' 'zlib' 'zstd'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_ceph-crypto() {
  pkgdesc='Ceph Storage crypto libs'
  depends=(
    'gcc-libs' 'openssl'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_ceph-erasure() {
  pkgdesc='Ceph Storage erasure coding libs'
  depends=(
    'gcc-libs'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_librados() {
  pkgdesc='Ceph Storage client library to the RADOS distributed object store'
  depends=(
    "ceph-common=${__version}"

    'bash'   'boost-libs'   'fmt'   'lua'   'oath-toolkit'
  )
  provides=(
    'libradosstriper.so'   'librados.so'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_ceph-rados() {
  pkgdesc='Ceph Storage utilities and tools for librados'
  depends=(
    "librados=${__version}"

    'gcc-libs'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_libcephsqlite() {
  pkgdesc='Ceph Storage client library for a RADOS backed sqlite3 VFS extension'
  depends=(
    "librados=${__version}"

    'fmt'
  )
  provides=(
    'libcephsqlite.so'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

###############################################
#         Ceph clients / applications         #
###############################################

package_librbd() {
  pkgdesc='Ceph Storage client library for RADOS block devices'
  depends=(
    "librados=${__version}"

    'cryptsetup' 'fmt'
  )
  provides=(
    'librbd.so' 'libceph_librbd_parent_cache.so'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_ceph-rbd() {
  pkgdesc='Ceph Storage utilities and tooling for librbd'
  depends=(
    "librbd=${__version}"

    'libnl'   'fmt'          'fuse3'   'gperftools'   'boost-libs'
    'bash'    'cryptsetup'

  )
  backup=(
    'etc/udev/rules.d/50-ceph-rbd.rules'
  )

  # rbd udev rules
  install -Dm644 "${srcdir}/${pkgbase}-${pkgver}/udev/50-rbd.rules" \
    "${pkgdir}/etc/udev/rules.d/50-ceph-rbd.rules"

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_libcephfs() {
  pkgdesc='Ceph Storage client library for CephFS, a distributed POSIX filesystem'
  depends=(
    "librados=${__version}"

    'fmt'
  )
  provides=(
    'libcephfs.so'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_ceph-cephfs() {
  pkgdesc='Ceph Storage utilities and tooling for libcephfs'
  depends=(
    "libcephfs=${__version}"

    'fuse3'   'fmt'   'gperftools'   'libcap-ng'   'lua'   'python'
  )
  optdepends=(
    "cephfs-shell: Shell access to a CephFS filesystem"
    "cephfs-top: Usage and metrics for CephFS, inspired by top(1)"
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

package_librgw() {
  pkgdesc='Ceph Storage client library to RADOS Object Gateway, a S3 and Swift compatible REST API'
  depends=(
    "librados=${__version}"

    'librabbitmq-c'   'lua'   'librdkafka'   'expat'   'boost-libs'   'gperftools'
  )
  provides=(
    'librgw.so'
  )

  mv __pkg__/$pkgname/* "$pkgdir"
  _print
}

# vim:set ts=2 sw=2 et: