summaryrefslogtreecommitdiffstats
path: root/libopkg/pkg_hash.c
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:21:36 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:21:36 (EST)
commit8c9c7528c65a2e5c9ba7e92521e00fa04052131e (patch)
tree96bd542757e1117db13aae2cf54a65e64a144753 /libopkg/pkg_hash.c
parent53737805077d2f83df7d030cb4e43e7a9be8aed1 (diff)
opkg: consolidate error enums and add an error for when no package matches
current architecture git-svn-id: http://opkg.googlecode.com/svn/trunk@128 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/pkg_hash.c')
-rw-r--r--libopkg/pkg_hash.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c
index 2fb0d1d..917f433 100644
--- a/libopkg/pkg_hash.c
+++ b/libopkg/pkg_hash.c
@@ -170,7 +170,7 @@ abstract_pkg_vec_t *pkg_hash_fetch_all_installation_candidates(hash_table_t *has
pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pkg_t *apkg,
- int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet)
+ int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet, int *err)
{
int i;
int nprovides = 0;
@@ -185,6 +185,9 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pk
pkg_t *held_pkg = NULL;
pkg_t *good_pkg_by_name = NULL;
+ if (err)
+ *err = 0;
+
if (matching_apkgs == NULL || providers == NULL ||
apkg == NULL || apkg->provided_by == NULL || (apkg->provided_by->len == 0))
return NULL;
@@ -251,6 +254,14 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(opkg_conf_t *conf, abstract_pk
pkg_vec_insert(matching_pkgs, maybe);
}
}
+
+ if (vec->len > 0 && matching_pkgs->len < 1)
+ {
+ opkg_message (conf, OPKG_ERROR, " Packages found, but none available for the current "
+ "architecture\n");
+ if (err)
+ *err = OPKG_PKG_HAS_NO_AVAILABLE_ARCH;
+ }
}
}
@@ -351,15 +362,18 @@ static int pkg_name_constraint_fcn(pkg_t *pkg, void *cdata)
return 0;
}
-pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name)
+pkg_t *pkg_hash_fetch_best_installation_candidate_by_name(opkg_conf_t *conf, const char *name, int *err)
{
hash_table_t *hash = &conf->pkg_hash;
abstract_pkg_t *apkg = NULL;
+ pkg_t *ret;
if (!(apkg = abstract_pkg_fetch_by_name(hash, name)))
return NULL;
-
- return pkg_hash_fetch_best_installation_candidate(conf, apkg, pkg_name_constraint_fcn, apkg->name, 0);
+
+ ret = pkg_hash_fetch_best_installation_candidate(conf, apkg, pkg_name_constraint_fcn, apkg->name, 0, err);
+
+ return ret;
}
@@ -517,7 +531,7 @@ static void pkg_hash_dump_helper(const char *pkg_name, void *entry, void *data)
if (dependents != NULL)
while (dependents [i] != NULL && i < ab_pkg->provided_by->len)
printf ("\tprovided by - %s\n", dependents [i ++]->name);
- pkg = pkg_hash_fetch_best_installation_candidate_by_name (conf, ab_pkg->name);
+ pkg = pkg_hash_fetch_best_installation_candidate_by_name (conf, ab_pkg->name, NULL);
if (pkg) {
i = 0;
while (i < pkg->depends_count)