del: report non-matching names and install-if rule non-deletion

cute-signatures
Timo Teräs 2019-12-29 19:33:44 +02:00
parent 7af5384db7
commit 90fc52e2b8
3 changed files with 38 additions and 29 deletions

View File

@ -193,6 +193,7 @@ int apk_pkg_write_index_entry(struct apk_package *pkg, struct apk_ostream *os);
int apk_pkg_version_compare(struct apk_package *a, struct apk_package *b);
unsigned int apk_foreach_genid(void);
int apk_pkg_match_genid(struct apk_package *pkg, unsigned int match);
void apk_pkg_foreach_matching_dependency(
struct apk_package *pkg, struct apk_dependency_array *deps,
unsigned int match, struct apk_package *mpkg,

View File

@ -58,22 +58,30 @@ static void print_not_deleted_pkg(struct apk_package *pkg0, struct apk_dependenc
struct apk_package *pkg, void *pctx)
{
struct not_deleted_ctx *ctx = (struct not_deleted_ctx *) pctx;
struct apk_dependency *d;
struct apk_provider *p;
if (pkg0->name == ctx->name)
goto no_print;
if (pkg0->name != ctx->name) {
if (!ctx->header) {
apk_message("World updated, but the following packages are not removed due to:");
ctx->header = 1;
}
if (!ctx->indent.indent) {
ctx->indent.x = printf(" %s:", ctx->name->name);
ctx->indent.indent = ctx->indent.x + 1;
}
if (!ctx->header) {
apk_message("World updated, but the following packages are not removed due to:");
ctx->header = 1;
}
if (!ctx->indent.indent) {
ctx->indent.x = printf(" %s:", ctx->name->name);
ctx->indent.indent = ctx->indent.x + 1;
apk_print_indented(&ctx->indent, APK_BLOB_STR(pkg0->name->name));
}
apk_print_indented(&ctx->indent, APK_BLOB_STR(pkg0->name->name));
no_print:
apk_pkg_foreach_reverse_dependency(pkg0, ctx->matches, print_not_deleted_pkg, pctx);
foreach_array_item(d, pkg0->install_if) {
foreach_array_item(p, d->name->providers) {
if (!p->pkg->marked) continue;
if (apk_pkg_match_genid(p->pkg, ctx->matches)) continue;
print_not_deleted_pkg(p->pkg, NULL, NULL, pctx);
}
}
}
static void print_not_deleted_name(struct apk_database *db, const char *match,
@ -111,6 +119,7 @@ static void delete_name(struct apk_database *db, const char *match,
struct apk_package *pkg;
if (!name) {
apk_error("No such package: %s", match);
ctx->errors++;
return;
}

View File

@ -1168,21 +1168,27 @@ unsigned int apk_foreach_genid(void)
return foreach_genid;
}
int apk_pkg_match_genid(struct apk_package *pkg, unsigned int match)
{
unsigned int genid = match & APK_FOREACH_GENID_MASK;
if (pkg && genid) {
if (pkg->foreach_genid >= genid)
return 1;
pkg->foreach_genid = genid;
}
return 0;
}
void apk_pkg_foreach_matching_dependency(
struct apk_package *pkg, struct apk_dependency_array *deps,
unsigned int match, struct apk_package *mpkg,
void cb(struct apk_package *pkg0, struct apk_dependency *dep0, struct apk_package *pkg, void *ctx),
void *ctx)
{
unsigned int genid = match & APK_FOREACH_GENID_MASK;
unsigned int one_dep_only = genid && !(match & APK_FOREACH_DEP);
unsigned int one_dep_only = (match & APK_FOREACH_GENID_MASK) && !(match & APK_FOREACH_DEP);
struct apk_dependency *d;
if (pkg && genid) {
if (pkg->foreach_genid >= genid)
return;
pkg->foreach_genid = genid;
}
if (apk_pkg_match_genid(pkg, match)) return;
foreach_array_item(d, deps) {
if (apk_dep_analyze(d, mpkg) & match) {
@ -1199,10 +1205,9 @@ static void foreach_reverse_dependency(
void cb(struct apk_package *pkg0, struct apk_dependency *dep0, struct apk_package *pkg, void *ctx),
void *ctx)
{
unsigned int genid = match & APK_FOREACH_GENID_MASK;
unsigned int marked = match & APK_FOREACH_MARKED;
unsigned int installed = match & APK_FOREACH_INSTALLED;
unsigned int one_dep_only = genid && !(match & APK_FOREACH_DEP);
unsigned int one_dep_only = (match & APK_FOREACH_GENID_MASK) && !(match & APK_FOREACH_DEP);
struct apk_name **pname0, *name0;
struct apk_provider *p0;
struct apk_package *pkg0;
@ -1212,15 +1217,9 @@ static void foreach_reverse_dependency(
name0 = *pname0;
foreach_array_item(p0, name0->providers) {
pkg0 = p0->pkg;
if (installed && pkg0->ipkg == NULL)
continue;
if (marked && !pkg0->marked)
continue;
if (genid) {
if (pkg0->foreach_genid >= genid)
continue;
pkg0->foreach_genid = genid;
}
if (installed && pkg0->ipkg == NULL) continue;
if (marked && !pkg0->marked) continue;
if (apk_pkg_match_genid(pkg0, match)) continue;
foreach_array_item(d0, pkg0->depends) {
if (apk_dep_analyze(d0, pkg) & match) {
cb(pkg0, d0, pkg, ctx);