diff options
-rw-r--r-- | lib/common.sh | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/common.sh b/lib/common.sh index 9eb5753..fdcd5a0 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -33,6 +33,7 @@ JAIL_LIST="$BASE_CONF/jailist" # pkgtool stuff function package_name { + STRING=`basename $1 .tgz` # Check for old style package name with one segment: if [ "`echo $STRING | cut -f 1 -d -`" = "`echo $STRING | cut -f 2 -d -`" ]; then @@ -53,6 +54,7 @@ function package_name { echo $NAME fi fi + } function package_version { @@ -90,26 +92,44 @@ function package_build { function install_packages { + # check if is time to clean the local repository if [[ "$SIMPLARET_CLEAN" == "1" ]]; then ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge elif [[ ! -z "$SIMPLARET_PURGE_WEEKS" ]] && [[ "$SIMPLARET_PURGE_WEEKS" != "0" ]]; then ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge -w $SIMPLARET_PURGE_WEEKS fi + # now tries to install each package listed in the template for pack in `cat $TEMPLATE | grep -v -e "^#" | cut -d : -f 1`; do + package_downloaded="0" if [ "$SIMPLARET" == "simplaret" ]; then extrafolder="$ARCH/$VERSION/" else unset extrafolder fi - for file in `find $STORAGE/$extrafolder -name $pack*tgz`; do + + # first search the package in the patches folder + for file in `find $PATCHES_DIR/$extrafolder -name $pack*tgz`; do if [[ "`package_name $file`" == "$pack" ]]; then package_downloaded="1" package_file="$file" break fi done + + # then search the package in the standard packages folder + if [[ "$package_downloaded" != "1" ]]; then + for file in `find $STORAGE/$extrafolder -name $pack*tgz`; do + if [[ "`package_name $file`" == "$pack" ]]; then + package_downloaded="1" + package_file="$file" + break + fi + done + fi + + # if the package wasnt found, try to donwload it if [[ "$package_downloaded" != "1" ]]; then ARCH=$ARCH VERSION=$VERSION $SIMPLARET --get $pack -a for file in `find $STORAGE/$extrafolder -name $pack*tgz`; do @@ -119,6 +139,8 @@ function install_packages { fi done fi + + # now tries to install the package, if available if [ -z "$package_file" ]; then echo error: could not install package $pack else @@ -146,20 +168,28 @@ function install_packages { fi fi fi + unset package_file + done + + # purge packages, if needed if [[ "$SIMPLARET_DELETE_DOWN" == "1" ]]; then ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge fi + } function remove_packages { + for pack in `cat $TEMPLATE | grep -v -e "^#" | cut -d : -f 1`; do ROOT=/$JAIL_ROOT/$server removepkg $pack done + } function eval_config { + if [ -f "$CONF" ]; then source $CONF else @@ -220,5 +250,6 @@ function eval_config { # package is apllied; if in doubt, just say no or leave blank. CONSIDER_ALL_PACKAGES_AS_PATCHES="0" fi + } |