summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--helper/fileutil.inc16
-rw-r--r--helper/logging.inc7
-rwxr-xr-xmltk2
-rwxr-xr-xremote/setup_tools11
-rwxr-xr-xserver/build_core27
5 files changed, 35 insertions, 28 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc
index 3c165d99..3e1ea56a 100644
--- a/helper/fileutil.inc
+++ b/helper/fileutil.inc
@@ -1,16 +1,18 @@
# copy list of files using tar
tarcopy () {
[ $# -ne 2 ] && perror "Sanity check failed: tarcopy needs exactly two params, but $# were given."
- if [ -z $1 ]; then
- pwarning "tarcopy called with empty input list (dest was '$2')"
+ local FROM=$(trim "$1")
+ local TO=$(trim "$2")
+ if [ -z "$FROM" ]; then
+ pwarning "tarcopy called with empty input list (dest was '$TO')"
return
fi
- local SHORT=$1
+ local SHORT=$FROM
[ ${#SHORT} -gt 23 ] && SHORT=$(echo "$SHORT" | cut -c-18)...$(echo "$SHORT" | cut -c$[${#SHORT} - 4]-)
- [ -z $2 ] && perror "tarcopy called with empty destination."
- tar -cp "$1" | tar -xp -C "$2"
+ [ -z "$TO" ] && perror "tarcopy called with empty destination."
+ tar -cp $FROM | tar -xp -C "$TO"
local PS=(${PIPESTATUS[*]})
- [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$2' failed. (${PS[0]})"
- [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$2' failed. (${PS[1]})"
+ [ "x${PS[0]}" != "x0" ] && perror "packing-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[0]})"
+ [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[1]})"
}
diff --git a/helper/logging.inc b/helper/logging.inc
index 4daf1e12..2d79c67c 100644
--- a/helper/logging.inc
+++ b/helper/logging.inc
@@ -20,9 +20,10 @@ set_quiet () {
unset_quiet () {
if [ "x$MLTK_QUIET" = "x1" ]; then
- exec 1>&6 6>&-
- exec 2>&7 7>&-
- MLTK_QUIET="0"
+ exec 1>&6 6>&-
+ exec 2>&7 7>&-
+ exec 6>&2
+ MLTK_QUIET="0"
fi
}
diff --git a/mltk b/mltk
index 424f63e3..40c49cbc 100755
--- a/mltk
+++ b/mltk
@@ -132,7 +132,7 @@ run() {
[ $BUILD ] && generate_stage32 $TOOLS
fi
if [ $TARGET_CORE ]; then
- unset_quiet # TODO: Make build_core logging.inc aware
+ local TOOL_STR="[CORE]"
. ${BUILD_CORE}
[ $CLEAN ] && clean_core
[ $BUILD ] && generate_stage31
diff --git a/remote/setup_tools b/remote/setup_tools
index 116dc4b1..67099197 100755
--- a/remote/setup_tools
+++ b/remote/setup_tools
@@ -167,11 +167,10 @@ generate_stage32 () {
cd ${TOOL_DIR}
while (( "$#" )); do
TOOL=$1
- if [ -d ${TOOL} ];
- then
- TOOL_STR="[${TOOL}]"
- pinfo "## ## Processing module ## ##"
-
+ TOOL_STR=""
+ pinfo ">>>>>>>>>>>>>>>> Processing module [ $TOOL ]"
+ TOOL_STR="[${TOOL}]"
+ if [ -d ${TOOL} ]; then
#[ "x$DEBUG" != "x1" ] \
# && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \
# && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log
@@ -199,13 +198,13 @@ generate_stage32 () {
#[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&-
# TODO
pinfo "## ## Module completed ## ##"
- TOOL_STR=""
else
perror "Tool directory for '$TOOL' not found."
# maybe make this a warning instead of error?
fi
shift
done
+ TOOL_STR=""
}
clean_tools() {
diff --git a/server/build_core b/server/build_core
index 6d975984..411036df 100755
--- a/server/build_core
+++ b/server/build_core
@@ -26,16 +26,17 @@ STAGE32_DIR=${ROOT_DIR}/remote/stage3.2
# initial checks
initial_checks() {
- [ -d ${STAGE32_DIR} ] || perror "No stage3.2 directory found. Please run './mltk tools build' first."
+ local TOOL_STR="$TOOL_STR initial_checks:"
+ [ -d "${STAGE32_DIR}" ] || perror "No stage3.2 directory found. Please run './mltk tools build' first."
- [ -e ${STAGE32_DIR}/openslx/bin/busybox ] || perror "Busybox not found, run './mltk tools build busybox' first."
+ [ -e "${STAGE32_DIR}/openslx/bin/busybox" ] || perror "Busybox not found, run './mltk tools build busybox' first."
# shouldn't squashfs-tools be automatically installed as we need them nevertheless!?
# what if it is already on the machine? faster to check with which than the apt-get check?
- if [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
+ [ -z $(which mksquashfs) ] && perror "mksquashfs not found, please install squashfs-tools first."
#check for kernel modules, if not present copy from system
- if [ ! -d ${STAGE32_DIR}/lib/modules ];
+ if [ ! -d "${STAGE32_DIR}/lib/modules" ];
then
pinfo "Couldn't find kernel modules in stage3.2."
pinfo "Copying modules for kernel $(uname -r)..."
@@ -49,6 +50,7 @@ initial_checks() {
}
generate_rootfs() {
+ local TOOL_STR="$TOOL_STR generate_rootfs:"
# produce stage3.1
mkdir -p "${STAGE31_DIR}" || perror "Cannot create stage3.1 dir '${STAGE31_DIR}'"
@@ -61,7 +63,7 @@ generate_rootfs() {
"${STAGE31_DIR}"/dev || perror "Cannot copy devices from running system"
# copy busybox, its libs and static data to stage3.1
- cp -r "${STAGE32_DIR}/openslx/*" "${STAGE31_STATIC_DIR}/*" "${STAGE31_DIR}" || perror "Copying busybox, its libs and static data failed."
+ cp -r "${STAGE32_DIR}"/openslx/* "${STAGE31_STATIC_DIR}"/* "${STAGE31_DIR}" || perror "Copying busybox, its libs and static data failed."
# fix for aufs & squashfs modules needed for stage 3.1
mkdir -p "${STAGE31_DIR}/lib/modules.0/" || perror "Creating modules.0 dir for aufs & squashfs in stage 3.1 failed."
@@ -82,18 +84,20 @@ generate_rootfs() {
}
generate_squashfs() {
+ local TOOL_STR="$TOOL_STR generate_squashfs:"
# finalize the initramfs target
[ -e "${STAGE31_DIR}/mnt/openslx.sqfs" ] && rm "${STAGE31_DIR}/mnt/openslx.sqfs"
- mksquashfs "${STAGE32_DIR}" "${STAGE31_DIR}/mnt/openslx.sqfs" -comp xz -b 1M -no-recovery || perror "mksquashfs failed ($?)."
+ mksquashfs "${STAGE32_DIR}" "${STAGE31_DIR}/mnt/openslx.sqfs" -comp xz -b 1M -no-recovery >&6 || perror "mksquashfs failed ($?)."
}
generate_initramfs() {
+ local TOOL_STR="$TOOL_STR generate_initramfs:"
cd "${STAGE31_DIR}" || perror "Cannot cd to '${STAGE31_DIR}'"
find . | cpio --format="newc" --create | gzip -9 > "${MODULE_DIR}/initramfs"
- local PS=($PIPESTATUS[*])
- [ "x${PS[0]}" != "x0" ] && perror "'find .' failed."
+ local PS=(${PIPESTATUS[*]})
+ [ "x${PS[0]}" != "x0" ] && perror "'find .' in '$(pwd)' failed."
[ "x${PS[1]}" != "x0" ] && perror "cpio create failed."
[ "x${PS[2]}" != "x0" ] && perror "gzip to '${MODULE_DIR}/initramfs' failed."
cd -
@@ -108,13 +112,14 @@ generate_stage31() {
# TODO better kernel copy
cp "/boot/vmlinuz-$(uname -r)" "${MODULE_DIR}/kernel" || perror "Cannot copy kernel from '/boot/vmlinuz-$(uname -r)' to '${MODULE_DIR}/kernel'"
- pinfo "[core] kernel $(uname -r) copied to ${MODULE_DIR}/kernel"
+ pinfo "kernel $(uname -r) copied to ${MODULE_DIR}/kernel"
}
clean_core() {
+ local TOOL_STR="$TOOL_STR clean_core:"
pinfo "Cleaning '${STAGE31_DIR}'..."
- [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed." }
+ [ -d ${STAGE31_DIR} ] && { rm -rf ${STAGE31_DIR} || perror "rm -rf failed."; }
pinfo "Cleaning '${MODULE_DIR}/initramfs'..."
- [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed." }
+ [ -e ${MODULE_DIR}/initramfs ] && { rm ${MODULE_DIR}/initramfs || perror "rm failed."; }
}