summaryrefslogtreecommitdiffstats
path: root/core/bin/setup_target
diff options
context:
space:
mode:
Diffstat (limited to 'core/bin/setup_target')
-rwxr-xr-xcore/bin/setup_target107
1 files changed, 99 insertions, 8 deletions
diff --git a/core/bin/setup_target b/core/bin/setup_target
index 30fafbf5..667f590e 100755
--- a/core/bin/setup_target
+++ b/core/bin/setup_target
@@ -324,7 +324,7 @@ generate_target_real() {
mkdir -p "$TARGET_BUILD_DIR" || perror "Failed to create $TARGET_BUILD_DIR"
prepare_usr_split "${TARGET_BUILD_DIR}"
- # if no arguments assume all.
+ # Set modules first, assume all if no arguments is given.
if [ "x$1" = "x" -o "x$1" = "xall" ]; then
MODULES=$( ls "${TARGET_DIR}" )
set -- $MODULES
@@ -333,16 +333,38 @@ generate_target_real() {
MODULES=$@
fi
+ # Now detect sub-targets
+ declare -Ag SUBTARGETS=()
+ for mod in $MODULES; do
+ SUBTARGET_DIR="${CORE_DIR}/targets/${mod}"
+ if [ -d "$SUBTARGET_DIR" ]; then
+ SUBTARGETS["$mod"]="$(ls $SUBTARGET_DIR)"
+ fi
+ done
+
pinfo "Activated modules in '${TARGET}':"
pinfo "\t$(echo ${MODULES})"
+ if [ -n "${SUBTARGETS[*]}" ]; then
+ pinfo "From subtargets '${!SUBTARGETS[*]}':"
+ pinfo "\t$(echo ${SUBTARGETS[*]})"
+ fi
# copy basic libs
pinfo "Copying libc and ld-linux used by ${SHELL}"
tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}"
- # now iterate over given tools and copy them
+ # now iterate over modules and/or subtargets and process them
+ declare -g MAINTARGET_DIR="$TARGET_DIR"
while (( "$#" )); do
- process_module "$1"
+ if [ -n "${SUBTARGETS["$1"]}" ]; then
+ declare -g TARGET_DIR="${CORE_DIR}/targets/${1}"
+ for submod in ${SUBTARGETS["$1"]}; do
+ process_module "$submod"
+ done
+ else
+ declare -g TARGET_DIR="$MAINTARGET_DIR"
+ process_module "$1"
+ fi
shift
done
@@ -376,6 +398,15 @@ process_module() {
local MD5FILE="${TARGET_BUILD_DIR}/opt/openslx/.mltk/${MODULE}.md5"
mkdir -p "${TARGET_BUILD_DIR}/opt/openslx/.mltk"
if [ ! -d "${MODULE_DIR}" ]; then
+ # not in this target's dir, check subtargets...
+ for target in "$MAINTARGET_DIR" "${!SUBTARGETS[@]}"; do
+ if [ -d "${target}/${MODULE}" ]; then
+ MODULE_DIR="${target}/${MODULE}"
+ break
+ fi
+ done
+ fi
+ if [ ! -d "${MODULE_DIR}" ]; then
if [ -z "$DEPOF" ]; then
perror "Module directory for '$MODULE' not found in ${TARGET_DIR}"
fi
@@ -490,6 +521,53 @@ process_module() {
post_process_target() {
local TOOL_STR="$TOOL_STR post_process_target:"
+ # For debugging purposes, install mode does not set TARGET_BUILD_DIR
+ # to / but rather builds the target traditionally. We then check file
+ # by file instead of a blind tarcopy
+ if [ ${REMOTE_LOCAL_INSTALL} -eq 1 ]; then
+ # default dest and exclude list for non-addons
+ local RSYNC_DEST='/'
+ local RSYNC_EXCLUDE_LIST="$(mktemp)"
+ # always exclude ld.so.cache, we handle that separately
+ echo 'etc/ld.so*' > "$RSYNC_EXCLUDE_LIST"
+ echo 'autoexec.bat' >> "$RSYNC_EXCLUDE_LIST"
+ if [ -e "${TARGET_DIR}/.addon" ]; then
+ RSYNC_DEST="/opt/openslx/addons/${TARGET_BUILD_DIR##*/}"
+ pinfo "Target is an addon, preparing install to '${RSYNC_DEST}'."
+ mkdir -p "${RSYNC_DEST}" || perror "Failed to mkdir '${RSYNC_DEST}'."
+ RSYNC_OPTS+=("--delete" "--delete-excluded")
+ cd "$TARGET_BUILD_DIR"
+ for entry in $(find . -not -type d); do
+ # diff them to be sure they are the same?
+ if [ -e "${entry:1}" ] && diff -q "${entry:1}" "${entry}"; then
+ echo "${entry:2}" >> "$RSYNC_EXCLUDE_LIST"
+ fi
+ done
+ cd - &> /dev/null
+ pinfo "Calling ldconfig on overlay'ed ${TARGET_BUILD_DIR##*/}..."
+ chroot_run "${TARGET_BUILD_DIR}" <<< "ldconfig"
+ if [ -f "${TARGET_BUILD_DIR}/etc/ld.so.cache" ]; then
+ mkdir -p "${TARGET_BUILD_DIR}/opt/openslx/etc"
+ mv -f -- "${TARGET_BUILD_DIR}/etc/ld.so.cache" \
+ "${TARGET_BUILD_DIR}/opt/openslx/etc/${TARGET_BUILD_DIR##*/}.ld.so.cache"
+ pinfo "... generated cache at '${TARGET_BUILD_DIR}/opt/openslx/etc/${TARGET_BUILD_DIR##*/}.ld.so.cache'."
+ fi
+ fi
+ pinfo "Rsyncing local build of '${TARGET_BUILD_DIR}' to '${RSYNC_DEST}'..."
+ rsync -aAXv "${RSYNC_OPTS[@]}" \
+ --exclude-from="${RSYNC_EXCLUDE_LIST}" \
+ "${TARGET_BUILD_DIR}/" "${RSYNC_DEST}" || \
+ perror "Failed to rsync, your system is probably trashed ;-("
+
+ [ "$REMOTE_DEBUG" -eq 0 ] && rm -f -- "$RSYNC_EXCLUDE_LIST"
+
+ # finish by running ldconfig for the running system (when processing non-addons).
+ if [ ! -e "${TARGET_DIR}/.addon" ]; then
+ ldconfig -v
+ depmod -a "${TARGET_KERNEL_LONG}"
+ fi
+ return 0
+ fi
# figure out all relevant ld-paths
pinfo "Running ldconfig"
cp -r -L /etc/ld.so.conf* "${TARGET_BUILD_DIR}/etc/"
@@ -518,13 +596,26 @@ clean_modules() {
else
rm -rf -- "${TARGET_BUILD_DIR}" || perror "Could not delete target build dir for $TARGET"
fi
- # exclude kernel on "all"
- set -- $(ls "${TARGET_DIR}" | grep -vE "^kernel$")
+ # prepare the list of modules to clean, e.g. <target>:<module>
+ # and exclude kernel on "all"
+ modlist=()
+ for active in $(ls "$TARGET_DIR"); do
+ [ "$active" = "kernel" ] && continue
+ if [ -d "${CORE_DIR}/targets/${active}" ]; then
+ for submod in $( ls ${CORE_DIR}/targets/${active} ); do
+ [ "$submod" = "kernel" ] && continue
+ modlist+=( "${active}:${submod}" )
+ done
+ else
+ modlist+=( "${TARGET}:${active}" )
+ fi
+ done
+ set -- "${modlist[@]}"
fi
- cd "$TARGET_DIR"
+ cd "$TARGET_DIR"
while (( "$#" )); do
- clean_module "${TARGET}:$1"
+ clean_module "$1"
shift
done
cd - &> /dev/null
@@ -532,7 +623,7 @@ clean_modules() {
clean_module() {
[ -z "$1" ] && perror "No module given on clean_module()"
- pinfo "## clean_module $1"
+ pinfo "## clean_module $1"
local TARGET=${1%:*}
local MODULE=${1#*:}