diff options
author | Timo Teräs <timo.teras@iki.fi> | 2020-08-24 15:26:25 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2020-08-24 15:26:25 +0300 |
commit | e2afc7e7a9960eaf6cb40267bc1f39aa6638dccb (patch) | |
tree | 267888911a9f46b096e5c76689c6f1fbf5acea28 /src/app_upgrade.c | |
parent | f3cf824948f11cd7b9af4b7e7232c71b5e96d89b (diff) | |
download | apk-tools-e2afc7e7a9960eaf6cb40267bc1f39aa6638dccb.tar.gz apk-tools-e2afc7e7a9960eaf6cb40267bc1f39aa6638dccb.tar.bz2 apk-tools-e2afc7e7a9960eaf6cb40267bc1f39aa6638dccb.tar.xz apk-tools-e2afc7e7a9960eaf6cb40267bc1f39aa6638dccb.zip |
fix, simplify and document upgrade --ignore
Diffstat (limited to 'src/app_upgrade.c')
-rw-r--r-- | src/app_upgrade.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/app_upgrade.c b/src/app_upgrade.c index b666d8e..b9c50d5 100644 --- a/src/app_upgrade.c +++ b/src/app_upgrade.c @@ -138,8 +138,10 @@ static void set_upgrade_for_name(struct apk_database *db, const char *match, str if (!name) { apk_error("Package '%s' not found", match); uctx->errors++; - } else - apk_solver_set_name_flags(name, APK_SOLVERF_UPGRADE, 0); + return; + } + + apk_solver_set_name_flags(name, uctx->ignore ? APK_SOLVERF_INSTALLED : APK_SOLVERF_UPGRADE, 0); } static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_array *args) @@ -157,7 +159,7 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar } solver_flags = APK_SOLVERF_UPGRADE | uctx->solver_flags; - if (!uctx->no_self_upgrade) { + if (!uctx->no_self_upgrade && !args->num) { r = apk_do_self_upgrade(db, solver_flags, uctx->self_upgrade_only); if (r != 0) return r; @@ -165,15 +167,6 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar if (uctx->self_upgrade_only) return 0; - if (uctx->ignore) { - char **pkg_name; - struct apk_name *name; - foreach_array_item(pkg_name, args) { - name = apk_db_get_name(db, APK_BLOB_STR(*pkg_name)); - apk_solver_set_name_flags(name, solver_flags | APK_SOLVERF_IGNORE_UPGRADE, 0); - } - } - if (solver_flags & APK_SOLVERF_AVAILABLE) { apk_dependency_array_copy(&world, db->world); foreach_array_item(dep, world) { @@ -188,12 +181,9 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar if (args->num > 0) { /* if specific packages are listed, we don't want to upgrade world. */ - solver_flags &= ~APK_SOLVERF_UPGRADE; - - apk_name_foreach_matching(db, args, apk_foreach_genid(), set_upgrade_for_name, &uctx); - - if (uctx->errors) - return uctx->errors; + if (!uctx->ignore) solver_flags &= ~APK_SOLVERF_UPGRADE; + apk_name_foreach_matching(db, args, apk_foreach_genid(), set_upgrade_for_name, uctx); + if (uctx->errors) return uctx->errors; } r = apk_solver_commit(db, solver_flags, world); |