Set the arch_priority when parsing the Architecture.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 21 Dec 2009 03:49:21 +0000 (03:49 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 21 Dec 2009 03:49:21 +0000 (03:49 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@507 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/pkg.c
libopkg/pkg_hash.c
libopkg/pkg_parse.c

index bd7e9f8866fba6e01b25b9a6233b3de3bd2745df..c5a33361bfc841d12bd10a5756db54037169a59c 100644 (file)
@@ -1315,54 +1315,12 @@ pkg_arch_supported(pkg_t *pkg)
      return 0;
 }
 
-static int
-pkg_get_arch_priority(const char *archname)
-{
-     nv_pair_list_elt_t *l;
-
-     list_for_each_entry(l , &conf->arch_list.head, node) {
-         nv_pair_t *nv = (nv_pair_t *)l->data;
-         if (strcmp(nv->name, archname) == 0) {
-              int priority = strtol(nv->value, NULL, 0);
-              return priority;
-         }
-     }
-     return 0;
-}
-
 void
 pkg_info_preinstall_check(void)
 {
      int i;
-     pkg_vec_t *available_pkgs = pkg_vec_alloc();
      pkg_vec_t *installed_pkgs = pkg_vec_alloc();
 
-     opkg_msg(INFO, "Updating arch priority for each package.\n");
-     pkg_hash_fetch_available(available_pkgs);
-     /* update arch_priority for each package */
-     for (i = 0; i < available_pkgs->len; i++) {
-         pkg_t *pkg = available_pkgs->pkgs[i];
-         int arch_priority = 1;
-         if (!pkg)
-              continue;
-         arch_priority = pkg_get_arch_priority(pkg->architecture);
-         pkg->arch_priority = arch_priority;
-     }
-
-     for (i = 0; i < available_pkgs->len; i++) {
-         pkg_t *pkg = available_pkgs->pkgs[i];
-         if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) {
-              /* clear flags and want for any uninstallable package */
-              opkg_msg(DEBUG, "Clearing state_want and state_flag for pkg=%s "
-                              "(arch_priority=%d flag=%d want=%d)\n", 
-                              pkg->name, pkg->arch_priority,
-                              pkg->state_flag, pkg->state_want);
-              pkg->state_want = SW_UNKNOWN;
-              pkg->state_flag = 0;
-         }
-     }
-     pkg_vec_free(available_pkgs);
-
      /* update the file owner data structure */
      opkg_msg(INFO, "Updating file owner list.\n");
      pkg_hash_fetch_all_installed(installed_pkgs);
index 2fc539ea88ec1411db51de3692114e648cfb5848..5850082d469d553223b0e509eec735b60dbb9acb 100644 (file)
@@ -105,10 +105,10 @@ pkg_hash_add_from_file(const char *file_name,
                        continue;
                }
 
-               if (!pkg->architecture) {
+               if (!pkg->architecture || !pkg->arch_priority) {
                        char *version_str = pkg_version_str_alloc(pkg);
                        opkg_msg(ERROR, "Package %s version %s has no "
-                                       "architecture specified, ignoring.\n",
+                                       "valid architecture, ignoring.\n",
                                        pkg->name, version_str);
                        free(version_str);
                        continue;
index 6c9c7eed8aad99f3c48da2978d6db083ac678e68..f1725de3a33ad09ebcf2feee3c701b2bc54a1c95 100644 (file)
@@ -148,6 +148,19 @@ parse_version(pkg_t *pkg, const char *vstr)
        return 0;
 }
 
+static int
+get_arch_priority(const char *arch)
+{
+       nv_pair_list_elt_t *l;
+
+       list_for_each_entry(l , &conf->arch_list.head, node) {
+               nv_pair_t *nv = (nv_pair_t *)l->data;
+               if (strcmp(nv->name, arch) == 0)
+                       return strtol(nv->value, NULL, 0);
+       }
+       return 0;
+}
+
 static int
 pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
 {
@@ -163,9 +176,10 @@ pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
 
        switch (*line) {
        case 'A':
-               if ((mask & PFM_ARCHITECTURE ) && is_field("Architecture", line))
+               if ((mask & PFM_ARCHITECTURE ) && is_field("Architecture", line)) {
                        pkg->architecture = parse_simple("Architecture", line);
-               else if ((mask & PFM_AUTO_INSTALLED) && is_field("Auto-Installed", line)) {
+                       pkg->arch_priority = get_arch_priority(pkg->architecture);
+               } else if ((mask & PFM_AUTO_INSTALLED) && is_field("Auto-Installed", line)) {
                        char *tmp = parse_simple("Auto-Installed", line);
                        if (strcmp(tmp, "yes") == 0)
                            pkg->auto_installed = 1;