Bundle libyaml (#14704)
* bundle libyaml * remove comment * .github/workflows/coverity.yml * add to coverity and tests * add deps * add to netdata.spec.in * add to contrib/debia/control * remove extra gentoo libyaml
Emmanuel Vasilakis committed
Mar 20, 2023 at 10:46 UTC
6ee42875c3303ee2056c753a06c622aeb2b2dc84
23 files changed
+152
-3
.github/workflows/coverity.yml
+1
-1
@@ -30,7 +30,7 @@ jobs:
30
run: |
31
./packaging/installer/install-required-packages.sh \
32
--dont-wait --non-interactive netdata
33
- sudo apt-get install -y libjson-c-dev libipmimonitoring-dev \
33
+ sudo apt-get install -y libjson-c-dev libyaml-dev libipmimonitoring-dev \
34
libcups2-dev libsnappy-dev libprotobuf-dev \
35
libprotoc-dev libssl-dev protobuf-compiler \
36
libnetfilter-acct-dev
.github/workflows/tests.yml
+1
-1
@@ -31,7 +31,7 @@ jobs:
31
- name: Prepare environment
32
run: |
33
./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
34
- sudo apt-get install -y libjson-c-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \
34
+ sudo apt-get install -y libjson-c-dev libyaml-dev libipmimonitoring-dev libcups2-dev libsnappy-dev \
35
libprotobuf-dev libprotoc-dev libssl-dev protobuf-compiler \
36
libnetfilter-acct-dev
37
- name: Run ./tests/run-unit-tests.sh
Makefile.am
+7
@@ -73,6 +73,8 @@ dist_noinst_DATA = \
73
packaging/installer/UPDATE.md \
74
packaging/jsonc.checksums \
75
packaging/jsonc.version \
76
+ packaging/yaml.checksums \
77
+ packaging/yaml.version \
78
packaging/libbpf.checksums \
79
packaging/libbpf.version \
80
packaging/protobuf.checksums \
@@ -981,6 +983,7 @@ NETDATA_COMMON_LIBS = \
983
libjudy.a \
984
$(OPTIONAL_SSL_LIBS) \
985
$(OPTIONAL_JSONC_LIBS) \
986
+ $(OPTIONAL_YAML_LIBS) \
987
$(OPTIONAL_ATOMIC_LIBS) \
988
$(OPTIONAL_DL_LIBS) \
989
$(NULL)
@@ -993,6 +996,10 @@ if LINK_STATIC_JSONC
996
NETDATA_COMMON_LIBS += $(abs_top_srcdir)/externaldeps/jsonc/libjson-c.a
997
endif
998
999
+if LINK_STATIC_YAML
1000
+ NETDATA_COMMON_LIBS += $(abs_top_srcdir)/externaldeps/libyaml/libyaml.a
1001
+endif
1002
+
1003
NETDATACLI_FILES = \
1004
daemon/commands.h \
1005
$(LIBNETDATA_FILES) \
configure.ac
+45
-1
@@ -481,6 +481,17 @@ PKG_CHECK_MODULES([JSON],[json-c],AC_CHECK_LIB(
481
482
OPTIONAL_JSONC_LIBS="${JSONC_LIBS}"
483
484
+# -----------------------------------------------------------------------------
485
+# YAML library
486
+
487
+AC_CHECK_LIB(
488
+ [yaml],
489
+ [yaml_parser_initialize],
490
+ [YAML_LIBS="-lyaml"]
491
+)
492
+
493
+OPTIONAL_YAML_LIBS="${YAML_LIBS}"
494
+
495
# -----------------------------------------------------------------------------
496
# DB engine and HTTPS
497
test "${enable_dbengine}" = "yes" -a -z "${LZ4_LIBS}" && \
@@ -610,6 +621,38 @@ fi
621
AC_MSG_RESULT([${enable_jsonc}])
622
AM_CONDITIONAL([ENABLE_JSONC], [test "${enable_jsonc}" = "yes"])
623
624
+# -----------------------------------------------------------------------------
625
+# YAML
626
+
627
+if test -z "${YAML_LIBS}"; then
628
+ # Try and detect manual static build presence (from netdata-installer.sh)
629
+ AC_MSG_CHECKING([if statically built libyaml is present])
630
+ HAVE_libyaml_a="no"
631
+ if test -f "externaldeps/libyaml/libyaml.a"; then
632
+ LIBS_BKP="${LIBS}"
633
+ LIBS="externaldeps/libyaml/libyaml.a"
634
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[#include "externaldeps/libyaml/yaml.h"
635
+ int main (int argc, char **argv) {
636
+ yaml_parser_t parser;
637
+ yaml_parser_initialize(&parser);
638
+ }]])],
639
+ [HAVE_libyaml_a="yes"],
640
+ [HAVE_libyaml_a="no"])
641
+ LIBS="${LIBS_BKP}"
642
+ fi
643
+
644
+ if test "${HAVE_libyaml_a}" = "yes"; then
645
+ AC_DEFINE([LINK_STATIC_YAML], [1], [static yaml should be used])
646
+ YAML_LIBS="static"
647
+ OPTIONAL_YAML_STATIC_CFLAGS="-I \$(abs_top_srcdir)/externaldeps/libyaml"
648
+ fi
649
+ AC_MSG_RESULT([${HAVE_libyaml_a}])
650
+fi
651
+AM_CONDITIONAL([LINK_STATIC_YAML], [test "${YAML_LIBS}" = "static"])
652
+
653
+test -z "${YAML_LIBS}" && \
654
+ AC_MSG_ERROR([LIBYAML required but not found. Try installing 'libyaml-dev'.])
655
+
656
# -----------------------------------------------------------------------------
657
# compiler options
658
@@ -1602,7 +1645,7 @@ CFLAGS="${originalCFLAGS} ${OPTIONAL_LTO_CFLAGS} ${OPTIONAL_PROTOBUF_CFLAGS} ${O
1645
${OPTIONAL_ZLIB_CFLAGS} ${OPTIONAL_UUID_CFLAGS} \
1646
${OPTIONAL_LIBCAP_CFLAGS} ${OPTIONAL_IPMIMONITORING_CFLAGS} ${OPTIONAL_CUPS_CFLAGS} ${OPTIONAL_XENSTAT_FLAGS} \
1647
${OPTIONAL_KINESIS_CFLAGS} ${OPTIONAL_PUBSUB_CFLAGS} ${OPTIONAL_PROMETHEUS_REMOTE_WRITE_CFLAGS} \
1605
- ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${JUDY_CFLAGS} \
1648
+ ${OPTIONAL_MONGOC_CFLAGS} ${LWS_CFLAGS} ${OPTIONAL_JSONC_STATIC_CFLAGS} ${OPTIONAL_YAML_STATIC_CFLAGS} ${OPTIONAL_BPF_CFLAGS} ${JUDY_CFLAGS} \
1649
${OPTIONAL_ACLK_CFLAGS} ${OPTIONAL_ML_CFLAGS} ${OPTIONAL_OS_DEP_CFLAGS}"
1650
1651
CXXFLAGS="${CFLAGS} ${CXX11FLAG}"
@@ -1624,6 +1667,7 @@ AC_SUBST([OPTIONAL_UV_LIBS])
1667
AC_SUBST([OPTIONAL_LZ4_LIBS])
1668
AC_SUBST([OPTIONAL_SSL_LIBS])
1669
AC_SUBST([OPTIONAL_JSONC_LIBS])
1670
+AC_SUBST([OPTIONAL_YAML_LIBS])
1671
AC_SUBST([OPTIONAL_NFACCT_CFLAGS])
1672
AC_SUBST([OPTIONAL_NFACCT_LIBS])
1673
AC_SUBST([OPTIONAL_ZLIB_CFLAGS])
contrib/debian/control
+1
@@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 9.20160709),
10
libssl-dev,
11
libmnl-dev,
12
libjson-c-dev,
13
+ libyaml-dev,
14
libcups2-dev,
15
libipmimonitoring-dev,
16
libnetfilter-acct-dev,
libnetdata/libnetdata.h
+1
@@ -551,6 +551,7 @@ extern char *netdata_configured_host_prefix;
551
#include "onewayalloc/onewayalloc.h"
552
#include "worker_utilization/worker_utilization.h"
553
#include "parser/parser.h"
554
+#include "yaml.h"
555
556
// BEWARE: Outside of the C code this also exists in alarm-notify.sh
557
#define DEFAULT_CLOUD_BASE_URL "https://api.netdata.cloud"
netdata-installer.sh
+64
@@ -709,6 +709,70 @@ bundle_jsonc() {
709
710
bundle_jsonc
711
712
+# -----------------------------------------------------------------------------
713
+build_yaml() {
714
+ env_cmd=''
715
+
716
+ if [ -z "${DONT_SCRUB_CFLAGS_EVEN_THOUGH_IT_MAY_BREAK_THINGS}" ]; then
717
+ env_cmd="env CFLAGS='-fPIC -pipe -Wno-unused-value' CXXFLAGS='-fPIC -pipe' LDFLAGS="
718
+ fi
719
+
720
+ cd "${1}" > /dev/null || return 1
721
+ run eval "${env_cmd} ./configure --disable-shared --disable-dependency-tracking --with-pic"
722
+ run eval "${env_cmd} ${make} ${MAKEOPTS}"
723
+ cd - > /dev/null || return 1
724
+}
725
+
726
+copy_yaml() {
727
+ target_dir="${PWD}/externaldeps/libyaml"
728
+
729
+ run mkdir -p "${target_dir}" || return 1
730
+
731
+ run cp "${1}/src/.libs/libyaml.a" "${target_dir}/libyaml.a" || return 1
732
+ run cp "${1}/include/yaml.h" "${target_dir}/" || return 1
733
+}
734
+
735
+bundle_yaml() {
736
+ if pkg-config yaml-0.1; then
737
+ return 0
738
+ fi
739
+
740
+ if [ -z "$(command -v cmake)" ]; then
741
+ run_failed "Could not find cmake, which is required to build YAML. Critical error."
742
+ return 0
743
+ fi
744
+
745
+ [ -n "${GITHUB_ACTIONS}" ] && echo "::group::Bundling YAML."
746
+
747
+ progress "Prepare YAML"
748
+
749
+ YAML_PACKAGE_VERSION="$(cat packaging/yaml.version)"
750
+
751
+ tmp="$(mktemp -d -t netdata-yaml-XXXXXX)"
752
+ YAML_PACKAGE_BASENAME="yaml-${YAML_PACKAGE_VERSION}.tar.gz"
753
+
754
+ if fetch_and_verify "yaml" \
755
+ "https://github.com/yaml/libyaml/releases/download/${YAML_PACKAGE_VERSION}/${YAML_PACKAGE_BASENAME}" \
756
+ "${YAML_PACKAGE_BASENAME}" \
757
+ "${tmp}" \
758
+ "${NETDATA_LOCAL_TARBALL_OVERRIDE_YAML}"; then
759
+ if run tar --no-same-owner -xf "${tmp}/${YAML_PACKAGE_BASENAME}" -C "${tmp}" &&
760
+ build_yaml "${tmp}/yaml-${YAML_PACKAGE_VERSION}" &&
761
+ copy_yaml "${tmp}/yaml-${YAML_PACKAGE_VERSION}" &&
762
+ rm -rf "${tmp}"; then
763
+ run_ok "YAML built and prepared."
764
+ else
765
+ run_failed "Failed to build YAML, critical error."
766
+ fi
767
+ else
768
+ run_failed "Unable to fetch sources for YAML, critical error."
769
+ fi
770
+
771
+ [ -n "${GITHUB_ACTIONS}" ] && echo "::endgroup::"
772
+}
773
+
774
+bundle_yaml
775
+
776
# -----------------------------------------------------------------------------
777
778
get_kernel_version() {
netdata.spec.in
+3
@@ -145,12 +145,14 @@ BuildRequires: protobuf-devel
145
BuildRequires: libprotobuf-c-devel
146
BuildRequires: liblz4-devel
147
BuildRequires: libjson-c-devel
148
+BuildRequires: libyaml-devel
149
%else
150
%if 0%{?fedora}
151
BuildRequires: protobuf-devel
152
BuildRequires: protobuf-c-devel
153
BuildRequires: lz4-devel
154
BuildRequires: json-c-devel
155
+BuildRequires: libyaml-devel
156
%else
157
%if 0%{?centos_ver} >= 8
158
BuildRequires: protobuf-devel
@@ -158,6 +160,7 @@ BuildRequires: protobuf-c-devel
160
%endif
161
BuildRequires: lz4-devel
162
BuildRequires: json-c-devel
163
+BuildRequires: libyaml-devel
164
%endif
165
%endif
166
packaging/installer/dependencies/alpine.sh
+1
@@ -31,6 +31,7 @@ package_tree="
31
util-linux-dev
32
libmnl-dev
33
json-c-dev
34
+ yaml-dev
35
"
36
37
usage() {
packaging/installer/dependencies/arch.sh
+1
@@ -20,6 +20,7 @@ declare -a package_tree=(
20
util-linux
21
libmnl
22
json-c
23
+ libyaml
24
libuv
25
lz4
26
openssl
packaging/installer/dependencies/centos.sh
+1
@@ -19,6 +19,7 @@ declare -a package_tree=(
19
libuuid-devel
20
libmnl-devel
21
json-c-devel
22
+ libyaml-devel
23
libuv-devel
24
lz4-devel
25
openssl-devel
packaging/installer/dependencies/clearlinux.sh
+1
@@ -15,6 +15,7 @@ declare -a package_tree=(
15
devpkg-util-linux
16
devpkg-libmnl
17
devpkg-json-c
18
+ yaml-dev
19
devpkg-libuv
20
devpkg-lz4
21
devpkg-openssl
packaging/installer/dependencies/debian.sh
+1
@@ -31,6 +31,7 @@ package_tree="
31
liblz4-dev
32
libssl-dev
33
libelf-dev
34
+ libyaml-dev
35
python
36
python3
37
"
packaging/installer/dependencies/fedora.sh
+1
@@ -39,6 +39,7 @@ declare -a package_tree=(
39
libuuid-devel
40
libmnl-devel
41
json-c-devel
42
+ libyaml-devel
43
libuv-devel
44
lz4-devel
45
openssl-devel
packaging/installer/dependencies/freebsd.sh
+1
@@ -21,6 +21,7 @@ package_tree="
21
lzlib
22
e2fsprogs-libuuid
23
json-c
24
+ libyaml
25
libuv
26
liblz4
27
openssl
packaging/installer/dependencies/gentoo.sh
+1
@@ -24,6 +24,7 @@ package_tree="
24
sys-apps/util-linux
25
net-libs/libmnl
26
dev-libs/json-c
27
+ dev-libs/libyaml
28
dev-libs/libuv
29
app-arch/lz4
30
dev-libs/openssl
packaging/installer/dependencies/ol.sh
+1
@@ -24,6 +24,7 @@ declare -a package_tree=(
24
libuuid-devel
25
libmnl-devel
26
json-c-devel
27
+ libyaml-devel
28
libuv-devel
29
lz4-devel
30
openssl-devel
packaging/installer/dependencies/opensuse.sh
+1
@@ -25,6 +25,7 @@ declare -a package_tree=(
25
libuuid-devel
26
libmnl-devel
27
libjson-c-devel
28
+ libyaml-devel
29
libuv-devel
30
liblz4-devel
31
libopenssl-devel
packaging/installer/dependencies/rockylinux.sh
+1
@@ -23,6 +23,7 @@ declare -a package_tree=(
23
libuuid-devel
24
libmnl-devel
25
json-c-devel
26
+ libyaml-devel
27
libuv-devel
28
lz4-devel
29
openssl-devel
packaging/installer/dependencies/ubuntu.sh
+1
@@ -27,6 +27,7 @@ package_tree="
27
uuid-dev
28
libmnl-dev
29
libjson-c-dev
30
+ libyaml-dev
31
libuv1-dev
32
liblz4-dev
33
libssl-dev
packaging/installer/install-required-packages.sh
+15
@@ -676,6 +676,20 @@ declare -A pkg_json_c_dev=(
676
['default']="json-c-devel"
677
)
678
679
+#TODO:: clearlinux ?
680
+declare -A pkg_libyaml_dev=(
681
+ ['alpine']="yaml-dev"
682
+ ['arch']="libyaml"
683
+ ['clearlinux']="yaml-dev"
684
+ ['debian']="libyaml-dev"
685
+ ['gentoo']="dev-libs/libyaml"
686
+ ['sabayon']="dev-libs/libyaml"
687
+ ['suse']="libyaml-devel"
688
+ ['freebsd']="libyaml"
689
+ ['macos']="libyaml"
690
+ ['default']="libyaml-devel"
691
+)
692
+
693
declare -A pkg_libatomic=(
694
['arch']="NOTREQUIRED"
695
['clearlinux']="NOTREQUIRED"
@@ -1227,6 +1241,7 @@ packages() {
1241
suitable_package libuuid-dev
1242
suitable_package libmnl-dev
1243
suitable_package json-c-dev
1244
+ suitable_package libyaml-dev
1245
fi
1246
1247
# -------------------------------------------------------------------------
packaging/yaml.checksums
new
+1
@@ -0,0 +1 @@
1
+c642ae9b75fee120b2d96c712538bd2cf283228d2337df2cf2988e3c02678ef4 yaml-0.2.5.tar.gz
packaging/yaml.version
new
+1
@@ -0,0 +1 @@
1
+0.2.5