summaryrefslogtreecommitdiff
path: root/lib/libalpm/remove.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2012-08-11 16:07:44 +1000
committerAllan McRae <allan@archlinux.org>2012-12-14 12:35:34 +1000
commiteb9e74ecc7b7aa489de07bc52bb6d5220943154e (patch)
treeb74c8fece6520bf75e6095ef6dd745632f93dc35 /lib/libalpm/remove.c
parent0c2edbdd4992f3107d7a2bd600829fcb3f344d48 (diff)
downloadpacman-eb9e74ecc7b7aa489de07bc52bb6d5220943154e.tar.xz
Notify of removed package required as optdepend
When a package is being removed, provide a notification (via a callback) if any local package requires it as an optdepend. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/remove.c')
-rw-r--r--lib/libalpm/remove.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index f189e30d..0a4a5f97 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -158,6 +158,32 @@ static void remove_prepare_keep_needed(alpm_handle_t *handle, alpm_list_t *lp)
}
/**
+ * @brief Send a callback for any optdepend being removed.
+ *
+ * @param handle the context handle
+ * @param lp list of packages to be removed
+ */
+static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t *lp)
+{
+ alpm_list_t *i;
+
+ for(i = _alpm_db_get_pkgcache(handle->db_local); i; i = alpm_list_next(i)) {
+ alpm_pkg_t *pkg = i->data;
+ alpm_list_t *optdeps = alpm_pkg_get_optdepends(pkg);
+
+ if(optdeps && !_alpm_pkg_find(lp, pkg->name)) {
+ alpm_list_t *j;
+ for(j = optdeps; j; j = alpm_list_next(j)) {
+ alpm_depend_t *optdep = j->data;
+ if(_alpm_pkg_find(lp, optdep->name)) {
+ EVENT(handle, ALPM_EVENT_OPTDEP_REQUIRED, pkg, optdep);
+ }
+ }
+ }
+ }
+}
+
+/**
* @brief Transaction preparation for remove actions.
*
* This functions takes a pointer to a alpm_list_t which will be
@@ -228,6 +254,9 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
}
}
+ /* Note packages being removed that are optdepends for installed packages */
+ remove_notify_needed_optdepends(handle, trans->remove);
+
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
EVENT(handle, ALPM_EVENT_CHECKDEPS_DONE, NULL, NULL);
}