diff mbox series

libopkg: preserve package flags on upgrade

Message ID CAK2wXtk4Sdu_QKq_vMZ9cecrN4FPVvGuFm3r-=v_8Y+3csZsUQ@mail.gmail.com
State New
Headers show
Series libopkg: preserve package flags on upgrade | expand

Commit Message

Justin Klaassen June 13, 2023, 3:46 p.m. UTC
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@tidylabs.app>
---
 libopkg/opkg_upgrade.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

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);
 }