]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
simplaret: changing --upgrade behaviour
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 11 Jan 2007 22:00:22 +0000 (22:00 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 11 Jan 2007 22:00:22 +0000 (22:00 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@92 04377dda-e619-0410-9926-eae83683ac58

src/simplaret

index d307726c6372e71a66742d283a6eb678a2344881..62e9c82a9f096d50f49928daa7f403a4d1d324cd 100755 (executable)
@@ -425,7 +425,12 @@ function simplaret_get {
     candidate="`basename $file`"
     if [ "`package_name $candidate`" == "$1" ]; then
       simplaret_repository_url
+
+      # TODO: if repos_type == root and the package is a patch,
+      #       save it on $PATCHES_DIR/root-$root_name/
+
       simplaret_download $repository_url $file $storage/$repository_name
+
       if [ ! -f "$storage/$repository_name/$candidate" ]; then
         if [ "$2" != "--silent" ]; then
           echo error downloading $candidate from $repos_type repository $repository_url, please check your settings
@@ -439,6 +444,7 @@ function simplaret_get {
         simplaret_checksum $storage/$repository_name/CHECKSUMS.md5 $storage/$repository_name/$candidate --silent
         return $?
       fi
+
     fi
 
   done
@@ -447,7 +453,11 @@ function simplaret_get {
 
 function simplaret_search_and_download_patch {
 
-  local package_version package_build
+  local package_version package_build installed_version
+  local installed_build repos_type get
+
+  # get the repository type
+  repos_type="`echo $sugested | cut -d , -f 2`"
 
   # get just the file name
   sugested="`echo $sugested | cut -d , -f 1`"
@@ -469,12 +479,29 @@ function simplaret_search_and_download_patch {
     for installed in $installed_packs; do
       if [[ "$sugested" == "`package_name $installed.tgz`" ]]; then
         package_installed="1"
+        installed_version="`package_version $installed.tgz`"
+        installed_build="`package_build $installed.tgz`"
         break
       fi
     done
 
     # if the package is installed, download the patch
-    if [[ "$package_installed" == "1" ]]; then
+    if [ "$package_installed" == "1" ]; then
+      if [ "$repos_type" == "patches" ] || [ "$repos_type" == "root" ]; then
+        # TODO: DOWNLOAD_EVEN_APPLIED_PATCHES
+        get="yes"
+      else
+        # here, we're dealing with repositories other than ROOT and REPOS,
+        # so we need to check if either version or build number are different,
+        # otherwise all installed packages would be downloaded
+        if [ "$package_version" != "$installed_version" ] || [ "$package_build" != "$installed_build" ]; then
+          get="yes"
+        fi
+      fi
+    fi
+
+    # finally, get the package
+    if [ "$get" == "yes" ]; then
       simplaret_get $sugested
       if [ "$?" == "0" ]; then
         DOWNLOADED_PATCHES="$DOWNLOADED_PATCHES $sugested " # the ending space is important
@@ -483,7 +510,7 @@ function simplaret_search_and_download_patch {
 
   fi
 
-  unset package_installed
+  unset package_installed get
 
 }
 
@@ -507,7 +534,7 @@ function simplaret_get_jail_patches {
   VERSION="`default_version`"
   ARCH="`default_arch`"
 
-  # TODO: remove it, forcing user to always do a simplaret --update?
+  # we need to do that for each arch/version pairs
   simplaret_update
 
   # in case there's something wrong with the jail, abort
@@ -520,17 +547,14 @@ function simplaret_get_jail_patches {
 
   echo fetching patches for arch $ARCH and version $VERSION for jail $root
 
-  # list all available patches in PATCHES repositories
+  # list all available patches
   for sugested in `simplaret_search --formatted | grep patches`; do
     simplaret_search_and_download_patch
   done
 
   # grab patches from every other places
   if [ "$CONSIDER_ALL_PACKAGES_AS_PATCHES" == "1" ]; then
-    # TODO: for sugested in `simplaret_search --formatted`; do
-    #       and also think yet some more about this scheme... does ROOT/patches
-    #       should be dealed as a PATCHES repository?
-    for sugested in `simplaret_search patches --formatted | grep -v patches`; do
+    for sugested in `simplaret_search --formatted | grep -v patches`; do
       simplaret_search_and_download_patch
     done
   fi