Skip to content

Commit

Permalink
Merge pull request Normation#326 from Kegeruneku/ust_4798/int/4799_up…
Browse files Browse the repository at this point in the history
…grade_to_cfengine_3_6

Fixes #4798: Switch to CFEngine 3.6.0rc1 for Rudder
  • Loading branch information
Kegeruneku committed May 28, 2014
2 parents 5cccadb + a246c55 commit f68483c
Show file tree
Hide file tree
Showing 18 changed files with 122 additions and 771 deletions.
31 changes: 12 additions & 19 deletions rudder-agent/SOURCES/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,32 @@
.DEFAULT_GOAL := localdepends

RUDDER_VERSION_TO_PACKAGE = <put Rudder version or version-snapshot here>
CFENGINE_RELEASE = 3.5.3
CFENGINE_RELEASE = 3.6.0rc1
FUSION_RELEASE = 2.3.6
TOKYOCABINET_RELEASE = 1.4.48
LMDB_RELEASE = 0.9.11
TMP_DIR := $(shell mktemp -dq /tmp/rudder.XXXXXX)
WGET := $(if $(PROXY), http_proxy=$(PROXY) ftp_proxy=$(PROXY)) /usr/bin/wget -q
PATCH := /usr/bin/patch
FIND := /usr/bin/find

localdepends: ./initial-promises ./detect_os.sh ./files ./fusioninventory-agent ./tokyocabinet-source ./cfengine-source ../debian/rudder-agent.init ../debian/rudder-agent.default ./rudder-agent.cron ../debian/rudder-agent.cron.d
localdepends: ./initial-promises ./detect_os.sh ./files ./fusioninventory-agent ./lmdb-source ./cfengine-source ../debian/rudder-agent.init ../debian/rudder-agent.default ./rudder-agent.cron ../debian/rudder-agent.cron.d
rm -rf $(TMP_DIR)

./cfengine-source: /usr/bin/wget
# Original URL: http://cfengine.com/source-code/download?file=cfengine-$(CFENGINE_RELEASE).tar.gz
$(WGET) -O $(TMP_DIR)/cfengine.tgz http://www.normation.com/tarball/cfengine-$(CFENGINE_RELEASE).tar.gz
tar xzf $(TMP_DIR)/cfengine.tgz -C $(TMP_DIR)
mv $(TMP_DIR)/cfengine-$(CFENGINE_RELEASE) ./cfengine-source
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0001-add-support-for-openvz.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0002-cfengine-report-on-package-removal.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0003-dont-remove-blank-line-in-templates.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0004-partially-revert-a-change-intended-to-alter-the-log.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0005-tiny-optimization-in-safe-open.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0006-fix-failure-to-open-paths-ending-in-a-slash.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0007-fix-incorrect-return-value-for-empty-string-in-safe.patch
$(PATCH) -d ./cfengine-source -p1 < ./patches/cfengine/0008-make-safe-open-treat-trailing-slashes-like-open.patch

./tokyocabinet-source: /usr/bin/wget
# Original URL: http://fallabs.com/tokyocabinet/tokyocabinet-${TOKYOCABINET_RELEASE}.tar.gz
$(WGET) -O $(TMP_DIR)/tokyocabinet.tgz http://www.normation.com/tarball/tokyocabinet-${TOKYOCABINET_RELEASE}.tar.gz
tar xzf $(TMP_DIR)/tokyocabinet.tgz -C $(TMP_DIR)
mv $(TMP_DIR)/tokyocabinet-$(TOKYOCABINET_RELEASE) ./tokyocabinet-source
# No patches to apply

./lmdb-source: /usr/bin/wget
# Original URL: http://ftp.fr.debian.org/debian/pool/main/l/lmdb/lmdb_$(LMDB_RELEASE).orig.tar.xz
$(WGET) -O $(TMP_DIR)/lmdb.tgz http://www.normation.com/tarball/lmdb-$(LMDB_RELEASE).tar.gz
tar xzf $(TMP_DIR)/lmdb.tgz -C $(TMP_DIR)
mv $(TMP_DIR)/lmdb-$(LMDB_RELEASE) ./lmdb-source

