summaryrefslogtreecommitdiffstats
path: root/core/modules/kernel-system
diff options
context:
space:
mode:
authorSebastian2016-04-25 12:01:08 +0200
committerSebastian2016-04-25 12:01:08 +0200
commit5acda3eaeabae9045609539303a8c12c4ce401f1 (patch)
tree7e71975f8570b05aafe2ea6ec0e242a8912387bb /core/modules/kernel-system
parentinitial commit (diff)
downloadmltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.gz
mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.tar.xz
mltk-5acda3eaeabae9045609539303a8c12c4ce401f1.zip
merge with latest dev version
Diffstat (limited to 'core/modules/kernel-system')
-rw-r--r--core/modules/kernel-system/TODO3
-rw-r--r--core/modules/kernel-system/module.build88
-rw-r--r--core/modules/kernel-system/module.conf3
-rw-r--r--core/modules/kernel-system/module.conf.fedora6
-rw-r--r--core/modules/kernel-system/module.conf.opensuse6
-rw-r--r--core/modules/kernel-system/module.conf.ubuntu7
-rwxr-xr-xcore/modules/kernel-system/patch-speaker6
7 files changed, 119 insertions, 0 deletions
diff --git a/core/modules/kernel-system/TODO b/core/modules/kernel-system/TODO
new file mode 100644
index 00000000..7665abac
--- /dev/null
+++ b/core/modules/kernel-system/TODO
@@ -0,0 +1,3 @@
+make the modules load in stage31/init since we dont know which ones are compiled within kernel and which need to be loaded explicitly
+
+Idea: do it like DRM stuff, with pci-ids.
diff --git a/core/modules/kernel-system/module.build b/core/modules/kernel-system/module.build
new file mode 100644
index 00000000..a5bd747c
--- /dev/null
+++ b/core/modules/kernel-system/module.build
@@ -0,0 +1,88 @@
+# kernel-system: Try to use the system's kernel without recompiling
+
+# overloaded get_kernel_version function from kernel.inc
+get_kernel_version(){
+ [ -z "${SYSTEM_KERNEL_LONG}" ] && perror "SYSTEM_KERNEL_LONG is not set, should be done by kernel.inc on startup. Aborting..."
+ [ -n "${TARGET_KERNEL_LONG}" ] && return
+
+ # set TARGET_KERNEL_LONG and TARGET_KERNEL_SHORT correctly
+ declare -rg TARGET_KERNEL_LONG="${SYSTEM_KERNEL_LONG}"
+ declare -rg TARGET_KERNEL_SHORT="$(echo ${SYSTEM_KERNEL_LONG} | grep -o -E '^[0-9\.]+')"
+
+ # figure out linux headers directory
+ local DIR
+ local RES=
+ for DIR in "/lib/modules/$SYSTEM_KERNEL_LONG/build" "/lib/modules/$SYSTEM_KERNEL_LONG/source" \
+ "/usr/src/linux-headers-$SYSTEM_KERNEL_LONG" "/usr/src/kernels/$SYSTEM_KERNEL_LONG"; do
+ [ -e "$DIR/include/linux/input" ] && RES=$DIR && break
+ # Sometimes the directory exists, but doesn't contain headers yet. Need a good way to
+ # figure that out. "include/linux/input" is a quick first idea that works on fedora and ubuntu. :)
+ done
+ # maybe fetch source did not install the headers correctly?
+ [ -z "$RES" ] && perror "kernel headers for $SYSTEM_KERNEL_LONG not found! Re-build the kernel-system module"
+ declare -rg KERNEL_HEADERS_DIR="$RES" 2>/dev/null
+
+ # check kernel modules/firmware directory
+ if [ -d "/lib/modules/${SYSTEM_KERNEL_LONG}" -a -d "/lib/firmware" ]; 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 '$SYSTEM_KERNEL_LONG'. \
+ Does '/lib/modules/$SYSTEM_KERNEL_LONG' exist?"
+ fi
+
+ # print debug info
+ pinfo "TARGET_KERNEL_LONG: '$TARGET_KERNEL_LONG'"
+ pinfo "TARGET_KERNEL_SHORT: '$TARGET_KERNEL_SHORT'"
+ pdebug "KERNEL_BASE_DIR: '$KERNEL_BASE_DIR'"
+
+}
+
+
+
+fetch_source() {
+ :
+}
+
+build() {
+
+ # simply copy the kernel from the running system
+ # to the build directory as it is.
+ local KERNEL_SYSTEM_PATH=""
+ local BOOT_IMAGE=""
+
+ # 1st "parse" /proc/cmdline for the kernel name
+ for i in $(cat /proc/cmdline); do
+ [[ "$i" == BOOT_IMAGE=* ]] && BOOT_IMAGE="$(basename "${i#BOOT_IMAGE=}")"
+ done
+ [ -z "${BOOT_IMAGE}" ] && local BOOT_IMAGE="$(uname -r)"
+
+ # 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 -name "${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 no or more than one kernel named '${BOOT_IMAGE}' in '${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
+ cp "${KERNEL_SYSTEM_PATH}" "${MODULE_BUILD_DIR}/kernel" \
+ || perror "Copy of kernel failed: From '${KERNEL_SYSTEM_PATH}' to '${MODULE_BUILD_DIR}/kernel'"
+}
+
+post_copy() {
+ :
+}
+
diff --git a/core/modules/kernel-system/module.conf b/core/modules/kernel-system/module.conf
new file mode 100644
index 00000000..0cd03752
--- /dev/null
+++ b/core/modules/kernel-system/module.conf
@@ -0,0 +1,3 @@
+REQUIRED_BINARIES=""
+REQUIRED_LIBRARIES=""
+REQUIRED_DIRECTORIES=""
diff --git a/core/modules/kernel-system/module.conf.fedora b/core/modules/kernel-system/module.conf.fedora
new file mode 100644
index 00000000..cf683784
--- /dev/null
+++ b/core/modules/kernel-system/module.conf.fedora
@@ -0,0 +1,6 @@
+REQUIRED_INSTALLED_PACKAGES="
+ kernel-headers
+"
+REQUIRED_CONTENT_PACKAGES="
+ kernel-headers
+"
diff --git a/core/modules/kernel-system/module.conf.opensuse b/core/modules/kernel-system/module.conf.opensuse
new file mode 100644
index 00000000..6bfc2078
--- /dev/null
+++ b/core/modules/kernel-system/module.conf.opensuse
@@ -0,0 +1,6 @@
+REQUIRED_INSTALLED_PACKAGES="
+ kernel-desktop-devel
+"
+REQUIRED_CONTENT_PACKAGES="
+ kernel-desktop-devel
+"
diff --git a/core/modules/kernel-system/module.conf.ubuntu b/core/modules/kernel-system/module.conf.ubuntu
new file mode 100644
index 00000000..2f2ce122
--- /dev/null
+++ b/core/modules/kernel-system/module.conf.ubuntu
@@ -0,0 +1,7 @@
+REQUIRED_INSTALLED_PACKAGES="
+ linux-headers-${SYSTEM_KERNEL_LONG}
+"
+REQUIRED_CONTENT_PACKAGES="
+ linux-headers-${SYSTEM_KERNEL_LONG}
+"
+
diff --git a/core/modules/kernel-system/patch-speaker b/core/modules/kernel-system/patch-speaker
new file mode 100755
index 00000000..5d5a9f9a
--- /dev/null
+++ b/core/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