aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common.sh105
1 files changed, 22 insertions, 83 deletions
diff --git a/lib/common.sh b/lib/common.sh
index aea8ba2..4c337e2 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -30,6 +30,7 @@
BASE_CONF="/etc/simplepkg"
CONF="$BASE_CONF/simplepkg.conf"
JAIL_LIST="$BASE_CONF/jailist"
+SIMPLARET="simplaret"
# pkgtool stuff
function package_name {
@@ -92,108 +93,47 @@ function package_build {
function install_packages {
+ local check installed unable_to_install
+
# check if is time to clean the local repository
- if [[ "$SIMPLARET_CLEAN" == "1" ]]; then
+ if [ "$SIMPLARET_CLEAN" == "1" ]; then
ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge
- elif [[ ! -z "$SIMPLARET_PURGE_WEEKS" ]] && [[ "$SIMPLARET_PURGE_WEEKS" != "0" ]]; then
+ 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"
+ # try to install the package
+ ROOT=/$JAIL_ROOT ARCH=$ARCH VERSION=$VERSION $SIMPLARET --install $pack $extraoptions
- if [ "$SIMPLARET" == "simplaret" ]; then
- extrafolder="$ARCH/$VERSION/"
- extraoptions=""
- else
- unset extrafolder
- extraoptions="-a"
- fi
+ # check if the package was installed
+ installed=`eval "ls /$JAIL_ROOT/var/log/packages/ | egrep '^$pack-[^-]+-[^-]+-[^-]+$'"`
+ check=$?
- # 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
+ if [ ! -z "$installed" ] && [ "$check" == "0" ]; then
+ # the package is installed
+ if [ ! -z "$SIMPLARET_DELETE_DURING" ] && [ "$SIMPLARET_DELETE_DURING" != "0" ]; then
+ SILENT=1 ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge
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 $extraoptions
-
- # it can be stored at the patches folder
- for file in `find $PATCHES_DIR/$extrafolder -name $pack*tgz`; do
- if [[ "`package_name $file`" == "$pack" ]]; then
- package_file="$file"
- break
- fi
- done
-
- # or it can be stored at the standard packages folder
- if [ -z "$package_file" ]; then
- for file in `find $STORAGE/$extrafolder -name $pack*tgz`; do
- if [[ "`package_name $file`" == "$pack" ]]; then
- package_file="$file"
- break
- fi
- done
- fi
-
- fi
-
- # now tries to install the package, if available
- if [ -z "$package_file" ]; then
- echo error: could not install package $pack
else
- installed_packs="`ls /$JAIL_ROOT/$server/var/log/packages/$pack* 2> /dev/null`"
- if [ ! -z "$installed_packs" ]; then
- for installed in $installed_packs; do
- if [[ "$pack" == "`package_name $installed.tgz`" ]]; then
- echo "package $pack already installed in $JAIL_ROOT/$server ($installed)"
- package_installed="1"
- break
- fi
- if [[ "$package_installed" != "1" ]]; then
- installpkg -root /$JAIL_ROOT/$server $package_file
- unset package_installed
- if [ ! -z "$SIMPLARET_DELETE_DURING" ] && [ "$SIMPLARET_DELETE_DURING" != "0" ]; then
- SILENT=1 ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge
- fi
- break
- fi
- done
- else
- installpkg -root /$JAIL_ROOT/$server $package_file
- if [ ! -z "$SIMPLARET_DELETE_DURING" ] && [ "$SIMPLARET_DELETE_DURING" != "0" ]; then
- SILENT=1 ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge
- fi
- fi
+ echo error: could not install package $pack
+ unable_to_install="$unable_to_install\n\t$pack"
fi
- unset package_file
-
done
# purge packages, if needed
- if [[ "$SIMPLARET_DELETE_DOWN" == "1" ]]; then
+ if [ "$SIMPLARET_DELETE_DOWN" == "1" ]; then
ARCH=$ARCH VERSION=$VERSION $SIMPLARET --purge
fi
+ if [ ! -z "$unable_to_install" ]; then
+ echo "mkjail was unable to install the following packages on $JAIL_ROOT:"
+ echo -e "$unable_to_install"
+ fi
+
}
function remove_packages {
@@ -246,7 +186,6 @@ function eval_config {
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`"