summaryrefslogtreecommitdiff
path: root/src/package.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-13 18:20:39 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-13 18:22:00 +0300
commite51232e710dfd32764e2c2d0599df83ab85a9c74 (patch)
tree5eac93c05cf2fe77d2857a48a9fc55c7bf7e33d0 /src/package.c
parent25ff68a87e3264b6dfdc846823d4912b4dd870b2 (diff)
downloadapk-tools-e51232e710dfd32764e2c2d0599df83ab85a9c74.tar.gz
apk-tools-e51232e710dfd32764e2c2d0599df83ab85a9c74.tar.bz2
apk-tools-e51232e710dfd32764e2c2d0599df83ab85a9c74.tar.xz
apk-tools-e51232e710dfd32764e2c2d0599df83ab85a9c74.zip
errors: rewrite the logic how errors are reported
Instead of the dependency oriented logic, switch to print them for each package or name needed. Might give a bit more readable errors now. There's still few corner cases that proper error is not output, which are cought by the test cases.
Diffstat (limited to 'src/package.c')
-rw-r--r--src/package.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/package.c b/src/package.c
index ecf88c2..e9eb45a 100644
--- a/src/package.c
+++ b/src/package.c
@@ -399,6 +399,40 @@ int apk_dep_is_materialized_or_provided(struct apk_dependency *dep, struct apk_p
return dep->conflict;
}
+int apk_dep_analyze(struct apk_dependency *dep, struct apk_package *pkg)
+{
+ int i;
+
+ if (pkg == NULL)
+ return APK_DEP_IRRELEVANT;
+
+ if (dep->name == pkg->name)
+ return apk_dep_is_materialized(dep, pkg) ? APK_DEP_SATISFIED : APK_DEP_CONFLICTED;
+
+ for (i = 0; i < pkg->provides->num; i++) {
+ struct apk_provider p;
+
+ if (pkg->provides->item[i].name != dep->name)
+ continue;
+
+ p = APK_PROVIDER_FROM_PROVIDES(pkg, &pkg->provides->item[i]);
+ return apk_dep_is_provided(dep, &p) ? APK_DEP_SATISFIED : APK_DEP_CONFLICTED;
+ }
+
+ return APK_DEP_IRRELEVANT;
+}
+
+char *apk_dep_snprintf(char *buf, size_t n, struct apk_dependency *dep)
+{
+ apk_blob_t b = APK_BLOB_PTR_LEN(buf, n);
+ apk_blob_push_dep(&b, NULL, dep);
+ if (b.len)
+ apk_blob_push_blob(&b, APK_BLOB_PTR_LEN("", 1));
+ else
+ b.ptr[-1] = 0;
+ return buf;
+}
+
void apk_blob_push_dep(apk_blob_t *to, struct apk_database *db, struct apk_dependency *dep)
{
int result_mask = dep->result_mask;