libopkg: store checksums in binary form, use integer index for architecture
[oweals/opkg-lede.git] / libopkg / pkg_hash.c
index edc51886d691af8c8815688069724441de2dc4cf..f5c049507848e31748624079e69e7522ceb9abb8 100644 (file)
@@ -141,7 +141,7 @@ pkg_hash_add_from_file(const char *file_name,
                        continue;
                }
 
-               if (!pkg->architecture || !pkg->arch_priority) {
+               if (!pkg_get_architecture(pkg) || !pkg_get_arch_priority(pkg)) {
                        char *version_str = pkg_version_str_alloc(pkg);
                        opkg_msg(NOTICE, "Package %s version %s has no "
                                 "valid architecture, ignoring.\n",
@@ -237,6 +237,7 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
        int nprovides = 0;
        int nmatching = 0;
        int wrong_arch_found = 0;
+       int arch_priority;
        pkg_vec_t *matching_pkgs;
        abstract_pkg_vec_t *matching_apkgs;
        abstract_pkg_vec_t *provided_apkg_vec;
@@ -317,13 +318,15 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                        /* count packages matching max arch priority and keep track of last one */
                        for (j = 0; j < vec->len; j++) {
                                pkg_t *maybe = vec->pkgs[j];
+                               arch_priority = pkg_get_arch_priority(maybe);
+
                                opkg_msg(DEBUG,
                                         "%s arch=%s arch_priority=%d version=%s.\n",
-                                        maybe->name, maybe->architecture,
-                                        maybe->arch_priority, maybe->version);
+                                        maybe->name, pkg_get_architecture(maybe),
+                                        arch_priority, pkg_get_string(maybe, PKG_VERSION));
                                /* We make sure not to add the same package twice. Need to search for the reason why
                                   they show up twice sometimes. */
-                               if ((maybe->arch_priority > 0)
+                               if ((arch_priority > 0)
                                    &&
                                    (!pkg_vec_contains(matching_pkgs, maybe))) {
                                        max_count++;
@@ -359,7 +362,7 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                pkg_t *matching = matching_pkgs->pkgs[i];
                if (constraint_fcn(matching, cdata)) {
                        opkg_msg(DEBUG, "Candidate: %s %s.\n",
-                                matching->name, matching->version);
+                                matching->name, pkg_get_string(matching, PKG_VERSION));
                        good_pkg_by_name = matching;
                        /* It has been provided by hand, so it is what user want */
                        if (matching->provided_by_hand == 1)
@@ -389,9 +392,10 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                int prio = 0;
                for (i = 0; i < matching_pkgs->len; i++) {
                        pkg_t *matching = matching_pkgs->pkgs[i];
-                       if (matching->arch_priority > prio) {
+                       arch_priority = pkg_get_arch_priority(matching);
+                       if (arch_priority > prio) {
                                priorized_matching = matching;
-                               prio = matching->arch_priority;
+                               prio = arch_priority;
                                opkg_msg(DEBUG, "Match %s with priority %i.\n",
                                         matching->name, prio);
                        }
@@ -405,8 +409,8 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                for (i = 0; i < matching_pkgs->len; i++) {
                        pkg_t *matching = matching_pkgs->pkgs[i];
                        opkg_msg(INFO, "%s %s %s\n",
-                                matching->name, matching->version,
-                                matching->architecture);
+                                matching->name, pkg_get_string(matching, PKG_VERSION),
+                                pkg_get_architecture(matching));
                }
        }
 
@@ -431,8 +435,8 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
        }
        if (priorized_matching) {
                opkg_msg(INFO, "Using priorized matching %s %s %s.\n",
-                        priorized_matching->name, priorized_matching->version,
-                        priorized_matching->architecture);
+                        priorized_matching->name, pkg_get_string(priorized_matching, PKG_VERSION),
+                        pkg_get_architecture(priorized_matching));
                return priorized_matching;
        }
        if (nmatching > 1) {
@@ -442,8 +446,8 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
        }
        if (latest_matching) {
                opkg_msg(INFO, "Using latest matching %s %s %s.\n",
-                        latest_matching->name, latest_matching->version,
-                        latest_matching->architecture);
+                        latest_matching->name, pkg_get_string(latest_matching, PKG_VERSION),
+                        pkg_get_architecture(latest_matching));
                return latest_matching;
        }
        return NULL;
@@ -648,6 +652,8 @@ void hash_insert_pkg(pkg_t * pkg, int set_status)
 
        buildProvides(ab_pkg, pkg);
 
+       init_providelist(pkg, NULL);
+
        /* Need to build the conflicts graph before replaces for correct
         * calculation of replaced_by relation.
         */