aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-01-18 01:54:06 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-01-18 01:54:06 +0000
commit9ed605710d1acdb16a12b47a2c83474cebd5c819 (patch)
treeab2d2593d16642d1e7aa8c9579e298c889356a86 /lib
parent46410c89229ba465a86b51fb57b2a0986f2f1732 (diff)
downloadsimplepkg-9ed605710d1acdb16a12b47a2c83474cebd5c819.tar.gz
simplepkg-9ed605710d1acdb16a12b47a2c83474cebd5c819.tar.bz2
lots of changes
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@108 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh124
1 files changed, 86 insertions, 38 deletions
diff --git a/lib/common.sh b/lib/common.sh
index 0749dd4..d5e84c8 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -103,10 +103,13 @@ function install_packages {
for pack in `cat $TEMPLATE | grep -v -e "^#" | cut -d : -f 1`; do
package_downloaded="0"
+
if [ "$SIMPLARET" == "simplaret" ]; then
extrafolder="$ARCH/$VERSION/"
+ extraoptions=""
else
unset extrafolder
+ extraoptions="-a"
fi
# first search the package in the patches folder
@@ -131,7 +134,7 @@ function install_packages {
# if the package wasnt found, try to donwload it
if [[ "$package_downloaded" != "1" ]]; then
- ARCH=$ARCH VERSION=$VERSION $SIMPLARET --get $pack -a
+ ARCH=$ARCH VERSION=$VERSION $SIMPLARET --get $pack $extraoptions
# it can be stored at the patches folder
for file in `find $PATCHES_DIR/$extrafolder -name $pack*tgz`; do
@@ -201,35 +204,87 @@ function remove_packages {
}
-function eval_config {
+function eval_parameter {
- if [ -f "$CONF" ]; then
- source $CONF
+ # usage: eval $1 parameter from $CONF
+ # return the evaluated parameter if available or $2 $3 ... $n
+
+ if grep -qe "^$1=" $CONF; then
+ grep -e "^$1=" $CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | awk '{ print $1 }'
else
- echo $1 error: config file $CONFIG not found
- exit 1
+ shift
+ echo $*
fi
- if [ -z "$SIMPLARET" ]; then
- SIMPLARET="simplaret"
- fi
+}
- if [ -z "$STORAGE" ]; then
- if [ -d "/var/$SIMPLARET" ]; then
- STORAGE="/var/$SIMPLARET"
- else
- echo error: please adjust value for STORAGE at $CONF
- exit 1
- fi
+function eval_boolean_parameter {
+
+ # get a boolean parameter from the configuration
+
+ local value
+
+ # get the value
+ value="`eval_parameter $1 $2`"
+
+ # force case insensitiveness
+ value="`echo $value | tr '[:upper:]' '[:lower:]'`"
+
+ # convert it to wheter 0 or 1
+ if [ "$value" == "yes" ] || [ "$value" == "1" ]; then
+ echo 1
+ else
+ echo 0
fi
- if [ ! -z "$ROOT" ]; then
- JAIL_ROOT="$ROOT"
- elif [ -z "$JAIL_ROOT" ]; then
- echo error: please adjust value for JAIL_ROOT at $CONF
+}
+
+function eval_config {
+
+ # simplepkg config file evaluation
+ # usage: eval_config <program-name> [-u]
+
+ if [ -f "$CONF" ]; then
+
+ SIMPLARET="`eval_parameter SIMPLARET simplaret`"
+ STORAGE="`eval_parameter STORAGE /var/simplaret/packages`"
+ JAIL_ROOT="`eval_parameter JAIL_ROOT /vservers`"
+ PATCHES_DIR="`eval_parameter PATCHES_DIR /var/simplaret/patches`"
+ ROOT_PRIORITY="`eval_parameter ROOT_PRIORITY patches slackware extra testing pasture`"
+ SIMPLARET_PURGE_WEEKS="`eval_parameter SIMPLARET_PURGE_WEEKS 0`"
+
+ SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`"
+ SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`"
+ SIMPLARET_UPDATE="`eval_boolean_parameter SIMPLARET_UPDATE 0`"
+ SIMPLARET_DELETE_DURING="`eval_boolean_parameter SIMPLARET_DELETE_DURING 0`"
+ SIMPLARET_PURGE_PATCHES="`eval_boolean_parameter SIMPLARET_PURGE_PATCHES 0`"
+ CONSIDER_ALL_PACKAGES_AS_PATCHES="`eval_boolean_parameter CONSIDER_ALL_PACKAGES_AS_PATCHES 0`"
+ DOWNLOAD_EVEN_APPLIED_PATCHES="`eval_boolean_parameter DOWNLOAD_EVEN_APPLIED_PATCHES 0`"
+ PASSIVE_FTP="`eval_boolean_parameter PASSIVE_FTP 0`"
+ WARNING="`eval_boolean_parameter WARNING 0`"
+
+ DEFAULT_ARCH="`eval_parameter DEFAULT_ARCH $(default_arch)`"
+ DEFAULT_VERSION="`eval_parameter DEFAULT_VERSION $(default_version)`"
+
+ # Enabling this option, jail-upgrade will look at your
+ # standard repositories for new packages; if it find a package
+ # with different version of your current installed package and
+ # also this package isnt in the packages folder, then the new
+ # package is apllied; if in doubt, just say no or leave blank.
+ CONSIDER_ALL_PACKAGES_AS_PATCHES="`eval_boolean_parameter CONSIDER_ALL_PACKAGES_AS_PATCHES 0`"
+
+ # 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
fi
+ if [ ! -d "$STORAGE" ]; then
+ mkdir -p $STORAGE
+ else
+
if [ -z "$ARCH" ]; then
ARCH="$DEFAULT_ARCH"
fi
@@ -239,8 +294,8 @@ function eval_config {
fi
if which $SIMPLARET &> /dev/null; then
- if [[ "$SIMPLARET_UPDATE" == "1" ]]; then
- if [[ "$2" == "-u" ]]; then
+ if [ "$SIMPLARET_UPDATE" == "1" ]; then
+ if [ "$2" == "-u" ]; then
echo "updating package database..."
ARCH=$ARCH VERSION=$VERSION $SIMPLARET --update
fi
@@ -249,21 +304,6 @@ function eval_config {
echo "$SIMPLARET not found, please install it before run $0"
fi
- if [ -z "$PATCHES_DIR" ]; then
- echo error: please adjust a value for PATCHES_DIR at $CONF
- fi
-
- CONSIDER_ALL_PACKAGES_AS_PATCHES="`echo $CONSIDER_ALL_PACKAGES_AS_PATCHES | tr '[:lower:]' '[:upper:]'`"
- if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" != "YES" ] && \
- [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" != "1" ]; then
- # Enabling this option, jail-upgrade will look at your
- # standard repositories for new packages; if it find a package
- # with different version of your current installed package and
- # also this package isnt in the packages folder, then the new
- # package is apllied; if in doubt, just say no or leave blank.
- CONSIDER_ALL_PACKAGES_AS_PATCHES="0"
- fi
-
}
function default_version {
@@ -276,7 +316,15 @@ function default_version {
function default_arch {
# get arch from /etc/slackware-version
- cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'
+
+ local arch
+ arch="`cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'`"
+
+ if [ -z "$arch" ]; then
+ echo i386
+ else
+ echo $arch
+ fi
}