summaryrefslogtreecommitdiffstats
path: root/remote/modules/kernel
diff options
context:
space:
mode:
authorMichael Neves2013-04-24 18:19:49 +0200
committerMichael Neves2013-04-24 18:19:49 +0200
commit97472f07e21c73e9d767de7960dc1e05ba48b53d (patch)
treee4119718dbddd68664480436767fc12d4a319700 /remote/modules/kernel
parentfix rsyslog (diff)
parentWe will require wpad for the future ... (diff)
downloadtm-scripts-97472f07e21c73e9d767de7960dc1e05ba48b53d.tar.gz
tm-scripts-97472f07e21c73e9d767de7960dc1e05ba48b53d.tar.xz
tm-scripts-97472f07e21c73e9d767de7960dc1e05ba48b53d.zip
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote/modules/kernel')
-rw-r--r--remote/modules/kernel/.gitignore3
-rw-r--r--remote/modules/kernel/kernel.build81
-rw-r--r--remote/modules/kernel/kernel.conf3
3 files changed, 87 insertions, 0 deletions
diff --git a/remote/modules/kernel/.gitignore b/remote/modules/kernel/.gitignore
new file mode 100644
index 00000000..56c69270
--- /dev/null
+++ b/remote/modules/kernel/.gitignore
@@ -0,0 +1,3 @@
+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=""