summaryrefslogtreecommitdiffstats
path: root/remote
diff options
context:
space:
mode:
authorSimon Rettberg2014-07-04 20:04:41 +0200
committerSimon Rettberg2014-07-04 20:04:41 +0200
commitb7a021b2df67c6d08457df32f3ba1514897ac70b (patch)
treef038199bdd92329808f1c54bf41d646d9dfe6fd3 /remote
parent[downloader.inc] Special case sourceforge: Allow setting a mirror in ./config (diff)
downloadtm-scripts-b7a021b2df67c6d08457df32f3ba1514897ac70b.tar.gz
tm-scripts-b7a021b2df67c6d08457df32f3ba1514897ac70b.tar.xz
tm-scripts-b7a021b2df67c6d08457df32f3ba1514897ac70b.zip
Try to clean up the mess with all the different kernel version variables everywhere
Diffstat (limited to 'remote')
-rw-r--r--remote/includes/kernel.inc76
-rw-r--r--remote/modules/dnbd3/module.build2
-rw-r--r--remote/modules/kernel-system/module.build92
-rw-r--r--remote/modules/kernel-system/module.conf.ubuntu5
-rw-r--r--remote/modules/kernel/module.build57
-rw-r--r--remote/modules/nvidia_kernel/module.build2
-rw-r--r--remote/modules/vmware/module.build16
-rw-r--r--remote/rootfs/rootfs-stage31/module.build4
-rwxr-xr-xremote/setup_target19
9 files changed, 107 insertions, 166 deletions
diff --git a/remote/includes/kernel.inc b/remote/includes/kernel.inc
index 3acb1810..941e2621 100644
--- a/remote/includes/kernel.inc
+++ b/remote/includes/kernel.inc
@@ -7,30 +7,22 @@
# copies kernel modules as given in the module config file
# * depends on 'depmod'
# * requires REQUIRED_KERNEL_MODULES to be set.
-# (entries must be a relative path to /lib/modules/<KERNEL_CURRENT_VERSION>)
+# (entries must be a relative path to /lib/modules/<SYSTEM_KERNEL_LONG>)
#
# ex: for /lib/modules/3.2.0/kernel/fs/nfs/nfs.ko
# must be given as kernel/fs/nfs/nfs.ko
#
-# set global KERNEL_TARGET_NAME
-KERNEL_TARGET_NAME="kernel"
-
# set global KERNEL_BASE_DIR as in the directory containing lib/modules and lib/firmware
# for system kernel, that is "/" and for an openslx kernel KERNEL_BUILD_DIR
KERNEL_BASE_DIR=""
get_kernel_version () {
- # determine kernel version currently running on this machine
- [ -z "$KERNEL_CURRENT_VERSION" ] && declare -rg KERNEL_CURRENT_VERSION="$(uname -r)"
- [ -z "$KERNEL_CURRENT_VERSION" ] && pwarning "Could not determine kernel version."
-
- # set empty SYS_UTS_RELEASE and SYS_KERNEL
- SYS_UTS_RELEASE="(unknown)"
- SYS_KERNEL="$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+')"
- # System kernel version
- SYSTEM_KERNEL_LONG=$(uname -r)
- SYSTEM_KERNEL_SHORT=$(grep -o -E '^[0-9\.]+' <<<$SYSTEM_KERNEL_LONG)
+ # Running system kernel version
+ if [ -z "$SYSTEM_KERNEL_LONG" ]; then
+ declare -rg SYSTEM_KERNEL_LONG=$(uname -r)
+ declare -rg SYSTEM_KERNEL_SHORT=$(grep -o -E '^[0-9\.]+' <<<$SYSTEM_KERNEL_LONG)
+ fi
}
check_kernel_base_dir () {
@@ -50,9 +42,9 @@ check_kernel_base_dir () {
}
copy_kernel_modules () {
- pinfo "Copying kernel modules for kernel ${KERNEL_CURRENT_VERSION}..."
+ pinfo "Copying kernel modules for kernel ${SYSTEM_KERNEL_LONG}..."
[ -z "${REQUIRED_KERNEL_MODULES}" ] && perror "REQUIRED_KERNEL_MODULES is empty. Check your config file."
- [ -z "${KERNEL_HEADERS_PATH}" ] && perror "KERNEL_HEADERS_PATH is empty. Kernel headers appears to be missing."
+ [ -z "${KERNEL_HEADERS_DIR}" ] && perror "KERNEL_HEADERS_DIR is empty. Kernel headers appears to be missing."
check_kernel_base_dir
@@ -65,7 +57,7 @@ copy_kernel_modules () {
# search for modules in KERNEL_BASE_DIR
cd "${KERNEL_BASE_DIR}" || perror "Could not cd to ${KERNEL_BASE_DIR}"
- local KERNEL_MODULES_DIR="lib/modules/${KERNEL_NEW_VERSION}"
+ local KERNEL_MODULES_DIR="lib/modules/${TARGET_KERNEL_LONG}"
local KERNEL_MODULES_LIST=""
local REQUIRED_KERNEL_MODULES_EXPANDED=""
local KERNEL_MODULE=""
@@ -125,7 +117,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_NEW_VERSION}"
+ depmod -b "${TARGET_BUILD_DIR}" -a "${TARGET_KERNEL_LONG}"
# go back to wherever we were
cd "${OLD_DIR}" || perror "Could not cd back to ${OLD_DIR}."
@@ -133,7 +125,7 @@ copy_kernel_modules () {
copy_firmware () {
- pinfo "Copying firmware for kernel ${KERNEL_CURRENT_VERSION}..."
+ pinfo "Copying firmware for kernel ${SYSTEM_KERNEL_LONG}..."
[ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file."
check_kernel_base_dir
@@ -148,7 +140,7 @@ copy_firmware () {
for FIRMWARE in ${REQUIRED_FIRMWARE}; do
local FOUND=0
# check for firmware in the build directory of the kernel
- for CANDIDATE in "${FIRMWARE_DIR}/${FIRMWARE}" "${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}"; do
+ for CANDIDATE in "${FIRMWARE_DIR}/${FIRMWARE}" "${FIRMWARE_DIR}/${TARGET_KERNEL_LONG}/${FIRMWARE}"; do
if [ -e "${CANDIDATE}" ]; then
pdebug "Copying from kernel base dir ('$KERNEL_BASE_DIR'): '${CANDIDATE}'"
FIRMWARE_LIST+=" ${CANDIDATE}"
@@ -158,28 +150,28 @@ copy_firmware () {
# dont look under / if KERNEL_BASE_DIR is already /
if [ "x${KERNEL_BASE_DIR}" == "x/" ]; then
- [ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}' found on the system"
+ [ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${TARGET_KERNEL_LONG}/${FIRMWARE}' found on the system"
continue
fi
# if we didn't found it in the kernel build directory, check for firmware in the system firmware directory
if [ $FOUND -ne 1 ]; then
pdebug "Did not found '$FIRMWARE' in kernel base dir. Searching system..."
- for CANDIDATE in "/${FIRMWARE_DIR}/${FIRMWARE}" "/${FIRMWARE_DIR}/${KERNEL_CURRENT_VERSION}/${FIRMWARE}"; do
+ for CANDIDATE in "/${FIRMWARE_DIR}/${FIRMWARE}" "/${FIRMWARE_DIR}/${SYSTEM_KERNEL_LONG}/${FIRMWARE}"; do
if [ -e "${CANDIDATE}" ]; then
- if [ $(echo "${CANDIDATE}" | grep -c "${KERNEL_CURRENT_VERSION}") -eq 0 ]; then
+ if [ $(echo "${CANDIDATE}" | grep -c "${SYSTEM_KERNEL_LONG}") -eq 0 ]; then
pdebug "Copying from system: '${CANDIDATE}'"
FIRMWARE_LIST+=" ${CANDIDATE}"
else
- pdebug "Copying from system: '${CANDIDATE}' to ${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}"
- FIRMWARE_LIST+=" /${FIRMWARE_DIR}/${KERNEL_CURRENT_VERSION}/${FIRMWARE}"
+ pdebug "Copying from system: '${CANDIDATE}' to ${FIRMWARE_DIR}/${TARGET_KERNEL_LONG}/${FIRMWARE}"
+ FIRMWARE_LIST+=" /${FIRMWARE_DIR}/${SYSTEM_KERNEL_LONG}/${FIRMWARE}"
fi
FOUND=1
fi
done
fi
- [ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}' "\
+ [ $FOUND -ne 1 ] && pwarning "Neither '${FIRMWARE_DIR}/${FIRMWARE}' nor '${FIRMWARE_DIR}/${TARGET_KERNEL_LONG}/${FIRMWARE}' "\
" was found on the system. Skipping. (might cause problems on certain clients!)"
done
@@ -192,16 +184,16 @@ copy_firmware () {
# only for kernel-openslx
# post-process to fix the path of the firmwares found on the system unter /lib/firmware/$(uname -r)
- # which have to be copied to /lib/firmware/${KERNEL_NEW_VERSION}
+ # which have to be copied to /lib/firmware/${TARGET_KERNEL_LONG}
if [ "x${KERNEL_BASE_DIR}" != "x/" ]; then
- if [ -d "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" ]; then
- mkdir -p "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_NEW_VERSION}/"
- cd "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" || perror "old kernel but no old kernel"
- tarcopy "$(ls)" "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_NEW_VERSION}/"
+ if [ -d "${TARGET_BUILD_DIR}/lib/firmware/${SYSTEM_KERNEL_LONG}" ]; then
+ mkdir -p "${TARGET_BUILD_DIR}/lib/firmware/${TARGET_KERNEL_LONG}/"
+ cd "${TARGET_BUILD_DIR}/lib/firmware/${SYSTEM_KERNEL_LONG}" || perror "old kernel but no old kernel"
+ tarcopy "$(ls)" "${TARGET_BUILD_DIR}/lib/firmware/${TARGET_KERNEL_LONG}/"
cd -
- rm -r "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" || perror "something went very wrong..."
+ rm -r "${TARGET_BUILD_DIR}/lib/firmware/${SYSTEM_KERNEL_LONG}" || perror "something went very wrong..."
else
- pdebug "No ${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION} directory, skipping the merge."
+ pdebug "No ${TARGET_BUILD_DIR}/lib/firmware/${SYSTEM_KERNEL_LONG} directory, skipping the merge."
fi
fi
@@ -216,23 +208,9 @@ copy_kernel () {
[ -d "${KERNEL_DIR}" ] || mkdir -p "${KERNEL_DIR}"
- # here we need special logic for the 2 different kind of kernels
- # if KERNEL_BASE_DIR is '/' then we are using the kernel-system module
- # else if it is '*tm-scripts/remote/modules/*" then we use the openslx-module
- # TODO til the configuration interface is done, it is ugly...
- if [ "${KERNEL_BASE_DIR}" = "/" ]; then
- # remote/modules/kernel-system/build/kernel
- cp "${MODULES_DIR}/kernel-system/build/kernel" "${KERNEL_DIR}" \
- || perror "Could not copy '${MODULES_DIR}/kernel-system/build/kernel' to '${KERNEL_DIR}'"
- pinfo "Copied '${MODULES_DIR}/kernel-system/build/kernel' to '${KERNEL_DIR}'"
- elif [[ "${KERNEL_BASE_DIR}" = *tm-scripts/remote/modules/kernel* ]]; then
- # kernel-openslx
- cp "${MODULES_DIR}/kernel/build/kernel" "${KERNEL_DIR}" \
- || perror "Could not copy '${MODULES_DIR}/kernel/build/kernel' to '${KERNEL_DIR}'"
- pinfo "Copied '${MODULES_DIR}/kernel/build/kernel' to '${KERNEL_DIR}'"
- fi
+ cp "${TARGET_DIR}/kernel/build/kernel" "${KERNEL_DIR}" || perror "Could not copy '${TARGET_DIR}/kernel/build/kernel' to '${KERNEL_DIR}'"
# kernel has 0600 perms since ubuntu 14.04, change that once we copied it
chmod +r "${KERNEL_DIR}/kernel"
- pinfo "You may want to update your systems firmware/modules to match the current kernel."
}
+
diff --git a/remote/modules/dnbd3/module.build b/remote/modules/dnbd3/module.build
index 2651daac..cdbd8251 100644
--- a/remote/modules/dnbd3/module.build
+++ b/remote/modules/dnbd3/module.build
@@ -25,7 +25,7 @@ HEREEND
build() {
cd "$MODULE_DIR/src/kmod" || perror "Could not CD to standalone dnbd3 kmod dir"
- make MODULE_NAME=dnbd3 KDIR="$KERNEL_HEADERS_PATH" || perror "Could not compile kernel module"
+ make MODULE_NAME=dnbd3 KDIR="$KERNEL_HEADERS_DIR" || perror "Could not compile kernel module"
mkdir -p "$MODULE_BUILD_DIR/lib/modules/dnbd3" || perror "Could not create lib/modules/dnbd3"
mkdir -p "$MODULE_BUILD_DIR/opt/openslx/bin" || perror "Coould not create opt/openslx/bin"
cp "$MODULE_DIR/src/kmod/dnbd3.ko" "$MODULE_BUILD_DIR/lib/modules/dnbd3/" || perror "could not cp dnbd3.ko"
diff --git a/remote/modules/kernel-system/module.build b/remote/modules/kernel-system/module.build
index d698db22..a5bd747c 100644
--- a/remote/modules/kernel-system/module.build
+++ b/remote/modules/kernel-system/module.build
@@ -1,42 +1,39 @@
-# overloaded get_kernel_version function
+# kernel-system: Try to use the system's kernel without recompiling
+
+# overloaded get_kernel_version function from kernel.inc
get_kernel_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 "/lib/modules/$KERNEL_CURRENT_VERSION/build" ]; then
- declare -rg KERNEL_HEADERS_PATH="/lib/modules/$KERNEL_CURRENT_VERSION/build" 2>/dev/null
- elif [ -d "/lib/modules/$KERNEL_CURRENT_VERSION/source" ]; then
- declare -rg KERNEL_HEADERS_PATH="/lib/modules/$KERNEL_CURRENT_VERSION/source" 2>/dev/null
- elif [ -d "/usr/src/linux-headers-$KERNEL_CURRENT_VERSION" ]; then
- declare -rg KERNEL_HEADERS_PATH="/usr/src/linux-headers-$KERNEL_CURRENT_VERSION" 2>/dev/null
- elif [ -d "/usr/src/kernels/$KERNEL_CURRENT_VERSION" ]; then
- declare -rg KERNEL_HEADERS_PATH="/usr/src/kernels/$KERNEL_CURRENT_VERSION" 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
+ [ -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/${KERNEL_CURRENT_VERSION}" -a \
- -d "/lib/firmware" ]; then
+ 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 '$KERNEL_CURRENT_VERSION'. \
- Does '/lib/modules/$KERNEL_CURRENT_VERSION' exist?"
+ perror "Could not find kernel modules / firmware for kernel version '$SYSTEM_KERNEL_LONG'. \
+ Does '/lib/modules/$SYSTEM_KERNEL_LONG' exist?"
fi
# print debug info
- pdebug "SYS_UTS_RELEASE: '$SYS_UTS_RELEASE'"
- pdebug "SYS_KERNEL: '$SYS_KERNEL'"
- pdebug "KERNEL_NEW_VERSION: '$KERNEL_NEW_VERSION'"
+ pinfo "TARGET_KERNEL_LONG: '$TARGET_KERNEL_LONG'"
+ pinfo "TARGET_KERNEL_SHORT: '$TARGET_KERNEL_SHORT'"
pdebug "KERNEL_BASE_DIR: '$KERNEL_BASE_DIR'"
}
@@ -44,13 +41,7 @@ get_kernel_version(){
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() {
@@ -87,34 +78,11 @@ build() {
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}'"
+ cp "${KERNEL_SYSTEM_PATH}" "${MODULE_BUILD_DIR}/kernel" \
+ || perror "Copy of kernel failed: From '${KERNEL_SYSTEM_PATH}' to '${MODULE_BUILD_DIR}/kernel'"
}
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."
}
-# currently not used
-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."
-
-}
diff --git a/remote/modules/kernel-system/module.conf.ubuntu b/remote/modules/kernel-system/module.conf.ubuntu
index 4d47b243..2f2ce122 100644
--- a/remote/modules/kernel-system/module.conf.ubuntu
+++ b/remote/modules/kernel-system/module.conf.ubuntu
@@ -1,6 +1,7 @@
REQUIRED_INSTALLED_PACKAGES="
- linux-headers-$(uname -r)
+ linux-headers-${SYSTEM_KERNEL_LONG}
"
REQUIRED_CONTENT_PACKAGES="
- linux-headers-$(uname -r)
+ linux-headers-${SYSTEM_KERNEL_LONG}
"
+
diff --git a/remote/modules/kernel/module.build b/remote/modules/kernel/module.build
index 9270024d..78179df6 100644
--- a/remote/modules/kernel/module.build
+++ b/remote/modules/kernel/module.build
@@ -1,28 +1,28 @@
+# 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() {
+ [ -n "${TARGET_KERNEL_LONG}" ] && return 0
+ [ ! -e "${MODULE_DIR}/ksrc/include/generated/utsrelease.h" ] && return 0
# determine kernel version that will be running in the generated system
- if [ -e "$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h" ]; then
- # declare kernel version stuff
- declare -rg SYS_UTS_RELEASE=$(grep 'UTS_RELEASE' "$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h" | awk -F '"' '{print $2}')
- declare -rg SYS_KERNEL=$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+')
- declare -rg KERNEL_NEW_VERSION="$SYS_UTS_RELEASE"
-
- # declare path to kernel headers and modules/firmware
- declare -rg KERNEL_HEADERS_PATH="$MODULES_DIR/kernel/ksrc"
- declare -rg KERNEL_BASE_DIR="$MODULES_DIR/kernel/build"
- fi
+
+ # declare kernel version stuff
+ declare -rg TARGET_KERNEL_LONG=$(grep 'UTS_RELEASE' "${MODULE_DIR}/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="${MODULE_DIR}/ksrc"
+ declare -rg KERNEL_BASE_DIR="${MODULE_DIR}/build"
# print debug info
- pdebug "SYS_UTS_RELEASE: '$SYS_UTS_RELEASE'"
- pdebug "SYS_KERNEL: '$SYS_KERNEL'"
- pdebug "KERNEL_NEW_VERSION: '$KERNEL_NEW_VERSION'"
+ pinfo "TARGET_KERNEL_LONG: '$TARGET_KERNEL_LONG'"
+ pinfo "TARGET_KERNEL_SHORT: '$TARGET_KERNEL_SHORT'"
pdebug "KERNEL_BASE_DIR: '$KERNEL_BASE_DIR'"
-
- # check the headers/src path
}
fetch_source() {
pdebug "getting kernel sources via git ...."
- [ -d ./ksrc ] && rm -rf ./ksrc # slightly brutal ...
+ [ -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)
@@ -33,16 +33,16 @@ fetch_source() {
pinfo "aufs detected in kernel source :)"
fi
# remember the current kernel version
- echo "${KERNEL_CURRENT_VERSION}" > ksrc/KVERSION
+ echo "${SYSTEM_KERNEL_LONG}" > ksrc/KVERSION
}
build() {
local TARGET_CONFIG_FILE="openslx.config"
- [ -e "${TARGET_CONFIG_FILE}" ] && rm -f "${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
+ 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')."
@@ -55,14 +55,9 @@ build() {
make scripts || perror "make scripts failed."
pinfo "Compiling kernel... (this will take some time)"
- if gcc --version | grep "4\.7" && which distcc; then
- pinfo "USING DISTCC"
- make CC="distcc gcc-4.7" -j16 || perror "make failed."
- else
- # explicitly state number of cores here, as MAKEFLAGS seems to be overridden
- make "-j$CPU_CORES" || perror "make failed."
- fi
-
+ # 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
@@ -72,8 +67,8 @@ build() {
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}"
+ 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}"
}
@@ -123,8 +118,8 @@ patch_aufs() {
# 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 ${KERNEL_CURRENT_VERSION} ] && local NEEDED_BRANCH=$(echo $KERNEL_CURRENT_VERSION | awk -F "." '{print $1"."$2}') \
- || perror "KERNEL_CURRENT_VERSION not set, this should not happen!"
+ [ ! -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_DIR/aufs3-standalone" || perror "Could not CD to aufs3-standalone"
git checkout "origin/aufs$NEEDED_BRANCH" || perror "Could not checkout needed branch."
diff --git a/remote/modules/nvidia_kernel/module.build b/remote/modules/nvidia_kernel/module.build
index a1275c70..648115c1 100644
--- a/remote/modules/nvidia_kernel/module.build
+++ b/remote/modules/nvidia_kernel/module.build
@@ -28,7 +28,7 @@ build() {
chroot_run "$ROOTUPPERDIR" <<-EOF
- /NVIDIA/nvidia-installer --no-nouveau-check --no-network --no-backup --no-rpms --no-runlevel-check --no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent --kernel-source-path /"$KERNEL_HEADERS_PATH" # Do the work!
+ /NVIDIA/nvidia-installer --no-nouveau-check --no-network --no-backup --no-rpms --no-runlevel-check --no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent --kernel-source-path /"$KERNEL_HEADERS_DIR" # Do the work!
# fake success since the installer will exit with an error due to the module not loading properly.
exit 0
EOF
diff --git a/remote/modules/vmware/module.build b/remote/modules/vmware/module.build
index 57e8cb91..094d5271 100644
--- a/remote/modules/vmware/module.build
+++ b/remote/modules/vmware/module.build
@@ -28,8 +28,8 @@ build() {
cp "${MODULE_DIR}/src/$VMWARE_BUNDLE_FILE" "${MODULE_BUILD_DIR}/$VMWARE_BUNDLE_FILE"
cp -r "${MODULE_DIR}/patches" "${MODULE_BUILD_DIR}"
- # sanity check to see if KERNEL_HEADERS_PATH is set and exists
- [ -z "${KERNEL_HEADERS_PATH}" -o ! -e "${KERNEL_HEADERS_PATH}" ] && perror "KERNEL_HEADERS_PATH ('"${KERNEL_HEADERS_PATH}"') not found. Was the kernel module built?"
+ # sanity check to see if KERNEL_HEADERS_DIR is set and exists
+ [ -z "${KERNEL_HEADERS_DIR}" -o ! -e "${KERNEL_HEADERS_DIR}" ] && perror "KERNEL_HEADERS_DIR ('"${KERNEL_HEADERS_DIR}"') not found. Was the kernel module built?"
# build in two steps, to be able to use mltk function while patching modules
pinfo "Installing vmware per chroot..."
@@ -49,11 +49,11 @@ build() {
for PATCH in $(find "${MODULE_DIR}/patches/" -name "${SHORT}__*__*.patch"); do
parse_patch_name "$PATCH"
[ -z "${MIN_KERN}" -o -z "${MAX_KERN}" ] && perror "Could not parse patch filename"
- if version_lt "$SYS_KERNEL" "$MIN_KERN" || version_gt "$SYS_KERNEL" "$MAX_KERN"; then
- pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$SYS_KERNEL)"
+ if version_lt "$TARGET_KERNEL_SHORT" "$MIN_KERN" || version_gt "$TARGET_KERNEL_SHORT" "$MAX_KERN"; then
+ pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
continue # Not suitable for our kernel
fi
- pinfo "Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$SYS_KERNEL)"
+ pinfo "Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)"
[ ! -d "${SHORT}-only" ] && tar xf "$KMOD"
[ ! -d "${SHORT}-only" ] && perror "untar of $KMOD failed."
cd "${SHORT}-only" || perror "Where is ${SHORT}-only?"
@@ -74,8 +74,8 @@ build() {
# now build modules inside the chroot
chroot_run "${MODULE_BUILD_DIR}" <<-EOF
- vmware-modconfig --console --build-mod -k "${SYS_UTS_RELEASE}" vmnet $(which gcc) "${KERNEL_HEADERS_PATH}/include" vmplayer vmnet
- vmware-modconfig --console --build-mod -k "${SYS_UTS_RELEASE}" vmmon $(which gcc) "${KERNEL_HEADERS_PATH}/include" vmplayer vmmon
+ vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmnet $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer vmnet
+ vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmmon $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer vmmon
EOF
# cleanup unneeded files
@@ -97,7 +97,7 @@ post_copy() {
date +'%Y.%m.%d' >"${TARGET_BUILD_DIR}/etc/arch-release"
mkdir -p "$TARGET_BUILD_DIR/lib/modules/vmware/"
- cp "${MODULE_BUILD_DIR}/lib/modules/$SYS_UTS_RELEASE/vmplayer/"* "$TARGET_BUILD_DIR/lib/modules/vmware/" || perror "Could not cp vmware modules to target!"
+ cp "${MODULE_BUILD_DIR}/lib/modules/$TARGET_KERNEL_LONG/vmplayer/"* "$TARGET_BUILD_DIR/lib/modules/vmware/" || perror "Could not cp vmware modules to target!"
}
parse_patch_name() {
diff --git a/remote/rootfs/rootfs-stage31/module.build b/remote/rootfs/rootfs-stage31/module.build
index bc45b6fd..ad2eedca 100644
--- a/remote/rootfs/rootfs-stage31/module.build
+++ b/remote/rootfs/rootfs-stage31/module.build
@@ -20,11 +20,11 @@ build() {
# generate drm module loading database
pinfo "Generating PCI ID database for DRM drivers"
- DRM_MODULES="$KERNEL_BASE_DIR/lib/modules/$SYS_UTS_RELEASE/kernel/drivers/gpu/drm"
+ DRM_MODULES="$KERNEL_BASE_DIR/lib/modules/$TARGET_KERNEL_LONG/kernel/drivers/gpu/drm"
PCI_FILE="$MODULE_BUILD_DIR/drm.cfg"
[ -d "$DRM_MODULES" ] || perror "DRM dir not found at $DRM_MODULES"
cp "$MODULE_DIR/templates/drm.cfg" "$PCI_FILE" || perror "Could not copy drm.cfg from templates dir"
- echo "# -- generated from kernel $SYS_UTS_RELEASE modules:" >> "$PCI_FILE"
+ echo "# -- generated from kernel $TARGET_KERNEL_LONG modules:" >> "$PCI_FILE"
for FILE in $(find "$DRM_MODULES" -name "*.ko"); do
MODNAME=$(basename "$FILE")
MODNAME=${MODNAME%.ko}
diff --git a/remote/setup_target b/remote/setup_target
index f76c7831..11e1d5be 100755
--- a/remote/setup_target
+++ b/remote/setup_target
@@ -52,7 +52,6 @@
# -----------------------------------------------------------------------------
#
MODE_DIR="${ROOT_DIR}/remote"
-MODULES_DIR="${MODE_DIR}/modules"
EXPORT_DIR="/export/build"
[ -z "$REMOTE_EXPORT_DIR" ] || EXPORT_DIR=$REMOTE_EXPORT_DIR
# Keep track of processed modules so we don't
@@ -288,20 +287,20 @@ generate_target() {
# we need a bit of special logic for kernel specifically
# to check if the built version is corresponding to the
# current kernel version. If not we had a kernel update
- # and need to ask the user what to do
- if [[ "$MODULES" =~ .*\ kernel\ .* ]]; then
+ # and need to tell the user
+ if [[ -e "${TARGET_DIR}/kernel" ]]; then
# if so, check what kernels have been built
- if [ -e "${MODULES_DIR}/kernel/ksrc/KVERSION" ]; then
- local BUILT_KERNEL_VERSION=$(cat "${MODULES_DIR}/kernel/ksrc/KVERSION")
- if [[ "${BUILT_KERNEL_VERSION}" != "${KERNEL_CURRENT_VERSION}" ]]; then
- pinfo "The built kernel (${BUILT_KERNEL_VERSION}) is older than the running one (${KERNEL_CURRENT_VERSION})!"
+ if [ -e "${TARGET_DIR}/kernel/ksrc/KVERSION" ]; then
+ local BUILT_KERNEL_VERSION=$(cat "${TARGET_DIR}/kernel/ksrc/KVERSION")
+ if [[ "${BUILT_KERNEL_VERSION}" != "${SYSTEM_KERNEL_LONG}" ]]; then
+ pinfo "The built kernel (${BUILT_KERNEL_VERSION}) is older than the running one (${SYSTEM_KERNEL_LONG})!"
# cleaning the module is enough as it forces to rebuild.
[[ "${AUTO_UPDATE_KERNEL}" == 1 ]] && pinfo "Auto-Udpate Kernel..." && clean_kernel_module --force
fi
- elif [ -e "${MODULES_DIR}/kernel/ksrc" ]; then
+ elif [ -e "${TARGET_DIR}/kernel/ksrc" ]; then
# check if ksrc is there, since that would be problematic
- pwarning "${MODULES_DIR}/kernel/ksrc exists, but KVERSION is not found!"
- pwarning "Kernel was probably build with an older version of mltk."
+ pwarning "${TARGET_DIR}/kernel/ksrc exists, but KVERSION is not found!"
+ pwarning "Kernel was probably built with an older version of mltk."
pwarning "If errors arise, either write your KVERSION manually or clean the kernel."
fi
fi