#
# Codes:
# ---   = Information
# !!!   = Error
# >>>   = Executing command

print()
{
    echo $* | tee -a $LOG_ALL | tee -a $LOG_THIS
}

printi()
{
    print '---' $*
}

printe()
{
    print '!!!' $* 
}

printx()
{
    print '>>>' $*
}

printfile()
{
    cat $* | tee -a $LOG_ALL | tee -a $LOG_THIS
}

execute()
{
    printx $*
    (
        $*
        if [ $? != 0 ]; then
            touch /tmp/_aros_build_fail
        fi
    ) 2>&1 | tee -a $LOG_ALL | tee -a $LOG_THIS
    if [ -f /tmp/_aros_build_fail ]; then
        printe "Command '$*' returned error. ABORTING BUILD!"
        rm -f /tmp/_aros_build_fail
        exit 5
    fi
}

archive()
{
    archdir=$(dirname $1)
    archname=$(basename $1)
    oldpwd=$(pwd)
    
    makedir $archdir
    execute tar cjvf $1 --exclude=.svn $2
    cd      $archdir
    echo    ">>> md5sum $archname >$archname.md5"
    md5sum  $archname >$archname.md5
    cd      $oldpwd
}

ziparc()
{
    archdir=$(dirname $1)
    archname=$(basename $1)
    oldpwd=$(pwd)
    
    makedir $archdir
    execute zip -r9 $1 $2 -x \*/.svn/\*
    cd      $archdir
    echo    ">>> md5sum $archname >$archname.md5"
    md5sum  $archname >$archname.md5
    cd      $oldpwd
}

lhaarc()
{
    archdir=$(dirname $1)
    archname=$(basename $1)
    oldpwd=$(pwd)
    
    makedir $archdir
    execute lha -a -x=\*/.svn/\* $1 $2
    cd      $archdir
    echo    ">>> md5sum $archname >$archname.md5"
    md5sum  $archname >$archname.md5
    cd      $oldpwd
}

resetl()
{
    LOG_THIS=/dev/null
}

setl()
{
    LOG_THIS=$LOG_BASE/$1
    if [ ! -f $LOG_THIS ]; then
        touch $LOG_THIS >/dev/null
    fi    
}
