fix output for mac

master
Marc Wäckerlin 7 years ago
parent 186a7dde78
commit ef69ea0655
  1. 164
      scripts/bootstrap.sh
  2. 130
      scripts/template.sh

@ -302,7 +302,91 @@ EOF
shift; shift;
done done
echo -en "\e[1m-> checking:\e[0m for version control system ..." # check if stdout is a terminal...
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi
notice() {
echo "${yellow}→ notice: ${bold}$*${normal}"
}
running() {
echo -n "${bold}${blue}→ running: ${bold}${white}$*${normal}"
}
checking() {
echo -n "${bold}${blue}→ checking: ${bold}${white}$*${normal}"
}
generating() {
echo -n "${bold}${blue}→ generating: ${bold}${white}$*${normal}"
}
configuring() {
echo -n "${bold}${blue}→ configuring ${bold}${white}$1${normal}:"
shift
echo -n "${white}$*${normal}"
}
ignored() {
echo "${bold}${yellow}ignored $*${normal}"
}
success() {
echo "${bold}${green}success $*${normal}"
}
error() {
echo "${bold}${red}→ error: $1${normal}"
shift
if test -n "$*"; then
echo "${bold}$*${normal}"
fi
exit 1
}
run() {
check=1
while test $# -gt 0; do
case "$1" in
(--no-check) check=0;;
(*) break;;
esac
shift;
done
running $*
result=$($* 2>&1)
res=$?
if test $res -ne 0; then
if test $check -eq 1; then
error "Failed with return code: $res" "$result"
else
ignored
fi
else
success
fi
}
checking for version control system
VCS="" VCS=""
VCSDEPENDS="" VCSDEPENDS=""
for path in . .. ../.. ../../..; do for path in . .. ../.. ../../..; do
@ -310,18 +394,18 @@ for path in . .. ../.. ../../..; do
VCS="svn" VCS="svn"
VCSDEPENDS_DEB="svn2cl, subversion, subversion-tools," VCSDEPENDS_DEB="svn2cl, subversion, subversion-tools,"
VCSDEPENDS_RPM="subversion, " VCSDEPENDS_RPM="subversion, "
echo -e " \e[32msuccess\e[0m detected ${VCS}" success detected ${VCS}
break break
elif test -d ${path}/.git; then elif test -d ${path}/.git; then
VCS="git" VCS="git"
VCSDEPENDS_DEB="git2cl, git," VCSDEPENDS_DEB="git2cl, git,"
VCSDEPENDS_RPM="git, " VCSDEPENDS_RPM="git, "
echo -e " \e[32msuccess\e[0m detected ${VCS}" success detected ${VCS}
break break
fi fi
done done
if test -z "$VCS"; then if test -z "$VCS"; then
echo -e " \e[33mignored\e[0m" ignored
fi fi
HEADER='## @id '"\$Id\$"' HEADER='## @id '"\$Id\$"'
@ -349,43 +433,6 @@ CHEADER='/** @id '"\$Id\$"'
' '
notice() {
echo -e "\e[1;33m$*\e[0m"
}
error() {
echo -e " \e[31merror\e[0m $*"
exit 1
}
run() {
check=1
while test $# -gt 0; do
case "$1" in
(--no-check) check=0;;
(*) break;;
esac
shift;
done
echo -en "\e[1m-> running:\e[0m $* ..."
result=$($* 2>&1)
res=$?
if test $res -ne 0; then
if test $check -eq 1; then
echo -e " \e[31merror\e[0m"
echo -e "\e[1m*** Failed with return code: $res\e[0m"
if test -n "$result"; then
echo "$result"
fi
exit 1
else
echo -e " \e[33mignored\e[0m"
fi
else
echo -e " \e[32msuccess\e[0m"
fi
}
testtag() { testtag() {
local IFS="|" local IFS="|"
egrep -q '^ *'"($*)"' *(\(.*)? *$' configure.ac egrep -q '^ *'"($*)"' *(\(.*)? *$' configure.ac
@ -438,18 +485,13 @@ to() {
return 1 return 1
fi fi
checkdir "$(dirname ${1})" checkdir "$(dirname ${1})"
echo -en "\e[1m-> generating:\e[0m $1 ..." generating $1
result=$(cat > "$1" 2>&1) result=$(cat > "$1" 2>&1)
res=$? res=$?
if test $res -ne 0; then if test $res -ne 0; then
echo -e " \e[31merror\e[0m" error "Failed with return code: $res" "$result"
echo -e "\e[1m*** Failed with return code: $res\e[0m"
if test -n "$result"; then
echo "$result"
fi
exit 1
else else
echo -e " \e[32msuccess\e[0m" success
fi fi
run chmod $mode $1 run chmod $mode $1
if test $exists -eq 0; then if test $exists -eq 0; then
@ -491,24 +533,20 @@ copy() {
} }
doxyreplace() { doxyreplace() {
echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..." configuring doxyfile $1
if sed -i 's|\(^'"$1"' *=\) *.*|\1'" $2"'|g' doc/doxyfile.in; then if sed -i 's|\(^'"$1"' *=\) *.*|\1'" $2"'|g' doc/doxyfile.in; then
echo -e " \e[32msuccess\e[0m" success
else else
echo -e " \e[31merror\e[0m" error $0 $*
echo -e "\e[1m**** command: $0 $*\e[0m"
exit 1
fi fi
} }
doxyadd() { doxyadd() {
echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..." configuring doxyfile $1
if sed -i '/^'"$1"' *=/a'"$1"' += '"$2" doc/doxyfile.in; then if sed -i '/^'"$1"' *=/a'"$1"' += '"$2" doc/doxyfile.in; then
echo -e " \e[32msuccess\e[0m" success
else else
echo -e " \e[31merror\e[0m" error $0 $*
echo -e "\e[1m**** command: $0 $*\e[0m"
exit 1
fi fi
} }
@ -1801,9 +1839,9 @@ fi
aclocal aclocal
$(if testtag AX_USE_LIBTOOL; then $(if testtag AX_USE_LIBTOOL; then
cat <<EOF1 cat <<EOF1
if which -s libtoolize; then if which libtoolize > /dev/null; then
run libtoolize --force; run libtoolize --force;
elif which -s glibtoolize; then elif which glibtoolize > /dev/null; then
run glibtoolize --force; run glibtoolize --force;
else else
echo "error: libtoolize not found" 1>&2 echo "error: libtoolize not found" 1>&2
@ -1879,9 +1917,9 @@ else
run --no-check vcs2cl run --no-check vcs2cl
run aclocal run aclocal
if testtag AX_USE_LIBTOOL; then if testtag AX_USE_LIBTOOL; then
if which -s libtoolize; then if which libtoolize > /dev/null; then
run libtoolize --force; run libtoolize --force;
elif which -s glibtoolize; then elif which glibtoolize > /dev/null; then
run glibtoolize --force; run glibtoolize --force;
else else
error libtoolize not found error libtoolize not found

@ -1,81 +1,89 @@
#!/bin/bash -e #!/bin/bash -e
# template for bash scripts ##########################################################################################
#### template for bash scripts #### START BELOW ##########################################
##########################################################################################
############################################################################ begin logging
# check if stdout is a terminal...
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi
# internal use only
append_msg() { append_msg() {
if test $# -ne 0; then if test $# -ne 0; then
echo -en ":\e[0m \e[1m$*" echo -n ": ${bold}$*"
fi fi
echo -e "\e[0m" echo "${normal}"
} }
# write a notice # write a message
notice() { message() {
if test $# -eq 0; then if test $# -eq 0; then
return return
fi fi
echo -e "\e[1m$*\e[0m" 1>&2 echo "${bold}${while}$*${normal}" 1>&2
} }
# write error message # write a success message
error() { success() {
echo -en "\e[1;31merror" 1>&2 echo -n "${bold}${green}success" 1>&2
append_msg $* 1>&2
}
# write a notice
notice() {
echo -n "${bold}${yellow}notice" 1>&2
append_msg $* 1>&2 append_msg $* 1>&2
} }
# write a warning message # write a warning message
warning() { warning() {
echo -en "\e[1;33mwarning" 1>&2 echo -en "${bold}${red}warning" 1>&2
append_msg $* 1>&2 append_msg $* 1>&2
} }
# write a success message # write error message
success() { error() {
echo -en "\e[1;32msuccess" 1>&2 echo -en "${bold}${red}error" 1>&2
append_msg $* 1>&2 append_msg $* 1>&2
} }
# commandline parameter evaluation
while test $# -gt 0; do
case "$1" in
(--help|-h) less <<EOF
SYNOPSIS
$0 [OPTIONS]
OPTIONS
--help, -h show this help
DESCRIPTION
EOF
exit;;
(*) error "unknow option $1, try $0 --help"; exit 1;;
esac
if test $# -eq 0; then
error "missing parameter, try $0 --help"; exit 1
fi
shift;
done
# run a command, print the result and abort in case of error # run a command, print the result and abort in case of error
# option: --no-check: ignore the result, continue in case of error # option: --ignore: ignore the result, continue in case of error
run() { run() {
check=1 ignore=1
while test $# -gt 0; do while test $# -gt 0; do
case "$1" in case "$1" in
(--no-check) check=0;; (--ignore) ignore=0;;
(*) break;; (*) break;;
esac esac
shift; shift;
done done
echo -en "\e[1m-> running:\e[0m $* ..." echo -n "${bold}${yellow}running:${white} $*${normal}"
set +e
result=$($* 2>&1) result=$($* 2>&1)
res=$? res=$?
set -e
if test $res -ne 0; then if test $res -ne 0; then
if test $check -eq 1; then if test $ignore -eq 1; then
error "failed with return code: $res" error "failed with return code: $res"
if test -n "$result"; then if test -n "$result"; then
echo "$result" echo "$result"
@ -89,7 +97,7 @@ run() {
fi fi
} }
# error handler ############################################################################ error handler
function traperror() { function traperror() {
set +x set +x
local err=($1) # error status local err=($1) # error status
@ -101,9 +109,9 @@ function traperror() {
if test -n "$e" -a "$e" != "0"; then if test -n "$e" -a "$e" != "0"; then
error "line $line - command '$command' exited with status: $e (${err[@]})" error "line $line - command '$command' exited with status: $e (${err[@]})"
if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
echo -n " ... error at ${funcstack} " echo -n " ... error at ${funcstack} " 1>&2
if [ "$linecallfunc" != "" ]; then if [ "$linecallfunc" != "" ]; then
echo -n "called at line $linecallfunc" echo -n "called at line $linecallfunc" 1>&2
fi fi
echo echo
fi fi
@ -117,5 +125,35 @@ function traperror() {
# catch errors # catch errors
trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT
##########################################################################################
#### START HERE ##########################################################################
########################################################################################## ##########################################################################################
######################################################### commandline parameter evaluation
while test $# -gt 0; do
case "$1" in
(--help|-h) less <<EOF
SYNOPSIS
$0 [OPTIONS]
OPTIONS
--help, -h show this help
DESCRIPTION
EOF
exit;;
(*) error "unknow option $1, try $0 --help"; exit 1;;
esac
if test $# -eq 0; then
error "missing parameter, try $0 --help"; exit 1
fi
shift;
done
##################################################################################### Main

Loading…
Cancel
Save