Module: check_mk
Branch: master
Commit: a81cef6729bc53e70aadc5e88a1d0d3ebab1a200
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a81cef6729bc53…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 20 11:43:08 2017 +0200
Fixed windows agent build
* Fixed environment processing of su command
* do-chroot: Use chrooted command exit code as final exit code
* Moved CHROOT_NAME to make-agent script
Change-Id: I62a791c431541f08f9ec9f1362bf25a1d9a6dbb9
---
agents/windows/build-agent | 6 ++++--
agents/windows/configure.ac | 2 +-
agents/windows/do-chroot | 7 +++++--
agents/windows/make-agent | 14 ++++++++------
4 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/agents/windows/build-agent b/agents/windows/build-agent
index 4f7fd61..3f9847e 100755
--- a/agents/windows/build-agent
+++ b/agents/windows/build-agent
@@ -15,10 +15,12 @@ set -e
# Ensure that CHROOT_BUILD_DIR is set.
[[ -z $CHROOT_BUILD_DIR ]] && exit 1
-. $CHROOT_BUILD_DIR/agents/windows/build.sh
+. /$CHROOT_BUILD_DIR/agents/windows/build.sh
parse-args "$@"
-cd $CHROOT_BUILD_DIR/agents/windows
+
+cd /$CHROOT_BUILD_DIR/agents/windows
+
autoreconf --install
build_archs=(32 64)
diff --git a/agents/windows/configure.ac b/agents/windows/configure.ac
index 1221acb..8871127 100644
--- a/agents/windows/configure.ac
+++ b/agents/windows/configure.ac
@@ -5,7 +5,7 @@ AC_PREREQ([2.69])
AC_INIT([Check_MK Windows Agent], [1.5.0i1], [feedback(a)check-mk.org])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_COMMANDS([check_chroot], \
- [[[ -z $CHROOTNAME ]] && \
+ [[[ -z $CHROOT_NAME ]] && \
echo "Not allowed outside chroot. Please call
'./make-agent' instead." && \
exit 1])
AC_CONFIG_SRCDIR([config.h.in])
diff --git a/agents/windows/do-chroot b/agents/windows/do-chroot
index fec56fa..f6527fb 100755
--- a/agents/windows/do-chroot
+++ b/agents/windows/do-chroot
@@ -6,7 +6,6 @@
CMD="$1"
export HOSTNAME=cmk-windows-agent-chroot
unset LANG
-CHROOTNAME=WinAgent
BASE="$(realpath ../..)"
@@ -41,10 +40,12 @@ if [ ! -e $CHROOT_PATH/$CHROOT_BUILD_DIR/Makefile ] ; then
fi
if [ -n "$CMD" ] ; then
- chroot $CHROOT_PATH /usr/bin/env CHROOTNAME=$CHROOTNAME \
+ chroot $CHROOT_PATH /usr/bin/env \
NEW_VERSION=$NEW_VERSION bash -c "$CMD"
+ EXIT_CODE=$?
else
chroot $CHROOT_PATH /usr/bin/env CHROOTNAME=$CHROOTNAME bash -l
+ EXIT_CODE=$?
fi
umount $CHROOT_PATH/$CHROOT_BUILD_DIR
@@ -52,3 +53,5 @@ umount $CHROOT_PATH/dev/pts
sleep 2
umount $CHROOT_PATH/dev
umount $CHROOT_PATH/proc
+
+exit $EXIT_CODE
diff --git a/agents/windows/make-agent b/agents/windows/make-agent
index 3199353..619f0c3 100755
--- a/agents/windows/make-agent
+++ b/agents/windows/make-agent
@@ -10,6 +10,11 @@
set -e
+if [ -z $SUDO_USER ]; then
+ echo "ERROR: $0 must be executed with sudo"
+ exit 1
+fi
+
. build.sh
parse-args "$@"
@@ -22,6 +27,7 @@ base="$(realpath ../..)"
# directory in agents/windows
export CHROOT_PATH=${CHROOT_PATH:-$base/agents/windows/chroot}
export CHROOT_BUILD_DIR=${CHROOT_BUILD_DIR:-build}
+export CHROOT_NAME=${CHROOT_NAME:-WinAgent}
if [ ! -f "$base/agents/windows/$versionfile" ] ; then
echo "Error: File $base/agents/windows/$versionfile not found."
@@ -51,9 +57,5 @@ fi
# Build the Windows agent within chroot by calling the 'build-agent' script as
# $SUDO_USER.
-CHROOT_PATH=$CHROOT_PATH CHROOT_BUILD_DIR=$CHROOT_BUILD_DIR \
- NEW_VERSION=$NEW_VERSION ./do-chroot \
- "/bin/su - $SUDO_USER -m -c '$CHROOT_BUILD_DIR/agents/windows/build-agent
-j${njobs} $targets'"
-EXIT_CODE=$?
-
-exit $EXIT_CODE
+./do-chroot \
+ "/bin/su - $SUDO_USER -c bash -c 'CHROOT_NAME=$CHROOT_NAME
CHROOT_PATH=$CHROOT_PATH CHROOT_BUILD_DIR=$CHROOT_BUILD_DIR NEW_VERSION=$NEW_VERSION
/$CHROOT_BUILD_DIR/agents/windows/build-agent -j${njobs} $targets'"