From d0ab838d0cf6cb0ecd741873c436a1954aca2da9 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 01:48:50 -0700 Subject: [packagemanager] improve list_content_packages function added "--files" and "--dirs" switches to list only files or dirs respectively. added support for external "EXTRA_PACKAGES" bash variables with which the content of additional packages can be listed without them beeing in the REQUIRED_CONTENT_PACKAGES vairable of the config file --- remote/includes/packagemanager.inc | 102 ++++++++++++++++++++++++++----------- 1 file changed, 71 insertions(+), 31 deletions(-) diff --git a/remote/includes/packagemanager.inc b/remote/includes/packagemanager.inc index 358dd8b1..66013807 100644 --- a/remote/includes/packagemanager.inc +++ b/remote/includes/packagemanager.inc @@ -1,44 +1,84 @@ # # get all files of required packages by a module # -list_packet_files() { +# Usage: +# list_content_packages +# - lists all files/directories in REQUIRED_CONTENT_PACKAGES +# list_content_packages --files +# - lists all files in REQUIRED_CONTENT_PACKAGES +# list_content_packages --dirs +# - lists all dirs in REQUIRED_CONTENT_PACKAGES +# +# NOTE: additional packages needed to be listed can be given +# through the environment variable EXTRA_PACKAGES + +list_content_packages() { [ -z "$REQUIRED_CONTENT_PACKAGES" ] && pinfo "No required packages for $TOOL" && return 1 + [ $# -gt 2 ] && perror "'list_content_packages' accepts only 1 or no args. $# given." local PACKAGE="" - for PACKAGE in $REQUIRED_CONTENT_PACKAGES; do - local OPTIONAL="$(echo "$PACKAGE" | cut -c 1)" - [ "x$OPTIONAL" = "x@" ] && PACKAGE="$(echo "$PACKAGE" | cut -c 2-)" - local FILES="" - if [ "$PACKET_HANDLER" = "dpkg" ]; then - PACKAGECOMMAND="dpkg -L" - elif [ "$PACKET_HANDLER" = "rpm" ]; then - PACKAGECOMMAND="rpm -ql" - fi + for PACKAGE in $REQUIRED_CONTENT_PACKAGES $EXTRA_PACKAGES; do + list_content_package $1 $PACKAGE + done - if [ -n "$REQUIRED_PACKET_FILES_BLACKLIST" ]; then - FILES="$($PACKAGECOMMAND "$PACKAGE" | grep "^/" | \ - grep -v "$REQUIRED_PACKET_FILES_BLACKLIST" | \ - grep -v -E 'share/(man|doc)|/var/run|/var/log|/etc/init\.d'; \ - echo ":###:${PIPESTATUS[0]}")" - else - FILES="$($PACKAGECOMMAND "$PACKAGE" | grep "^/" | grep -v -E 'share/(man|doc)|/var/run|/var/log|/etc/init\.d'; echo ":###:${PIPESTATUS[0]}")" - fi +} +list_content_package(){ + #[ -z "$EXTRA_PACKAGES" ] || pinfo "Listing additional packages: $EXTRA_PACKAGES" + [ $# -gt 2 ] && perror "'list_content_package' accepts max 2 args. $# given." + local OP="-e" + case "$1" in + --files) + OP="-f" + ;; + --dirs) + OP="-d" + ;; + "") + OP="-e" + ;; + *) + perror "'list_content_packages' invalid argument: $1" + ;; + esac + local PACKAGE="$2" + local OPTIONAL="$(echo "$PACKAGE" | cut -c 1)" + [ "x$OPTIONAL" = "x@" ] && PACKAGE="$(echo "$PACKAGE" | cut -c 2-)" + local FILES="" + if [ "$PACKET_HANDLER" = "dpkg" ]; then + PACKAGECOMMAND="dpkg -L" + elif [ "$PACKET_HANDLER" = "rpm" ]; then + PACKAGECOMMAND="rpm -ql" + fi + + if [ -n "$REQUIRED_PACKET_FILES_BLACKLIST" ]; then + FILES="$($PACKAGECOMMAND "$PACKAGE" | grep "^/" | \ + grep -v "$REQUIRED_PACKET_FILES_BLACKLIST" | \ + grep -v -E 'share/(man|doc)|/var/run|/var/log|/etc/init\.d'; \ + echo ":###:${PIPESTATUS[0]}")" + else + FILES="$($PACKAGECOMMAND "$PACKAGE" | grep "^/" | grep -v -E 'share/(man|doc)|/var/run|/var/log|/etc/init\.d'; echo ":###:${PIPESTATUS[0]}")" + fi # FILES="$(rpm -ql "$PACKAGE" | grep "^/" | grep -v -E 'share/(man|doc)|/var/run|/var/log'; echo ":###:${PIPESTATUS[0]}")" - # ugly hack to get our return value - local LPRET=$(echo "$FILES" | awk -F ':###:' '{printf $2}') - FILES=$(echo "$FILES" | awk -F ':###:' '{print $1}') - if [ "x$LPRET" != "x0" -a "x$OPTIONAL" != "x@" ]; then - pdebug "FILES: '$FILES'" - perror "dpkg/rpm exited with code '$LPRET' for required package ${PACKAGE}." - fi - [ "x$LPRET" != "x0" ] && pwarning "dpkg/rpm exited with code '$LPRET' for optional package ${PACKAGE}." && continue - [ -z "$FILES" ] && pwarning "list_packet_files empty for packet ${PACKAGE}." && continue - pdebug "Packet $PACKAGE has $(echo $FILES | wc -w) files..." - for FILE in $FILES; do - [ ! -d "$FILE" ] && echo "$FILE" - done + # ugly hack to get our return value + local LPRET=$(echo "$FILES" | awk -F ':###:' '{printf $2}') + FILES=$(echo "$FILES" | awk -F ':###:' '{print $1}') + if [ "x$LPRET" != "x0" -a "x$OPTIONAL" != "x@" ]; then + pdebug "FILES: '$FILES'" + perror "dpkg/rpm exited with code '$LPRET' for required package ${PACKAGE}." + fi + [ "x$LPRET" != "x0" ] && pwarning "dpkg/rpm exited with code '$LPRET' for optional package ${PACKAGE}." && continue + [ -z "$FILES" ] && pwarning "list_packet_files empty for packet ${PACKAGE}." && continue + pdebug "Packet $PACKAGE has $(echo $FILES | wc -w) files..." + for FILE in $FILES; do + [ "$OP" "$FILE" ] && echo "$FILE" done } +# +# Convenience function +# +list_packet_files() { + list_content_packages --files +} # # Convenience function -- cgit v1.2.3-55-g7522 From 901d911c9837a83b75b452e85c52f8c0c5ec0f06 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:43:42 +0100 Subject: [kernel.inc] major rework to support system kernel changed how we determine the path of headers and kernel modules to support the "kernel-system" module --- remote/includes/kernel.inc | 97 ++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/remote/includes/kernel.inc b/remote/includes/kernel.inc index 4eef36e5..e92eed3c 100644 --- a/remote/includes/kernel.inc +++ b/remote/includes/kernel.inc @@ -16,36 +16,54 @@ # 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 - KERNEL_CURRENT_VERSION=$(uname -r) + [ -z "$KERNEL_CURRENT_VERSION" ] && declare -rg KERNEL_CURRENT_VERSION="$(uname -r)" [ -z "$KERNEL_CURRENT_VERSION" ] && pwarning "Could not determine kernel version." - # determine kernel version that will be running in the generated system - if [ -e "$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h" ]; then - SYS_UTS_RELEASE=$(grep 'UTS_RELEASE' "$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h" | awk -F '"' '{print $2}') - SYS_KERNEL=$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+') - else - SYS_UTS_RELEASE="(unknown-not-compiled-yet)" - SYS_KERNEL="$SYS_UTS_RELEASE" - fi + pinfo "$KERNEL_CURRENT_VERSION" + # set empty SYS_UTS_RELEASE and SYS_KERNEL + SYS_UTS_RELEASE="(unknown)" + SYS_KERNEL="$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+')" } -check_kernel_build_dir() { +check_kernel_base_dir() { + + # check if KERNEL_BASE_DIR was set, if not we don't know + # whether kernel-openslx or kernel-system has been built + # and therefore not were to look for kernel modules, + # firmware and the kernel itself + + if [ -z "${KERNEL_BASE_DIR}" ]; then + # this is bad, abort + perror "KERNEL_BASE_DIR is not set. The kernel module did not run properly" + fi + # all good, keep going + + # old deprecated KERNEL_BUILD_DIR variable, here for compat reasons for now. TODO: delete [ -d "${MODULES_DIR}/kernel/build" ] && KERNEL_BUILD_DIR="${MODULES_DIR}/kernel/build" \ - || perror "No build directory set for the kernel. Was is built?" + || 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) + #KERNEL_NEW_VERSION=$(ls ${KERNEL_BUILD_DIR}/lib/modules) } copy_kernel_modules() { pinfo "Copying kernel modules for kernel ${KERNEL_CURRENT_VERSION}..." [ -z "${REQUIRED_KERNEL_MODULES}" ] && perror "REQUIRED_KERNEL_MODULES is empty. Check your config file." - check_kernel_build_dir + [ -z "${KERNEL_HEADERS_PATH}" ] && perror "KERNEL_HEADERS_PATH is empty. Kernel headers appears to be missing." + + + check_kernel_base_dir + # # process modules list # - # search for modules in KERNEL_BUILD_DIR - cd "${KERNEL_BUILD_DIR}" || perror "Could not cd to ${KERNEL_BUILD_DIR}" + # 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_LIST="" @@ -62,12 +80,12 @@ copy_kernel_modules() { REQUIRED_KERNEL_MODULES_EXPANDED+=" $ELEM" done done - cd - + cd - 2>/dev/null pinfo "Expanded the list of $(echo "$REQUIRED_KERNEL_MODULES" | wc -w) required kernel modules to $(echo "$REQUIRED_KERNEL_MODULES_EXPANDED" | wc -w)" for KERNEL_MODULE in ${REQUIRED_KERNEL_MODULES_EXPANDED}; do local KERNEL_MODULE_PATH="${KERNEL_MODULES_DIR}/${KERNEL_MODULE}" - if grep "^${KERNEL_MODULE}$" "${KERNEL_BUILD_DIR}/${KERNEL_MODULES_DIR}/modules.builtin" >/dev/null; then + if grep "^${KERNEL_MODULE}$" "${KERNEL_BASE_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}'" @@ -78,7 +96,7 @@ copy_kernel_modules() { fi # check for dependencies - local DEPS=$(grep "${KERNEL_MODULE}:" "${KERNEL_BUILD_DIR}/${KERNEL_MODULES_DIR}/modules.dep" | cut -d ":" -f2-) + local DEPS=$(grep "${KERNEL_MODULE}:" "${KERNEL_BASE_DIR}/${KERNEL_MODULES_DIR}/modules.dep" | cut -d ":" -f2-) if [ ! -z "$DEPS" ]; then for DEP in $DEPS; do pdebug "Adding dep: ${KERNEL_MODULES_DIR}/$DEP" @@ -114,11 +132,13 @@ copy_firmware() { pinfo "Copying firmware for kernel ${KERNEL_CURRENT_VERSION}..." [ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file." local OLD_DIR=$(pwd) - check_kernel_build_dir + + check_kernel_base_dir + # # process firmware list # - cd "${KERNEL_BUILD_DIR}" || perror "Could not cd!" + cd "${KERNEL_BASE_DIR}" || perror "Could not cd to ${KERNEL_BASE_DIR}" local FIRMWARE_DIR="lib/firmware" local FIRMWARE_LIST="" for FIRMWARE in ${REQUIRED_FIRMWARE}; do @@ -126,14 +146,21 @@ copy_firmware() { # check for firmware in the build directory of the kernel for CANDIDATE in "${FIRMWARE_DIR}/${FIRMWARE}" "${FIRMWARE_DIR}/${KERNEL_NEW_VERSION}/${FIRMWARE}"; do if [ -e "${CANDIDATE}" ]; then - pdebug "Copying from kernel build dir: '${CANDIDATE}'" + pdebug "Copying from kernel base dir ('$KERNEL_BASE_DIR'): '${CANDIDATE}'" FIRMWARE_LIST+=" ${CANDIDATE}" FOUND=1 fi done - + + # 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" + 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 + pwarning "Did not found '$FIRMWARE' in kernel base dir. Searching system..." for CANDIDATE in "/${FIRMWARE_DIR}/${FIRMWARE}" "/${FIRMWARE_DIR}/${KERNEL_CURRENT_VERSION}/${FIRMWARE}"; do if [ -e "${CANDIDATE}" ]; then if [ $(echo "${CANDIDATE}" | grep -c "${KERNEL_CURRENT_VERSION}") -eq 0 ]; then @@ -153,33 +180,37 @@ copy_firmware() { done if [ ! -z "${FIRMWARE_LIST}" ]; then + echo "$FIRMWARE_LIST" > /fwlist local COUNT=$(echo "${FIRMWARE_LIST}" | wc -w) pinfo "Copying $COUNT firmware to target directory." tarcopy "${FIRMWARE_LIST}" "${TARGET_BUILD_DIR}" fi + # 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} - 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}/" - cd - - rm -r "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" || perror "something went very wrong..." - else - pdebug "No ${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION} directory, skipping the merge." + 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}/" + cd - + rm -r "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" || perror "something went very wrong..." + else + pdebug "No ${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION} directory, skipping the merge." + fi fi - + cd "$OLD_DIR" } copy_kernel() { - check_kernel_build_dir + check_kernel_base_dir local TOOL_STR="$TOOL_STR copy_kernel:" 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!" + cp "${KERNEL_BASE_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." } -- cgit v1.2.3-55-g7522 From e1f710a498b0da764deb046f0acba51307c476a0 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:45:36 +0100 Subject: [vmware] adapted .build to new kernel stuff --- remote/modules/vmware/vmware.build | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/remote/modules/vmware/vmware.build b/remote/modules/vmware/vmware.build index c1dd77ce..5d91b02d 100644 --- a/remote/modules/vmware/vmware.build +++ b/remote/modules/vmware/vmware.build @@ -21,17 +21,19 @@ fetch_source() { } build() { + # prepare the build directory with the files needed during the chroot 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?" pinfo "Installing vmware per chroot..." chroot_run "${MODULE_BUILD_DIR}" <<-EOF - # PS1='\[\e[1;33m\](chroot) \u@\h:\w\$ \[\e[1;32m\]' /bin/bash -norc # un-comment for debugging within chroot yes | sh /"${VMWARE_BUNDLE_FILE}" --eulas-agreed --console --required - vmware-modconfig --console --build-mod -k "${SYS_UTS_RELEASE}" vmnet $(which gcc) "${MODULES_DIR}"/kernel/ksrc/include/ vmplayer vmnet - vmware-modconfig --console --build-mod -k "${SYS_UTS_RELEASE}" vmmon $(which gcc) "${MODULES_DIR}"/kernel/ksrc/include/ vmplayer vmmon - # PS1='\[\e[1;33m\](chroot) \u@\h:\w\$ \[\e[1;32m\]' /bin/bash -norc # un-comment for debugging within chroot + 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 EOF # cleanup unneeded files -- cgit v1.2.3-55-g7522 From 7cd3eb5224e61fd7bf150594aac4200b347d45b4 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:45:53 +0100 Subject: [dnbd3] adapted .build to new kernel functions --- remote/modules/dnbd3/dnbd3.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/modules/dnbd3/dnbd3.build b/remote/modules/dnbd3/dnbd3.build index e285788b..2651daac 100644 --- a/remote/modules/dnbd3/dnbd3.build +++ b/remote/modules/dnbd3/dnbd3.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="$MODULES_DIR/kernel/ksrc" || perror "Could not compile kernel module" + make MODULE_NAME=dnbd3 KDIR="$KERNEL_HEADERS_PATH" || 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" -- cgit v1.2.3-55-g7522 From 9fef57bae0dfb22157beaea39efe437959c91a35 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:46:13 +0100 Subject: [kernel] adapted .build to new kernel functions --- remote/modules/kernel/kernel.build | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/remote/modules/kernel/kernel.build b/remote/modules/kernel/kernel.build index 78832905..f74403f1 100644 --- a/remote/modules/kernel/kernel.build +++ b/remote/modules/kernel/kernel.build @@ -1,3 +1,29 @@ +get_kernel_version() { + # 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" + + else + # TODO handle + perror "'$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h' does not exist yes." + 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'" + + # check the headers/src path +} + fetch_source() { pdebug "getting kernel sources via git ...." [ -d ./ksrc ] && rm -rf ./ksrc # slightly brutal ... -- cgit v1.2.3-55-g7522 From 9a89fc12fc005a5cf1eba86f4ae302950266f078 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:46:48 +0100 Subject: [nvidia_kernel] adapted .build to new kernel functions --- remote/modules/nvidia_kernel/nvidia_kernel.build | 3 +-- remote/modules/nvidia_kernel/nvidia_kernel.conf | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/remote/modules/nvidia_kernel/nvidia_kernel.build b/remote/modules/nvidia_kernel/nvidia_kernel.build index bde06c60..a1275c70 100644 --- a/remote/modules/nvidia_kernel/nvidia_kernel.build +++ b/remote/modules/nvidia_kernel/nvidia_kernel.build @@ -7,7 +7,6 @@ fetch_source() { build() { local ROOTUPPERDIR="$MODULE_DIR/rootupper" - local KERNELSRCDIR="$MODULES_DIR/kernel/ksrc" # kernel sources local NVIDIA="$MODULE_DIR/src/$REQUIRED_NVIDIA" local NVIDIAEXTRACTDIR="$ROOTUPPERDIR/NVIDIA" @@ -29,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 /"$KERNELSRCDIR" # 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_PATH" # 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/nvidia_kernel/nvidia_kernel.conf b/remote/modules/nvidia_kernel/nvidia_kernel.conf index 34e66b99..9880100d 100644 --- a/remote/modules/nvidia_kernel/nvidia_kernel.conf +++ b/remote/modules/nvidia_kernel/nvidia_kernel.conf @@ -5,3 +5,6 @@ REQUIRED_URL="http://download.nvidia.com/XFree86/Linux-x86_64/$REQUIRED_VERSION/ REQUIRED_DIRECTORIES=" /lib/modules/nvidia " +REQUIRED_MODULES=" + kernel +" -- cgit v1.2.3-55-g7522 From bfba9c692d8e18008d2035ffaf07f1e789a1122f Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:47:37 +0100 Subject: [vmware] added 'kernel' to REQUIRED_MODULES --- remote/modules/vmware/vmware.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/remote/modules/vmware/vmware.conf b/remote/modules/vmware/vmware.conf index 51e73b85..017d1d5b 100644 --- a/remote/modules/vmware/vmware.conf +++ b/remote/modules/vmware/vmware.conf @@ -1,5 +1,6 @@ REQUIRED_DOWNLOAD_BASE="http://softwareupdate.vmware.com/cds/vmw-desktop/ws/10.0.1/1379776/linux/core/" REQUIRED_TYPE="workstation" +REQUIRED_MODULES="kernel" REQUIRED_DIRECTORIES=" /etc/vmware /usr/sbin -- cgit v1.2.3-55-g7522 From 5601ed57f105f4fa6f127f119897abf99355e029 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:47:59 +0100 Subject: [rfs-s31] adapted to new kernel functions --- remote/rootfs/rootfs-stage31/rootfs-stage31.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.build b/remote/rootfs/rootfs-stage31/rootfs-stage31.build index 3711e16d..34d954f4 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.build +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.build @@ -20,7 +20,7 @@ build() { # generate drm module loading database pinfo "Generating PCI ID database for DRM drivers" - DRM_MODULES="$MODULES_DIR/kernel/build/lib/modules/$SYS_UTS_RELEASE/kernel/drivers/gpu/drm" + DRM_MODULES="$KERNEL_BASE_DIR/lib/modules/$SYS_UTS_RELEASE/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" @@ -53,7 +53,7 @@ post_copy() { # copy kernel, modules and firmware copy_kernel_modules copy_firmware - copy_kernel + #copy_kernel } # -- cgit v1.2.3-55-g7522 From 9b95e363b95fa3262ecf3a7be0ed2e93d5ca2c31 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:53:40 +0100 Subject: [rfs-s32] adapted to new kernel functions --- remote/rootfs/rootfs-stage32/rootfs-stage32.build | 2 +- remote/rootfs/rootfs-stage32/rootfs-stage32.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index bd6d3106..156d1afe 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -117,7 +117,7 @@ post_copy() { # copy kernel, modules and firmware copy_kernel_modules copy_firmware - copy_kernel + #copy_kernel # Try to fetch distro logo if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf index d55bcfa8..34d3507a 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.conf +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.conf @@ -3,7 +3,7 @@ REQUIRED_MODULES=" " REQUIRED_BINARIES=" bash - dmesg + dmesg curl less agetty -- cgit v1.2.3-55-g7522 From 7a72dc1402ec97478404b7ac3d548605b70a4456 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:54:20 +0100 Subject: [setup_target] kernel version check only check if kernel version changed since last build for the "kernel" module and not the new "kernel-system" module --- remote/setup_target | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/setup_target b/remote/setup_target index 172bc7d4..f9e91f96 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -283,7 +283,7 @@ generate_target() { # 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 + if [[ "$MODULES" =~ .*\ 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") -- cgit v1.2.3-55-g7522 From 06bf4e941bc938a4ed3ad987b6fdef0a3e9d6ff0 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:57:01 +0100 Subject: [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... --- remote/modules/kernel-system/kernel-system.build | 114 +++++++++++++++++++++ remote/modules/kernel-system/kernel-system.conf | 3 + .../kernel-system/kernel-system.conf.opensuse | 6 ++ .../kernel-system/kernel-system.conf.ubuntu | 6 ++ remote/modules/kernel-system/patch-speaker | 6 ++ 5 files changed, 135 insertions(+) create mode 100644 remote/modules/kernel-system/kernel-system.build create mode 100644 remote/modules/kernel-system/kernel-system.conf create mode 100644 remote/modules/kernel-system/kernel-system.conf.opensuse create mode 100644 remote/modules/kernel-system/kernel-system.conf.ubuntu create mode 100755 remote/modules/kernel-system/patch-speaker 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 -- cgit v1.2.3-55-g7522 From 62f0ad492ba49fc5ecec2f4e30edec7d33e50537 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 13:59:26 +0100 Subject: [kernel-system] added TODO. DO NOT USE YET, WIP! You have been warned. --- remote/modules/kernel-system/TODO | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 remote/modules/kernel-system/TODO diff --git a/remote/modules/kernel-system/TODO b/remote/modules/kernel-system/TODO new file mode 100644 index 00000000..7665abac --- /dev/null +++ b/remote/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. -- cgit v1.2.3-55-g7522 From f416b8a81f2a52f7512c0d1090ce4d15551b4eef Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 14:24:34 +0100 Subject: [kernel.inc] less spam in non-debug mode --- remote/includes/kernel.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/includes/kernel.inc b/remote/includes/kernel.inc index e92eed3c..ffac5731 100644 --- a/remote/includes/kernel.inc +++ b/remote/includes/kernel.inc @@ -160,7 +160,7 @@ copy_firmware() { # if we didn't found it in the kernel build directory, check for firmware in the system firmware directory if [ $FOUND -ne 1 ]; then - pwarning "Did not found '$FIRMWARE' in kernel base dir. Searching system..." + pdebug "Did not found '$FIRMWARE' in kernel base dir. Searching system..." for CANDIDATE in "/${FIRMWARE_DIR}/${FIRMWARE}" "/${FIRMWARE_DIR}/${KERNEL_CURRENT_VERSION}/${FIRMWARE}"; do if [ -e "${CANDIDATE}" ]; then if [ $(echo "${CANDIDATE}" | grep -c "${KERNEL_CURRENT_VERSION}") -eq 0 ]; then -- cgit v1.2.3-55-g7522 From 01aef7c5bab0475b3fef61ffd2f40d8f9a39f5ae Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 14:25:39 +0100 Subject: [vmware] added link to kernel in vmware target --- remote/targets/vmware/kernel | 1 + 1 file changed, 1 insertion(+) create mode 120000 remote/targets/vmware/kernel diff --git a/remote/targets/vmware/kernel b/remote/targets/vmware/kernel new file mode 120000 index 00000000..044f086d --- /dev/null +++ b/remote/targets/vmware/kernel @@ -0,0 +1 @@ +../../modules/kernel \ No newline at end of file -- cgit v1.2.3-55-g7522 From 60aa1d1e6422499870d75f95a5c2d3d5c58b44fa Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 24 Mar 2014 14:32:11 +0100 Subject: [kernel] remove forgotten pinfo used while dev'ing --- remote/includes/kernel.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote/includes/kernel.inc b/remote/includes/kernel.inc index ffac5731..a3c64d9a 100644 --- a/remote/includes/kernel.inc +++ b/remote/includes/kernel.inc @@ -24,7 +24,7 @@ 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." - pinfo "$KERNEL_CURRENT_VERSION" + # set empty SYS_UTS_RELEASE and SYS_KERNEL SYS_UTS_RELEASE="(unknown)" SYS_KERNEL="$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+')" -- cgit v1.2.3-55-g7522