# Contributor: Couchbase SDK Team # Maintainer: Couchbase SDK Team pkgname=couchbase-cxx-client pkgver=@COUCHBASE_CXX_CLIENT_PACKAGE_VERSION@ pkgrel=1 _number_of_commits=@COUCHBASE_CXX_CLIENT_NUMBER_OF_COMMITS@ _git_revision_short=@COUCHBASE_CXX_CLIENT_GIT_REVISION_SHORT@ if [ "${_number_of_commits}" -gt 0 ]; then # Encode commit count and git hash into _p version for uniqueness # Extract first 3 hex bytes from git hash, convert to decimal # Map each byte mod 100 to create 6-digit suffix # Formula: p = commits × 10_000_000 + (byte1%100)*10000 + (byte2%100)*100 + (byte3%100) # Example: 1.2.0-75-gfeb729b2 → 1.2.0_p750548341 _b1=$((0x${_git_revision_short:0:2})) _b2=$((0x${_git_revision_short:2:2})) _b3=$((0x${_git_revision_short:4:2})) _sha_pack=$(( (_b1 % 100) * 10000 + (_b2 % 100) * 100 + (_b3 % 100) )) _p_version=$(( _number_of_commits * 10000000 + _sha_pack )) pkgver="${pkgver}_p${_p_version}" fi source="${pkgname}-${pkgver}.tar.gz" pkgdesc="Couchbase C++ SDK" url="https://docs.couchbase.com/cxx-sdk/current/hello-world/overview.html" arch="all" license="Apache-2.0" depends="" # The -dev subpackage installs the static library's CMake config, which runs find_dependency(ZLIB); # a build dependency does not reach whoever installs that package, so zlib-dev is declared for it # here as it is in the RPM and Debian manifests. depends_dev="zlib-dev" makedepends=" linux-headers cmake ninja zlib-dev nlohmann-json " subpackages="${pkgname}-dev ${pkgname}-tools" options="!check" unpack() { (cd "${srcdir}"; tar -xzf "${source}" --strip-components=1) } build() { cmake -B apk-build -S "${srcdir}" -G Ninja \ -DCMAKE_INSTALL_PREFIX=/usr \ -DCMAKE_BUILD_TYPE=MinSizeRel \ -DBUILD_SHARED_LIBS=OFF \ -DCOUCHBASE_CXX_CLIENT_PKGCONFIG_VERSION="${pkgver}" \ -DCOUCHBASE_CXX_CLIENT_INSTALL=ON \ -DCOUCHBASE_CXX_CLIENT_STATIC_BORINGSSL=ON \ -DCOUCHBASE_CXX_CLIENT_PACKAGE_BUILD=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_EXAMPLES=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_TESTS=OFF \ -DCOUCHBASE_CXX_CLIENT_BUILD_OPENTELEMETRY=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_TOOLS=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_STATIC=ON \ -DCOUCHBASE_CXX_CLIENT_BUILD_SHARED=ON cmake --build apk-build } tools() { pkgdesc="${pkgdesc} (tools)" amove usr/bin # cbc no longer depends on the library package and carries the SDK and taocpp code inside the # binary, so the notices for that code have to ship with it. Copied under this subpackage's own # documentation directory rather than shared with the base package, which is what the Debian # packaging has to do -- dpkg rejects two packages owning one path even when the contents match. # Whether apk would tolerate sharing was not established; a private directory needs no answer. local _doc="${subpkgdir}/usr/share/doc/${subpkgname}" mkdir -p "${_doc}/tao/json" "${_doc}/tao/pegtl" cp "${pkgdir}/usr/share/doc/couchbase_cxx_client/LICENSE.txt" "${_doc}/" cp "${pkgdir}/usr/share/doc/tao/json/LICENSE" "${_doc}/tao/json/" cp "${pkgdir}/usr/share/doc/tao/pegtl/LICENSE" "${_doc}/tao/pegtl/" # And the notices for the vendored dependencies compiled into cbc, which the base package # receives from the install step but this subpackage does not. cp -r "${pkgdir}/usr/share/doc/couchbase_cxx_client/third_party" "${_doc}/" } package() { DESTDIR="${pkgdir}" cmake --install apk-build # The vendored gRPC and curl install their headers, archives and pkg-config files regardless of # the options that are supposed to gate them; cmake/GrpcProtobuf.cmake and # cmake/ThirdPartyDependencies.cmake redirect all of it under this one prefix so it can be # dropped in a single step. Nothing packaged here comes from it. rm -rf "${pkgdir}/usr/vendored-not-installed" }