Skip to content

Commit

Permalink
Fixes #18615: Embed augeas in the agent 7.0 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
peckpeck committed Nov 19, 2020
1 parent 66c962c commit 64fd447
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 22 deletions.
35 changes: 32 additions & 3 deletions rudder-agent/SOURCES/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ zlib_RELEASE = 1.2.11
zlib_SHA256 = c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
# Original URL: http://ftp.fr.debian.org/debian/pool/main/l/lmdb/lmdb_$(LMDB_RELEASE).orig.tar.xz
lmdb_RELEASE = 0.9.24
lmdb_SHA256 = 8e7200fdc9bb09b0cfad1d4eee8b20d539e43fe05c7ef9406247d64659c4a480
lmdb_SHA256 = 44602436c52c29d4f301f55f6fd8115f945469b868348e3cddaf91ab2473ea26
# Original URL: http://vorboss.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.tar.gz
pcre_RELEASE = 8.38
pcre_SHA256 = 9883e419c336c63b0cb5202b09537c140966d585e4d0da66147dc513da13e629
Expand All @@ -47,6 +47,12 @@ libxml2_SHA256 = f63c5e7d30362ed28b38bfa1ac6313f9a80230720b7fb6c80575eeab3ff5900
# Original URL: https://curl.haxx.se/download/curl-7.58.0.tar.gz
libcurl_RELEASE = 7.73.0
libcurl_SHA256 = ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91
# Original URL: https://ftp.gnu.org/gnu/readline/readline-8.0.tar.gz
readline_RELEASE = 8.0
readline_SHA256 = e339f51971478d369f8a053a330a190781acb9864cf4c541060f12078948e461
# Original URL: http://download.augeas.net/augeas-1.12.0.tar.gz
augeas_RELEASE = 1.12.0
augeas_SHA256 = 321942c9cc32185e2e9cb72d0a70eea106635b50269075aca6714e3ec282cb87
# Original URL: https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz
jq_RELEASE = 1.6
jq_SHA256 = 1b3906e0c6dea26b5b9dcf864cc7334522f520d69543043c64b2c487e0c663ca
Expand Down Expand Up @@ -113,6 +119,10 @@ install: install-agent

@libcurl_SOURCE@

@readline_SOURCE@

@augeas_SOURCE@

@jq_SOURCE@
# this value is not propery defined on AIX (must be > 500 for c99)
cd jq-source && $(SED) 's/^# define _XOPEN_SOURCE$$/# define _XOPEN_SOURCE 600/' src/builtin.c > src/builtin.c.new && mv src/builtin.c.new src/builtin.c
Expand Down Expand Up @@ -236,6 +246,21 @@ build-libcurl: libcurl-source @openssl_DEP@ @zlib_DEP@
cd libcurl-source && $(MAKE) install DESTDIR=$(CURDIR)/dependencies
touch $@

build-readline: readline-source
# do not override flags as they don't work here
cd readline-source && ./configure --prefix=$(RUDDER_DIR)
cd augeas-source && $(MAKE)
cd augeas-source && $(MAKE) install DESTDIR=$(CURDIR)/dependencies
touch $@

build-augeas: augeas-source @readline_DEP@ @libxml2_DEP@
@xml2conf@ cd augeas-source && ./configure --disable-dependency-tracking --prefix=$(RUDDER_DIR) @AUGEAS_ARGS@ CPPFLAGS="-I$(CURDIR)/dependencies$(RUDDER_DIR)/include/libxml2 -I$(CURDIR)/dependencies$(RUDDER_DIR)/include" $(BUILD_FLAGS_EXE)
cd augeas-source && $(MAKE)
cd augeas-source && $(MAKE) install DESTDIR=$(CURDIR)/dependencies
# remove augeas tests
rm -rf $(CURDIR)/dependencies/$(RUDDER_DIR)/share/augeas/lenses/dist/tests/
touch $@

build-jq: jq-source
cd jq-source && ./configure --prefix=$(RUDDER_DIR) $(BUILD_FLAGS_EXE) --disable-maintainer-mode --disable-docs --with-oniguruma=builtin --disable-error-injection
ifeq (AIX,$(OS_FAMILY))
Expand All @@ -245,9 +270,9 @@ endif
cd jq-source && $(MAKE) install DESTDIR=$(CURDIR)/dependencies
touch $@

