summaryrefslogtreecommitdiffstats
path: root/remote/modules/kernel-system
diff options
context:
space:
mode:
authorJonathan Bauer2014-03-24 13:57:01 +0100
committerJonathan Bauer2014-03-24 13:57:01 +0100
commit06bf4e941bc938a4ed3ad987b6fdef0a3e9d6ff0 (patch)
tree199041b5384efe3af87849a43b46081789cdf124 /remote/modules/kernel-system
parent[setup_target] kernel version check (diff)
downloadtm-scripts-06bf4e941bc938a4ed3ad987b6fdef0a3e9d6ff0.tar.gz
tm-scripts-06bf4e941bc938a4ed3ad987b6fdef0a3e9d6ff0.tar.xz
tm-scripts-06bf4e941bc938a4ed3ad987b6fdef0a3e9d6ff0.zip
[kernel-system] new module
kernel-system provides the kernel from the running system without the need of compiling our own. also installs kernel headers through the package manager to be able to build kernel modules as required by other modules like vmware, dndb3...
Diffstat (limited to 'remote/modules/kernel-system')
-rw-r--r--remote/modules/kernel-system/kernel-system.build114
-rw-r--r--remote/modules/kernel-system/kernel-system.conf3
-rw-r--r--remote/modules/kernel-system/kernel-system.conf.opensuse6
-rw-r--r--remote/modules/kernel-system/kernel-system.conf.ubuntu6
-rwxr-xr-xremote/modules/kernel-system/patch-speaker6
5 files changed, 135 insertions, 0 deletions
diff --git a/remote/modules/kernel-system/kernel-system.build b/remote/modules/kernel-system/kernel-system.build
new file mode 100644
index 00000000..d542a80d
--- /dev/null
+++ b/remote/modules/kernel-system/kernel-system.build
@@ -0,0 +1,114 @@
+# overloaded get_kernel_version function
+get_kernel_version(){
+ pinfo "KERNEL_CURRENT_VERSION: ${KERNEL_CURRENT_VERSION}"
+ [ -z "${KERNEL_CURRENT_VERSION}" ] && perror "KERNEL_CURRENT_VERSION is not set, 'uname -r' output: '$(uname -r)'. Aborting..."
+
+ # set SYS_UTS_RELEASE and SYS_KERNEL correctly
+ declare -rg SYS_UTS_RELEASE="${KERNEL_CURRENT_VERSION}" 2>/dev/null
+ declare -rg SYS_KERNEL="$(echo ${KERNEL_CURRENT_VERSION} | grep -o -E '^[0-9\.]+')" 2>/dev/null
+
+ # KERNEL_NEW_VERSION is the same as KERNEL_CURRENT_VERSION
+ declare -rg KERNEL_NEW_VERSION="$KERNEL_CURRENT_VERSION" 2>/dev/null
+
+ # check linux headers directory
+ if [ -d "/usr/src/linux-headers-$(uname -r)" ]; then
+ declare -rg KERNEL_HEADERS_PATH="/usr/src/linux-headers-$(uname -r)" 2>/dev/null
+ else
+ # fetch source did not install the headers correctly.
+ perror "kernel headers for $KERNEL_CURRENT_VERSION not found! Re-build the kernel-system module"
+ fi
+
+ # check kernel modules/firmware directory
+ if [ -d "/lib/modules/${KERNEL_CURRENT_VERSION}" -a \
+ -d "/lib/firmware/${KERNEL_CURRENT_VERSION}" ]; then
+ # The expected paths exists, set KERNEL_BASE_DIR to /
+ declare -rg KERNEL_BASE_DIR="/" 2>/dev/null
+ else
+ perror "Could not find kernel modules / firmware for kernel version '$KERNEL_CURRENT_VERSION'. \
+ Does '/lib/modules/$KERNEL_CURRENT_VERSION' exist?"
+ fi
+
+ # print debug info
+ pdebug "SYS_UTS_RELEASE: '$SYS_UTS_RELEASE'"
+ pdebug "SYS_KERNEL: '$SYS_KERNEL'"
+ pdebug "KERNEL_NEW_VERSION: '$KERNEL_NEW_VERSION'"
+ pdebug "KERNEL_BASE_DIR: '$KERNEL_BASE_DIR'"
+
+ # set KERNEL_HEADERS_PATH
+ #get_kernel_headers_path
+}
+
+get_kernel_headers_path(){
+ # determine the path to the kernel headers we just installed
+ for DIR in $(list_content_package --dirs linux-headers-$(uname -r) ); do
+ if [[ "$DIR" =~ .*linux-headers-$(uname -r)$ ]]; then
+ # validate candidate
+ [ -e "$DIR/./include/generated/utsrelease.h" ] \
+ || perror "Could not find utsrelease.h at '$DIR/./include/generated/utsrelease.h'"
+ # TODO: maybe check if SYS_UTS_RELEASE is the same as in the header.
+
+ # all good, we found it
+ pinfo "Kernel headers found at '$DIR'."
+ declare -rg KERNEL_HEADERS_PATH="$DIR"
+ break
+ fi
+ done
+
+ [ -z "$KERNEL_HEADERS_PATH" ] && perror "KERNEL_HEADERS_PATH was not set correctly."
+
+}
+
+fetch_source() {
+
+ # get the source from repos, use meta-package for now
+ pinfo "Installing kernel headers from the repositories for version '${KERNEL_CURRENT_VERSION}'"
+
+ # the actual install routine is done via config file
+ # through the REQUIRED_INSTALLED_PACKAGES variable
+
+}
+
+build() {
+
+ # simply copy the kernel from the running system
+ # to the build directory as it is.
+ local KERNEL_SYSTEM_PATH=""
+
+ # 1st "parse" /proc/cmdline for the kernel name
+ for i in $(cat /proc/cmdline); do
+ [[ "$i" =~ ^BOOT_IMAGE=.* ]] && local BOOT_IMAGE="$(basename $(echo $i|cut -c 12-))"
+ done
+
+ # exit if KERNEL_SYSTEM_FILENAME is empty, should not happen
+ [ -z "${BOOT_IMAGE}" ] && perror "Could not determine the full path to the running kernel..."
+
+ # now find it in KERNEL_SYSTEM_SEARCH_PATH
+ # NOTE: this variable should be expanded in the future if new locations are to be searched
+ local KERNEL_SYSTEM_SEARCH_PATH="/boot"
+ local KERNEL_SYSTEM_SEARCH_RESULTS="$(find "${KERNEL_SYSTEM_SEARCH_PATH}" -type f -iname "*${BOOT_IMAGE}*")"
+
+ if [ "$(echo $KERNEL_SYSTEM_SEARCH_RESULTS|wc -w)" -eq 1 ]; then
+ # we found the running kernel path
+ KERNEL_SYSTEM_PATH="${KERNEL_SYSTEM_SEARCH_RESULTS}"
+ else
+ # we found more than one, shouldn't happen...
+ perror "Found more than one kernel named '${BOOT_IMAGE}' inside '${KERNEL_SYSTEM_SEARCH_PATH}'."
+ fi
+
+ # at this point, we should definitly have KERNEL_SYSTEM_PATH, check just in case :)
+ [ -z "${KERNEL_SYSTEM_PATH}" ] && perror "KERNEL_SYSTEM_PATH isn't set, kernel not found. This shouldn't happen!"
+ pinfo "Live kernel path: $KERNEL_SYSTEM_PATH"
+
+ # copy kernel to build directory
+ [ -z "${KERNEL_TARGET_NAME}" ] && perror "KERNEL_TARGET_NAME not set, this mean something is wrong with remote/include/kernel.inc"
+ cp "${KERNEL_SYSTEM_PATH}" "${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}" && \
+ pinfo "Copied kernel from '${KERNEL_SYSTEM_PATH}' to '${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}'"
+ #[ -z "${KERNEL_BUILD_DIR}" ] && KERNEL_BUILD_DIR="${MODULE_BUILD_DIR}"
+}
+
+post_copy() {
+ :
+ #mkdir -p "$TARGET_BUILD_DIR/../kernel"
+ #cp -a "$MODULE_BUILD_DIR/kernel" "$TARGET_BUILD_DIR/../kernel/kernel" || perror "could not copy kernel to remote build dir."
+}
+
diff --git a/remote/modules/kernel-system/kernel-system.conf b/remote/modules/kernel-system/kernel-system.conf
new file mode 100644
index 00000000..0cd03752
--- /dev/null
+++ b/remote/modules/kernel-system/kernel-system.conf
@@ -0,0 +1,3 @@
+REQUIRED_BINARIES=""
+REQUIRED_LIBRARIES=""
+REQUIRED_DIRECTORIES=""
diff --git a/remote/modules/kernel-system/kernel-system.conf.opensuse b/remote/modules/kernel-system/kernel-system.conf.opensuse
new file mode 100644
index 00000000..6bfc2078
--- /dev/null
+++ b/remote/modules/kernel-system/kernel-system.conf.opensuse
@@ -0,0 +1,6 @@
+REQUIRED_INSTALLED_PACKAGES="
+ kernel-desktop-devel
+"
+REQUIRED_CONTENT_PACKAGES="
+ kernel-desktop-devel
+"
diff --git a/remote/modules/kernel-system/kernel-system.conf.ubuntu b/remote/modules/kernel-system/kernel-system.conf.ubuntu
new file mode 100644
index 00000000..4d47b243
--- /dev/null
+++ b/remote/modules/kernel-system/kernel-system.conf.ubuntu
@@ -0,0 +1,6 @@
+REQUIRED_INSTALLED_PACKAGES="
+ linux-headers-$(uname -r)
+"
+REQUIRED_CONTENT_PACKAGES="
+ linux-headers-$(uname -r)
+"
diff --git a/remote/modules/kernel-system/patch-speaker b/remote/modules/kernel-system/patch-speaker
new file mode 100755
index 00000000..5d5a9f9a
--- /dev/null
+++ b/remote/modules/kernel-system/patch-speaker
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+if ! grep notes "ksrc/drivers/input/misc/pcspkr.c" > /dev/null; then
+ echo "Patching pc speaker :-)"
+ sed -i.nomusic -r 's#^static.*int.*pcspkr_event#static const int notes[] = { /*tetris*/ 1319, 988, 1047, 1175, 1047, 988, 880, 880, 1047, 1319, 1175, 1047, 988, 1047, 1175, 1319, 1047, 880, 880, 1175, 1397, 1760, 1568, 1397, 1319, 1047, 1319, 1175, 1047, 988, 988, 1047, 1175, 1319, 1047, 880, 880, /*mario*/ 660, 660, 660, 510, 660, 770, 380, 510, 380, 320, 440, 480, 450, 430, 380, 660, 760, 860, 700, 760, 660, 520, 580, 480, 510, 380, 320, 440, 480, 450, 430, 380, 660, 760, 860, 700, 760, 660, 520, 580, 480, 500, 760, 720, 680, 620, 650, 380, 430, 500, 430, 500, 570, 500, 760, 720, 680, 620, 650, 1020, 1020, 1020, 380, 500, 760, 720, 680, 620, 650, 380, 430, 500, 430, 500, 570, 500, 760, 720, 680, 620, 650, 1020, 1020, 1020, 380, 500, 760, 720, 680, 620, 650, 380, 430, 500, 430, 500, 570, 585, 550, 500, 380, 500, 500, 500, 500, 500, 500, 500, 580, 660, 500, 430, 380, 500, 500, 500, 500, 580, 660, 870, 760, 500, 500, 500, 500, 580, 660, 500, 430, 380, 660, 660, 660, 510, 660, 770, 380, /* elise */ 420, 400, 420, 400, 420, 315, 370, 335, 282, 180, 215, 282, 315, 213, 262, 315, 335, 213, 420, 400, 420, 400, 420, 315, 370, 335, 282, 180, 215, 282, 315, 213, 330, 315, 282 };\nstatic int notePos = 0;\n\n&#g;s#\s*if \(value > 20 && value < 32767\)#\n if (value) value = notes[notePos++ % (sizeof(notes) / sizeof(notes[0]))];\n\n&#g' "ksrc/drivers/input/misc/pcspkr.c"
+fi