aboutsummaryrefslogtreecommitdiff
path: root/trunk/lib/common.sh
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-07-23 22:45:12 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-07-23 22:45:12 +0000
commit014f0374d20bf965427fcff7aeca0536523d4cfa (patch)
treeedfd1a42f55b005830482fa222932285e45e5b58 /trunk/lib/common.sh
parent22fad27c413ff4413d4a5273f228e2e00c8568ea (diff)
downloadsimplepkg-014f0374d20bf965427fcff7aeca0536523d4cfa.tar.gz
simplepkg-014f0374d20bf965427fcff7aeca0536523d4cfa.tar.bz2
merged branches/0.6 into trunk
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@403 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'trunk/lib/common.sh')
-rw-r--r--trunk/lib/common.sh74
1 files changed, 68 insertions, 6 deletions
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 <jail-path>
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> <message>
+ # message-type can be: commun, messag, error, normal
+
+ echo -e "${1}${2}${normal}"
+
+}
+