summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2020-07-14 18:16:38 -0600
committerTimo Teräs <timo.teras@iki.fi>2020-07-30 11:41:35 +0300
commitbef1faf1cba44b6d4106a37728f769edaf90ee87 (patch)
treeb7ea307b87316bb163f85bedfc628b67c014607a /src
parentffcdd350d02fb51d91e83a153e58ddbb66bfeb31 (diff)
downloadapk-tools-bef1faf1cba44b6d4106a37728f769edaf90ee87.tar.gz
apk-tools-bef1faf1cba44b6d4106a37728f769edaf90ee87.tar.bz2
apk-tools-bef1faf1cba44b6d4106a37728f769edaf90ee87.tar.xz
apk-tools-bef1faf1cba44b6d4106a37728f769edaf90ee87.zip
upgrade: allow for specified package upgrades
Fixes #10667 and #10700
Diffstat (limited to 'src')
-rw-r--r--src/app_upgrade.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/app_upgrade.c b/src/app_upgrade.c
index 7e5347f..06008f6 100644
--- a/src/app_upgrade.c
+++ b/src/app_upgrade.c
@@ -21,6 +21,7 @@ struct upgrade_ctx {
int no_self_upgrade : 1;
int self_upgrade_only : 1;
int ignore : 1;
+ int errors;
};
enum {
@@ -137,6 +138,17 @@ ret:
return r;
}
+static void set_upgrade_for_name(struct apk_database *db, const char *match, struct apk_name *name, void *pctx)
+{
+ struct upgrade_ctx *uctx = (struct upgrade_ctx *) pctx;
+
+ if (!name) {
+ apk_error("Package '%s' not found", match);
+ uctx->errors++;
+ } else
+ apk_solver_set_name_flags(name, APK_SOLVERF_UPGRADE, 0);
+}
+
static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_array *args)
{
struct upgrade_ctx *uctx = (struct upgrade_ctx *) ctx;
@@ -181,6 +193,16 @@ static int upgrade_main(void *ctx, struct apk_database *db, struct apk_string_ar
world = db->world;
}
+ 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;
+ }
+
r = apk_solver_commit(db, solver_flags, world);
if (solver_flags & APK_SOLVERF_AVAILABLE)