-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! fixup! Fixes #17941: Create a configure to make the agent package
Fixes #17941: Create a configure to make the agent package
- Loading branch information
Showing
1 changed file
with
92 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,92 @@ | ||
diff --color -ruN cfengine-source.bak/cf-agent/cf-agent.c cfengine-source/cf-agent/cf-agent.c | ||
--- cfengine-source.bak/cf-agent/cf-agent.c 2020-03-23 18:10:31.000000000 +0100 | ||
+++ cfengine-source/cf-agent/cf-agent.c 2020-05-05 14:55:48.802030168 +0200 | ||
@@ -298,7 +298,6 @@ | ||
GenerateReports(config, ctx); | ||
|
||
PurgeLocks(); | ||
- BackupLockDatabase(); | ||
|
||
if (config->agent_specific.agent.show_evaluated_classes != NULL) | ||
{ | ||
diff --color -ruN cfengine-source.bak/libpromises/locks.c cfengine-source/libpromises/locks.c | ||
--- cfengine-source.bak/libpromises/locks.c 2020-03-23 18:10:31.000000000 +0100 | ||
+++ cfengine-source/libpromises/locks.c 2020-05-05 14:56:04.890133564 +0200 | ||
@@ -133,8 +133,6 @@ | ||
{ | ||
CF_DB *dbp; | ||
|
||
- VerifyThatDatabaseIsNotCorrupt(); | ||
- | ||
if (!OpenDB(&dbp, dbid_locks)) | ||
{ | ||
return NULL; | ||
#!/bin/bash | ||
|
||
set -xe | ||
|
||
slibclean | ||
|
||
# relink all binaries from a given directory to use absolute library path for rudder embedded libraries | ||
dir="$1" | ||
if [ "${dir}" = "" ] | ||
then | ||
echo "Usage $0 <rudder directory>" | ||
exit 1 | ||
fi | ||
|
||
# point real /opt/rudder/lib to $dir | ||
if [ -e "/opt/ruder/lib" ] | ||
then | ||
echo "Rudder must no be installed on this machine" | ||
exit 1 | ||
fi | ||
mkdir -p /opt/rudder | ||
ln -s "${dir}/lib" /opt/rudder/lib | ||
|
||
# function to relink executable files (binaries and .so) | ||
relink() { | ||
mode="$1" | ||
base="$2" | ||
rudder_libpath="/opt/rudder/lib:/usr/lib:/lib" | ||
|
||
# list executable files | ||
if [ "${mode}" = "bin" ]; then | ||
files=$(for i in ${base}/*; do file $i; done | grep "executable" | sed 's/:.*//') | ||
elif [ "${mode}" = "so" ]; then | ||
files=$(for i in ${base}/*.so*; do file $i; done | grep "executable" | sed 's/:.*//') | ||
fi | ||
|
||
# keep files with rudder dependencies | ||
executables=$(for f in ${files} | ||
do | ||
if LIBPATH="${rudder_libpath}" ldd "${f}" | grep " /opt/rudder/lib" > /dev/null | ||
then | ||
echo "${f}" | ||
fi | ||
done) | ||
|
||
# relink | ||
for f in ${executables} | ||
do | ||
echo $f | ||
dest=$(mktemp) | ||
# extract rudder dependencies with full path to final destination | ||
path=$(LIBPATH="${rudder_libpath}" ldd "${f}" | grep " /opt/rudder/lib" | sed 's/(.*//' | sort -u) | ||
# extract other dependencies with library name | ||
lib=$(LIBPATH="${rudder_libpath}" ldd "${f}" | grep -e " /usr/lib/lib" -e " /lib/lib" | sed 's|.*/lib/lib\([^.]*\).*|-l\1|' | sort -u) | ||
# relink with static paths and proper libpath (just in case) | ||
if [ "${mode}" = "bin" ]; then | ||
ld -bipath -bsvr4 -blibpath:${rudder_libpath} "${f}" ${path} ${lib} -o "${dest}" && mv "${dest}" "${f}" | ||
elif [ "${mode}" = "so" ]; then | ||
ld -bipath -bsvr4 -blibpath:${rudder_libpath} -bnoentry -bstatic "${f}" -bshared ${path} ${lib} -o "${dest}" && mv "${dest}" "${f}" | ||
fi | ||
done | ||
} | ||
|
||
# 1- relink binaries | ||
relink "bin" "${dir}/bin" | ||
|
||
# 2- relink .so libraries | ||
relink "so" "${dir}/lib" | ||
|
||
# 3- relink .a libraries | ||
# list only libraries that contain .so files | ||
archive_files=$(for i in ${dir}/lib/*.a; do file $i; done | grep "archive" | sed 's/:.*//') | ||
archives=$(for i in ${archive_files}; do dump -H $i; done | grep '\[.*\.so.*\]' | sed 's/\[.*//') | ||
# extract so files from archives | ||
tmpdir=$(mktemp -d) | ||
cd "${tmpdir}" | ||
for f in ${archives} | ||
do | ||
ar x "${f}" | ||
done | ||
# relink .so from within .a | ||
relink "so" "${tmpdir}" | ||
# put back .so to their place | ||
for f in ${archives} | ||
do | ||
so=$(ar t "${f}") | ||
ar r "${f}" "${so}" | ||
done | ||
cd | ||
rm -rf "${tmpdir}" | ||
|
||
rm /opt/rudder/lib |