#include "parse_util.h"
#include "pkg_parse.h"
#include "opkg_utils.h"
+#include "opkg_cmd.h"
#include "sprintf_alloc.h"
#include "file_util.h"
#include "libbb/libbb.h"
hash_table_deinit(&conf->pkg_hash);
}
-int dist_hash_add_from_file(const char *lists_dir, pkg_src_t * dist)
-{
- nv_pair_list_elt_t *l;
- char *list_file, *subname;
-
- list_for_each_entry(l, &conf->arch_list.head, node) {
- nv_pair_t *nv = (nv_pair_t *) l->data;
- sprintf_alloc(&subname, "%s-%s", dist->name, nv->name);
- sprintf_alloc(&list_file, "%s/%s", lists_dir, subname);
-
- if (file_exists(list_file)) {
- if (pkg_hash_add_from_file(list_file, dist, NULL, 0, 0, NULL, NULL)) {
- free(list_file);
- return -1;
- }
- pkg_src_list_append(&conf->pkg_src_list, subname,
- dist->value, "__dummy__", 0);
- }
-
- free(list_file);
- }
-
- return 0;
-}
-
int
pkg_hash_add_from_file(const char *file_name,
pkg_src_t * src, pkg_dest_t * dest, int is_status_file, int state_flags,
{
char **unresolved = NULL;
char **tmp;
- pkg_vec_t *depends, *all;
- int i, res = 0;
+ pkg_vec_t *depends;
+ int res = 0;
depends = pkg_vec_alloc();
- pkg_hash_fetch_unsatisfied_dependencies(maybe, depends, &unresolved);
+ pkg_hash_fetch_unsatisfied_dependencies(maybe, depends, &unresolved, 1);
if (unresolved) {
res = 1;
tmp = unresolved;
- while (tmp)
+ while (*tmp) {
+ opkg_msg(ERROR, "cannot find dependency %s for %s\n", *tmp, maybe->name);
free(*(tmp++));
+ }
free(unresolved);
}
pkg_vec_free(depends);
- /* clear depenacy checked marks, left by pkg_hash_fetch_unsatisfied_dependencies */
- all = pkg_vec_alloc();
- pkg_hash_fetch_available(all);
- for (i = 0; i < all->len; i++) {
- all->pkgs[i]->parent->dependencies_checked = 0;
- }
- pkg_vec_free(all);
-
return res;
}
int nmatching = 0;
int wrong_arch_found = 0;
int arch_priority;
+ int good_pkg_score = 0;
pkg_vec_t *matching_pkgs;
abstract_pkg_vec_t *matching_apkgs;
abstract_pkg_vec_t *provided_apkg_vec;
they show up twice sometimes. */
if ((arch_priority > 0)
&&
- (!pkg_vec_contains(matching_pkgs, maybe))
- &&
- (!pkg_hash_check_unresolved(maybe))) {
- max_count++;
- abstract_pkg_vec_insert(matching_apkgs,
- maybe->parent);
- pkg_vec_insert(matching_pkgs, maybe);
+ (!pkg_vec_contains(matching_pkgs, maybe))) {
+ if (!pkg_hash_check_unresolved(maybe)) {
+ max_count++;
+ abstract_pkg_vec_insert(matching_apkgs,
+ maybe->parent);
+ pkg_vec_insert(matching_pkgs, maybe);
+ }
}
}
for (i = 0; i < matching_pkgs->len; i++) {
pkg_t *matching = matching_pkgs->pkgs[i];
if (constraint_fcn(matching, cdata)) {
- opkg_msg(DEBUG, "Candidate: %s %s.\n",
- matching->name, pkg_get_string(matching, PKG_VERSION));
+ int score = 1;
+ if (strcmp(matching->name, apkg->name) == 0)
+ score++;
+
+ for (j = 0; j < opkg_cli_argc; ++j) {
+ if (!strcmp(matching->name, opkg_cli_argv[j])) {
+ score++;
+ break;
+ }
+ }
+
+ opkg_msg(DEBUG, "Candidate: %s %s (score %d).\n",
+ matching->name, pkg_get_string(matching, PKG_VERSION),
+ score);
+ if (score < good_pkg_score)
+ continue;
+
good_pkg_by_name = matching;
+ good_pkg_score = score;
/* It has been provided by hand, so it is what user want */
if (matching->provided_by_hand == 1)
break;