summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apk_package.h1
-rw-r--r--src/del.c33
-rw-r--r--src/package.c35
3 files changed, 39 insertions, 30 deletions
diff --git a/src/apk_package.h b/src/apk_package.h
index 6c4ff29..fc43a61 100644
--- a/src/apk_package.h
+++ b/src/apk_package.h
@@ -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,
diff --git a/src/del.c b/src/del.c
index 8e149ab..a67bc23 100644
--- a/src/del.c
+++ b/src/del.c
@@ -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 (!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 (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;
+ }
+
+ 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;
}
diff --git a/src/package.c b/src/package.c
index baa8a90..262bda2 100644
--- a/src/package.c
+++ b/src/package.c
@@ -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);