DEPS_CACHE_PARAMETERS = --with-env name=dependencies zlib=$(zlib_SHA256) lmdb=$(lmdb_SHA256) pcre=$(pcre_SHA256) openssl=$(openssl_SHA256) libyaml=$(libyaml_SHA256) libxml2=$(libxml2_SHA256) libcurl=$(libcurl_SHA256) jq=$(jq_SHA256)
DEPS_CACHE_PARAMETERS = --with-env name=dependencies zlib=$(zlib_SHA256) lmdb=$(lmdb_SHA256) pcre=$(pcre_SHA256) openssl=$(openssl_SHA256) libyaml=$(libyaml_SHA256) libxml2=$(libxml2_SHA256) libcurl=$(libcurl_SHA256) augeas=$(augeas_SHA256) readline=$(readline_SHA256) jq=$(jq_SHA256)
# Strictly speaking we don't need jq here but it's easier to include it in the cache
CFENGINE_DEPS = $(shell ../../build-caching get dependencies/ $(DEPS_CACHE_PARAMETERS) || echo @lmdb_DEP@ @pcre_DEP@ @openssl_DEP@ @libyaml_DEP@ @libxml2_DEP@ @libcurl_DEP@ @jq_DEP@ )
CFENGINE_DEPS = $(shell ../../build-caching get dependencies/ $(DEPS_CACHE_PARAMETERS) || echo @lmdb_DEP@ @pcre_DEP@ @openssl_DEP@ @libyaml_DEP@ @libxml2_DEP@ @libcurl_DEP@ @augeas_DEP@ @jq_DEP@ )

# Cache cfengine build itself
CFENGINE_PATCHES_SHA = $(shell find patches/cfengine -type f | sort | xargs openssl dgst -sha256 | openssl dgst -sha256 | awk '{print $$2}')
Expand Down Expand Up @@ -390,6 +415,7 @@ install-agent: build cleanup-build rudder-agent rudder-agent.cron debug-script/r
cp -rp dependencies/opt/rudder/bin/cf-* $(DESTDIR)/opt/rudder/bin/
@IF_libcurl@ cp -rp dependencies/opt/rudder/bin/curl $(DESTDIR)/opt/rudder/bin/
@IF_jq@ cp -rp dependencies/opt/rudder/bin/jq $(DESTDIR)/opt/rudder/bin/
@IF_augeas@ cp -rp dependencies/opt/rudder/bin/aug* $(DESTDIR)/opt/rudder/bin/

mkdir -p $(DESTDIR)/opt/rudder/share/man/man8
cd $(DESTDIR)/opt/rudder/bin && for binary in cf-agent cf-promises cf-key cf-execd cf-serverd cf-net cf-runagent; do \
Expand All @@ -407,6 +433,9 @@ install-agent: build cleanup-build rudder-agent rudder-agent.cron debug-script/r
mkdir -p $(DESTDIR)/opt/rudder/share/
@IF_fusion@ cp -rp fusion/opt/rudder/share/fusion* $(DESTDIR)/opt/rudder/share/

# Augeas lens
@IF_augeas@ cp -rp dependencies/opt/rudder/share/augeas $(DESTDIR)/opt/rudder/share/

# Systemd files
@IF_systemd@ mkdir -p $(DESTDIR)/lib/systemd/system
@IF_systemd@ $(INSTALL) -m 644 systemd/rudder-agent.service $(DESTDIR)/lib/systemd/system/rudder-agent.service
Expand Down
15 changes: 14 additions & 1 deletion rudder-agent/SOURCES/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
# Overridable environment: PROXY=

# Dependencies defaults: use everything from system except fusion
DEPENDENCIES="zlib lmdb pcre openssl libyaml libxml2 libcurl jq perl fusion"
DEPENDENCIES="zlib lmdb pcre openssl libyaml libxml2 libcurl readline augeas jq perl fusion"
for dep in ${DEPENDENCIES}; do
eval "BUILD_${dep}=false"
done
Expand Down Expand Up @@ -156,6 +156,17 @@ do
fi
done

# Augeas specific parameter for xml
# augeas configure doesn't take the classic --with-libxml argument
if [ "${BUILD_libxml2}" = "true" ]
then
AUGEAS_ARGS='LIBXML_LIBS="$${XML2_LIBS}" LIBXML_CFLAGS=" "'
xml2conf='. $(CURDIR)/dependencies$(RUDDER_DIR)/lib/xml2Conf.sh &&'
else
AUGEAS_ARGS=""
xml2conf=""
fi

# Add adequate --with statements to compilation options
LIBCURL_ARGS="${WITH_zlib} ${WITH_openssl}"
LIBXML2_ARGS="${WITH_zlib}"
Expand Down Expand Up @@ -294,6 +305,8 @@ s%@_GET@%${_GET}%;t t
s%@SSL_CONFIGURE@%${SSL_CONFIGURE}%;t t
s%@LIBXML2_ARGS@%${LIBXML2_ARGS}%;t t
s%@LIBCURL_ARGS@%${LIBCURL_ARGS}%;t t
s%@AUGEAS_ARGS@%${AUGEAS_ARGS}%;t t
s%@xml2conf@%${xml2conf}%;t t
s%@SOURCE_DEPS@%${SOURCE_DEPS}%;t t"

