# Copyright 2024-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 CRATES=" adler32-1.2.0 aho-corasick-1.1.4 allocator-api2-0.2.21 android_system_properties-0.1.5 anstream-0.6.21 anstyle-1.0.13 anstyle-parse-0.2.7 anstyle-query-1.1.5 anstyle-wincon-3.0.11 anyhow-1.0.100 arrayvec-0.5.2 atty-0.2.14 autocfg-1.5.0 bitflags-1.3.2 bitflags-2.10.0 bumpalo-3.19.0 cast-0.3.0 cc-1.2.47 cfg-if-1.0.4 chrono-0.4.42 clap-2.34.0 clap-4.5.53 clap_builder-4.5.53 clap_derive-4.5.49 clap_lex-0.7.6 codespan-reporting-0.11.1 colorchoice-1.0.4 colored-2.2.0 core-foundation-sys-0.8.7 core2-0.4.0 crc32fast-1.5.0 criterion-0.3.6 criterion-plot-0.4.5 crossbeam-channel-0.5.15 crossbeam-deque-0.8.6 crossbeam-epoch-0.9.18 crossbeam-utils-0.8.21 csv-1.4.0 csv-core-0.1.13 dary_heap-0.3.8 derivative-2.2.0 derive_more-2.0.1 derive_more-impl-2.0.1 diff-0.1.13 dissimilar-1.0.10 either-1.15.0 ena-0.14.3 env_filter-0.1.4 env_logger-0.11.8 equivalent-1.0.2 errno-0.3.14 expect-test-1.5.1 fallible-iterator-0.3.0 fallible-streaming-iterator-0.1.9 fastrand-2.3.0 find-msvc-tools-0.1.5 flatbuffers-25.9.23 fluent-uri-0.1.4 fnv-1.0.7 foldhash-0.1.5 foldhash-0.2.0 getrandom-0.2.16 getrandom-0.3.4 half-1.8.3 hashbrown-0.12.3 hashbrown-0.15.5 hashbrown-0.16.1 hashlink-0.10.0 heck-0.3.3 heck-0.5.0 hermit-abi-0.1.19 iana-time-zone-0.1.64 iana-time-zone-haiku-0.1.2 indexmap-1.9.3 instant-0.1.13 is_terminal_polyfill-1.70.2 itertools-0.10.5 itoa-1.0.15 jiff-0.2.16 jiff-static-0.2.16 js-sys-0.3.82 lazy_static-1.5.0 libc-0.2.177 libflate-2.2.1 libflate_lz77-2.2.0 libsqlite3-sys-0.35.0 linux-raw-sys-0.11.0 lock_api-0.4.14 log-0.4.28 lsp-types-0.97.0 maplit-1.0.2 memchr-2.7.6 num-traits-0.2.19 once_cell-1.21.3 once_cell_polyfill-1.70.2 oorandom-11.1.5 ordered-float-3.9.2 pad-0.1.6 parking_lot-0.11.2 parking_lot_core-0.8.6 pkg-config-0.3.32 plotters-0.3.7 plotters-backend-0.3.7 plotters-svg-0.3.7 portable-atomic-1.11.1 portable-atomic-util-0.2.4 pretty-0.11.3 pretty_assertions-1.4.1 proc-macro2-1.0.103 pulldown-cmark-0.13.0 quote-1.0.42 r-efi-5.3.0 rand-0.8.6 rand_core-0.6.4 rayon-1.11.0 rayon-core-1.13.0 redox_syscall-0.2.16 regex-1.12.2 regex-automata-0.4.13 regex-syntax-0.8.8 rle-decode-fast-1.0.3 rusqlite-0.37.0 rustc-hash-1.1.0 rustc_version-0.4.1 rustix-1.1.2 rustversion-1.0.22 ryu-1.0.20 salsa-0.17.0-pre.2 salsa-macros-0.17.0-pre.2 same-file-1.0.6 scopeguard-1.2.0 semver-1.0.27 serde-1.0.228 serde_cbor-0.11.2 serde_core-1.0.228 serde_derive-1.0.228 serde_json-1.0.145 serde_repr-0.1.20 shlex-1.3.0 smallvec-1.15.1 strsim-0.11.1 syn-1.0.109 syn-2.0.111 tempfile-3.23.0 termcolor-1.4.1 textwrap-0.11.0 thiserror-1.0.69 thiserror-impl-1.0.69 tinytemplate-1.2.1 typed-arena-2.0.2 unicase-2.8.1 unicode-ident-1.0.22 unicode-segmentation-1.12.0 unicode-width-0.1.14 unicode-xid-0.2.6 utf8parse-0.2.2 vcpkg-0.2.15 walkdir-2.5.0 wasi-0.11.1+wasi-snapshot-preview1 wasip2-1.0.1+wasi-0.2.4 wasm-bindgen-0.2.105 wasm-bindgen-macro-0.2.105 wasm-bindgen-macro-support-0.2.105 wasm-bindgen-shared-0.2.105 web-sys-0.3.82 winapi-0.3.9 winapi-i686-pc-windows-gnu-0.4.0 winapi-util-0.1.11 winapi-x86_64-pc-windows-gnu-0.4.0 windows-core-0.62.2 windows-implement-0.60.2 windows-interface-0.59.3 windows-link-0.2.1 windows-result-0.4.1 windows-strings-0.5.1 windows-sys-0.59.0 windows-sys-0.61.2 windows-targets-0.52.6 windows_aarch64_gnullvm-0.52.6 windows_aarch64_msvc-0.52.6 windows_i686_gnu-0.52.6 windows_i686_gnullvm-0.52.6 windows_i686_msvc-0.52.6 windows_x86_64_gnu-0.52.6 windows_x86_64_gnullvm-0.52.6 windows_x86_64_msvc-0.52.6 wit-bindgen-0.46.0 yansi-1.0.1 " inherit cargo go-module systemd DESCRIPTION="Scalable datastore for metrics, events, and real-time analytics" HOMEPAGE="https://www.influxdata.com" FLUX_PV="0.201.0" UI_PV="2.10.0" SRC_URI="https://github.com/influxdata/influxdb/archive/v${PV}.tar.gz -> ${P}.tar.gz" SRC_URI+=" https://github.com/influxdata/ui/releases/download/OSS-v${UI_PV}/build.tar.gz -> ${P}-assets.tar.gz" SRC_URI+=" https://vendors.simple-co.de/${PN}/${P}-deps.tar.xz" SRC_URI+=" ${CARGO_CRATE_URIS}" LICENSE="Apache-2.0 BSD BSD-2 EPL-2.0 ISC MIT MPL-2.0" SLOT="0" KEYWORDS="~amd64 ~arm64" IUSE="test" RESTRICT="!test? ( test )" BDEPEND=" >=dev-lang/go-1.26.11 virtual/pkgconfig sys-devel/binutils " DEPEND=" acct-group/influxdb acct-user/influxdb " RDEPEND="${DEPEND}" src_unpack() { cargo_src_unpack } src_prepare() { default local data_dir data_dir="${S}/static/data" mkdir "${data_dir}" || die mv "${WORKDIR}/build" "${data_dir}" || die } src_compile() { # Phase 1: Build pkg-config helper (Go) mv "${WORKDIR}/go-mod" "${WORKDIR}/go-mod-tmp" || die mv "${WORKDIR}/go-mod-tmp/github.com/influxdata/pkg-config@v0.3.1/go-mod" "${WORKDIR}/go-mod" || die cd "${WORKDIR}"/go-mod-tmp/github.com/influxdata/pkg-config* || die ego build . mv "${WORKDIR}/go-mod" "${WORKDIR}/go-mod-tmp/github.com/influxdata/pkg-config@v0.3.1" || die mv "${WORKDIR}/go-mod-tmp" "${WORKDIR}/go-mod" || die # Phase 2: Build libflux (Rust/Cargo) — visible output cd "${WORKDIR}/go-mod/github.com/influxdata/flux@v${FLUX_PV}/libflux" || die cargo_src_compile # Phase 3: Build InfluxDB (Go) # The custom pkg-config may re-invoke cargo for libflux. # Rust's standard library embeds LLVM bitcode (.llvmbc sections) in all # staticlib archives. Go 1.22+ rejects these sections during cgo linking. # Fix: wrap pkg-config to strip .llvmbc from all .a files it produces. local _real_pkgconfig="${WORKDIR}/go-mod/github.com/influxdata/pkg-config@v0.3.1/pkg-config" cat > "${T}/pkg-config-strip-wrapper" <<-WRAPPER #!/bin/bash OUTPUT=\$("${_real_pkgconfig}" "\$@") RC=\$? for word in \${OUTPUT}; do if [[ "\${word}" == -L* ]]; then libdir="\${word#-L}" find "\${libdir}" -name '*.a' -exec objcopy --remove-section=.llvmbc --remove-section=.llvmcmd {} \; 2>/dev/null fi done echo "\${OUTPUT}" exit \${RC} WRAPPER chmod +x "${T}/pkg-config-strip-wrapper" export PKG_CONFIG="${T}/pkg-config-strip-wrapper" cd "${S}" || die ego generate ./static GOBIN="${S}/bin" \ ego install \ -tags 'assets,noasm,sqlite_json,sqlite_foreign_keys' \ -ldflags="-X main.version=${PV}" \ ./... # Restore system pkg-config for src_install (systemd eclass needs it) unset PKG_CONFIG } src_test() { ego test ./tests } src_install() { dobin bin/influx* dodoc *.md local _pkgfs="${S}/.circleci/packages/influxdb2/fs" systemd_dounit "${_pkgfs}/lib/systemd/system/influxdb.service" exeinto /usr/lib/influxdb/scripts doexe "${_pkgfs}/usr/lib/influxdb/scripts/influxd-systemd-start.sh" [[ -f "${_pkgfs}/usr/lib/influxdb/scripts/init.sh" ]] && \ doexe "${_pkgfs}/usr/lib/influxdb/scripts/init.sh" exeinto /usr/share/influxdb doexe "${_pkgfs}/usr/share/influxdb/influxdb2-upgrade.sh" newconfd "${FILESDIR}"/influxdb.confd-r1 influxdb newinitd "${FILESDIR}"/influxdb.initd-r1 influxdb keepdir /var/log/influxdb fowners influxdb:influxdb /var/log/influxdb newenvd - "99${PN}" <<-_EOF_ INFLUXD_CONFIG_PATH="/etc/influxdb" _EOF_ } pkg_postinst() { elog "Upgrading from InfluxDB 2.7.x to 2.10.x:" elog " Data format is compatible, no migration needed." elog " Review changelog for API changes." elog "" elog "Upgrading from InfluxDB 1.x requires migration of time series data." elog "See https://docs.influxdata.com/influxdb/v2/upgrade/v1-to-v2/" ewarn "The InfluxDB command line client has been moved to dev-db/influx-cli" ewarn "You will need to install it separately" }