[PATCH] libopkg: preserve package flags on upgrade

Justin Klaassen justin at tidylabs.app
Tue Jun 13 08:46:27 PDT 2023


Previously the auto_installed flag was cleared and the user flag was
set whenever a package is upgraded. This prevented upgraded dependent
packages from being removed with e.g. --autoremove.

This patch preserves the auto_installed and user flags when a package
is upgraded enabling dependent packages to be identified as such after
upgrade.

Signed-off-by: Justin Klaassen <justin at tidylabs.app>
---
 libopkg/opkg_upgrade.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libopkg/opkg_upgrade.c b/libopkg/opkg_upgrade.c
index 2112674..b27faa4 100644
--- a/libopkg/opkg_upgrade.c
+++ b/libopkg/opkg_upgrade.c
@@ -74,7 +74,8 @@ int opkg_upgrade_pkg(pkg_t * old)

  free(old_version);
  free(new_version);
- new->state_flag |= SF_USER;
+ new->auto_installed = old->auto_installed;
+ new->state_flag |= old->state_flag & SF_USER;
  return opkg_install_pkg(new, 1);
 }



More information about the openwrt-devel mailing list