diff options
Diffstat (limited to 'remote/setup_tools')
| -rwxr-xr-x | remote/setup_tools | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/remote/setup_tools b/remote/setup_tools index dc7fafda..b554f448 100755 --- a/remote/setup_tools +++ b/remote/setup_tools @@ -3,14 +3,14 @@ MODE_DIR="${ROOT_DIR}/remote" #Create tools directory if not exists -TOOL_DIR="${MODE_DIR}/tools" +MODULES_DIR="${MODE_DIR}/modules" # Keep track of processed modules PROCESSED_MODULES="" initial_checks () { # check for required tools - for BIN in git locate + for BIN in git locate depmod do local TEST=$(which ${BIN}) [ -z "$TEST" ] && pinfo "Installing $BIN..." && apt-get install $BIN @@ -27,21 +27,21 @@ read_config () { unset REQUIRED_PACKAGES unset REQUIRED_DEPENDENCIES - local TOOL_CONFIG="${TOOL_DIR}/${TOOL}/${TOOL}.conf" + local MODULE_CONFIG="${MODULE_DIR}/${MODULE}.conf" - if [ -e "${TOOL_CONFIG}.${PACKET_MANAGER}" ]; then + if [ -e "${MODULE_CONFIG}.${PACKET_MANAGER}" ]; then # a specific tool.conf seems to exist, try to use that one # TODO: Maybe move this down right after loading the generic one, to allow "overloading".... but might be a bit confusing - . "${TOOL_CONFIG}.${PACKET_MANAGER}" || perror "Sourcing '${TOOL_CONFIG}.${PACKET_MANAGER}' failed." + . "${MODULE_CONFIG}.${PACKET_MANAGER}" || perror "Sourcing '${MODULE_CONFIG}.${PACKET_MANAGER}' failed." else # otherwise, use the generic one - [ ! -e "${TOOL_CONFIG}" ] && perror "Config for '$TOOL' not found." - . "${TOOL_CONFIG}" || perror "Sourcing '${TOOL_CONFIG}' failed." + [ ! -e "${MODULE_CONFIG}" ] && perror "Config for '$MODULE' not found." + . "${MODULE_CONFIG}" || perror "Sourcing '${MODULE_CONFIG}' failed." fi } read_build () { - local BUILD_SCRIPT="${TOOL_DIR}/${TOOL}/${TOOL}.build" + local BUILD_SCRIPT="${MODULE_DIR}/${MODULE}.build" [ ! -e "${BUILD_SCRIPT}" ] && perror "Build script for specified tool not found." @@ -49,9 +49,9 @@ read_build () { } copyfileswithdependencies () { - [ ! -d build ] && pinfo "No build directory found, skipping dependency copying" && return 0 - cd build + [ ! -d $MODULE_BUILD_DIR ] && pinfo "No build directory found, skipping dependency copying" && return 0 + cd $MODULE_BUILD_DIR COPYFILES_LIST="list_wanted_stage3.2" [ -e ${COPYFILES_LIST} ] && rm ${COPYFILES_LIST} @@ -81,8 +81,8 @@ copyfileswithdependencies () { fi for FILE in $FINAL_LIST; do strip $FILE || pwarning "Could not strip '${FILE}'" - get_link_chain "${TOOL_DIR}/${TOOL}/build/${FILE}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}" - get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${FILE}" >> "${COPYFILES_LIST}" + get_link_chain "${MODULE_BUILD_DIR}/${FILE}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}" + get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${FILE}" >> "${COPYFILES_LIST}" done done @@ -93,8 +93,8 @@ copyfileswithdependencies () { do pdebug "* $LOCATION" strip $LOCATION || pwarning "Could not strip '${LOCATION}'" - get_link_chain "${TOOL_DIR}/${TOOL}/build/${LOCATION}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}" - get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${LOCATION}" >> "${COPYFILES_LIST}" + get_link_chain "${MODULE_BUILD_DIR}/${LOCATION}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}" + get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${LOCATION}" >> "${COPYFILES_LIST}" done done @@ -107,21 +107,21 @@ copyfileswithdependencies () { for BIN in $(find "./${ENTRY}" -type f -not -name '*.a' | xargs grep -l '^.ELF') do pdebug " Searching libs for ${BIN}..." - get_link_chain "${TOOL_DIR}/${TOOL}/build/${BIN}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}" - get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${BIN}" >> "${COPYFILES_LIST}" + get_link_chain "${MODULE_BUILD_DIR}/${BIN}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}" + get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${BIN}" >> "${COPYFILES_LIST}" done done [ ! -z "${REQUIRED_FILES}" ] && pinfo "Gathering required files from config file..." for ENTRY in ${REQUIRED_FILES} do - get_link_chain "${TOOL_DIR}/${TOOL}/build/${ENTRY}" "${TOOL_DIR}/${TOOL}/build" >> "${COPYFILES_LIST}" - get_dynamic_dependencies -l "${TOOL_DIR}/${TOOL}/build" "${TOOL_DIR}/${TOOL}/build/.${ENTRY}" >> "${COPYFILES_LIST}" + get_link_chain "${MODULE_BUILD_DIR}/${ENTRY}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}" + get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${MODULE_BUILD_DIR}/.${ENTRY}" >> "${COPYFILES_LIST}" done #copy to initramfsdir - pdebug "[stage32] Completed file list generation at ${TOOL_DIR}/${TOOL}/build/${COPYFILES_LIST}." + pdebug "[stage32] File list generated at ${MODULE_BUILD_DIR}/${COPYFILES_LIST}." if [ -s "$COPYFILES_LIST" ]; then local CLISTCOUNT=$(cat "$COPYFILES_LIST" | wc -l) pinfo "Copying $CLISTCOUNT files to stage 3.2 target directory." @@ -170,33 +170,34 @@ generate_target() { process_module() { [ "$#" -ne "1" ] && perror "process_module: want 1 param." - local TOOL="$1" - [[ "$PROCESSED_MODULES" == *"!${TOOL}!"* ]] && return # Already processed this module - PROCESSED_MODULES="${PROCESSED_MODULES}!${TOOL}!" + local MODULE="$1" + local MODULE_DIR="${TARGET_DIR}/${MODULE}" + local MODULE_BUILD_DIR="${MODULE_DIR}/build" + [[ "$PROCESSED_MODULES" == *"!${MODULE}!"* ]] && return # Already processed this module + PROCESSED_MODULES="${PROCESSED_MODULES}!${MODULE}!" local TOOL_STR="" - pinfo ">>>>>>>>>>>>>>>>> Processing module [ $TOOL ]" - TOOL_STR="[${TOOL}]" - if [ -d "${TOOL_DIR}/${TOOL}" ]; - then + 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 "${TOOL_DIR}/${TOOL}" || perror "Tool dir '${TOOL_DIR}/${TOOL}' seems to exist, but cd to it failed." + cd "${MODULE_DIR}" || perror "Module dir '${MODULE_DIR}' seems to exist, but cd to it failed." pinfo "## Reading config" read_config # Check if this module has a dependency that wasn't built yet: if [ ! -z "$REQUIRED_MODULES" ]; then - pinfo "$TOOL depends on ${REQUIRED_MODULES}...." + pinfo "$MODULE depends on ${REQUIRED_MODULES}...." for DEP in $REQUIRED_MODULES; do #[[ "$DESIRED_MODULES" != *"!${DEP}!"* ]] && perror "$TOOL has dependency $DEP, but $DEP is not in current profile." process_module "$DEP" done # Read old config again, as it got overwritten by the deps - cd "${TOOL_DIR}/${TOOL}" || perror "Tool dir '${TOOL_DIR}/${TOOL}' seems to exist, but cd to it failed (after building deps)." + cd "${MODULE_DIR}" || perror "Tool dir '${MODULE_DIR}' seems to exist, but cd to it failed (after building deps)." read_config - pinfo "<<<<<<<<<<<<<<<<< Dependency modules processed, back to module [ $TOOL ]" + pinfo "<<<<<<<<<<<<<<<<< Dependency modules processed, back to module [ $MODULE ]" fi pinfo "## Reading build" read_build @@ -207,7 +208,7 @@ process_module() { pinfo "## Building" build # remove *.la files as they might confuse libtool/linker of other tool packages - find "${TOOL_DIR}/${TOOL}/build" -name '*.la' -exec rm -f {} \; + find "${MODULE_DIR}/build" -name '*.la' -exec rm -f {} \; pinfo "## Copying files with dependencies" copyfileswithdependencies pinfo "## Post copy" @@ -218,7 +219,7 @@ process_module() { # TODO pinfo "Module completed." else - perror "Tool directory for '$TOOL' not found." + perror "Module directory for '$MODULE' not found." # maybe make this a warning instead of error? fi } @@ -229,8 +230,8 @@ clean_tools() { if [ -d ${TARGET_BUILD_DIR} ]; then rm -rf "${TARGET_BUILD_DIR}"/* || perror "Error deleting $TARGET_BUILD_DIR" fi - for TOOL in $(ls ${TOOL_DIR}); do - clean_tool $TOOL + for MODULE in $(ls ${MODULES_DIR}); do + clean_tool $MODULE done else while (( "$#" )); do @@ -241,25 +242,25 @@ clean_tools() { } clean_tool() { - TOOLDIR=${TOOL_DIR}/$1 - pinfo "Cleaning '${TOOLDIR}'..." + 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) - if [ -e ${TOOLDIR}/.built ]; then - rm "${TOOLDIR}/.built" || perror "Could not clear built flag" + if [ -e ${MODULE_DIR}/.built ]; then + rm "${MODULE_DIR}/.built" || perror "Could not clear built flag" fi - if [ -e ${TOOLDIR}/.fetched_source ]; then - rm "${TOOLDIR}/.fetched_source" || perror "Could not clear fetched_source flag" + if [ -e ${MODULE_DIR}/.fetched_source ]; then + rm "${MODULE_DIR}/.fetched_source" || perror "Could not clear fetched_source flag" fi - if [ -d ${TOOLDIR}/build ]; then - rm -rf "${TOOLDIR}/build" || perror "Could not delete build path" + if [ -d ${MODULE_DIR}/build ]; then + rm -rf "${MODULE_DIR}/build" || perror "Could not delete build path" fi - if [ -d ${TOOLDIR}/src ]; then - rm -rf "${TOOLDIR}/src" || perror "Could not delete src path" + if [ -d ${MODULE_DIR}/src ]; then + rm -rf "${MODULE_DIR}/src" || perror "Could not delete src path" fi - if [ -e ${TOOLDIR}/list_binaries_and_files ]; then - rm "${TOOLDIR}/list_binaries_and_files" || perror "Could not delete list_binaries_and_files" + 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 } |