# newlines must be backslashed in sed
Expand Down
6 changes: 3 additions & 3 deletions rudder-agent/SPECS/dependencies
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sles-10sp3:gcc bison flex autoconf automake libtool pcre-devel zlib-devel pam-devel libxml2-devel curl-devel libacl-devel
sles-11:gcc openssl-devel bison flex autoconf automake libtool pcre-devel zlib-devel libbz2-devel pam-devel libxml2-devel libcurl-devel libacl-devel
sles-12:gcc openssl-devel bison flex autoconf automake libtool pcre-devel zlib-devel libbz2-devel pam-devel libyaml-devel libxml2-devel curl-devel libacl-devel
sles-10sp3:gcc bison flex autoconf automake libtool pcre-devel zlib-devel pam-devel libxml2-devel curl-devel libacl-devel readline-devel
sles-11:gcc openssl-devel bison flex autoconf automake libtool pcre-devel zlib-devel libbz2-devel pam-devel libxml2-devel libcurl-devel libacl-devel readline-devel
sles-12:gcc openssl-devel bison flex autoconf automake libtool pcre-devel zlib-devel libbz2-devel pam-devel libyaml-devel libxml2-devel curl-devel libacl-devel readline-devel
sles-15:gcc openssl-devel bison flex autoconf automake libtool pcre-devel zlib-devel libbz2-devel pam-devel libyaml-devel libxml2-devel curl-devel libacl-devel
rhel-3:gcc bison flex autoconf automake libtool pcre-devel make byacc zlib-devel bzip2-devel kernel-utils pam-devel libxml2-devel curl-devel libacl-devel libattr-devel readline-devel
rhel-5:gcc openssl-devel bison flex autoconf automake libtool pcre-devel make byacc zlib-devel bzip2-devel pam-devel libxml2-devel curl-devel libacl-devel readline-devel
Expand Down
26 changes: 26 additions & 0 deletions rudder-agent/SPECS/rudder-agent.spec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
%define with_libyaml false
%define with_libxml2 false
%define with_libcurl false
%define with_augeas false
%define with_jq false
%define with_perl false
# replicate defauls from configure : all features
Expand Down Expand Up @@ -62,6 +63,7 @@
%define with_libyaml true
%define with_libxml2 true
%define with_libcurl true
%define with_augeas true
%define with_jq true
%define with_perl true
%define enable_https false
Expand All @@ -79,6 +81,8 @@
%if 0%{?rhel} && 0%{?rhel} <= 6
# PIE and PIC incompatible on old gcc
%define enable_pie false
# no augeas or augeas too old
%define with_augeas true
%endif
%if 0%{?rhel} && 0%{?rhel} < 8
# no jq before RHEL8
Expand All @@ -101,6 +105,10 @@
# PIE and PIC incompatible on old gcc
%define enable_pie false
%endif
%if 0%{?suse_version} && 0%{?suse_version} < 1500
# augeas too old on suse < 15
%define with_augeas true
%endif
%if 0%{?suse_version} && !0%{?is_opensuse}
# no jq on sles, only on opensuse
%define with_jq true
Expand Down Expand Up @@ -257,6 +265,14 @@ BuildRequires: curl-devel
Requires: curl
%endif

## Augeas dependencies
%if "%{use_system_augeas}" == "true"
Requires: augeas
%endif
%if "%{use_system_augeas}" == "false" && "%{?aix}" ==""
BuildRequires: readline-devel
%endif

## Openssl dependencies
%if "%{with_openssl}" == "false"
BuildRequires: openssl-devel
Expand Down Expand Up @@ -322,6 +338,16 @@ opt="${opt} --with-libxml2"
%if "%{with_libcurl}" == "true"
opt="${opt} --with-libcurl"
%endif
%if "%{with_augeas}" == "true"
opt="${opt} --with-augeas"
# augeas on aix depends on readline
%if "%{?aix}"
opt="${opt} --with-readline"
%endif
%endif
%if "%{with_libcurl}" == "true"
opt="${opt} --with-libcurl"
%endif
%if "%{with_jq}" == "true"
opt="${opt} --with-jq"
%endif
Expand Down
2 changes: 1 addition & 1 deletion rudder-agent/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: rudder-agent
Section: admin
Priority: extra
Maintainer: Rudder Team <dev@rudder.io>
Build-Depends: debhelper (>= 7), bison, gcc, flex, autoconf, automake, libtool, libpcre3-dev, libpam0g-dev, ca-certificates, perl, lsb-release, libyaml-dev, libxml2-dev, libacl1-dev, python, rsync, libssl-dev, libcurl4-openssl-dev, libmodule-corelist-perl, libmodule-install-perl
Build-Depends: debhelper (>= 7), bison, gcc, flex, autoconf, automake, libtool, libpcre3-dev, libpam0g-dev, ca-certificates, perl, lsb-release, libyaml-dev, libxml2-dev, libacl1-dev, python, rsync, libssl-dev, libcurl4-openssl-dev, libmodule-corelist-perl, libmodule-install-perl, libreadline-dev
Standards-Version: 3.8.0
Homepage: https://www.rudder.io

