pkg: apk_deps_del helper introduced
parent
4e08c87621
commit
968dfbb8b3
|
@ -70,6 +70,8 @@ APK_ARRAY(apk_package_array, struct apk_package *);
|
|||
|
||||
int apk_deps_add(struct apk_dependency_array **depends,
|
||||
struct apk_dependency *dep);
|
||||
void apk_deps_del(struct apk_dependency_array **deps,
|
||||
struct apk_name *name);
|
||||
void apk_deps_parse(struct apk_database *db,
|
||||
struct apk_dependency_array **depends,
|
||||
apk_blob_t blob);
|
||||
|
|
14
src/del.c
14
src/del.c
|
@ -19,7 +19,7 @@ static int del_main(void *ctx, int argc, char **argv)
|
|||
struct apk_database db;
|
||||
struct apk_state *state;
|
||||
struct apk_name *name;
|
||||
int i, j, r;
|
||||
int i, r;
|
||||
|
||||
if (apk_db_open(&db, apk_root, APK_OPENF_WRITE) < 0)
|
||||
return -1;
|
||||
|
@ -29,18 +29,8 @@ static int del_main(void *ctx, int argc, char **argv)
|
|||
|
||||
for (i = 0; i < argc; i++) {
|
||||
name = apk_db_get_name(&db, APK_BLOB_STR(argv[i]));
|
||||
|
||||
/* Remove from world, so we get proper changeset */
|
||||
name->flags &= ~APK_NAME_TOPLEVEL;
|
||||
for (j = 0; j < db.world->num; j++) {
|
||||
if (strcmp(db.world->item[j].name->name,
|
||||
argv[i]) == 0) {
|
||||
db.world->item[j] =
|
||||
db.world->item[db.world->num-1];
|
||||
db.world =
|
||||
apk_dependency_array_resize(db.world, db.world->num-1);
|
||||
}
|
||||
}
|
||||
apk_deps_del(&db.world, name);
|
||||
}
|
||||
|
||||
state = apk_state_new(&db);
|
||||
|
|
|
@ -90,6 +90,25 @@ int apk_deps_add(struct apk_dependency_array **depends,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void apk_deps_del(struct apk_dependency_array **pdeps,
|
||||
struct apk_name *name)
|
||||
{
|
||||
struct apk_dependency_array *deps = *pdeps;
|
||||
int i;
|
||||
|
||||
if (deps == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i < deps->num; i++) {
|
||||
if (deps->item[i].name != name)
|
||||
continue;
|
||||
|
||||
deps->item[i] = deps->item[deps->num-1];
|
||||
*pdeps = apk_dependency_array_resize(deps, deps->num-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
struct parse_depend_ctx {
|
||||
struct apk_database *db;
|
||||
struct apk_dependency_array **depends;
|
||||
|
|
Loading…
Reference in New Issue