Fix depended_upon_by to only contain pre_depends and depends.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Tue, 17 Nov 2009 05:58:41 +0000 (05:58 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Tue, 17 Nov 2009 05:58:41 +0000 (05:58 +0000)
Partially fixes Issue 23. Allows removal of suggested/recommended packages.

git-svn-id: http://opkg.googlecode.com/svn/trunk@328 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/pkg_depends.c

index d93ea0caa335e409d4c6fa1b7e07b3ff0a9f7757..10a8ab519437dafb245a74cfffbbc5ca15b1f547 100644 (file)
@@ -642,6 +642,11 @@ void buildDepends(hash_table_t * hash, pkg_t * pkg)
          depends++;
      }
 
+     for(i = 0; i < pkg->depends_count; i++){
+         parseDepends(depends, hash, pkg->depends_str[i]);
+         depends++;
+     }
+
      for(i = 0; i < pkg->recommends_count; i++){
          parseDepends(depends, hash, pkg->recommends_str[i]);
          depends->type = RECOMMEND;
@@ -653,11 +658,6 @@ void buildDepends(hash_table_t * hash, pkg_t * pkg)
          depends->type = SUGGEST;
          depends++;
      }
-
-     for(i = 0; i < pkg->depends_count; i++){
-         parseDepends(depends, hash, pkg->depends_str[i]);
-         depends++;
-     }
 }
 
 /*
@@ -675,6 +675,11 @@ char *pkg_depend_str(pkg_t *pkg, int index)
      }
      index -= pkg->pre_depends_count;
 
+     if (index < pkg->depends_count) {
+         return pkg->depends_str[index];
+     }
+     index -= pkg->depends_count;
+
      if (index < pkg->recommends_count) {
          return pkg->recommends_str[index];
      }
@@ -683,15 +688,15 @@ char *pkg_depend_str(pkg_t *pkg, int index)
      if (index < pkg->suggests_count) {
          return pkg->suggests_str[index];
      }
-     index -= pkg->suggests_count;
 
-     if (index < pkg->depends_count) {
-         return pkg->depends_str[index];
-     }
      fprintf(stderr, "pkg_depend_str: index %d out of range for pkg=%s\n", index, pkg->name);
      return NULL;
 }
 
+/*
+ * WARNING: This function assumes pre_depends and depends are at the
+ * start of the pkg->depends array.
+ */
 void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg)
 {
      compound_depend_t * depends;