diff options
| author | Jonathan Bauer | 2014-07-28 17:27:34 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2014-07-28 17:27:34 +0200 |
| commit | 962df83e5fe66190fee18da05cdf71d74b81b991 (patch) | |
| tree | dee2e3baf0512728708a18a308dd7f259decf9d1 /helper | |
| parent | [pvs2] also copy the qt4-svg package to stage32 (diff) | |
| parent | helpers/includes now should include an __init function and not just do stuff ... (diff) | |
| download | tm-scripts-962df83e5fe66190fee18da05cdf71d74b81b991.tar.gz tm-scripts-962df83e5fe66190fee18da05cdf71d74b81b991.tar.xz tm-scripts-962df83e5fe66190fee18da05cdf71d74b81b991.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'helper')
| -rw-r--r-- | helper/fileutil.inc | 5 | ||||
| -rw-r--r-- | helper/logging.inc | 32 | ||||
| -rw-r--r-- | helper/string.inc | 6 |
3 files changed, 20 insertions, 23 deletions
diff --git a/helper/fileutil.inc b/helper/fileutil.inc index 10b4bbc7..9dc2c07b 100644 --- a/helper/fileutil.inc +++ b/helper/fileutil.inc @@ -31,4 +31,9 @@ tarcopy () { [ "x${PS[1]}" != "x0" ] && perror "unpacking-part of tar-copy from '$SHORT' to '$TO' failed. (${PS[1]})" } +# usage: CANONICALIZED_PATH=$(canonalize <path>) +# usage with relative path requires you to be in the correct directory. +canonicalize() { + cd -P -- "$(dirname -- "$1")" && printf '%s\n' "$(pwd -P)/$(basename -- "$1")" +} diff --git a/helper/logging.inc b/helper/logging.inc index 8b102d4c..2e8eeeb7 100644 --- a/helper/logging.inc +++ b/helper/logging.inc @@ -1,22 +1,14 @@ +[ -n "$MLTK_QUIET" ] && return 0 -if [ "x$MLTK_QUIET" == "x" ]; then #ifndef _MLTK_QUIET -#define _MLTK_QUIET - -MLTK_QUIET=0 - -exec 6>&2 - -LOG_DIR=${ROOT_DIR}/logs - -mkdir -p "$LOG_DIR" - -exec 8>&0 # This redirection is used for chroot debugging +# This module is an exception, it doesn't use __init but runs commands directly... +# Otherwise we cannot ensure that other module's init functions won't run first +# and mess up the fds set_quiet () { if [ "x$MLTK_QUIET" != "x1" ]; then exec 6>&1 > "$LOG_DIR/stdout.log" exec 7>&2 2> "$LOG_DIR/stderr.log" - MLTK_QUIET="1" + MLTK_QUIET=1 fi } @@ -25,7 +17,7 @@ unset_quiet () { exec 1>&6 6>&- exec 2>&7 7>&- exec 6>&2 - MLTK_QUIET="0" + MLTK_QUIET=0 fi } @@ -34,7 +26,7 @@ pinfo () { echo -e "\033[38;5;10m[info]\033[0m $TOOL_STR $@" >&6 } -perror () { +perror () { echo -e "\033[38;5;9m[error]\033[0m $TOOL_STR $@" >&6 qnd_exit } @@ -51,5 +43,11 @@ pdebug () { fi } -#endif -fi +exec 6>&2 +exec 8>&0 # This redirection is used for chroot debugging + +MLTK_QUIET=0 +declare -rg LOG_DIR=${ROOT_DIR}/logs +mkdir -p "$LOG_DIR" || perror "Could not create '$LOG_DIR'" +true + diff --git a/helper/string.inc b/helper/string.inc index 75baf2ca..077f1719 100644 --- a/helper/string.inc +++ b/helper/string.inc @@ -12,12 +12,6 @@ itrim () { sed -r 's/^\s+//g;s/\s+$//g' } -# usage: CANONICALIZED_STRING=$(canonalize <path>) -# usage with relative path requires you to be in the correct directory. -canonicalize() { - cd -P -- "$(dirname -- "$1")" && printf '%s\n' "$(pwd -P)/$(basename -- "$1")" -} - escape_search() { sed -e 's/[]\/()$*.^|[]/\\&/g' |
