cmake,debian: enable ceph-mon-client-nvmeof on Debian derivatives

5843c6b04b gated the build on /etc/redhat-release because gRPC devel
libs weren't packaged on Debian yet. They are now (libgrpc++-dev,
protobuf-compiler-grpc), so we can finally bring Debian derivatives on
par with Fedora/RHEL and ship the NVMe-oF gateway monitor client there
too.

This change:

- drops the /etc/redhat-release sniff and unconditionally enables
  WITH_NVMEOF_GATEWAY_MONITOR_CLIENT.
- adds libgrpc++-dev and protobuf-compiler-grpc to debian/control's
  Build-Depends, plus a ceph-mon-client-nvmeof / -dbg pair so the
  binary actually gets packaged.
- adds a pkg-config fallback for gRPC discovery. Jammy's libgrpc++-dev
  (1.30.2) ships no cmake config files [1], so find_package(gRPC CONFIG
  REQUIRED) fails at configure time. Noble's libgrpc++-dev (1.51.1)
  does ship them [2], as do RHEL/Rocky packages. We now try cmake config
  first (QUIET) and fall back to pkg_check_modules(IMPORTED_TARGET
  grpc++) when it isn't found.
- patches PkgConfig::GRPCPP to carry protobuf::libprotobuf as an
  interface dependency. grpc++.pc omits protobuf from its Requires, so
  gateway.pb.cc (which calls GOOGLE_PROTOBUF_VERIFY_VERSION) would fail
  to link on the pkg-config path. The cmake-config gRPC::grpc++ declares
  this dependency properly; we match that behaviour with
  target_link_libraries(PkgConfig::GRPCPP INTERFACE protobuf::libprotobuf).
