aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/jail-upgrade85
1 files changed, 39 insertions, 46 deletions
diff --git a/src/jail-upgrade b/src/jail-upgrade
index a5803d0..578745e 100755
--- a/src/jail-upgrade
+++ b/src/jail-upgrade
@@ -24,20 +24,35 @@ function swaret_jail_upgrade {
if [ ! -d "$PATCHES_DIR" ]; then
for file in `find $PATCHES_DIR -name *tgz`; do
-
pack=`package_name $file`
- for installed in `ls $1/var/log/packages/$pack* 2> /dev/null`; do
- if [[ $pack == `package_name $installed.tgz` ]]; then
- if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then
-
- ROOT=$1 upgradepkg $file
- upgraded $pack
+ if check_for_upgrade $file $1; then
+ ROOT=$1 upgradepkg $file
+ upgraded $pack
+ fi
+ done
+ fi
+ 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
- fi
- done
-
- done
+ done
+ fi
fi
# clear the upgraded package list
@@ -58,19 +73,11 @@ function simplaret_jail_upgrade {
if [ -d "$PATCHES_DIR/$ARCH/$VERSION" ]; then
for file in `find $PATCHES_DIR/$ARCH/$VERSION -name *tgz`; do
-
pack=`package_name $file`
- for installed in `ls $1/var/log/packages/$pack* 2> /dev/null`; do
- if [[ "$pack" == "`package_name $installed.tgz`" ]]; then
- if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then
-
- ROOT=$1 upgradepkg $file
- upgraded $pack
-
- fi
- fi
- done
-
+ if check_for_upgrade $file $1; then
+ ROOT=$1 upgradepkg $file
+ upgraded $pack
+ fi
done
else
echo error: cant upgrade for arch $ARCH and version $VERSION on $1: no such patch dir $PATCHES_DIR/$ARCH/$VERSION
@@ -78,39 +85,25 @@ function simplaret_jail_upgrade {
if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "YES" ] ||
[ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then
- # TODO: search all packages in the repositories
- # apply a patch if:
+ # 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
-
pack=`package_name $file`
- for installed in `ls $1/var/log/packages/$pack* 2> /dev/null`; do
- if [[ "$pack" == "`package_name $installed.tgz`" ]]; then
- if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then
-
- # the package is installed
- if ! echo $UPGRADED | grep -q $pack; then
- # the package isnt already applied
- if [ "`package_version $file`" != "`package_version $installed.tgz`" ] ||
- [ "`package_build $file`" != "`package_build $installed.tgz`" ]; then
- # the stored package has a different version or build number
- # from the installed one; then we upgrade it
- ROOT=$1 upgradepkg $file
- upgraded $pack
- fi
- fi
-
- fi
+ 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
- done
-
+ fi
done
fi
- true
fi
# clear the upgraded package list