diff options
| author | Jonathan Bauer | 2013-03-15 18:07:22 +0100 |
|---|---|---|
| committer | Jonathan Bauer | 2013-03-15 18:07:22 +0100 |
| commit | c61c35397320ca4b36d25ea9b9b146d40e84c387 (patch) | |
| tree | 3d01880e0ac69a0e29ca7515d9ca136916557faf | |
| parent | yet another new structure (diff) | |
| download | tm-scripts-c61c35397320ca4b36d25ea9b9b146d40e84c387.tar.gz tm-scripts-c61c35397320ca4b36d25ea9b9b146d40e84c387.tar.xz tm-scripts-c61c35397320ca4b36d25ea9b9b146d40e84c387.zip | |
fix stage3.1 build script
| -rwxr-xr-x | mltk | 11 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage31/rootfs-stage31.build | 50 | ||||
| -rw-r--r-- | remote/rootfs/rootfs-stage31/rootfs-stage31.conf | 109 | ||||
| -rwxr-xr-x | remote/setup_core | 219 | ||||
| -rwxr-xr-x | remote/setup_target (renamed from remote/setup_tools) | 55 |
5 files changed, 100 insertions, 344 deletions
@@ -90,11 +90,8 @@ initial_checks() { pinfo "System's packet manager is $PACKET_MANAGER" # setup_tools and build_core - SETUP_CORE="${ROOT_DIR}/remote/setup_core" - SETUP_TOOLS="${ROOT_DIR}/remote/setup_tools" - - [ ! -e "${SETUP_CORE}" ] && perror "Missing script setup_core, re-clone. Exiting." - [ ! -e "${SETUP_TOOLS}" ] && perror "Missing script setup_tools, re-clone. Exiting." + SETUP_TARGET="${ROOT_DIR}/remote/setup_target" + [ ! -e "${SETUP_TARGET}" ] && perror "Missing script 'remote/setup_target', re-clone git. Exiting." } read_params() { @@ -182,8 +179,8 @@ read_params() { run() { if [[ $REMOTE_CLEAN == 1 || $REMOTE_BUILD == 1 ]]; then [[ $REMOTE_DEBUG == 1 ]] && unset_quiet || set_quiet - . "${SETUP_TOOLS}" || perror "Cannot source ${SETUP_TOOLS}" - [[ $REMOTE_CLEAN == 1 ]] && clean_tools $REMOTE_LIST_CLEAN + . "${SETUP_TARGET}" || perror "Cannot source ${SETUP_TARGET}" + [[ $REMOTE_CLEAN == 1 ]] && clean_modules $REMOTE_LIST_CLEAN [[ $REMOTE_BUILD == 1 ]] && generate_target $REMOTE_LIST_BUILD fi if [[ $SERVER_CLEAN == 1 || $SERVER_BUILD == 1 ]]; then diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.build b/remote/rootfs/rootfs-stage31/rootfs-stage31.build index d0a95238..e5e45312 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.build +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.build @@ -4,40 +4,18 @@ fetch_source() { } build() { - - BUILDDIR="${TARGET_DIR}/${MODULE}/build" - - FILELIST="list_binaries_and_files" - [ -e "${FILELIST}" ] && rm "${FILELIST}" - - for BIN in ${REQUIRED_BINARIES} - do + COPYLIST="list_binaries_and_files" + [ -e $COPYLIST ] && rm -f $COPYLIST + for BIN in $REQUIRED_BINARIES; do BIN_LOCATION=$(which ${BIN}) - if [ ! -z ${BIN_LOCATION} -a -e ${BIN_LOCATION} ]; - then - pdebug "Processing $BIN at $BIN_LOCATION ..." - get_link_chain ${BIN_LOCATION} >> "${FILELIST}" - else - perror "${BIN} not found on the system! Please install it." - fi + [ ! -z "${BIN_LOCATION}" -a -e "${BIN_LOCATION}" ] \ + && get_link_chain "${BIN_LOCATION}" >> "${COPYLIST}" done - - for FILE in ${REQUIRED_DIRECTORIES} - do - [ ! -d ${FILE} ] && perror "Missing required directory $FILE" - echo ${FILE} >> "${FILELIST}" - done - for FILE in ${REQUIRED_FILES} - do - [ ! -f ${FILE} ] && perror "Missing required file $FILE" - echo ${FILE} >> "${FILELIST}" + for FILE in $REQUIRED_FILES; do + get_link_chain "${FILE}" >> "${COPYLIST}" done - local NUMFILES=$(cat "${FILELIST}" | wc -l) - if [ "x$NUMFILES" != "x" -a "x$NUMFILES" != "x0" ]; then - pinfo "File list generated at ${BUILDDIR}/${FILELIST} ($NUMFILES entries)" - tarcopy "$(cat "${FILELIST}")" "${BUILDDIR}" - fi + tarcopy "$(cat $COPYLIST|sort -u)" "${MODULE_BUILD_DIR}" } post_copy() { @@ -47,6 +25,9 @@ post_copy() { copy_firmware } +# +# helper functions to generate the base rootfs +# generate_rootfs() { # create basic directory structure mkdir -p "${TARGET_BUILD_DIR}"/{bin,dev,proc,run,etc,mnt,sys} \ @@ -63,7 +44,7 @@ generate_rootfs() { tarcopy "${REQUIRED_FILES}" "${TARGET_BUILD_DIR}" # copy static data - cp -r "${MODULE_DIR}"/core/data/* "${TARGET_BUILD_DIR}" + cp -r "${MODULE_DIR}"/data/* "${TARGET_BUILD_DIR}" } copy_kernel_modules() { @@ -72,7 +53,7 @@ copy_kernel_modules() { [ -e $MODLIST ] && rm -f $MODLIST # process modules list - for MOD in ${REQUIRED_MODULES}; do + for MOD in ${REQUIRED_KERNEL_MODULES}; do local MOD_PATH="/lib/modules/${KERNEL_VERSION}/${MOD}" if [ ! -e "${MOD_PATH}" ]; then pwarning "Module $MOD not found. Skipping. (might cause problem on certain clients!)" @@ -88,13 +69,13 @@ copy_kernel_modules() { pinfo "Copying $MODLISTCOUNT modules to stage 3.1 target directory." tarcopy "$(cat "$MODLIST")" "${TARGET_BUILD_DIR}" fi - + rm -rf $MODLIST } generate_modules_map_files() { # first strip modules.order of all the modules we don't use - cat /lib/modules/"${KERNEL_VERSION}"/modules.order | grep -E $(echo ${REQUIRED_MODULES} | tr '\ ' '|') \ + cat /lib/modules/"${KERNEL_VERSION}"/modules.order | grep -E $(echo ${REQUIRED_KERNEL_MODULES} | tr '\ ' '|') \ >> "${TARGET_BUILD_DIR}"/lib/modules/"${KERNEL_VERSION}"/modules.order # copy list of builtin kernel modules @@ -131,4 +112,5 @@ copy_firmware() { pinfo "Copying $FWLISTCOUNT firmware to stage 3.1 target directory." tarcopy "$(cat "$FWLIST")" "${TARGET_BUILD_DIR}" fi + rm -f $FWLIST } diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf index 4015e4a3..ea9fd580 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf @@ -1,57 +1,58 @@ -REQUIRED_MODULES=" kernel/drivers/video/sis/sisfb.ko - kernel/drivers/video/via/viafb.ko - kernel/drivers/video/uvesafb.ko - kernel/drivers/acpi/video.ko - kernel/drivers/ssb/ssb.ko - kernel/drivers/gpu/drm/ttm/ttm.ko - kernel/drivers/gpu/drm/via/via.ko - kernel/drivers/gpu/drm/drm.ko - kernel/drivers/gpu/drm/tdfx/tdfx.ko - kernel/drivers/gpu/drm/nouveau/nouveau.ko - kernel/drivers/gpu/drm/savage/savage.ko - kernel/drivers/gpu/drm/radeon/radeon.ko - kernel/drivers/gpu/drm/drm_kms_helper.ko - kernel/drivers/gpu/drm/i810/i810.ko - kernel/drivers/gpu/drm/i2c/ch7006.ko - kernel/drivers/gpu/drm/i2c/sil164.ko - kernel/drivers/gpu/drm/sis/sis.ko - kernel/drivers/gpu/drm/mga/mga.ko - kernel/drivers/gpu/drm/i915/i915.ko - kernel/drivers/gpu/drm/r128/r128.ko - kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko - kernel/drivers/i2c/algos/i2c-algo-bit.ko - kernel/drivers/net/netconsole.ko - kernel/drivers/net/ethernet/realtek/8139too.ko - kernel/drivers/net/ethernet/realtek/r8169.ko - kernel/drivers/net/ethernet/nvidia/forcedeth.ko - kernel/drivers/net/ethernet/via/via-rhine.ko - kernel/drivers/net/ethernet/amd/pcnet32.ko - kernel/drivers/net/ethernet/atheros/atl1e/atl1e.ko - kernel/drivers/net/ethernet/atheros/atl1c/atl1c.ko - kernel/drivers/net/ethernet/sis/sis900.ko - kernel/drivers/net/ethernet/broadcom/tg3.ko - kernel/drivers/net/ethernet/broadcom/b44.ko - kernel/drivers/net/ethernet/intel/e1000/e1000.ko - kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko - kernel/drivers/net/ethernet/intel/e100.ko - kernel/drivers/net/ethernet/marvell/skge.ko - kernel/drivers/net/ethernet/3com/3c59x.ko - kernel/drivers/net/ethernet/dec/tulip/tulip.ko - kernel/drivers/hid/hid.ko - kernel/drivers/hid/usbhid/usbhid.ko - kernel/drivers/platform/x86/wmi.ko - kernel/drivers/platform/x86/mxm-wmi.ko - kernel/fs/configfs/configfs.ko - kernel/fs/nfs_common/nfs_acl.ko - kernel/fs/nfs/nfs.ko - kernel/fs/fscache/fscache.ko - kernel/fs/lockd/lockd.ko - kernel/fs/squashfs/squashfs.ko - kernel/net/sunrpc/sunrpc.ko - kernel/net/sunrpc/auth_gss/auth_rpcgss.ko - kernel/net/802/stp.ko - kernel/net/bridge/bridge.ko - kernel/ubuntu/aufs/aufs.ko" +REQUIRED_BINARIES=" v86d" +REQUIRED_KERNEL_MODULES=" kernel/drivers/video/sis/sisfb.ko + kernel/drivers/video/via/viafb.ko + kernel/drivers/video/uvesafb.ko + kernel/drivers/acpi/video.ko + kernel/drivers/ssb/ssb.ko + kernel/drivers/gpu/drm/ttm/ttm.ko + kernel/drivers/gpu/drm/via/via.ko + kernel/drivers/gpu/drm/drm.ko + kernel/drivers/gpu/drm/tdfx/tdfx.ko + kernel/drivers/gpu/drm/nouveau/nouveau.ko + kernel/drivers/gpu/drm/savage/savage.ko + kernel/drivers/gpu/drm/radeon/radeon.ko + kernel/drivers/gpu/drm/drm_kms_helper.ko + kernel/drivers/gpu/drm/i810/i810.ko + kernel/drivers/gpu/drm/i2c/ch7006.ko + kernel/drivers/gpu/drm/i2c/sil164.ko + kernel/drivers/gpu/drm/sis/sis.ko + kernel/drivers/gpu/drm/mga/mga.ko + kernel/drivers/gpu/drm/i915/i915.ko + kernel/drivers/gpu/drm/r128/r128.ko + kernel/drivers/gpu/drm/vmwgfx/vmwgfx.ko + kernel/drivers/i2c/algos/i2c-algo-bit.ko + kernel/drivers/net/netconsole.ko + kernel/drivers/net/ethernet/realtek/8139too.ko + kernel/drivers/net/ethernet/realtek/r8169.ko + kernel/drivers/net/ethernet/nvidia/forcedeth.ko + kernel/drivers/net/ethernet/via/via-rhine.ko + kernel/drivers/net/ethernet/amd/pcnet32.ko + kernel/drivers/net/ethernet/atheros/atl1e/atl1e.ko + kernel/drivers/net/ethernet/atheros/atl1c/atl1c.ko + kernel/drivers/net/ethernet/sis/sis900.ko + kernel/drivers/net/ethernet/broadcom/tg3.ko + kernel/drivers/net/ethernet/broadcom/b44.ko + kernel/drivers/net/ethernet/intel/e1000/e1000.ko + kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko + kernel/drivers/net/ethernet/intel/e100.ko + kernel/drivers/net/ethernet/marvell/skge.ko + kernel/drivers/net/ethernet/3com/3c59x.ko + kernel/drivers/net/ethernet/dec/tulip/tulip.ko + kernel/drivers/hid/hid.ko + kernel/drivers/hid/usbhid/usbhid.ko + kernel/drivers/platform/x86/wmi.ko + kernel/drivers/platform/x86/mxm-wmi.ko + kernel/fs/configfs/configfs.ko + kernel/fs/nfs_common/nfs_acl.ko + kernel/fs/nfs/nfs.ko + kernel/fs/fscache/fscache.ko + kernel/fs/lockd/lockd.ko + kernel/fs/squashfs/squashfs.ko + kernel/net/sunrpc/sunrpc.ko + kernel/net/sunrpc/auth_gss/auth_rpcgss.ko + kernel/net/802/stp.ko + kernel/net/bridge/bridge.ko + kernel/ubuntu/aufs/aufs.ko" REQUIRED_FIRMWARE=" 3com/ e100/ matrox/ diff --git a/remote/setup_core b/remote/setup_core deleted file mode 100755 index 31854db6..00000000 --- a/remote/setup_core +++ /dev/null @@ -1,219 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2013 - OpenSLX GmbH -# -# This program is free software distributed under the GPL version 2. -# See http://openslx.org/COPYING -# -# If you have any feedback please consult http://openslx.org/feedback and -# send your suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# -# -# Script to create the stage3.1 root file system: -# - generate the rootfs directory structure and copy system devices -# - copies kernel modules and firmware as given in the config -# file (core/core.conf) to be able to load NIC/GFX modules early. -# - compile and include following tools: 'busybox' and 'hwinfo' -# - -MODULE_DIR="${ROOT_DIR}/remote" -STAGE31_DIR="${MODULE_DIR}/stage3.1" - -initial_checks() { - - [ ! -z "${KERNEL_VERSION}" ] || perror "No kernel version, cannot proceed." - [ ! -z "${ARCH_TRIPLET}" ] || perror "No arch triplet, cannot proceed." - - [ -d "${STAGE31_DIR}" ] || mkdir -p "${STAGE31_DIR}" - [ ! -z "$(which depmod)" ] || perror "No 'depmod' found on this systemd." - - [ -d "${MODULE_DIR}"/tools/busybox/build ] \ - || perror "No busybox found, build it with './mltk tools -b busybox'" -} - -read_config() { - local CORE_CONFIG="${MODULE_DIR}/core/core.conf" - [ ! -e "${CORE_CONFIG}" ] && perror "${MODULE_DIR}/core/core.conf not found." - . "${CORE_CONFIG}" || perror "Sourcing "${MODULE_DIR}"/core/core.conf failed." -} - -generate_rootfs() { - # create basic directory structure - mkdir -p "${STAGE31_DIR}"/{bin,dev,proc,run,etc,mnt,sys} \ - || perror "Cannot create basic directory structure in '${STAGE31_DIR}'" - - # copy device files from running system - cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ - "${STAGE31_DIR}"/dev || perror "Cannot copy devices from running system" - - # copy libc and ld-linux - tarcopy "$(list_basic_libs)" "${STAGE31_DIR}" - - # copy required files - tarcopy "${REQUIRED_FILES}" "${STAGE31_DIR}" - - # copy static data - cp -r "${MODULE_DIR}"/core/data/* "${STAGE31_DIR}" -} - -copy_kernel_modules() { - - local MODLIST="stage31_modules_list" - [ -e $MODLIST ] && rm -f $MODLIST - - # process modules list - for MOD in ${REQUIRED_MODULES}; do - local MOD_PATH="/lib/modules/${KERNEL_VERSION}/${MOD}" - if [ ! -e "${MOD_PATH}" ]; then - pwarning "Module $MOD not found. Skipping. (might cause problem on certain clients!)" - continue - else - pdebug "Copying "${MOD_PATH}"" - echo "${MOD_PATH}" >> "${MODLIST}" - fi - done - - if [ -s "$MODLIST" ]; then - local MODLISTCOUNT=$(cat "$MODLIST" | wc -l) - pinfo "Copying $MODLISTCOUNT modules to stage 3.1 target directory." - tarcopy "$(cat "$MODLIST")" "${STAGE31_DIR}" - fi - -} - -generate_modules_map_files() { - - # first strip modules.order of all the modules we don't use - cat /lib/modules/"${KERNEL_VERSION}"/modules.order | grep -E $(echo ${REQUIRED_MODULES} | tr '\ ' '|') \ - >> "${STAGE31_DIR}"/lib/modules/"${KERNEL_VERSION}"/modules.order - - # copy list of builtin kernel modules - cp /lib/modules/"${KERNEL_VERSION}"/modules.builtin "${STAGE31_DIR}"/lib/modules/"${KERNEL_VERSION}" - # with modules.order and modules.builtin, we can run depmod for the rest of the files - depmod -b "${STAGE31_DIR}" -} - -copy_firmware() { - - local FWLIST="stage31_firmware_list" - [ -e $FWLIST ] && rm -f $FWLIST - - local FW_PATH="/lib/firmware" - - # process firmware list - for FW in ${REQUIRED_FIRMWARE}; do - local FOUND=0 - if [ -e "${FW_PATH}"/"${FW}" ]; then - pdebug "Copying "${FW_PATH}"/"${FW}"" - echo "${FW_PATH}"/"${FW}" >> "$FWLIST" - FOUND=1 - fi - if [ -e "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}" ]; then - pdebug "Copying "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}"" - echo "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}" >> "$FWLIST" - FOUND=1 - fi - [ $FOUND -ne 1 ] && pwarning "Neither "${FW_PATH}"/"${FW}" nor "${FW_PATH}"/"${KERNEL_VERSION}"/"${FW}" found on the system." - done - - if [ -s "${FWLIST}" ]; then - local FWLISTCOUNT=$(cat "$FWLIST"|wc -l) - pinfo "Copying $FWLISTCOUNT firmware to stage 3.1 target directory." - tarcopy "$(cat "$FWLIST")" "${STAGE31_DIR}" - fi -} - - -install_basic_tools() { - # get busybox from tools/ we checked earlier if its there. - pinfo "Copying busybox to ${STAGE31_DIR}." - cp -r "${MODULE_DIR}"/tools/busybox/build/openslx/* "${STAGE31_DIR}" - - # install plymouth - pinfo "Copying plymouth to ${STAGE31_DIR}." - rm -f list.ply - cd "${MODULE_DIR}"/tools/plymouth/build - echo ./bin/plymouth >> list.ply - echo ./sbin/plymouthd >> list.ply - get_dynamic_dependencies -l "${MODULE_DIR}"/tools/plymouth/build ./bin/plymouth >> list.ply - get_dynamic_dependencies -l "${MODULE_DIR}"/tools/plymouth/build ./sbin/plymouthd >> list.ply - for i in $(find lib/plymouth -name \*.so); do - get_link_chain "${MODULE_DIR}"/tools/plymouth/build/"$i" "${MODULE_DIR}"/tools/plymouth/build >> list.ply - get_dynamic_dependencies -l "${MODULE_DIR}"/tools/plymouth/build $i >> list.ply - done - tarcopy "$(cat list.ply | sort -u)" "${STAGE31_DIR}" - cd - &> /dev/null - cp -r "${MODULE_DIR}"/tools/plymouth/data/* "${STAGE31_DIR}" - - # copy debugging tools - STRACE=$(which strace) - [ "x${STRACE}" != "x" ] && tarcopy "$(get_link_chain ${STRACE})" "${STAGE31_DIR}" - - LDD=$(which ldd) - [ "x${LDD}" != "x" ] && tarcopy "$(get_link_chain ${LDD})" "${STAGE31_DIR}" - - # get hwinfo and the required libx86emu - [ ! -d "${MODULE_DIR}"/core/src ] && mkdir -p "${MODULE_DIR}"/core/src - cd "${MODULE_DIR}"/core/src - - # start with libx86emu - pinfo "Cloning 'git://gitorious.org/x86emu/libx86emu.git'..." - git clone git://gitorious.org/x86emu/libx86emu.git - cd libx86emu - pinfo "Compiling 'libx86emu'..." - make || perror "libx86emu: make failed." - pinfo "Installing 'libx86emu' in ${MODULE_DIR}/core/build" - DESTDIR="${MODULE_DIR}"/core/build make install || perror "libx86emu: make install to "${STAGE31_DIR}" failed." - cd - &> /dev/null - - # now hwinfo - pinfo "Cloning 'git://gitorious.org/opensuse/hwinfo.git'..." - git clone git://gitorious.org/opensuse/hwinfo.git - cd hwinfo - pinfo "Compiling 'hwinfo'..." - make || perror "hwinfo: make failed." - pinfo "Installing 'hwinfo' in ${MODULE_DIR}/core/build" - DESTDIR="${MODULE_DIR}"/core/build make install || perror "hwinfo: make install failed." - cd - &> /dev/null - - # get dependencies of hwinfo - cd "${MODULE_DIR}"/core/build - HWINFO=$(find . -type f -name hwinfo -executable) - get_link_chain "${MODULE_DIR}"/core/build/"${HWINFO}" "${MODULE_DIR}"/core/build >> list_wanted_stage3.1 - get_dynamic_dependencies -l "${MODULE_DIR}"/core/build "${MODULE_DIR}"/core/build/"${HWINFO}" >> list_wanted_stage3.1 - tarcopy "$(cat list_wanted_stage3.1)" "${STAGE31_DIR}" - cd - &> /dev/null -} - -generate_stage31() { - - local TOOL_STR="[core]" - - pinfo "Generating stage 3.1 file system..." - cd "${MODULE_DIR}"/core - initial_checks - read_config - generate_rootfs - copy_kernel_modules - generate_modules_map_files - copy_firmware - install_basic_tools - cd - &> /dev/null -} - -clean_core() { - pinfo "Cleaning '${STAGE31_DIR}'..." - [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed."; } - pinfo "Cleaning '${MODULE_DIR}/core'..." - [ -e ${MODULE_DIR}/core/stage31_modules_list ] && { rm -f ${MODULE_DIR}/core/stage31_modules_list || perror "rm -f failed."; } - [ -e ${MODULE_DIR}/core/stage31_firmware_list ] && { rm -f ${MODULE_DIR}/core/stage31_firmware_list || perror "rm -f failed."; } - pinfo "Cleaning '${MODULE_DIR}/core/build'..." - [ -e ${MODULE_DIR}/core/build ] && { rm -rf ${MODULE_DIR}/core/build || perror "rm -rf failed."; } - pinfo "Cleaning '${MODULE_DIR}/core/src'..." - [ -e ${MODULE_DIR}/core/src ] && { rm -rf ${MODULE_DIR}/core/src || perror "rm -rf failed."; } - -} diff --git a/remote/setup_tools b/remote/setup_target index 713d03fd..c1a45787 100755 --- a/remote/setup_tools +++ b/remote/setup_target @@ -1,10 +1,13 @@ #!/bin/bash MODE_DIR="${ROOT_DIR}/remote" - -#Create tools directory if not exists MODULES_DIR="${MODE_DIR}/modules" +# check for target directory +TARGET_DIR="${MODE_DIR}/targets/${TARGET}" +[ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET" +TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}" + # Keep track of processed modules PROCESSED_MODULES="" @@ -133,14 +136,8 @@ generate_target() { initial_checks - [[ $TARGET == build || $TARGET == modules ]] && \ - perror "Target directory cannot be named 'build' nor 'modules'." - - # check for target directory - TARGET_DIR="${MODE_DIR}/targets/${TARGET}" - [ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET" - - TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}" + [[ $TARGET == builds || $TARGET == modules ]] && \ + perror "Target directory cannot be named 'builds' nor 'modules'." pinfo "Generating '$TARGET_BUILD_DIR' for '$TARGET'" @@ -219,35 +216,30 @@ process_module() { # TODO pinfo "Module completed." else - perror "Module directory for '$MODULE' not found." - # maybe make this a warning instead of error? + pwarning "Module directory for '$MODULE' not found." fi } -clean_tools() { +clean_modules() { if [ "x$1" = "x" -o "x$1" = "xall" ]; then - #clean all if [ -d ${TARGET_BUILD_DIR} ]; then - rm -rf "${TARGET_BUILD_DIR}"/* || perror "Error deleting $TARGET_BUILD_DIR" + pinfo "Cleaning '${TARGET_BUILD_DIR}'" \ + && rm -rf "${TARGET_BUILD_DIR}"/* \ + || perror "Error deleting $TARGET_BUILD_DIR" fi - for MODULE in $(ls ${MODULES_DIR}); do - clean_tool $MODULE - done - else - while (( "$#" )); do - clean_tool $1 - shift - done + set -- $(ls ${TARGET_DIR}) fi + cd ${TARGET_DIR} + while (( "$#" )); do + clean_module $(readlink -f $1) + shift + done + cd - &> /dev/null } -clean_tool() { - local MODULE_DIR=${MODULES_DIR}/$1 - pinfo "Cleaning '${MODULE_DIR}'..." - #[ -e ${TOOLDIR}/build/list_wanted_stage3.2 ] && cd ${TARGET_BUILD_DIR} \ - # && xargs rm < ${TOOLDIR}/build/list_wanted_stage3.2 - #[ -d ${TOOLDIR}/data ] && cd ${TARGET_BUILD_DIR} \ -# && xargs rm < $(find ${TOOLDIR}/data -type f) +clean_module() { + pinfo "Cleaning '$1'..." + local MODULE_DIR=$1 if [ -e ${MODULE_DIR}/.built ]; then rm "${MODULE_DIR}/.built" || perror "Could not clear built flag" fi @@ -263,4 +255,7 @@ clean_tool() { if [ -e ${MODULE_DIR}/list_binaries_and_files ]; then rm "${MODULE_DIR}/list_binaries_and_files" || perror "Could not delete list_binaries_and_files" fi + if [ -e ${MODULE_DIR}/stage32.log ]; then + rm "${MODULE_DIR}/stage32.log" || perror "Could not delete stage32.log" + fi } |