- applies HAVE_ABSEIL only on the cmake-config path (Noble, RHEL/Rocky),
  where gRPC links system absl. Without it, opentelemetry-cpp's private
  absl (inline namespace otel_v1) collides with system absl (inline
  namespace debian7) in any TU that includes both tracer.h and
  grpcpp/grpcpp.h, giving "reference to base_internal is ambiguous".
  On the pkg-config path (Jammy's gRPC 1.30.2) libabsl-dev is not
  installed, so HAVE_ABSEIL must be skipped there.

[1] https://packages.ubuntu.com/jammy/amd64/libgrpc-dev/filelist
[2] https://packages.ubuntu.com/noble/amd64/libgrpc-dev/filelist

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
This commit is contained in:
Kefu Chai 2026-05-07 10:59:11 +08:00
parent 5eb650394b
commit 62cf01d0de
4 changed files with 58 additions and 19 deletions

1
debian/ceph-mon-client-nvmeof.install vendored Normal file
View File

@ -0,0 +1 @@
usr/bin/ceph-nvmeof-monitor-client

31
debian/control vendored
View File

@ -72,6 +72,8 @@ Build-Depends: automake,
libxml2-dev,
librabbitmq-dev,
libre2-dev,
libgrpc++-dev,
protobuf-compiler-grpc,
libutf8proc-dev (>= 2.2.0),
librdkafka-dev (>= 1.1.0),
libthrift-dev (>= 0.13.0),
@ -85,7 +87,7 @@ Build-Depends: automake,
libndctl-dev (>= 63) <pkg.ceph.pmdk>,
libpmem-dev <pkg.ceph.pmdk>,
libpmemobj-dev (>= 1.8) <pkg.ceph.pmdk>,
libprotobuf-dev <pkg.ceph.crimson>,
libprotobuf-dev,
libxsimd-dev <!pkg.ceph.arrow>,
ninja-build,
nlohmann-json3-dev,
@ -417,6 +419,33 @@ Description: debugging symbols for ceph-mon
.
This package contains the debugging symbols for ceph-mon.
Package: ceph-mon-client-nvmeof
Architecture: linux-any
Depends: librados2 (= ${binary:Version}),
${misc:Depends},
${shlibs:Depends},
Description: NVMe-oF Gateway Monitor Client for Ceph
Ceph is a massively scalable, open-source, distributed
storage system that runs on commodity hardware and delivers object,
block and file system storage.
.
This package contains the NVMe-oF Gateway Monitor Client. It distributes
Paxos ANA info to the NVMe-oF Gateway and provides beacons to the
ceph-mon daemon.
Package: ceph-mon-client-nvmeof-dbg
Architecture: linux-any
Section: debug
Priority: extra
Depends: ceph-mon-client-nvmeof (= ${binary:Version}),
${misc:Depends},
Description: debugging symbols for ceph-mon-client-nvmeof
Ceph is a massively scalable, open-source, distributed
storage system that runs on commodity hardware and delivers object,
block and file system storage.
.
This package contains the debugging symbols for ceph-mon-client-nvmeof.
Package: ceph-osd
Architecture: linux-any
Depends: ceph-osd-classic (= ${binary:Version}),

View File

@ -1015,12 +1015,7 @@ if(WITH_FUSE)
endif(WITH_FUSE)
# NVMEOF GATEWAY MONITOR CLIENT
# Supported on RPM-based platforms only, depends on grpc devel libraries/tools
if(EXISTS "/etc/redhat-release" OR EXISTS "/etc/fedora-release")
option(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT "build nvmeof gateway monitor client" ON)
else()
option(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT "build nvmeof gateway monitor client" OFF)
endif()
option(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT "build nvmeof gateway monitor client" ON)
if(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT)
@ -1037,17 +1032,32 @@ if(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT)
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
endif()
# Find gRPC installation
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
find_package(gRPC CONFIG REQUIRED)
# Find gRPC - try cmake config first (gRPC >= 1.50 and RHEL/Rocky packages),
# fall back to pkg-config for distros without cmake config files (e.g. Ubuntu 22.04).
find_package(gRPC CONFIG QUIET)
if(gRPC_FOUND)
message(STATUS "Using gRPC ${gRPC_VERSION}")
set(_GRPC_GRPCPP gRPC::grpc++)
if(CMAKE_CROSSCOMPILING)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin
REQUIRED)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin REQUIRED)
else()
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
endif()
# Modern gRPC links system absl; HAVE_ABSEIL makes opentelemetry-cpp do the
# same so their two absl inline namespaces don't collide in shared TUs.
set(_HAVE_ABSEIL ON)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(GRPCPP REQUIRED IMPORTED_TARGET grpc++)
message(STATUS "Using gRPC ${GRPCPP_VERSION} (via pkg-config)")
set(_GRPC_GRPCPP PkgConfig::GRPCPP)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin REQUIRED)
# Older gRPC (e.g. Jammy's 1.30.2) uses bundled absl; libabsl-dev not required.
set(_HAVE_ABSEIL OFF)
# grpc++.pc omits protobuf from Requires; add it so PkgConfig::GRPCPP
# carries the same transitive dependency as the cmake-config gRPC::grpc++.
target_link_libraries(PkgConfig::GRPCPP INTERFACE protobuf::libprotobuf)
endif()
# Gateway Proto file
get_filename_component(nvmeof_gateway_proto "nvmeof/gateway/control/proto/gateway.proto" ABSOLUTE)
@ -1111,9 +1121,7 @@ if(WITH_NVMEOF_GATEWAY_MONITOR_CLIENT)
nvmeof/NVMeofGwMonitorClient.cc)
add_executable(ceph-nvmeof-monitor-client ${ceph_nvmeof_monitor_client_srcs})
add_dependencies(ceph-nvmeof-monitor-client ceph-common)
# absl is installed as grpc build dependency on RPM based systems
# Also isolate this flag to specific targets which needs this package
if(EXISTS "/etc/redhat-release" OR EXISTS "/etc/fedora-release")
if(_HAVE_ABSEIL)
target_compile_definitions(ceph-nvmeof-monitor-client PRIVATE HAVE_ABSEIL)
target_compile_definitions(ceph-mon PRIVATE HAVE_ABSEIL)
endif()

View File

@ -196,6 +196,7 @@ cmake -D CMAKE_PREFIX_PATH=$depsDirs \
-D ENABLE_SHARED=$ENABLE_SHARED -D WITH_RBD=ON -D BUILD_GMOCK=ON \
-D WITH_CEPHFS=OFF -D WITH_MANPAGE=OFF \
-D WITH_MGR_DASHBOARD_FRONTEND=OFF -D WITH_SYSTEMD=OFF -D WITH_TESTS=ON \
-D WITH_NVMEOF_GATEWAY_MONITOR_CLIENT=OFF \
-D LZ4_INCLUDE_DIR=$lz4Include -D LZ4_LIBRARY=$lz4Lib \
-D Backtrace_INCLUDE_DIR="$backtraceDir/include" \
-D Backtrace_LIBRARY="$backtraceDir/lib/libbacktrace.a" \