Expand Down
25 changes: 14 additions & 11 deletions rudder-agent/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ BUILD_LDFLAGS=$(shell [ -x /usr/bin/dpkg-buildflags ] && /usr/bin/dpkg-buildflag
OS_CODENAME := $(shell lsb_release -s -c)
# Ubuntu 10.04
ifeq (lucid,$(OS_CODENAME))
WITH = --disable-https --disable-systemd --disable-pie --with-perl --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-https --disable-systemd --disable-pie --with-perl --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 12.04
ifeq (precise,$(OS_CODENAME))
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 12.10
ifeq (quantal,$(OS_CODENAME))
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 13.04
ifeq (raring,$(OS_CODENAME))
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 14.04
ifeq (trusty,$(OS_CODENAME))
WITH = --disable-systemd --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-systemd --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 15.10
ifeq (wily,$(OS_CODENAME))
WITH = --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 16.04
ifeq (xenial,$(OS_CODENAME))
WITH = --with-openssl --with-libcurl --with-lmdb
WITH = --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Ubuntu 18.04
ifeq (bionic,$(OS_CODENAME))
Expand All @@ -54,19 +54,19 @@ endif

# Debian 5
ifeq (lenny,$(OS_CODENAME))
WITH = --disable-https --disable-systemd --disable-pie --with-perl --with-jq --with-openssl --with-libcurl --with-lmdb --with-libxml2 --with-libyaml
WITH = --disable-https --disable-systemd --disable-pie --with-perl --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb --with-libxml2 --with-libyaml
endif
# Debian 6
ifeq (squeeze,$(OS_CODENAME))
WITH = --disable-https --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-https --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Debian 7
ifeq (wheezy,$(OS_CODENAME))
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --disable-systemd --disable-pie --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Debian 8
ifeq (jessie,$(OS_CODENAME))
WITH = --with-jq --with-openssl --with-libcurl --with-lmdb
WITH = --with-jq --with-openssl --with-libcurl --with-augeas --with-lmdb
endif
# Debian 9
ifeq (stretch,$(OS_CODENAME))
Expand All @@ -87,6 +87,9 @@ endif
ifeq ($(findstring libcurl,$(WITH)),)
DEPS := $(DEPS), curl
endif
ifeq ($(findstring augeas,$(WITH)),)
DEPS := $(DEPS), augeas
endif
ifeq ($(findstring jq,$(WITH)),)
DEPS := $(DEPS), jq
endif
Expand Down
2 changes: 1 addition & 1 deletion rudder-agent/slackware/rudder-agent.SlackBuild
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mkdir -p $TMP $PKG

# Compile the application and install it into the $PKG directory
cd ../SOURCES
./configure --disable-pam --with-jq --with-perl --with-openssl --with-libcurl --with-lmdb
./configure --disable-pam --with-jq --with-perl --with-openssl --with-libcurl --with-augeas --with-lmdb
make --debug
make install DESTDIR=$PKG/
cd $PKG
Expand Down
4 changes: 2 additions & 2 deletions rudder-agent/solaris/packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cd "${BASE}/SOURCES"

# 1- install build-dependencies

pkg install gcc gnu-binutils || true
pkg install gcc gnu-binutils flex bison || true

# 2- configure, make and install into tmpdir

Expand All @@ -25,7 +25,7 @@ cp -p "${BASE}/solaris/cc" /usr/gnu/bin/

env="RUDDER_VERSION_TO_PACKAGE=${VERSION}"

./configure --with-openssl --with-libcurl --with-zlib --with-lmdb --with-pcre --with-jq --with-libyaml --with-libxml2
./configure --with-openssl --with-libcurl --with-augeas --with-zlib --with-lmdb --with-pcre --with-jq --with-libyaml --with-libxml2

# build
# solaris 11.3 doesn't detect properly 64 bitness
Expand Down

0 comments on commit 64fd447

Please sign in to comment.