./rudder-sources.tar.bz2:
$(WGET) -O rudder-sources.tar.bz2 http://www.rudder-project.org/archives/rudder-sources-${RUDDER_VERSION_TO_PACKAGE}.tar.bz2
$(WGET) -O rudder-sources.tar.bz2 http://www.rudder-project.org/archives/rudder-sources-$(RUDDER_VERSION_TO_PACKAGE).tar.bz2

./rudder-sources: ./rudder-sources.tar.bz2
tar -xjf rudder-sources.tar.bz2
Expand Down Expand Up @@ -140,7 +133,7 @@ localdepends: ./initial-promises ./detect_os.sh ./files ./fusioninventory-agent

localclean:
rm -rf ./cfengine-source
rm -rf ./tokyocabinet-source
rm -rf ./lmdb-source
rm -rf ./initial-promises
rm -rf ./detect_os.sh
rm -f ../debian/rudder-agent.init
Expand Down
26 changes: 4 additions & 22 deletions rudder-agent/SOURCES/check-rudder-agent
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ set -e
# Ensure our PATH includes Rudder's bin dir (for uuidgen on AIX in particular)
export PATH=/opt/rudder/bin/:$PATH

# Variables
BACKUP_DIR=/var/backups/rudder/
OS_FAMILY=$(uname -s)

# If we are on AIX, use alternative commands and options
if [ "z${OS_FAMILY}" = "zAIX" ]; then
if [ "z$(uname -s)" = "zAIX" ]; then
CP_A="cp -hpPr"
PS_OPTIONS="-ef"
else
Expand All @@ -36,7 +34,7 @@ else
fi

echo_n() {
if [ "z${OS_FAMILY}" = "zAIX" ]; then
if [ "z$(uname -s)" = "zAIX" ]; then
/usr/bin/echo "$*\c"
else
echo -n $*
Expand Down Expand Up @@ -111,27 +109,12 @@ fi
if [ ${NB_CF_PROCESS_RUNNING} -gt 8 ]; then
echo_n "WARNING: Too many instance of CFEngine processes running. Killing them, and purging the TokyoCabinet database..."
echo "${CF_PROCESS_RUNNING}" | awk 'BEGIN { OFS=" "} {print $2 }' | xargs kill -9 || true
if [ "z${OS_FAMILY}" != "zAIX" ]; then
/etc/init.d/rudder-agent forcestop || true
fi
/etc/init.d/rudder-agent forcestop || true
clean_cf_lock_files
echo " Done"
fi
}

# Check the size of the cf_lock.tcdb file
check_and_fix_cf_lock() {
MAX_CF_LOCK_SIZE=10485760
if [ -e "${CFE_DIR}/state/cf_lock.tcdb" ]; then
CF_LOCK_SIZE=`stat -c%s "${CFE_DIR}/state/cf_lock.tcdb"`
if [ ${CF_LOCK_SIZE} -ge ${MAX_CF_LOCK_SIZE} ]; then
echo -n "WARNING: The file ${CFE_DIR}/state/cf_lock.tcdb is too big ( ${CF_LOCK_SIZE} bytes), purging it..."
clean_cf_lock_files
echo " Done"
fi
fi
}

