diff options
-rw-r--r-- | helper/kernel.inc | 38 | ||||
-rw-r--r-- | helper/system.inc | 4 | ||||
-rw-r--r-- | remote/modules/kernel/kernel.build | 10 | ||||
-rw-r--r-- | remote/rootfs/rootfs-stage31/rootfs-stage31.build | 3 | ||||
-rw-r--r-- | remote/rootfs/rootfs-stage32/rootfs-stage32.build | 20 | ||||
-rwxr-xr-x | remote/setup_target | 54 |
6 files changed, 72 insertions, 57 deletions
diff --git a/helper/kernel.inc b/helper/kernel.inc index af2af38b..61fa3efd 100644 --- a/helper/kernel.inc +++ b/helper/kernel.inc @@ -7,21 +7,21 @@ # 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_VERSION>) +# (entries must be a relative path to /lib/modules/<KERNEL_CURRENT_VERSION>) # # ex: for /lib/modules/3.2.0/kernel/fs/nfs/nfs.ko # must be given as kernel/fs/nfs/nfs.ko # -# 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. -if [ -z "${KERNEL_VERSION}" ]; then +# this code depends on KERNEL_CURRENT_VERSION, this file needs to be sourced after helper/system.inc! +# (TODO: maybe source system.inc if KERNEL_CURRENT_VERSION +if [ -z "${KERNEL_CURRENT_VERSION}" ]; then . ${ROOT_DIR}/helper/system.inc - [ -z "${KERNEL_VERSION}" ] && perror "KERNEL_VERSION still not set after sourcing, something is very wrong..." + [ -z "${KERNEL_CURRENT_VERSION}" ] && perror "KERNEL_CURRENT_VERSION still not set after sourcing, something is very wrong..." fi # set global KERNEL_TARGET_NAME -KERNEL_TARGET_NAME="vmlinuz-${KERNEL_VERSION}-openslx" +KERNEL_TARGET_NAME="kernel" check_kernel_build_dir() { [ -d "${MODULES_DIR}/kernel/build" ] && KERNEL_BUILD_DIR="${MODULES_DIR}/kernel/build" \ @@ -31,7 +31,7 @@ check_kernel_build_dir() { } 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 # @@ -104,8 +104,9 @@ copy_kernel_modules() { copy_firmware() { + pinfo "Copying firmware for kernel ${KERNEL_CURRENT_VERSION}..." [ -z "${REQUIRED_FIRMWARE}" ] && perror "REQUIRED_FIRMWARE is empty. Check your config file." - local HORST=$(pwd) + local OLD_DIR=$(pwd) check_kernel_build_dir # # process firmware list @@ -126,14 +127,14 @@ 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 - for CANDIDATE in "/${FIRMWARE_DIR}/${FIRMWARE}" "/${FIRMWARE_DIR}/${KERNEL_VERSION}/${FIRMWARE}"; do + for CANDIDATE in "/${FIRMWARE_DIR}/${FIRMWARE}" "/${FIRMWARE_DIR}/${KERNEL_CURRENT_VERSION}/${FIRMWARE}"; do if [ -e "${CANDIDATE}" ]; then - if [ $(echo "${CANDIDATE}" | grep -c "${KERNEL_VERSION}") -eq 0 ]; then + if [ $(echo "${CANDIDATE}" | grep -c "${KERNEL_CURRENT_VERSION}") -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_VERSION}/${FIRMWARE}" + FIRMWARE_LIST+=" /${FIRMWARE_DIR}/${KERNEL_CURRENT_VERSION}/${FIRMWARE}" fi FOUND=1 fi @@ -152,26 +153,23 @@ copy_firmware() { # 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_VERSION}" ]; then + if [ -d "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" ]; then mkdir -p "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_NEW_VERSION}/" - #mv -f "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_VERSION}/"* "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_NEW_VERSION}/" - cd "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_VERSION}" || perror "old kernel but no old kernel" + 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_VERSION}" || perror "something went very wrong..." + rm -r "${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION}" || perror "something went very wrong..." else - pdebug "No ${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_VERSION} directory, skipping the merge." + pdebug "No ${TARGET_BUILD_DIR}/lib/firmware/${KERNEL_CURRENT_VERSION} directory, skipping the merge." fi - cd "$HORST" + cd "$OLD_DIR" } copy_kernel() { - - local TOOL_STR="$TOOL_STR copy_kernel:" - check_kernel_build_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}" diff --git a/helper/system.inc b/helper/system.inc index c37368cb..0796c974 100644 --- a/helper/system.inc +++ b/helper/system.inc @@ -12,8 +12,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_CURRENT_VERSION=$(uname -r) +[ ! -z $KERNEL_CURRENT_VERSION ] || pwarning "Could not determine kernel version." # determine number of CPU cores CPU_CORES=$(cat /proc/cpuinfo | grep processor | wc -l) diff --git a/remote/modules/kernel/kernel.build b/remote/modules/kernel/kernel.build index 59bc8e99..a1a1fcd1 100644 --- a/remote/modules/kernel/kernel.build +++ b/remote/modules/kernel/kernel.build @@ -3,7 +3,7 @@ fetch_source() { if [ "x$PACKET_MANAGER" == "xapt" ]; then pdebug "apt-ing kernel source" apt-get install -y dpkg-dev || perror "Installing dpkg-dev failed." - apt-get source linux-image-${KERNEL_VERSION} || perror "Fetching kernel source failed." + apt-get source linux-image-${KERNEL_CURRENT_VERSION} || perror "Fetching kernel source failed." [ -z "$(ls -d linux-*/)" ] && perror "Source directory not found." [ ! -e ksrc ] && ln -s "$(ls -d linux-*/)" "ksrc" elif [ "x$PACKET_MANAGER" == "xzypper" ]; then @@ -29,6 +29,10 @@ fetch_source() { # fix pc speaker ./patch-speaker + + # remember the current kernel version + echo "${KERNEL_CURRENT_VERSION}" > ksrc/KVERSION + } build() { @@ -116,8 +120,8 @@ patch_aufs() { git clone "git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git" || perror "Cloning aufs3 failed." fi # get the needed version - [ ! -z ${KERNEL_VERSION} ] && local NEEDED_BRANCH=$(echo $KERNEL_VERSION | awk -F "." '{print $1"."$2}') \ - || perror "KERNEL_VERSION not set, this should not happen!" + [ ! -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!" pinfo "Getting branch origin/$NEEDED_BRANCH" cd "$MODULE_DIR/aufs3-standalone" || perror "Could not CD to aufs3-standalone" git checkout "origin/aufs$NEEDED_BRANCH" diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.build b/remote/rootfs/rootfs-stage31/rootfs-stage31.build index d547d7a4..d9f28636 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.build +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.build @@ -19,7 +19,10 @@ build() { } post_copy() { + pinfo "Generating rootfs for Stage 3.1 ..." generate_rootfs + + # copy kernel, modules and firmware copy_kernel_modules copy_firmware copy_kernel diff --git a/remote/rootfs/rootfs-stage32/rootfs-stage32.build b/remote/rootfs/rootfs-stage32/rootfs-stage32.build index 39c96ccc..93094f72 100644 --- a/remote/rootfs/rootfs-stage32/rootfs-stage32.build +++ b/remote/rootfs/rootfs-stage32/rootfs-stage32.build @@ -104,21 +104,12 @@ post_copy() { sed -i -r 's/^blacklist.*pcspkr/#&/g' "$TARGET_BUILD_DIR/etc/modprobe.d/blacklist.conf" echo "minilinux-$(hostname)" > "${TARGET_BUILD_DIR}/etc/hostname" - # check for kernel modules, if not present copy from system - if [ ! -d ${TARGET_BUILD_DIR}/lib/modules ]; then - pinfo "Copying modules for kernel ${KERNEL_VERSION}..." - copy_kernel_modules - else - pinfo "Not copying kernel modules from system, as '${TARGET_BUILD_DIR}/lib/modules' already exists." - fi - # check for firmware, if not present copy from system - if [ ! -d ${TARGET_BUILD_DIR}/lib/firmware ]; then - pinfo "Copying firmware for kernel ${KERNEL_VERSION}..." - copy_firmware - else - pinfo "Not copying firmware from system, as '${TARGET_BUILD_DIR}/lib/firmware' already exists." - fi + + # copy kernel, modules and firmware + copy_kernel_modules + copy_firmware + copy_kernel # Try to fetch distro logo if [ ! -s "$TARGET_BUILD_DIR/etc/distro.png" ]; then @@ -134,6 +125,5 @@ post_copy() { fi fi - copy_kernel } diff --git a/remote/setup_target b/remote/setup_target index 1638f392..f5df66ad 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -227,6 +227,30 @@ generate_target() { pinfo "Activated modules in '${TARGET}':" pinfo "\t$(echo ${MODULES})" + # 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 + # 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})!" + pinfo "Do you want to clean the old kernel and re-build for the new version? (Y/n)" + read USER_INPUT + if [ "x$USER_INPUT" == "xy" -o "x$USER_INPUT" == "xY" -o "x$USER_INPUT" == "x" ]; then + clean_kernel_module --force + # cleaning the module is enough as it forces to rebuild. + fi + fi + else + # KVERSION is not found. + pdebug "KVERSION not found under remote/modules/kernel/ksrc/KVERSION" + pdebug "Ignoring. If errors arise, either write your KVERSION manually or clean the kernel." + fi + fi + # copy basic libs pinfo "Copying libc and ld-linux used by ${SHELL}" tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}" @@ -255,11 +279,6 @@ process_module() { pinfo ">>>>>>>>>>>>>>>>> Processing module [ $MODULE ]" TOOL_STR="[${MODULE}]" if [ -d "${MODULE_DIR}" ]; then - - #[ "x$DEBUG" != "x1" ] \ - # && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \ - # && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log - # TODO: Make above work with the new logging system (add function to logging.inc to switch logfile) cd "${MODULE_DIR}" || perror "Module dir '${MODULE_DIR}' seems to exist, but cd to it failed." pinfo "## Reading config" read_config @@ -299,10 +318,8 @@ process_module() { copy_static_data pinfo "## Post copy" post_copy - # reset pipes - #[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&- - # TODO - calc_size #sets MODULE_BUILD_SIZE + # set MODULE_BUILD_SIZE + calc_size pinfo "Module completed. Total size: ${MODULE_BUILD_SIZE}" else pwarning "Module directory for '$MODULE' not found." @@ -310,10 +327,8 @@ process_module() { } post_process_target() { - local TOOL_STR="$TOOL_STR post_process_target:" - - #move systemd files from /lib to /etc/lib + # move systemd files from /lib to /etc/lib pinfo "move systemd files from /lib/systemd to /etc/systemd" if [ -d "${TARGET_BUILD_DIR}/lib/systemd" ]; then cd "${TARGET_BUILD_DIR}/lib" @@ -404,12 +419,17 @@ clean_module() { } clean_kernel_module() { + local CLEAN=0 + if [ "x$1" == "x--force" ]; then + CLEAN=1 + else + pinfo "It will take a long time to rebuild, are you sure? [y/N]" + read USER_INPUT + [ "x$USER_INPUT" == "xy" ] && CLEAN=1 + fi + pinfo "Cleaning kernel module (including sources and compiled stuff)." - pinfo "It will take a long time to rebuild, are you sure? [y/N]" - read USER_INPUT - if [ "x$USER_INPUT" == "xy" ]; then - pinfo "Confirmed, going on..." - # clean kernel module + if [[ $CLEAN == 1 ]]; then cd "${TARGET_DIR}/kernel" || perror "Could not cd to ${TARGET_DIR}/kernel" if [ -e build ]; then rm -rf build || perror "Could not delete ${TARGET_DIR}/kernel/build" |