diff options
Diffstat (limited to 'src/jail-upgrade')
-rwxr-xr-x | src/jail-upgrade | 93 |
1 files changed, 31 insertions, 62 deletions
diff --git a/src/jail-upgrade b/src/jail-upgrade index 6383cf5..c44f32d 100755 --- a/src/jail-upgrade +++ b/src/jail-upgrade @@ -18,63 +18,33 @@ COMMON="/usr/libexec/simplepkg/common.sh" -# TODO: merge upgrade functions +function jail_upgrade { -function swaret_jail_upgrade { + local patches_dir storage_dir echo upgrading jail $1... - if [ ! -d "$PATCHES_DIR" ]; then - for file in `find $PATCHES_DIR -name *tgz`; do - pack=`package_name $file` - if check_for_upgrade $file $1; then - ROOT=$1 upgradepkg $file - upgraded $pack - fi - done - fi + if [ "$SIMPLARET" == "simplaret" ]; then - if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "YES" ] || - [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then - # this option does the following: - # search all packages in the repositories and apply a patch if: - # - the package is installed - # - it hasnt already applied - # - has a different version from the current installed - # - has a different build number from the current installed - if [ -d "$STORAGE" ]; then - for file in `find $STORAGE -name *tgz`; do - pack=`package_name $file` - if check_for_upgrade $file $1; then - # the package is installed - if ! echo $UPGRADED | grep -q $pack; then - # it hasnt already applied - ROOT=$1 upgradepkg $file - upgraded $pack - fi - fi - done - fi - fi - - # clear the upgraded package list - unset UPGRADED + VERSION="`cat $1/etc/slackware-version | awk '{ print $2 }' | sed -e 's/.0$//'`" + ARCH="`cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'`" -} + if [ -z "$ARCH" ]; then + ARCH="i386" + fi -function simplaret_jail_upgrade { + patches_dir="$PATCHES_DIR/$ARCH/$VERSION" + storage_dir="$STORAGE/$ARCH/$VERSION" - echo upgrading jail $1... + elif [ "$SIMPLARET" == "swaret" ]; then - VERSION="`cat $1/etc/slackware-version | awk '{ print $2 }' | sed -e 's/.0$//'`" - ARCH="`cat $1/etc/slackware-version | awk '{ print $3 }' | sed -e 's/(//' -e 's/)//'`" + patches_dir="$PACTHES_DIR" + storage_dir="$STORAGE" - if [ -z "$ARCH" ]; then - ARCH="i386" fi - if [ -d "$PATCHES_DIR/$ARCH/$VERSION" ]; then - for file in `find $PATCHES_DIR/$ARCH/$VERSION -name *tgz`; do + if [ -d "$patches_dir" ]; then + for file in `find $patches_dir -name *tgz`; do pack=`package_name $file` if check_for_upgrade $file $1; then ROOT=$1 upgradepkg $file @@ -82,19 +52,22 @@ function simplaret_jail_upgrade { fi done else - echo error: cant upgrade for arch $ARCH and version $VERSION on $1: no such patch dir $PATCHES_DIR/$ARCH/$VERSION + if [ "$SIMPLARET" == "simplaret" ]; then + echo error: cant upgrade for arch $ARCH and version $VERSION on $1: no such patch dir $patches_dir + elif [ "$SIMPLARET" == "swaret" ]; then + echo error: cant upgrade on $1: no such patch dir $patches_dir + fi + return fi + # optionally, search all packages in the repositories and apply a patch if: + # - the package is installed in the jail + # - it hasn't already applied in the jail + # - has different version or build from the current installed package if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "YES" ] || [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then - # this option does the following: - # search all packages in the repositories and apply a patch if: - # - the package is installed - # - it hasnt already applied - # - has a different version from the current installed - # - has a different build number from the current installed - if [ -d "$STORAGE/$ARCH/$VERSION" ]; then - for file in `find $STORAGE/$ARCH/$VERSION -name *tgz`; do + if [ -d "$storage_dir" ]; then + for file in `find $storage_dir -name *tgz`; do pack=`package_name $file` if check_for_upgrade $file $1; then # the package is installed @@ -164,11 +137,7 @@ if [ ! -z "$PATCHES" ]; then fi fi -if [ "$SIMPLARET" == "simplaret" ]; then - upgrade_method="simplaret_jail_upgrade" -elif [ "$SIMPLARET" == "swaret" ]; then - upgrade_method="swaret_jail_upgrade" -else +if [ "$SIMPLARET" != "simplaret" ] || [ "$SIMPLARET" == "swaret" ]; then echo invalid value $SIMPLARET for SIMPLARET, please check your $CONF exit 1 fi @@ -177,16 +146,16 @@ UPGRADED="" if [ -z "$1" ]; then if [ -d "/var/log/packages" ]; then - $upgrade_method / + jail_upgrade / fi for vserver in `ls $JAIL_ROOT`; do if [ -d "$JAIL_ROOT/$vserver/var/log/packages" ]; then - $upgrade_method $JAIL_ROOT/$vserver + jail_upgrade $JAIL_ROOT/$vserver fi done elif [ -d "$JAIL_ROOT/$1" ]; then if [ -d "$JAIL_ROOT/$1/var/log/packages" ]; then - $upgrade_method $JAIL_ROOT/$1 + jail_upgrade $JAIL_ROOT/$1 else echo error: jail $JAIL_ROOT/$1 dont looks like a slackware system fi |