info: support dependency style tests in package existance checking

cute-signatures
Timo Teras 2009-08-05 15:36:04 +03:00
parent 46e9329568
commit f14cbbf4e5
1 changed files with 18 additions and 11 deletions

View File

@ -84,26 +84,33 @@ static int info_exists(struct info_ctx *ctx, struct apk_database *db,
int argc, char **argv) int argc, char **argv)
{ {
struct apk_name *name; 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++) { for (i = 0; i < argc; i++) {
name = apk_db_query_name(db, APK_BLOB_STR(argv[i])); r = apk_dep_from_blob(&dep, db, APK_BLOB_STR(argv[i]));
if (name == NULL) { if (r != 0)
ret++;
continue; continue;
}
name = dep.name;
for (j = 0; j < name->pkgs->num; j++) { 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; break;
} }
if (j >= name->pkgs->num) { if (j >= name->pkgs->num)
ret++; continue;
} else
verbose_print_pkg(name->pkgs->item[j], 0); 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, static int info_who_owns(struct info_ctx *ctx, struct apk_database *db,