summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2013-04-24 17:15:47 +0200
committerJonathan Bauer2013-04-24 17:15:47 +0200
commita0bd2b22b8db8e5d16333852467d07a1cf2f8c82 (patch)
tree102178175cf80c255c5875f294d02d672106ecd6
parentgitignore kernel build stuff (diff)
downloadtm-scripts-a0bd2b22b8db8e5d16333852467d07a1cf2f8c82.tar.gz
tm-scripts-a0bd2b22b8db8e5d16333852467d07a1cf2f8c82.tar.xz
tm-scripts-a0bd2b22b8db8e5d16333852467d07a1cf2f8c82.zip
compile kernel on the reference system with our config requirements
-rw-r--r--data/kernel.wanted.config1
-rw-r--r--helper/kernel.inc90
-rw-r--r--helper/system.inc4
-rwxr-xr-xmltk17
-rw-r--r--remote/modules/kernel/.gitignore5
-rw-r--r--remote/modules/kernel/kernel.build81
-rw-r--r--remote/modules/kernel/kernel.conf3
-rw-r--r--remote/rootfs/rootfs-stage31/rootfs-stage31.build1
-rw-r--r--remote/rootfs/rootfs-stage31/rootfs-stage31.conf3
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.build2
-rw-r--r--remote/rootfs/rootfs-stage32/rootfs-stage32.conf1
-rwxr-xr-xremote/setup_target8
l---------remote/targets/stage31/kernel1
l---------remote/targets/stage32/kernel1
14 files changed, 138 insertions, 80 deletions
diff --git a/data/kernel.wanted.config b/data/kernel.wanted.config
index b8101eae..35aceb6a 100644
--- a/data/kernel.wanted.config
+++ b/data/kernel.wanted.config
@@ -237,6 +237,7 @@ CONFIG_NS83820=y
CONFIG_PARPORT=y
CONFIG_PCH_GBE=y
CONFIG_PCMCIA_XIRCOM=y
+CONFIG_PCNET32=y
CONFIG_QLA3XXX=y
CONFIG_QLCNIC=y
CONFIG_QLGE=y
diff --git a/helper/kernel.inc b/helper/kernel.inc
index bae07afa..41a9c507 100644
--- a/helper/kernel.inc
+++ b/helper/kernel.inc
@@ -15,48 +15,37 @@
# this code depends on KERNEL_VERSION, this file needs to be sourced after helper/system.inc!
# (TODO: maybe source system.inc if KERNEL_VERSION is empty.
-#[ -z "${KERNEL_VERSION}" ] && perror "KERNEL_VERSION not set. Was helper/system.inc sourced?"
-
-KERNEL_NFS_DIR=""
-mount_kernel_dir() {
- [ -z "$KERNEL_NFS_DIR" ] || return 0
- KERNEL_NFS_DIR="$(mktemp -d)"
- mount -t nfs -o ro "132.230.8.228:/srv/openslx/kernel" "$KERNEL_NFS_DIR"
- local RET=$?
- if [ "x$RET" != "x0" ]; then
- local BROKEN_KERNEL_NFS_DIR="${KERNEL_NFS_DIR}"
- KERNEL_NFS_DIR=""
- perror "Mounting kernel nfs dir to $BROKEN_KERNEL_NFS_DIR failed. Is 'nfs-common' installed?"
- exit 1
- fi
- #pinfo "$KERNEL_NFS_DIR/$SELECTED_KERNEL"
- #qnd_exit
- [ -d "$KERNEL_NFS_DIR/$SELECTED_KERNEL" ] || perror "directory for $KERNEL_VERSION ($SELECTED_KERNEL) does not exist on NFS server"
-}
-
-unmount_kernel_dir() {
- [ -z "$KERNEL_NFS_DIR" ] && return 0
- pinfo "Unmounting kernel nfs stuff....."
- umount "$KERNEL_NFS_DIR" || perror "Could not unmount kernel NFS share at '$KERNEL_NFS_DIR' - check the following lsof output:\n$(lsof -n | grep "$KERNEL_NFS_DIR")\n- End of lsof output -"
- rmdir "$KERNEL_NFS_DIR"
- KERNEL_NFS_DIR=""
+if [ -z "${KERNEL_VERSION}" ]; then
+ . ${ROOT_DIR}/helper/system.inc
+ [ -z "${KERNEL_VERSION}" ] && perror "KERNEL_VERSION still not set after sourcing, something is very wrong..."
+fi
+
+# set global KERNEL_TARGET_NAME
+KERNEL_TARGET_NAME="vmlinuz-${KERNEL_VERSION}-openslx"
+
+check_kernel_build_dir() {
+ [ -d "${MODULES_DIR}/kernel/build" ] && KERNEL_BUILD_DIR="${MODULES_DIR}/kernel/build" \
+ || perror "No build directory set for the kernel. Was is built?"
+ # hack to get the real path of the installed modules
+ KERNEL_NEW_VERSION=$(ls ${KERNEL_BUILD_DIR}/lib/modules)
}
copy_kernel_modules() {
[ -z "${REQUIRED_KERNEL_MODULES}" ] && perror "REQUIRED_KERNEL_MODULES is empty. Check your config file."
-
+ check_kernel_build_dir
#
# process modules list
- #
- mount_kernel_dir
- mkdir -p "${TARGET_BUILD_DIR}/${KERNEL_MODULES_DIR}"
- cd "$KERNEL_NFS_DIR/$SELECTED_KERNEL" || perror "Could not cd to $KERNEL_NFS_DIR/$SELECTED_KERNEL"
- local KERNEL_MODULES_DIR="lib/modules/${KERNEL_VERSION}"
+ #
+ # search for modules in KERNEL_BUILD_DIR
+ cd "${KERNEL_BUILD_DIR}" || perror "Could not cd to ${KERNEL_BUILD_DIR}"
+
+ local KERNEL_MODULES_DIR="lib/modules/${KERNEL_NEW_VERSION}"
local KERNEL_MODULES_LIST=""
+
for KERNEL_MODULE in ${REQUIRED_KERNEL_MODULES}; do
local KERNEL_MODULE_PATH="${KERNEL_MODULES_DIR}/${KERNEL_MODULE}"
- if grep "^${KERNEL_MODULE}$" "${KERNEL_NFS_DIR}/${SELECTED_KERNEL}/${KERNEL_MODULES_DIR}/modules.builtin" >/dev/null; then
+ if grep "^${KERNEL_MODULE}$" "${KERNEL_BUILD_DIR}/${KERNEL_MODULES_DIR}/modules.builtin" >/dev/null; then
pdebug "Already built-in ${KERNEL_MODULE}."
elif [ -e "${KERNEL_MODULE_PATH}" ]; then
pdebug "Copying '${KERNEL_MODULE_PATH}'"
@@ -82,7 +71,7 @@ copy_kernel_modules() {
# copy list of builtin kernel modules
cp "${KERNEL_MODULES_DIR}/modules.builtin" "${TARGET_BUILD_DIR}/${KERNEL_MODULES_DIR}"
# with modules.order and modules.builtin, we can run depmod for the rest of the files
- depmod -b "${TARGET_BUILD_DIR}" -a "${KERNEL_VERSION}"
+ depmod -b "${TARGET_BUILD_DIR}" -a "${KERNEL_NEW_VERSION}"
cd - >/dev/null
}
@@ -90,17 +79,16 @@ copy_kernel_modules() {
copy_firmware() {
[ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file."
-
+ check_kernel_build_dir
#
# process firmware list
#
- mount_kernel_dir
- cd "$KERNEL_NFS_DIR/$SELECTED_KERNEL" || perror "Could not cd to $KERNEL_NFS_DIR/$SELECTED_KERNEL"
+ cd "${KERNEL_BUILD_DIR}" || perror "Could not cd!"
local FIRMWARE_DIR="lib/firmware"
local FIRMWARE_LIST=""
for FIRMWARE in ${REQUIRED_FIRMWARE}; do
local FOUND=0
- for CANDIDATE in "${FIRMWARE_DIR}/${FIRMWARE}" "${FIRMWARE_DIR}/${KERNEL_VERSION}/${FIRMWARE}"; do
+ for CANDIDATE in "${FIRMWARE_DIR}/${FIRMWARE}" "${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}"; do
if [ -e "${CANDIDATE}" ]; then
pdebug "Copying '${CANDIDATE}'"
FIRMWARE_LIST+=" ${CANDIDATE}"
@@ -108,7 +96,7 @@ copy_firmware() {
fi
done
- [ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${KERNEL_VERSION}/${FIRMWARE}' "\
+ [ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}' "\
" was found on the system. Skipping. (might cause problems on certain clients!)"
done
@@ -122,29 +110,13 @@ copy_firmware() {
copy_kernel() {
- local KERNEL_NAME="vmlinuz-${KERNEL_VERSION}"
-
local TOOL_STR="$TOOL_STR copy_kernel:"
- [ ! -d "${KERNEL_DIR}" ] && mkdir -p "${KERNEL_DIR}"
-
- pinfo "Copying '${KERNEL_NAME}' to '${KERNEL_DIR}'."
- mount_kernel_dir
-
- cp "$KERNEL_NFS_DIR/$SELECTED_KERNEL/bzImage" "$KERNEL_DIR/$KERNEL_NAME" || perror "Could not copy kernel from '$KERNEL_NFS_DIR/$SELECTED_KERNEL/bzImage' to '$KERNEL_DIR/$KERNEL_NAME'"
+ check_kernel_build_dir
+ local KERNEL_DIR="${MODE_DIR}/builds/kernel"
+ pinfo "Copying '${KERNEL_TARGET_NAME}' to '${KERNEL_DIR}'."
+ [ -d "${KERNEL_DIR}" ] || mkdir -p "${KERNEL_DIR}"
+ cp "${KERNEL_BUILD_DIR}/${KERNEL_TARGET_NAME}" "${KERNEL_DIR}" || perror "Could not copy kernel!"
pinfo "You may want to update your systems firmware/modules to match the current kernel."
}
-
-fetch_source() {
-
- if [ "x$PACKET_MANAGER" == "apt" ]; then
- apt-get source linux-image-${KERNEL_VERSION}
- elif [ "x$PACKET_MANAGER" == "zypper" ]; then
- # TODO
- fi
-}
-build_kernel() {
- :
-}
-
diff --git a/helper/system.inc b/helper/system.inc
index 21e92422..4c0ea467 100644
--- a/helper/system.inc
+++ b/helper/system.inc
@@ -11,8 +11,8 @@ ARCH_LIB_DIR=$(ldd $SHELL | grep "libc.so" | sed -r 's#^.*(/lib.*)/libc.so.*$#\1
[ -z "$ARCH_LIB_DIR" -o ! -d "$ARCH_LIB_DIR" ] && perror "Could not determine arch dependent lib dir (where libc.so resides)"
# determine kernel version
-#KERNEL_VERSION=$(uname -r)
-#[ ! -z $KERNEL_VERSION ] || pwarning "Could not determine kernel version."
+KERNEL_VERSION=$(uname -r)
+[ ! -z $KERNEL_VERSION ] || pwarning "Could not determine kernel version."
# determine number of CPU cores
CPU_CORES=$(cat /proc/cpuinfo | grep processor | wc -l)
diff --git a/mltk b/mltk
index 35ddac5a..137b4969 100755
--- a/mltk
+++ b/mltk
@@ -34,13 +34,13 @@ for HELPER in $ROOT_DIR/helper/*.inc; do
done
# TODO: Configurable!
-if [ "$(uname -p)" = "x86_64" ]; then
- KERNEL_VERSION="3.4.0-1.16-default+"
- SELECTED_KERNEL="x86_64/$KERNEL_VERSION"
-else
- KERNEL_VERSION="3.4.0-1.16-default"
- SELECTED_KERNEL="x86_32/$KERNEL_VERSION"
-fi
+#if [ "$(uname -p)" = "x86_64" ]; then
+# KERNEL_VERSION="3.2.40"
+# SELECTED_KERNEL="x86_64/$KERNEL_VERSION"
+#else
+# KERNEL_VERSION="3.2.40"
+# SELECTED_KERNEL="x86_32/$KERNEL_VERSION"
+#fi
banner () {
echo -e "\033[38;5;202m\t __ __ __ "
@@ -237,6 +237,3 @@ initial_checks
read_params $@
run
-
-unmount_kernel_dir
-
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=""
diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.build b/remote/rootfs/rootfs-stage31/rootfs-stage31.build
index 9030e972..19a5838a 100644
--- a/remote/rootfs/rootfs-stage31/rootfs-stage31.build
+++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.build
@@ -22,6 +22,7 @@ post_copy() {
generate_rootfs
copy_kernel_modules
copy_firmware
+ copy_kernel
# copy busybox that has been under /openslx back to /
cp -r "${TARGET_BUILD_DIR}"/openslx/* "${TARGET_BUILD_DIR}"
diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf
index 6d4af2c9..788ff8b3 100644
--- a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf
+++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf
@@ -1,4 +1,5 @@
-REQUIRED_MODULES=" busybox"
+REQUIRED_MODULES=" busybox
+ kernel"
REQUIRED_KERNEL_MODULES=" kernel/drivers/video/sis/sisfb.ko
kernel/drivers/video/via/viafb.ko
kernel/drivers/acpi/video.ko
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build
index a14bdfa4..e7c1d5f3 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build
@@ -99,6 +99,6 @@ post_copy() {
else
pinfo "Not copying firmware from system, as '${TARGET_BUILD_DIR}/lib/firmware' already exists."
fi
-
+ copy_kernel
}
diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
index 15bd0908..d2c1e5a9 100644
--- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
+++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf
@@ -1,3 +1,4 @@
+REQUIRED_MODULES=" kernel"
REQUIRED_DEPENDENCIES="nfs-common aufs-tools squashfs-tools whois xfsprogs"
REQUIRED_BINARIES=" bash
more
diff --git a/remote/setup_target b/remote/setup_target
index e004d8bd..c070f1fc 100755
--- a/remote/setup_target
+++ b/remote/setup_target
@@ -3,8 +3,6 @@
MODE_DIR="${ROOT_DIR}/remote"
MODULES_DIR="${MODE_DIR}/modules"
-KERNEL_DIR="${MODE_DIR}/builds/kernel"
-
# Keep track of processed modules
PROCESSED_MODULES=""
@@ -136,7 +134,7 @@ copy_files_with_deps () {
generate_target() {
initial_checks
- copy_kernel
+ #copy_kernel
TARGET=$1 && shift
TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
@@ -215,8 +213,8 @@ process_module() {
pinfo "## Building"
[ -e "${MODULE_DIR}/.built" ] || { build && touch "${MODULE_DIR}/.built"; }
# remove *.la files as they might confuse libtool/linker of other tool packages
- find "${MODULE_BUILD_DIR}" -name '*.la' -exec rm -f {} \;
- [ -d "$TARGET_BUILD_DIR" ] && TARGET_BUILD_SIZE=$(du -bc "${TARGET_BUILD_DIR}" | awk 'END {print $1}') || TARGET_BUILD_SIZE=0
+ [ -d "${MODULE_BUILD_DIR}" ] && find "${MODULE_BUILD_DIR}" -name '*.la' -exec rm -f {} \;
+ [ -d "${TARGET_BUILD_DIR}" ] && TARGET_BUILD_SIZE=$(du -bc "${TARGET_BUILD_DIR}" | awk 'END {print $1}') || TARGET_BUILD_SIZE=0
pinfo "## Copying files with dependencies"
copy_files_with_deps
pinfo "## Copying static module files"
diff --git a/remote/targets/stage31/kernel b/remote/targets/stage31/kernel
new file mode 120000
index 00000000..044f086d
--- /dev/null
+++ b/remote/targets/stage31/kernel
@@ -0,0 +1 @@
+../../modules/kernel \ No newline at end of file
diff --git a/remote/targets/stage32/kernel b/remote/targets/stage32/kernel
new file mode 120000
index 00000000..044f086d
--- /dev/null
+++ b/remote/targets/stage32/kernel
@@ -0,0 +1 @@
+../../modules/kernel \ No newline at end of file