diff options
23 files changed, 152 insertions, 3 deletions
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 9d1119a82a..8a1ee2486e 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -30,7 +30,7 @@ jobs: run: | ./packaging/installer/install-required-packages.sh \ --dont-wait --non-interactive netdata - sudo apt-get install -y libjson-c-dev libipmimonitoring-dev \ + sudo apt-get install -y libjson-c-dev libyaml-dev libipmimonitoring-dev \ libcups2-dev libsnappy-dev libprotobuf-dev \ libprotoc-dev libssl-dev protobuf-compiler \ libnetfilter-acct-dev diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d483868555..5f83a44059 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: - name: Prepare environment run: | ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all - sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \ + sudo apt-get install -y libjson-c-dev libyaml-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \ libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler \ libnetfilter-acct-dev - name: Run ./tests/run-unit-tests.sh diff --git a/Makefile.am b/Makefile.am index a922d4def5..05efd16983 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,6 +73,8 @@ dist_noinst_DATA = \ packaging/installer/UPDATE.md \ packaging/jsonc.checksums \ packaging/jsonc.version \ + packaging/yaml.checksums \ + packaging/yaml.version \ packaging/libbpf.checksums \ packaging/libbpf.version \ packaging/protobuf.checksums \ @@ -981,6 +983,7 @@ NETDATA_COMMON_LIBS = \ libjudy.a \ $(OPTIONAL_SSL_LIBS) \ $(OPTIONAL_JSONC_LIBS) \ + $(OPTIONAL_YAML_LIBS) \ $(OPTIONAL_ATOMIC_LIBS) \ $(OPTIONAL_DL_LIBS) \ $(NULL) @@ -993,6 +996,10 @@ if LINK_STATIC_JSONC NETDATA_COMMON_LIBS += $(abs_top_srcdir)/externaldeps/jsonc/libjson-c.a endif +if LINK_STATIC_YAML + NETDATA_COMMON_LIBS += $(abs_top_srcdir)/externaldeps/libyaml/libyaml.a +endif + NETDATACLI_FILES = \ daemon/commands.h \ $(LIBNETDATA_FILES) \ diff --git a/configure.ac b/configure.ac index 9b9143f7fb..af86783012 100644 --- a/configure.ac +++ b/configure.ac @@ -482,6 +482,17 @@ PKG_CHECK_MODULES([JSON],[json-c],AC_CHECK_LIB( OPTIONAL_JSONC_LIBS="${JSONC_LIBS}" # ----------------------------------------------------------------------------- +# YAML library + +AC_CHECK_LIB( + [yaml], + [yaml_parser_initialize], + [YAML_LIBS="-lyaml"] +) + +OPTIONAL_YAML_LIBS="${YAML_LIBS}" + +# ----------------------------------------------------------------------------- # DB engine and HTTPS test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \ AC_MSG_ERROR([liblz4 required but not found. Try installing 'liblz4-dev' or 'lz4-devel'.]) @@ -611,6 +622,38 @@ AC_MSG_RESULT([${enable_jsonc}]) AM_CONDITIONAL([ENABLE_JSONC], [test "${enable_jsonc}" = "yes"]) # ----------------------------------------------------------------------------- +# YAML + +if test -z "${YAML_LIBS}"; then + # Try and detect manual static build presence (from netdata-installer.sh) + AC_MSG_CHECKING([if statically built libyaml is present]) + HAVE_libyaml_a="no" + if test -f "externaldeps/libyaml/libyaml.a"; then + LIBS_BKP="${LIBS}" + LIBS="externaldeps/libyaml/libyaml.a" + AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/libyaml/yaml.h" + int main (int argc, char **argv) { + yaml_parser_t parser; + yaml_parser_initialize(&parser); + }]])], + [HAVE_libyaml_a="yes"], + [HAVE_libyaml_a="no"]) + LIBS="${LIBS_BKP}" + fi + + if test "${HAVE_libyaml_a}" = "yes"; then + AC_DEFINE([LINK_STATIC_YAML], [1], [static yaml should be used]) + YAML_LIBS="static" + OPTIONAL_YAML_STATIC_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/libyaml" + fi + AC_MSG_RESULT([${HAVE_libyaml_a}]) +fi +AM_CONDITIONAL([LINK_STATIC_YAML], [test "${YAML_LIBS}" = "static"]) + +test -z "${YAML_LIBS}" && \ + AC_MSG_ERROR([LIBYAML required but not found. Try installing 'libyaml-dev'.]) + +# ----------------------------------------------------------------------------- # compiler options AC_ARG_VAR([SSE_CANDIDATE], [C compiler flags for SSE]) @@ -1602,7 +1645,7 @@ CFLAGS="${originalCFLAGS} ${OPTIONAL_LTO_CFLAGS} ${OPTIONAL_PROTOBUF_CFLAGS} ${O ${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \ ${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \ ${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PUBSUB_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} \ - ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${JUDY_CFLAGS} \ + ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_YAML_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${JUDY_CFLAGS} \ ${OPTIONAL_ACLK_CFLAGS} ${OPTIONAL_ML_CFLAGS} ${OPTIONAL_OS_DEP_CFLAGS}" CXXFLAGS="${CFLAGS} ${CXX11FLAG}" @@ -1624,6 +1667,7 @@ AC_SUBST([OPTIONAL_UV_LIBS]) AC_SUBST([OPTIONAL_LZ4_LIBS]) AC_SUBST([OPTIONAL_SSL_LIBS]) AC_SUBST([OPTIONAL_JSONC_LIBS]) +AC_SUBST([OPTIONAL_YAML_LIBS]) AC_SUBST([OPTIONAL_NFACCT_CFLAGS]) AC_SUBST([OPTIONAL_NFACCT_LIBS]) AC_SUBST([OPTIONAL_ZLIB_CFLAGS]) diff --git a/contrib/debian/control b/contrib/debian/control index c5e5791ffa..eeeb8d25c6 100644 --- a/contrib/debian/control +++ b/contrib/debian/control @@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 9.20160709), libssl-dev, libmnl-dev, libjson-c-dev, + libyaml-dev, libcups2-dev, libipmimonitoring-dev, libnetfilter-acct-dev, diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h index 94d6e31eb1..da2d6c43ef 100644 --- a/libnetdata/libnetdata.h +++ b/libnetdata/libnetdata.h @@ -551,6 +551,7 @@ extern char *netdata_configured_host_prefix; #include "onewayalloc/onewayalloc.h" #include "worker_utilization/worker_utilization.h" #include "parser/parser.h" +#include "yaml.h" // BEWARE: Outside of the C code this also exists in alarm-notify.sh #define DEFAULT_CLOUD_BASE_URL "https://api.netdata.cloud" diff --git a/netdata-installer.sh b/netdata-installer.sh index 4ffe2925eb..6da397e987 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -710,6 +710,70 @@ bundle_jsonc() { bundle_jsonc # ----------------------------------------------------------------------------- +build_yaml() { + env_cmd='' + + if [ -z "${DONT_SCRUB_CFLAGS_EVEN_THOUGH_IT_MAY_BREAK_THINGS}" ]; then + env_cmd="env CFLAGS='-fPIC -pipe -Wno-unused-value' CXXFLAGS='-fPIC -pipe' LDFLAGS=" + fi + + cd "${1}" > /dev/null || return 1 + run eval "${env_cmd} ./configure --disable-shared --disable-dependency-tracking --with-pic" + run eval "${env_cmd} ${make} ${MAKEOPTS}" + cd - > /dev/null || return 1 +} + +copy_yaml() { + target_dir="${PWD}/externaldeps/libyaml" + + run mkdir -p "${target_dir}" || return 1 + + run cp "${1}/src/.libs/libyaml.a" "${target_dir}/libyaml.a" || return 1 + run cp "${1}/include/yaml.h" "${target_dir}/" || return 1 +} + +bundle_yaml() { + if pkg-config yaml-0.1; then + return 0 + fi + + if [ -z "$(command -v cmake)" ]; then + run_failed "Could not find cmake, which is required to build YAML. Critical error." + return 0 + fi + + [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling YAML." + + progress "Prepare YAML" + + YAML_PACKAGE_VERSION="$(cat packaging/yaml.version)" + + tmp="$(mktemp -d -t netdata-yaml-XXXXXX)" + YAML_PACKAGE_BASENAME="yaml-${YAML_PACKAGE_VERSION}.tar.gz" + + if fetch_and_verify "yaml" \ + "https://github.com/yaml/libyaml/releases/download/${YAML_PACKAGE_VERSION}/${YAML_PACKAGE_BASENAME}" \ + "${YAML_PACKAGE_BASENAME}" \ + "${tmp}" \ + "${NETDATA_LOCAL_TARBALL_OVERRIDE_YAML}"; then + if run tar --no-same-owner -xf "${tmp}/${YAML_PACKAGE_BASENAME}" -C "${tmp}" && + build_yaml "${tmp}/yaml-${YAML_PACKAGE_VERSION}" && + copy_yaml "${tmp}/yaml-${YAML_PACKAGE_VERSION}" && + rm -rf "${tmp}"; then + run_ok "YAML built and prepared." + else + run_failed "Failed to build YAML, critical error." + fi + else + run_failed "Unable to fetch sources for YAML, critical error." + fi + + [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::" +} + +bundle_yaml + +# ----------------------------------------------------------------------------- get_kernel_version() { r="$(uname -r | cut -f 1 -d '-')" diff --git a/netdata.spec.in b/netdata.spec.in index dd011c6b19..9bd8e6e438 100644 --- a/netdata.spec.in +++ b/netdata.spec.in @@ -145,12 +145,14 @@ BuildRequires: protobuf-devel BuildRequires: libprotobuf-c-devel BuildRequires: liblz4-devel BuildRequires: libjson-c-devel +BuildRequires: libyaml-devel %else %if 0%{?fedora} BuildRequires: protobuf-devel BuildRequires: protobuf-c-devel BuildRequires: lz4-devel BuildRequires: json-c-devel +BuildRequires: libyaml-devel %else %if 0%{?centos_ver} >= 8 BuildRequires: protobuf-devel @@ -158,6 +160,7 @@ BuildRequires: protobuf-c-devel %endif BuildRequires: lz4-devel BuildRequires: json-c-devel +BuildRequires: libyaml-devel %endif %endif diff --git a/packaging/installer/dependencies/alpine.sh b/packaging/installer/dependencies/alpine.sh index 65999dc3b0..321d57707a 100755 --- a/packaging/installer/dependencies/alpine.sh +++ b/packaging/installer/dependencies/alpine.sh @@ -31,6 +31,7 @@ package_tree=" util-linux-dev libmnl-dev json-c-dev + yaml-dev " usage() { diff --git a/packaging/installer/dependencies/arch.sh b/packaging/installer/dependencies/arch.sh index cdda527335..c0890d925b 100755 --- a/packaging/installer/dependencies/arch.sh +++ b/packaging/installer/dependencies/arch.sh @@ -20,6 +20,7 @@ declare -a package_tree=( util-linux libmnl json-c + libyaml libuv lz4 openssl diff --git a/packaging/installer/dependencies/centos.sh b/packaging/installer/dependencies/centos.sh index 1e44a9ffa4..845f1113ae 100755 --- a/packaging/installer/dependencies/centos.sh +++ b/packaging/installer/dependencies/centos.sh @@ -19,6 +19,7 @@ declare -a package_tree=( libuuid-devel libmnl-devel json-c-devel + libyaml-devel libuv-devel lz4-devel openssl-devel diff --git a/packaging/installer/dependencies/clearlinux.sh b/packaging/installer/dependencies/clearlinux.sh index 832dac55a4..f6f616d667 100755 --- a/packaging/installer/dependencies/clearlinux.sh +++ b/packaging/installer/dependencies/clearlinux.sh @@ -15,6 +15,7 @@ declare -a package_tree=( devpkg-util-linux devpkg-libmnl devpkg-json-c + yaml-dev devpkg-libuv devpkg-lz4 devpkg-openssl diff --git a/packaging/installer/dependencies/debian.sh b/packaging/installer/dependencies/debian.sh index a2c421a928..8186940e55 100755 --- a/packaging/installer/dependencies/debian.sh +++ b/packaging/installer/dependencies/debian.sh @@ -31,6 +31,7 @@ package_tree=" liblz4-dev libssl-dev libelf-dev + libyaml-dev python python3 " diff --git a/packaging/installer/dependencies/fedora.sh b/packaging/installer/dependencies/fedora.sh index a1c3a1df68..5891228827 100755 --- a/packaging/installer/dependencies/fedora.sh +++ b/packaging/installer/dependencies/fedora.sh @@ -39,6 +39,7 @@ declare -a package_tree=( libuuid-devel libmnl-devel json-c-devel + libyaml-devel libuv-devel lz4-devel openssl-devel diff --git a/packaging/installer/dependencies/freebsd.sh b/packaging/installer/dependencies/freebsd.sh index 9145135634..69a650a6e4 100755 --- a/packaging/installer/dependencies/freebsd.sh +++ b/packaging/installer/dependencies/freebsd.sh @@ -21,6 +21,7 @@ package_tree=" lzlib e2fsprogs-libuuid json-c + libyaml libuv liblz4 openssl diff --git a/packaging/installer/dependencies/gentoo.sh b/packaging/installer/dependencies/gentoo.sh index e7ed644558..cbe8c8e515 100755 --- a/packaging/installer/dependencies/gentoo.sh +++ b/packaging/installer/dependencies/gentoo.sh @@ -24,6 +24,7 @@ package_tree=" sys-apps/util-linux net-libs/libmnl dev-libs/json-c + dev-libs/libyaml dev-libs/libuv app-arch/lz4 dev-libs/openssl diff --git a/packaging/installer/dependencies/ol.sh b/packaging/installer/dependencies/ol.sh index 0f1f90e678..2166bcc506 100755 --- a/packaging/installer/dependencies/ol.sh +++ b/packaging/installer/dependencies/ol.sh @@ -24,6 +24,7 @@ declare -a package_tree=( libuuid-devel libmnl-devel json-c-devel + libyaml-devel libuv-devel lz4-devel openssl-devel diff --git a/packaging/installer/dependencies/opensuse.sh b/packaging/installer/dependencies/opensuse.sh index b1f0c2182e..81291ef725 100755 --- a/packaging/installer/dependencies/opensuse.sh +++ b/packaging/installer/dependencies/opensuse.sh @@ -25,6 +25,7 @@ declare -a package_tree=( libuuid-devel libmnl-devel libjson-c-devel + libyaml-devel libuv-devel liblz4-devel libopenssl-devel diff --git a/packaging/installer/dependencies/rockylinux.sh b/packaging/installer/dependencies/rockylinux.sh index 63981df4b8..7ac98f5e2e 100755 --- a/packaging/installer/dependencies/rockylinux.sh +++ b/packaging/installer/dependencies/rockylinux.sh @@ -23,6 +23,7 @@ declare -a package_tree=( libuuid-devel libmnl-devel json-c-devel + libyaml-devel libuv-devel lz4-devel openssl-devel diff --git a/packaging/installer/dependencies/ubuntu.sh b/packaging/installer/dependencies/ubuntu.sh index 295dbf0136..e3d734c68a 100755 --- a/packaging/installer/dependencies/ubuntu.sh +++ b/packaging/installer/dependencies/ubuntu.sh @@ -27,6 +27,7 @@ package_tree=" uuid-dev libmnl-dev libjson-c-dev + libyaml-dev libuv1-dev liblz4-dev libssl-dev diff --git a/packaging/installer/install-required-packages.sh b/packaging/installer/install-required-packages.sh index a4b93028b8..9b1f6518a5 100755 --- a/packaging/installer/install-required-packages.sh +++ b/packaging/installer/install-required-packages.sh @@ -676,6 +676,20 @@ declare -A pkg_json_c_dev=( ['default']="json-c-devel" ) +#TODO:: clearlinux ? +declare -A pkg_libyaml_dev=( + ['alpine']="yaml-dev" + ['arch']="libyaml" + ['clearlinux']="yaml-dev" + ['debian']="libyaml-dev" + ['gentoo']="dev-libs/libyaml" + ['sabayon']="dev-libs/libyaml" + ['suse']="libyaml-devel" + ['freebsd']="libyaml" + ['macos']="libyaml" + ['default']="libyaml-devel" +) + declare -A pkg_libatomic=( ['arch']="NOTREQUIRED" ['clearlinux']="NOTREQUIRED" @@ -1227,6 +1241,7 @@ packages() { suitable_package libuuid-dev suitable_package libmnl-dev suitable_package json-c-dev + suitable_package libyaml-dev fi # ------------------------------------------------------------------------- diff --git a/packaging/yaml.checksums b/packaging/yaml.checksums new file mode 100644 index 0000000000..563c273d45 --- /dev/null +++ b/packaging/yaml.checksums @@ -0,0 +1 @@ +c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4 yaml-0.2.5.tar.gz diff --git a/packaging/yaml.version b/packaging/yaml.version new file mode 100644 index 0000000000..3a4036fb45 --- /dev/null +++ b/packaging/yaml.version @@ -0,0 +1 @@ +0.2.5 |