check_and_fix_rudder_uuid() {

# Default variable about UUID backup
Expand Down Expand Up @@ -195,10 +178,9 @@ if [ ! $(whoami) = 'root' ];then echo "You must be root"; exit; fi
# Launch each check with a certain order
check_and_fix_rudder_uuid
check_and_fix_cfengine_processes
check_and_fix_cf_lock

# The following files are not present on AIX systems
if [ "z${OS_FAMILY}" != "zAIX" ]; then
if [ "z$(uname -s)" != "zAIX" ]; then
check_and_fix_specific_rudder_agent_file /etc/init.d/rudder-agent init
check_and_fix_specific_rudder_agent_file /etc/default/rudder-agent default
check_and_fix_specific_rudder_agent_file /etc/cron.d/rudder-agent cron
Expand Down
4 changes: 2 additions & 2 deletions rudder-agent/SOURCES/filter-reqs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use IPC::Open2;

# This scripts takes at least 2 arguments:
# - 1) the string "true" or "false" to tell us whether to *not* exclude tokyocabinet from list of requires (ie, if argument == false, then exclude it)
# - 1) the string "true" or "false" to tell us whether to *not* exclude LMDB from list of requires (ie, if argument == false, then exclude it)
# - 2) The command and it's arguments to run to auto-detect requirements (original RPM behaviour)
my $dont_exclude_tc = $ARGV[0];
my @command = @ARGV[1 .. $#ARGV];
Expand All @@ -20,6 +20,6 @@
$list =~ s/^perl .*?$//mg;
$list =~ s/^\/opt\/rudder\/bin\/perl.*?$//mg;

$list =~ s/^.*tokyocabinet.*?$//mg unless ($dont_exclude_tc eq "true");
$list =~ s/^.*lmdb.*?$//mg unless ($dont_exclude_tc eq "true");

print $list;
Original file line number Diff line number Diff line change
@@ -1,73 +1,75 @@
diff -Naurw debian/control debian-new/control
--- debian/control 2014-05-02 17:06:59.654516718 +0200
+++ debian/control 2014-05-02 17:06:59.654516718 +0200
@@ -2,7 +2,7 @@ Source: rudder-agent
--- debian/control 2014-05-13 12:20:49.811777659 +0200
+++ debian/control 2014-05-13 12:19:51.151566236 +0200
@@ -2,7 +2,7 @@
Section: admin
Priority: extra
Maintainer: Rudder packaging team <rudder-packaging@rudder-project.org>
-Build-Depends: debhelper (>= 7), libssl-dev, bison, gcc, flex, libpcre3-dev, libtokyocabinet-dev
+Build-Depends: debhelper (>= 7), libssl-dev, bison, gcc, flex, libpcre3-dev, zlib1g-dev, libbz2-dev
-Build-Depends: debhelper (>= 7), libssl-dev, bison, gcc, flex, libpcre3-dev, libpam0g-dev
+Build-Depends: debhelper (>= 7), libssl-dev, bison, gcc, flex, libpcre3-dev, libpam0g-dev, liblmdb-dev
Standards-Version: 3.8.0
Homepage: http://www.rudder-project.org

diff -Naurw debian/postinst debian-new/postinst
--- debian/postinst 2014-05-02 17:06:59.654516718 +0200
+++ debian/postinst 2014-05-02 17:06:59.654516718 +0200
@@ -33,6 +33,9 @@ case "$1" in
fi
fi

+ # Reload library of ldd
+ if [ -e /etc/ld.so.conf.d/rudder.conf ]; then ldconfig; fi
+
# Copy new binaries to workdir, make sure daemons are stopped first

# Set a "lock" to avoid CFEngine being restarted during the upgrade process
diff -Naurw debian/rules debian-new/rules
--- debian/rules 2014-05-02 17:06:59.654516718 +0200
+++ debian/rules 2014-05-02 17:06:59.654516718 +0200
@@ -14,9 +14,16 @@
--- debian/rules 2014-05-13 14:00:36.748017941 +0200
+++ debian/rules 2014-05-13 12:19:51.151566236 +0200
@@ -14,17 +14,9 @@
configure: configure-stamp
configure-stamp:
dh_testdir
+ # dh_prep has been moved from 'install' target since we need to build tokyocabinet first
+ dh_prep
- # dh_prep has been moved from 'install' target since we need to build LMDB first
- dh_prep
# Add here commands to configure the package.
cd SOURCES && ./perl-prepare.sh
- cd SOURCES/cfengine-source && ./configure --prefix=/opt/rudder --with-workdir=/var/rudder/cfengine-community --enable-static=yes --enable-shared=no
+ # Compile Tokyocabinet library and install it in /opt/rudder/lib
+ cd SOURCES/tokyocabinet-source && ./configure --prefix=/opt/rudder
+ cd SOURCES/tokyocabinet-source && make
+ cd SOURCES/tokyocabinet-source && make install DESTDIR=$(CURDIR)/debian/tmp
+ # Prepare CFEngine 3.4.x build with defined path of tokyocabinet library
+ cd SOURCES/cfengine-source && ./configure --prefix=/opt/rudder --with-workdir=/var/rudder/cfengine-community --enable-static=yes --enable-shared=no --with-tokyocabinet=$(CURDIR)/debian/tmp/opt/rudder
- # Compile the LMDB library and install it in /opt/rudder
- # LMDB source code does not know how to create destination folders, do it ourselves
- for i in bin lib include man/man1; do mkdir -p $(CURDIR)/debian/tmp/opt/rudder/$$i; done
- cd SOURCES/lmdb-source/libraries/liblmdb && make
- cd SOURCES/lmdb-source/libraries/liblmdb && make install prefix=/opt/rudder DESTDIR=$(CURDIR)/debian/tmp
- # Prepare CFEngine 3.6.x build with defined path of LMDB
- cd SOURCES/cfengine-source && ./configure --prefix=/opt/rudder --with-workdir=/var/rudder/cfengine-community --enable-static=yes --enable-shared=no --with-lmdb=$(CURDIR)/debian/tmp/opt/rudder
+ cd SOURCES/cfengine-source && ./configure --prefix=/opt/rudder --with-workdir=/var/rudder/cfengine-community --enable-static=yes --enable-shared=no

touch configure-stamp

@@ -47,7 +54,6 @@ clean:
@@ -55,6 +47,7 @@
install: build
dh_testdir
dh_testroot
- dh_prep
+ dh_prep
dh_installdirs

# Add here commands to install the package into debian/tmp
@@ -79,6 +85,9 @@ binary-arch: install
@@ -86,9 +79,6 @@
dh_install --SOURCEDIR=$(CURDIR)/SOURCES initial-promises /opt/rudder/share
# Install an empty uuid.hive file before generating an uuid
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ uuid.hive /opt/rudder/etc/
+ # Install /etc/ld.so.conf.d/rudder.conf in order to use libraries contain
+ # in /opt/rudder/lib like tokyocabinet
+ dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder.conf /etc/ld.so.conf.d
- # Install /etc/ld.so.conf.d/rudder.conf in order to use libraries contain
- # in /opt/rudder/lib like LMDB
- dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder.conf /etc/ld.so.conf.d
# Install a verification script for cron
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ check-rudder-agent /opt/rudder/bin/
# Install script to get local processes on VZ systems
@@ -91,7 +100,7 @@ binary-arch: install
@@ -101,7 +91,7 @@
dh_compress
dh_fixperms
# dh_perl
-# dh_makeshlibs
+ dh_makeshlibs
- dh_makeshlibs
+# dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol

diff -Naurw debian/control debian-new/control
--- debian/postinst 2014-05-13 14:12:43.838564255 +0200
+++ debian/postinst 2014-05-13 12:19:51.151566236 +0200
@@ -33,9 +33,6 @@
fi
fi

- # Reload the linker cache (to acknowledge LMDB's presence if needed)
- if [ -e /etc/ld.so.conf.d/rudder.conf ]; then ldconfig; fi
-
# Copy new binaries to workdir, make sure daemons are stopped first

# Set a "lock" to avoid CFEngine being restarted during the upgrade process

0 comments on commit f68483c

Please sign in to comment.