Skip to content

Commit 91cff1a

Browse files
committed
apk: add --force-reinstall option
Allow reinstalling already-installed packages without a version change. Only the named packages are reinstalled, not their dependencies. Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent 56bf67d commit 91cff1a

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

package/system/apk/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=apk
4-
PKG_RELEASE:=1
4+
PKG_RELEASE:=2
55

66
PKG_SOURCE_URL=https://gitlab.alpinelinux.org/alpine/apk-tools.git
77
PKG_SOURCE_PROTO:=git
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
From: Felix Fietkau <nbd@nbd.name>
2+
Date: Sun, 8 Mar 2026 13:41:16 +0000
3+
Subject: [PATCH] add: add --force-reinstall option
4+
5+
Allow reinstalling already-installed packages without a version change.
6+
Only the named packages are reinstalled, not their dependencies.
7+
8+
Signed-off-by: Felix Fietkau <nbd@nbd.name>
9+
---
10+
11+
--- a/src/app_add.c
12+
+++ b/src/app_add.c
13+
@@ -24,6 +24,7 @@ struct add_ctx {
14+
OPT(OPT_ADD_initdb, "initdb") \
15+
OPT(OPT_ADD_latest, APK_OPT_SH("l") "latest") \
16+
OPT(OPT_ADD_no_chown, "no-chown") \
17+
+ OPT(OPT_ADD_reinstall, "force-reinstall") \
18+
OPT(OPT_ADD_upgrade, APK_OPT_SH("u") "upgrade") \
19+
OPT(OPT_ADD_usermode, "usermode") \
20+
OPT(OPT_ADD_virtual, APK_OPT_ARG APK_OPT_SH("t") "virtual")
21+
@@ -41,6 +42,9 @@ static int add_parse_option(void *ctx, s
22+
case OPT_ADD_latest:
23+
actx->solver_flags |= APK_SOLVERF_LATEST;
24+
break;
25+
+ case OPT_ADD_reinstall:
26+
+ actx->solver_flags |= APK_SOLVERF_REINSTALL;
27+
+ break;
28+
case OPT_ADD_upgrade:
29+
actx->solver_flags |= APK_SOLVERF_UPGRADE;
30+
break;
31+
@@ -177,7 +181,7 @@ static int add_main(void *ctx, struct ap
32+
apk_deps_add(&world, &dep);
33+
apk_solver_set_name_flags(dep.name,
34+
actx->solver_flags,
35+
- actx->solver_flags);
36+
+ actx->solver_flags & ~APK_SOLVERF_REINSTALL);
37+
}
38+
}
39+
if (actx->virtpkg) {
40+
@@ -185,7 +189,7 @@ static int add_main(void *ctx, struct ap
41+
apk_deps_add(&world, &virtdep);
42+
apk_solver_set_name_flags(virtdep.name,
43+
actx->solver_flags,
44+
- actx->solver_flags);
45+
+ actx->solver_flags & ~APK_SOLVERF_REINSTALL);
46+
}
47+
48+
r = apk_solver_commit(db, 0, world);

0 commit comments

Comments
 (0)