From a0bd2b22b8db8e5d16333852467d07a1cf2f8c82 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 24 Apr 2013 17:15:47 +0200 Subject: compile kernel on the reference system with our config requirements --- remote/modules/kernel/.gitignore | 5 ++- remote/modules/kernel/kernel.build | 81 ++++++++++++++++++++++++++++++++++++++ remote/modules/kernel/kernel.conf | 3 ++ 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 remote/modules/kernel/kernel.build create mode 100644 remote/modules/kernel/kernel.conf (limited to 'remote/modules/kernel') diff --git a/remote/modules/kernel/.gitignore b/remote/modules/kernel/.gitignore index 5e077cd8..56c69270 100644 --- a/remote/modules/kernel/.gitignore +++ b/remote/modules/kernel/.gitignore @@ -1,2 +1,3 @@ -ksrc/ -linux-*/ +ksrc +linux* +openslx.config diff --git a/remote/modules/kernel/kernel.build b/remote/modules/kernel/kernel.build new file mode 100644 index 00000000..8b238abf --- /dev/null +++ b/remote/modules/kernel/kernel.build @@ -0,0 +1,81 @@ +fetch_source() { + # get the source according to the distro + if [ "x$PACKET_MANAGER" == "xapt" ]; then + pdebug "apt-ing kernel source" + apt-get source linux-image-${KERNEL_VERSION} + [ ! -e ksrc ] && ln -s $(ls -d linux-*/) ksrc + elif [ "x$PACKET_MANAGER" == "xzypper" ]; then + pdebug "zypping kernel source" + zypper si kernel-source + + # find src directory + local SOURCE_DIR=$(rpm -ql kernel-source |grep -E -o '^/.*src/linux-[^/]+/' |head -1) + [ -z "${SOURCE_DIR}" ] && perror "Could not determine directory of kernel source..." + ln -sf "${SOURCE_DIR}" ksrc + + else + pdebug "Packet manager not determined!" + fi +} + +build() { + local TARGET_CONFIG_FILE="openslx.config" + [ -e "${TARGET_CONFIG_FILE}" ] && rm -f "${TARGET_CONFIG_FILE}" + # update config and copy to ksrc + pinfo "Updating kernel config..." + update_config + cp "${TARGET_CONFIG_FILE}" ksrc/.config + + # make kernel with the new config + cd ksrc || perror "Could not cd to ksrc, was the kernel source fetched properly?" + pinfo "Preparing kernel for new config ('make oldconfig')" + yes n | make oldconfig || perror "make oldconfig failed" + pinfo "Compiling kernel... (this will take some time)" + make || perror "make failed" + + # install modules to build directory + pinfo "Installing kernel modules..." + make INSTALL_MOD_PATH="${MODULE_BUILD_DIR}" INSTALL_MOD_STRIP=1 modules_install || perror "make modules_install failed in ${MODULE_BUILD_DIR}" + cd - 2> /dev/null + + # copy kernel to build + cp ksrc/arch/x86/boot/bzImage "${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}" + pinfo "Kernel was successfully built at ${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}" + [ -z "${KERNEL_BUILD_DIR}" ] && KERNEL_BUILD_DIR="${MODULE_BUILD_DIR}" +} + +post_copy() { + : +} + +# helper function to update the current kernel config with our parameters +update_config() { + + # first we need to update the current config + local BASE_CONFIG_FILE="/boot/config-$(uname -r)" + [ -e "${BASE_CONFIG_FILE}" ] || perror "$BASE_CONFIG_FILE could not be found! This should not happen." + + # check for our wanted config parameter + local OPENSLX_WANTED_CONFIG="${ROOT_DIR}/data/kernel.wanted.config" + [ -e "${OPENSLX_WANTED_CONFIG}" ] || perror "$OPENSLX_WANTED_CONFIG does not exist! Please add a list of wanted kernel config parameters." + + # copy basic config file + cp "$BASE_CONFIG_FILE" "$TARGET_CONFIG_FILE" + + for WANTED_CONFIG in $(cat $OPENSLX_WANTED_CONFIG|sort -u); do + local CONFIG_PARAM_NAME=$(echo $WANTED_CONFIG | awk -F "=" '{print $1}') + local SEARCH_RESULT=$(grep "^$CONFIG_PARAM_NAME=" "$BASE_CONFIG_FILE") + + #echo "Process: $SEARCH_RESULT" + # analyse results + if [ "x$SEARCH_RESULT" == "x" ]; then + # no match, add it + echo $WANTED_CONFIG >> $TARGET_CONFIG_FILE + else + # match, change to our setting if they differ + if [ "x${SEARCH_RESULT: -1}" != "x${WANTED_CONFIG: -1}" ]; then + sed -i "s/$SEARCH_RESULT/$WANTED_CONFIG/" "$TARGET_CONFIG_FILE" + fi + fi + done +} diff --git a/remote/modules/kernel/kernel.conf b/remote/modules/kernel/kernel.conf new file mode 100644 index 00000000..0cd03752 --- /dev/null +++ b/remote/modules/kernel/kernel.conf @@ -0,0 +1,3 @@ +REQUIRED_BINARIES="" +REQUIRED_LIBRARIES="" +REQUIRED_DIRECTORIES="" -- cgit v1.2.3-55-g7522