From 014f0374d20bf965427fcff7aeca0536523d4cfa Mon Sep 17 00:00:00 2001 From: rhatto Date: Mon, 23 Jul 2007 22:45:12 +0000 Subject: merged branches/0.6 into trunk git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@403 04377dda-e619-0410-9926-eae83683ac58 --- trunk/lib/common.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 6 deletions(-) (limited to 'trunk/lib/common.sh') diff --git a/trunk/lib/common.sh b/trunk/lib/common.sh index 8d2bb2f..6ebd38a 100644 --- a/trunk/lib/common.sh +++ b/trunk/lib/common.sh @@ -5,7 +5,7 @@ # # Uses some functions from pkgtools, which license is: # -# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA +# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA # Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA # All rights reserved. # @@ -175,6 +175,18 @@ function eval_parameter { } +function set_constants { + + # Set common constants + # on/off + on=1 + off=0 + # yes/no + yes=1 + no=0 + +} + function eval_boolean_parameter { # get a boolean parameter from the configuration @@ -184,11 +196,17 @@ function eval_boolean_parameter { # get the value value="`eval_parameter $1 $2`" + convert_boolean $value + +} + +function convert_boolean { + # force case insensitiveness - value="`echo $value | tr '[:upper:]' '[:lower:]'`" + local value="`echo $1 | tr '[:upper:]' '[:lower:]'`" # convert it to wheter 0 or 1 - if [ "$value" == "yes" ] || [ "$value" == "1" ]; then + if [ "$value" == "yes" ] || [ "$value" == "1" ] || [ "$value" == "on" ]; then echo 1 else echo 0 @@ -257,6 +275,7 @@ function eval_config { # now we place "patches" on the top of ROOT_PRIORITY ROOT_PRIORITY="patches `echo $ROOT_PRIORITY | sed -e 's/patches//'`" + else echo $1 error: config file $CONFIG not found exit 1 @@ -271,7 +290,7 @@ function eval_config { fi if [ -z "$ARCH" ]; then - ARCH="$DEFAULT_ARCH" + ARCH="$DEFAULT_ARCH" fi if [ -z "$VERSION" ]; then @@ -527,7 +546,7 @@ function copy_template_files { # usage: copy_template_files if [ -d "$1" ]; then - if [ -d "$TEMPLATE_BASE.d" ]; then + if [ -d "$TEMPLATE_BASE.d" ]; then echo "Copying template files to $1..." if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then rsync -av --exclude=.svn $TEMPLATE_BASE.d/ $1/ @@ -572,7 +591,6 @@ function svn_add_meta { } function gen_filelist { - # generate FILELIST.TXT # usage: gen_filelist @@ -710,3 +728,47 @@ function slash { } +function color_select { + + # Select color mode: gray, color or none (*) + # commun - Communication + # messag - Commum messages + # error - Error messages + # normal - turn off color + case "$1" in + 'gray') + commun="\033[37;1m" + messag="\033[37;1m" + error="\033[30;1m" + alert="\033[37m" + normal="\033[m" + ;; + 'color') + commun="\033[34;1m" # green + messag="\033[32;1m" # blue + error="\033[31;1m" # red + alert="\033[33;1m" # yellow + normal="\033[m" # normal + ;; + *) + commun="" + messag="" + error="" + alert="" + normal="" + ;; + esac + +} + + +function eecho { + + # echoes a message + # usage: eecho + # message-type can be: commun, messag, error, normal + + echo -e "${1}${2}${normal}" + +} + -- cgit v1.2.3