summaryrefslogtreecommitdiffstats
path: root/core/modules/kernel
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
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')
-rw-r--r--core/modules/kernel/.gitignore3
-rw-r--r--core/modules/kernel/module.build146
-rw-r--r--core/modules/kernel/module.conf3
-rw-r--r--core/modules/kernel/module.conf.centos3
-rw-r--r--core/modules/kernel/module.conf.fedora3
-rw-r--r--core/modules/kernel/module.conf.opensuse3
-rw-r--r--core/modules/kernel/module.conf.ubuntu2
-rw-r--r--core/modules/kernel/module.conf.ubuntu.13.042
-rw-r--r--core/modules/kernel/module.conf.ubuntu.14.042
-rwxr-xr-xcore/modules/kernel/patch-speaker6
10 files changed, 173 insertions, 0 deletions
diff --git a/core/modules/kernel/.gitignore b/core/modules/kernel/.gitignore
new file mode 100644
index 00000000..56c69270
--- /dev/null
+++ b/core/modules/kernel/.gitignore
@@ -0,0 +1,3 @@
+ksrc
+linux*
+openslx.config
diff --git a/core/modules/kernel/module.build b/core/modules/kernel/module.build
new file mode 100644
index 00000000..f2245ee0
--- /dev/null
+++ b/core/modules/kernel/module.build
@@ -0,0 +1,146 @@
+# Customized kernel from system: fetch Distro's kernel sources, patch configuration, recompile
+
+# This overrides get_kernel_version from kernel.inc, so the variables will be set properly
+get_kernel_version() {
+ # Do not use MODULE_DIR here as this function might run when we process another module!
+ [ -n "${TARGET_KERNEL_LONG}" ] && return 0
+ [ ! -e "${ROOT_DIR}/tmp/work/kernel/ksrc/include/generated/utsrelease.h" ] && return 0
+ # determine kernel version that will be running in the generated system
+
+ # declare kernel version stuff
+ declare -rg TARGET_KERNEL_LONG=$(grep 'UTS_RELEASE' "${ROOT_DIR}/tmp/work/kernel/ksrc/include/generated/utsrelease.h" | awk -F '"' '{print $2}')
+ declare -rg TARGET_KERNEL_SHORT=$(echo "$TARGET_KERNEL_LONG" | grep -o -E '^[0-9\.]+')
+
+ # declare path to kernel headers and modules/firmware
+ declare -rg KERNEL_HEADERS_DIR="${ROOT_DIR}/tmp/work/kernel/ksrc"
+ declare -rg KERNEL_BASE_DIR="${ROOT_DIR}/tmp/work/kernel/build"
+
+ # 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() {
+ pdebug "getting kernel sources via git ...."
+ [ -d ./ksrc ] && rm -rf ./ksrc
+ git clone --depth 1 "${REQUIRED_GIT}" -b "${REQUIRED_GIT_BRANCH}" ksrc || perror "Could not clone kernel git."
+ # check for aufs
+ local RSL=$(find ksrc/ -type d -name aufs)
+ if [ -z "$RSL" ]; then
+ pinfo "aufs not found in kernel sources, patching it..."
+ patch_aufs
+ else
+ pinfo "aufs detected in kernel source :)"
+ fi
+ # remember the current kernel version
+ echo "${SYSTEM_KERNEL_LONG}" > ksrc/KVERSION
+}
+
+build() {
+ local TARGET_CONFIG_FILE="openslx.config"
+ 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')."
+ if [ "x$MLTK_QUIET" = "x1" ]; then
+ make olddefconfig || perror "make olddefconfig failed."
+ else
+ make oldconfig || perror "make oldconfig failed."
+ fi
+ make prepare || perror "make prepare failed."
+ make scripts || perror "make scripts failed."
+
+ pinfo "Compiling kernel... (this will take some time)"
+ # explicitly state number of cores here, as MAKEFLAGS seems to be overridden
+ make "-j$CPU_CORES" || perror "make failed."
+
+ # install modules to build directory
+ pinfo "Installing kernel modules..."
+ if [ -d "${MODULE_BUILD_DIR}/lib/modules" ]; then
+ rm -r "${MODULE_BUILD_DIR}/lib/modules" || pwarning "Could not clean old modules."
+ fi
+ 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"
+ pinfo "Kernel was successfully built at ${MODULE_BUILD_DIR}/kernel"
+ [ -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 -E "^\s*$(echo "$CONFIG_PARAM_NAME" | escape_search)=" "$BASE_CONFIG_FILE")"
+
+ #echo "Process: $SEARCH_RESULT"
+ # analyse results
+ if [ "x$SEARCH_RESULT" == "x" ]; then
+ # no match, add it
+ sed -i -r "s/^\s*#.*\s$(echo "$CONFIG_PARAM_NAME" | escape_search)[^_A-Z0-9].*$//" "$TARGET_CONFIG_FILE"
+ echo "$WANTED_CONFIG" >> "$TARGET_CONFIG_FILE"
+ else
+ # match, change to our setting if they differ
+ if [ "x$SEARCH_RESULT" != "x$WANTED_CONFIG" ]; then
+ sed -i "s/$(echo "$SEARCH_RESULT" | escape_search)/$(echo "$WANTED_CONFIG" | escape_replace)/" "$TARGET_CONFIG_FILE"
+ fi
+ fi
+ done
+}
+
+# helper to patch aufs
+patch_aufs() {
+ pinfo "Cloning aufs3 standalone git"
+ cd "$MODULE_WORK_DIR"
+ [ -d "aufs3-standalone/.git" ] && rm -rf "aufs3-standalone" # if already there, kill it.
+ # git: --depth 1 won't work here due to later "checkout origin/branch"
+ git clone "git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git" || perror "Cloning aufs3 failed."
+ # get the needed version
+ [ ! -z ${SYSTEM_KERNEL_LONG} ] && local NEEDED_BRANCH=$(echo $SYSTEM_KERNEL_LONG | awk -F "." '{print $1"."$2}') \
+ || perror "SYSTEM_KERNEL_LONG not set, this should not happen!"
+ pinfo "Getting branch origin/$NEEDED_BRANCH"
+ cd "$MODULE_WORK_DIR/aufs3-standalone" || perror "Could not CD to aufs3-standalone"
+ git checkout "origin/aufs$NEEDED_BRANCH" || perror "Could not checkout needed branch."
+ pinfo "Starting to patch... $NEEDED_BRANCH"
+ tarcopy "Documentation fs" "$MODULE_WORK_DIR/ksrc"
+
+ # Quick-and-dirty aufs_type.h copying:
+ [ -e "include/linux/aufs_type.h" ] && cp "include/linux/aufs_type.h" "$MODULE_WORK_DIR/ksrc/include/linux/"
+ [ -e "include/uapi/linux/aufs_type.h" ] && cp "include/uapi/linux/aufs_type.h" "$MODULE_WORK_DIR/ksrc/include/uapi/linux/"
+
+ cd "$MODULE_WORK_DIR/ksrc" || perror "Could not CD to kernel-source dir ksrc"
+
+ patch -p1 < "$MODULE_WORK_DIR/aufs3-standalone/aufs3-kbuild.patch" || perror "aufs3-standalone/aufs3-kbuild.patch failed!"
+ patch -p1 < "$MODULE_WORK_DIR/aufs3-standalone/aufs3-base.patch" || perror "aufs3-standalone/aufs3-base.patch failed!"
+
+ # this following 'if' is a burning shame - caused as patching under eg. openSuse 13.1 is always unsuccessful due to hunk failing
+ if [ -f "$MODULE_WORK_DIR/aufs3-standalone/aufs3-mmap.patch" ]; then
+ patch -p1 < "$MODULE_WORK_DIR/aufs3-standalone/aufs3-mmap.patch" || pwarning "Problem patching aufs3-mmap.patch: hunks failed?"
+ fi
+ pinfo "Patched kernel source with aufs-${NEEDED_BRANCH}"
+ cd "$MODULE_WORK_DIR"
+}
+
diff --git a/core/modules/kernel/module.conf b/core/modules/kernel/module.conf
new file mode 100644
index 00000000..0cd03752
--- /dev/null
+++ b/core/modules/kernel/module.conf
@@ -0,0 +1,3 @@
+REQUIRED_BINARIES=""
+REQUIRED_LIBRARIES=""
+REQUIRED_DIRECTORIES=""
diff --git a/core/modules/kernel/module.conf.centos b/core/modules/kernel/module.conf.centos
new file mode 100644
index 00000000..2e958ce4
--- /dev/null
+++ b/core/modules/kernel/module.conf.centos
@@ -0,0 +1,3 @@
+REQUIRED_GIT_BRANCH="v${SYSTEM_KERNEL_SHORT%.0}"
+REQUIRED_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
+
diff --git a/core/modules/kernel/module.conf.fedora b/core/modules/kernel/module.conf.fedora
new file mode 100644
index 00000000..53e6ccb6
--- /dev/null
+++ b/core/modules/kernel/module.conf.fedora
@@ -0,0 +1,3 @@
+REQUIRED_GIT_BRANCH="v${SYSTEM_KERNEL_SHORT}"
+REQUIRED_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
+
diff --git a/core/modules/kernel/module.conf.opensuse b/core/modules/kernel/module.conf.opensuse
new file mode 100644
index 00000000..cdf57cc7
--- /dev/null
+++ b/core/modules/kernel/module.conf.opensuse
@@ -0,0 +1,3 @@
+REQUIRED_GIT_BRANCH="openSUSE-${SYS_VERSION}"
+REQUIRED_GIT="git://kernel.opensuse.org/kernel.git"
+
diff --git a/core/modules/kernel/module.conf.ubuntu b/core/modules/kernel/module.conf.ubuntu
new file mode 100644
index 00000000..1cab5fcd
--- /dev/null
+++ b/core/modules/kernel/module.conf.ubuntu
@@ -0,0 +1,2 @@
+REQUIRED_GIT_BRANCH="master"
+REQUIRED_GIT="git://kernel.ubuntu.com/ubuntu/ubuntu-${SYS_CODENAME}.git"
diff --git a/core/modules/kernel/module.conf.ubuntu.13.04 b/core/modules/kernel/module.conf.ubuntu.13.04
new file mode 100644
index 00000000..e9192f01
--- /dev/null
+++ b/core/modules/kernel/module.conf.ubuntu.13.04
@@ -0,0 +1,2 @@
+REQUIRED_GIT_BRANCH="-b master"
+REQUIRED_GIT="git://kernel.ubuntu.com/ubuntu-archive/ubuntu-${SYS_CODENAME}.git $REQUIRED_GIT_BRANCH"
diff --git a/core/modules/kernel/module.conf.ubuntu.14.04 b/core/modules/kernel/module.conf.ubuntu.14.04
new file mode 100644
index 00000000..77ae8d18
--- /dev/null
+++ b/core/modules/kernel/module.conf.ubuntu.14.04
@@ -0,0 +1,2 @@
+REQUIRED_GIT_BRANCH="lts-backport-vivid"
+REQUIRED_GIT="git://kernel.ubuntu.com/ubuntu/ubuntu-${SYS_CODENAME}.git"
diff --git a/core/modules/kernel/patch-speaker b/core/modules/kernel/patch-speaker
new file mode 100755
index 00000000..5d5a9f9a
--- /dev/null
+++ b/core/modules/kernel/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