]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
jail-upgrade now coded to work as expected, hope there's no bugs
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Tue, 14 Nov 2006 17:24:00 +0000 (17:24 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Tue, 14 Nov 2006 17:24:00 +0000 (17:24 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@30 04377dda-e619-0410-9926-eae83683ac58

doc/CHANGELOG
src/jail-upgrade

index 258dcc8db395fd32ea5af3950959e97cdf1d9242..a8b5b8597fd99c8c2e1e0688a0d18814bbbaf306 100644 (file)
@@ -1,15 +1,16 @@
 simplepkg changelog
 -------------------
 
-0.4.9pre7: jail-upgrade:
-             - fix in swaret upgrade method
+0.5pre1: jail-upgrade:
+             - added option CONSIDER_ALL_PACKAGES_AS_PATCHES
+             - merged swaret and simplaret upgrade procedures
              - act recursively on patches' folder
 
-           simplaret:
-             - for --get, check if an already existing package
-               in the local repository has the same version and
-               build number, otherwise erase the old and download
-               the new one.
+          simplaret:
+            - for --get, check if an already existing package
+              in the local repository has the same version and
+              build number, otherwise erase the old and download
+              the new one.
 
 0.4.9pre6: createpkg:
              - fixes
index 6383cf545e75af384eb71d3fcc798c521b60f613..c44f32d5bd4f24c974ebab62b932c7bf9ee5545a 100755 (executable)
 
 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