audit, index, search, upgrade: use foreach_array_item
parent
59d15ab259
commit
edf03b155b
|
@ -195,12 +195,11 @@ recurse_check:
|
||||||
atctx->pathlen--;
|
atctx->pathlen--;
|
||||||
} else {
|
} else {
|
||||||
struct apk_db_file *dbf;
|
struct apk_db_file *dbf;
|
||||||
struct apk_protected_path_array *ppaths = dir->protected_paths;
|
struct apk_protected_path *ppath;
|
||||||
int i, protected = dir->protected, symlinks_only = dir->symlinks_only;
|
int protected = dir->protected, symlinks_only = dir->symlinks_only;
|
||||||
|
|
||||||
/* inherit file's protection mask */
|
/* inherit file's protection mask */
|
||||||
for (i = 0; i < ppaths->num; i++) {
|
foreach_array_item(ppath, dir->protected_paths) {
|
||||||
struct apk_protected_path *ppath = &ppaths->item[i];
|
|
||||||
char *slash = strchr(ppath->relative_pattern, '/');
|
char *slash = strchr(ppath->relative_pattern, '/');
|
||||||
if (slash == NULL) {
|
if (slash == NULL) {
|
||||||
if (fnmatch(ppath->relative_pattern, name, FNM_PATHNAME) != 0)
|
if (fnmatch(ppath->relative_pattern, name, FNM_PATHNAME) != 0)
|
||||||
|
|
|
@ -92,7 +92,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
|
||||||
struct counts counts = {0};
|
struct counts counts = {0};
|
||||||
struct apk_ostream *os;
|
struct apk_ostream *os;
|
||||||
struct apk_file_info fi;
|
struct apk_file_info fi;
|
||||||
int total, r, i, j, found, newpkgs = 0, errors = 0;
|
int total, r, i, found, newpkgs = 0, errors = 0;
|
||||||
struct index_ctx *ictx = (struct index_ctx *) ctx;
|
struct index_ctx *ictx = (struct index_ctx *) ctx;
|
||||||
struct apk_package *pkg;
|
struct apk_package *pkg;
|
||||||
|
|
||||||
|
@ -119,6 +119,7 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
|
||||||
|
|
||||||
found = FALSE;
|
found = FALSE;
|
||||||
do {
|
do {
|
||||||
|
struct apk_provider *p;
|
||||||
struct apk_name *name;
|
struct apk_name *name;
|
||||||
char *fname, *fend;
|
char *fname, *fend;
|
||||||
apk_blob_t bname, bver;
|
apk_blob_t bname, bver;
|
||||||
|
@ -145,8 +146,8 @@ static int index_main(void *ctx, struct apk_database *db, int argc, char **argv)
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (j = 0; j < name->providers->num; j++) {
|
foreach_array_item(p, name->providers) {
|
||||||
pkg = name->providers->item[j].pkg;
|
pkg = p->pkg;
|
||||||
if (pkg->name != name)
|
if (pkg->name != name)
|
||||||
continue;
|
continue;
|
||||||
if (apk_blob_compare(bver, *pkg->version) != 0)
|
if (apk_blob_compare(bver, *pkg->version) != 0)
|
||||||
|
|
12
src/search.c
12
src/search.c
|
@ -119,16 +119,14 @@ static void print_result_pkg(struct search_ctx *ctx, struct apk_package *pkg)
|
||||||
|
|
||||||
static void print_result(struct search_ctx *ctx, struct apk_name *name)
|
static void print_result(struct search_ctx *ctx, struct apk_name *name)
|
||||||
{
|
{
|
||||||
int i;
|
struct apk_provider *p;
|
||||||
|
struct apk_package *pkg = NULL;
|
||||||
|
apk_blob_t *version = NULL;
|
||||||
|
|
||||||
if (ctx->show_all) {
|
if (ctx->show_all) {
|
||||||
for (i = 0; i < name->providers->num; i++)
|
foreach_array_item(p, name->providers)
|
||||||
print_result_pkg(ctx, name->providers->item[i].pkg);
|
print_result_pkg(ctx, p->pkg);
|
||||||
} else {
|
} else {
|
||||||
struct apk_package *pkg = NULL;
|
|
||||||
struct apk_provider *p;
|
|
||||||
apk_blob_t *version = NULL;
|
|
||||||
|
|
||||||
foreach_array_item(p, name->providers) {
|
foreach_array_item(p, name->providers) {
|
||||||
if (version == NULL ||
|
if (version == NULL ||
|
||||||
apk_version_compare_blob(*p->version, *version) == APK_VERSION_GREATER)
|
apk_version_compare_blob(*p->version, *version) == APK_VERSION_GREATER)
|
||||||
|
|
|
@ -89,8 +89,9 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
|
||||||
{
|
{
|
||||||
struct upgrade_ctx *uctx = (struct upgrade_ctx *) ctx;
|
struct upgrade_ctx *uctx = (struct upgrade_ctx *) ctx;
|
||||||
unsigned short solver_flags;
|
unsigned short solver_flags;
|
||||||
|
struct apk_dependency *dep;
|
||||||
struct apk_dependency_array *world = NULL;
|
struct apk_dependency_array *world = NULL;
|
||||||
int i, r;
|
int r;
|
||||||
|
|
||||||
if (apk_db_check_world(db, db->world) != 0) {
|
if (apk_db_check_world(db, db->world) != 0) {
|
||||||
apk_error("Not continuing with upgrade due to missing repository tags. Use --force to override.");
|
apk_error("Not continuing with upgrade due to missing repository tags. Use --force to override.");
|
||||||
|
@ -106,8 +107,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, int argc, char **arg
|
||||||
|
|
||||||
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
if (solver_flags & APK_SOLVERF_AVAILABLE) {
|
||||||
apk_dependency_array_copy(&world, db->world);
|
apk_dependency_array_copy(&world, db->world);
|
||||||
for (i = 0; i < world->num; i++) {
|
foreach_array_item(dep, world) {
|
||||||
struct apk_dependency *dep = &world->item[i];
|
|
||||||
if (dep->result_mask == APK_DEPMASK_CHECKSUM) {
|
if (dep->result_mask == APK_DEPMASK_CHECKSUM) {
|
||||||
dep->result_mask = APK_DEPMASK_ANY;
|
dep->result_mask = APK_DEPMASK_ANY;
|
||||||
dep->version = apk_blob_atomize(APK_BLOB_NULL);
|
dep->version = apk_blob_atomize(APK_BLOB_NULL);
|
||||||
|
|
Loading…
Reference in New Issue