From 695a2f8231f11f690ba96d6c4b537e22dd6571fd Mon Sep 17 00:00:00 2001 From: nrybowski Date: Tue, 10 Dec 2019 02:14:49 +0100 Subject: upgrade: implement --ignore to exclude some packages from upgrade --- src/upgrade.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/upgrade.c') diff --git a/src/upgrade.c b/src/upgrade.c index 6c3eafa..d1ec36c 100644 --- a/src/upgrade.c +++ b/src/upgrade.c @@ -22,6 +22,7 @@ struct upgrade_ctx { unsigned short solver_flags; int no_self_upgrade : 1; int self_upgrade_only : 1; + int ignore : 1; }; static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int optch, const char *optarg) @@ -35,6 +36,9 @@ static int option_parse_applet(void *ctx, struct apk_db_options *dbopts, int opt case 0x10001: uctx->self_upgrade_only = 1; break; + case 0x10002: + uctx->ignore = 1; + break; case 'a': uctx->solver_flags |= APK_SOLVERF_AVAILABLE; break; @@ -59,6 +63,8 @@ static const struct apk_option options_applet[] = { { 0x10000, "no-self-upgrade", "Do not do early upgrade of 'apk-tools' package" }, { 0x10001, "self-upgrade-only", "Only do self-upgrade" }, + { 0x10002, "ignore", "Ignore the upgrade of PACKAGE. Partial " + "upgrades not supported, this might break your system."}, }; static const struct apk_option_group optgroup_applet = { @@ -158,6 +164,15 @@ 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) { -- cgit v1.2.3-60-g2f50