]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
jail-upgrade: now everything using function check_for_upgrade
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Tue, 14 Nov 2006 00:09:25 +0000 (00:09 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Tue, 14 Nov 2006 00:09:25 +0000 (00:09 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@28 04377dda-e619-0410-9926-eae83683ac58

src/jail-upgrade

index a5803d0a0619e157377edda5223d850f04c65bc2..578745e5cce1607b601932c119cccbd7d4a89211 100755 (executable)
@@ -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