summaryrefslogtreecommitdiffstats
path: root/remote/setup_target
diff options
context:
space:
mode:
authorMichael Neves2013-03-20 15:22:51 +0100
committersr2013-04-12 19:11:30 +0200
commit97b4ba82596ae5484079483afeaba7986958ecab (patch)
treef85896acc369038481d6a3338561258a6683ea69 /remote/setup_target
parentuse default location for aufs.ko (diff)
downloadtm-scripts-97b4ba82596ae5484079483afeaba7986958ecab.tar.gz
tm-scripts-97b4ba82596ae5484079483afeaba7986958ecab.tar.xz
tm-scripts-97b4ba82596ae5484079483afeaba7986958ecab.zip
KERNEL_VERSION from system.inc
gitignore and calc_size in fileutil calculates the build size of a module fix generate_target argument parsing add xfs to rootfs-stage31.conf added server sync option -s - Fix sshd module failing to set permissions on sshd config - Add all required packages for openSUSE to xorg module - Softlink sh to bash in rootfs-stage32, as some scripts might fail otherwise Thanks hwinfo but we don't need you anymore Added size log fix list_packet_files exiting loop when a packet wasnt installed remove flag checks, now done in setup_target check if kernel module is already built-in
Diffstat (limited to 'remote/setup_target')
-rwxr-xr-xremote/setup_target93
1 files changed, 44 insertions, 49 deletions
diff --git a/remote/setup_target b/remote/setup_target
index e7370b1b..ade57c8b 100755
--- a/remote/setup_target
+++ b/remote/setup_target
@@ -19,22 +19,6 @@ initial_checks () {
}
-copy_kernel() {
-
- local KERNEL_VER="vmlinuz-$(uname -r)"
- [ -e "${KERNEL_DIR}/${KERNEL_VER}" ] && return
-
- local TOOL_STR="$TOOL_STR copy_kernel:"
-
- [ ! -d "${KERNEL_DIR}" ] && mkdir -p ${KERNEL_DIR}
-
- pinfo "New kernel found. Copying '${KERNEL_VER}' to '${KERNEL_DIR}'."
- pinfo "You may want to update your systems firmware/modules to match the current kernel."
-
- cp "/boot/${KERNEL_VER}" "${KERNEL_DIR}" || perror "Cannot copy kernel from '/boot/${KERNEL_VER}' to '${KERNEL_DIR}'"
-
-}
-
read_config () {
# unset previous variables from other config files
@@ -44,14 +28,12 @@ read_config () {
local MODULE_CONFIG="${MODULE_DIR}/${MODULE}.conf"
+ # otherwise, use the generic one
+ [ ! -e "${MODULE_CONFIG}" ] && perror "Config for '$MODULE' not found."
+ . "${MODULE_CONFIG}" || perror "Sourcing '${MODULE_CONFIG}' failed."
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
+ # a specific tool.conf seems to exist, use it to override certain vars
. "${MODULE_CONFIG}.${PACKET_MANAGER}" || perror "Sourcing '${MODULE_CONFIG}.${PACKET_MANAGER}' failed."
- else
- # otherwise, use the generic one
- [ ! -e "${MODULE_CONFIG}" ] && perror "Config for '$MODULE' not found."
- . "${MODULE_CONFIG}" || perror "Sourcing '${MODULE_CONFIG}' failed."
fi
}
@@ -77,25 +59,31 @@ copy_files_with_deps () {
for FILENAME in ${REQUIRED_BINARIES}
do
local FILE_CANDIDATES=$( find . -name "${FILENAME}" -a \( -type f -o -type l \) )
- pdebug "Candidates for $FILENAME are: $FILE_CANDIDATES"
- local FINAL_LIST=""
- for FILE in $FILE_CANDIDATES; do
- local TESTFILE="$(readlink -f "$FILE")"
- pdebug " $FILE leads to $TESTFILE"
- [ -f "$TESTFILE" -a -x "$TESTFILE" ] && [ "x$(grep -l -E '^(.ELF|#!)' "$TESTFILE")" != "x" ] && FINAL_LIST="$FINAL_LIST $FILE"
- done
- FINAL_LIST=$(trim "$FINAL_LIST")
- pdebug " Final list is $FINAL_LIST"
- if [ -z "$FINAL_LIST" ]; then
- pwarning "\tNo Binary found for ${FILENAME}. Skipping."
- continue
- fi
- if [[ "$FINAL_LIST" == *" "* ]]; then
- pwarning "Found more than one match for required file '$FILENAME': $FINAL_LIST"
+ # only do if more than one candidate found
+ if [ $(echo $FILE_CANDIDATES | wc -w) -gt 1 ]; then
+ pdebug "Candidates for $FILENAME are: $(echo $FILE_CANDIDATES)"
+ local FINAL_LIST=""
+ for FILE in $FILE_CANDIDATES; do
+ local TESTFILE="$(readlink -f "$FILE")"
+ pdebug " $FILE leads to $TESTFILE"
+ [ -f "$TESTFILE" -a -x "$TESTFILE" ] && [ "x$(grep -l -E '^(.ELF|#!)' "$TESTFILE")" != "x" ] && FINAL_LIST="$FINAL_LIST $FILE"
+ done
+ FINAL_LIST=$(trim "$FINAL_LIST")
+ if [ -z "$FINAL_LIST" ]; then
+ pwarning "\tNo Binary found for ${FILENAME}. Skipping."
+ continue
+ fi
+ if [[ "$FINAL_LIST" == *" "* ]]; then
+ pwarning "Found more than one match for required file '$FILENAME': $FINAL_LIST"
+ else
+ pdebug "\tFound ${FILENAME} at ${FILE}"
+ fi
else
- pdebug "\tFound ${FILENAME} at ${FILE}"
+ # one candidate
+ FINAL_LIST=${FILE_CANDIDATES}
fi
for FILE in $FINAL_LIST; do
+ pdebug "* $FILE"
strip $FILE || pwarning "Could not strip '${FILE}'"
get_link_chain "${MODULE_BUILD_DIR}/${FILE}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}"
get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${FILE}" >> "${COPYFILES_LIST}"
@@ -118,11 +106,11 @@ copy_files_with_deps () {
local CURRENT_PWD=$(pwd) # Prevent calling pwd 50000 times inside the loop below
for ENTRY in ${REQUIRED_DIRECTORIES}
do
- pdebug "* ./$ENTRY"
+ pdebug "* .$ENTRY"
echo "./${ENTRY}" >> "${COPYFILES_LIST}"
- for BIN in $(find "./${ENTRY}" -type f -not -name '*.a' | xargs grep -l '^.ELF')
+ for BIN in $(find ".${ENTRY}" -type f -not -name '*.a' | xargs grep -l '^.ELF')
do
- pdebug " Searching libs for ${BIN}..."
+ #pdebug "\tSearching libs for ${BIN}..."
get_link_chain "${MODULE_BUILD_DIR}/${BIN}" "${MODULE_BUILD_DIR}" >> "${COPYFILES_LIST}"
get_dynamic_dependencies -l "${MODULE_BUILD_DIR}" "${BIN}" >> "${COPYFILES_LIST}"
done
@@ -137,7 +125,7 @@ copy_files_with_deps () {
#copy to initramfsdir
- pdebug "[stage32] File list generated at ${MODULE_BUILD_DIR}/${COPYFILES_LIST}."
+ pdebug "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 '${TARGET_BUILD_DIR}'."
@@ -150,9 +138,12 @@ generate_target() {
initial_checks
copy_kernel
- TARGET=$1
+ TARGET=$1 && shift
TARGET_DIR="${MODE_DIR}/targets/${TARGET}"
TARGET_BUILD_DIR="${MODE_DIR}/builds/${TARGET}"
+ [ -d "$TARGET_BUILD_DIR" ] && TARGET_BUILD_SIZE=$(du -bc "${TARGET_BUILD_DIR}" | awk 'END {print $1}') || TARGET_BUILD_SIZE=0
+ [ -e "${ROOT_DIR}/logs/${TARGET}.size" ] && . "${ROOT_DIR}/logs/${TARGET}.size" || echo "declare -A BUILD_SIZE" >> "${ROOT_DIR}/logs/${TARGET}.size"
+
[ -d $TARGET_DIR ] || perror "Given target directory does not exist: $TARGET_DIR"
[[ $TARGET == builds || $TARGET == modules ]] && \
@@ -161,7 +152,7 @@ generate_target() {
pinfo "Generating '$TARGET_BUILD_DIR' for '$TARGET'"
# if no arguments assume all.
- if [ "x$2" = "x" -o "x$2" = "xall" ]; then
+ if [ "x$1" = "x" -o "x$1" = "xall" ]; then
MODULES=$(ls ${TARGET_DIR})
set -- $MODULES
else
@@ -181,6 +172,7 @@ generate_target() {
process_module "$1"
shift
done
+ pinfo "Target completed. Total size: $(du -bsh "${TARGET_BUILD_DIR}" | awk 'END {print $1}')"
TOOL_STR=""
}
@@ -219,22 +211,22 @@ process_module() {
pinfo "## Installing dependencies"
install_dependencies
pinfo "## Fetching source"
- fetch_source
+ [ -e "${MODULE_DIR}/.fetched_source" ] || { fetch_source && touch "${MODULE_DIR}/.fetched_source"; }
pinfo "## Building"
- build
+ [ -e "${MODULE_DIR}/.built" ] || { build && touch "${MODULE_DIR}/.built"; }
# remove *.la files as they might confuse libtool/linker of other tool packages
- find "${MODULE_DIR}/build" -name '*.la' -exec rm -f {} \;
+ find "${MODULE_BUILD_DIR}" -name '*.la' -exec rm -f {} \;
pinfo "## Copying files with dependencies"
copy_files_with_deps
pinfo "## Copying static module files"
copy_static_data
pinfo "## Post copy"
post_copy
-
# reset pipes
#[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&-
# TODO
- pinfo "Module completed."
+ calc_size #sets MODULE_BUILD_SIZE and TARGET_BUILD_SIZE
+ pinfo "Module completed. Total size: ${MODULE_BUILD_SIZE}"
else
pwarning "Module directory for '$MODULE' not found."
fi
@@ -278,6 +270,9 @@ clean_module() {
if [ -d ${MODULE_DIR}/src ]; then
rm -rf "${MODULE_DIR}/src" || perror "Could not delete src path"
fi
+ if [ -e ${MODULE_DIR}/list_dpkg_output ]; then
+ rm "${MODULE_DIR}/list_dpkg_output" || perror "Could not delete list_dpkg_output"
+ fi
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