summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-08-05 15:36:04 +0300
committerTimo Teras <timo.teras@iki.fi>2009-08-05 15:36:46 +0300
commitf14cbbf4e52883b73d713b45237f914949f942c1 (patch)
tree4d463ec0b45be3dfca4529bc392dfbfcd5f1c873
parent46e93295688385af6b4b5d17f97675087a90aba4 (diff)
downloadapk-tools-f14cbbf4e52883b73d713b45237f914949f942c1.tar.gz
apk-tools-f14cbbf4e52883b73d713b45237f914949f942c1.tar.bz2
apk-tools-f14cbbf4e52883b73d713b45237f914949f942c1.tar.xz
apk-tools-f14cbbf4e52883b73d713b45237f914949f942c1.zip
info: support dependency style tests in package existance checking
-rw-r--r--src/info.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/info.c b/src/info.c
index 7a50a67..a222b8c 100644
--- a/src/info.c
+++ b/src/info.c
@@ -84,26 +84,33 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db,
int argc, char **argv)
{
struct apk_name *name;
- int i, j, ret = 0;
+ struct apk_package *pkg = NULL;
+ struct apk_dependency dep;
+ int r, i, j, ok = 0;
for (i = 0; i < argc; i++) {
- name = apk_db_query_name(db, APK_BLOB_STR(argv[i]));
- if (name == NULL) {
- ret++;
+ r = apk_dep_from_blob(&dep, db, APK_BLOB_STR(argv[i]));
+ if (r != 0)
continue;
- }
+ name = dep.name;
for (j = 0; j < name->pkgs->num; j++) {
- if (apk_pkg_get_state(name->pkgs->item[j]) == APK_PKG_INSTALLED)
+ pkg = name->pkgs->item[j];
+ if (apk_pkg_get_state(pkg) == APK_PKG_INSTALLED)
break;
}
- if (j >= name->pkgs->num) {
- ret++;
- } else
- verbose_print_pkg(name->pkgs->item[j], 0);
+ if (j >= name->pkgs->num)
+ continue;
+
+ if (!(apk_version_compare(pkg->version, dep.version)
+ & dep.result_mask))
+ continue;
+
+ verbose_print_pkg(pkg, 0);
+ ok++;
}
- return ret;
+ return argc - ok;
}
static int info_who_owns(struct info_ctx *ctx, struct apk_database *db,