summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2009-10-08 04:52:09 +0200
committerDan McGee <dan@archlinux.org>2010-03-24 04:24:14 +0100
commitcdbb90aceb288034dbf4f228fc4c49da1e2ed0c0 (patch)
tree4762094260856cb5ed34f72adbba8ae8eb90f513 /lib/libalpm/package.c
parentad4efa539de1e8e9e51baee82efeafde9fb24380 (diff)
downloadpacman-cdbb90aceb288034dbf4f228fc4c49da1e2ed0c0.tar.gz
pacman-cdbb90aceb288034dbf4f228fc4c49da1e2ed0c0.tar.xz
Show 'Required By' in -Sii output
Just as we do in -Qi, we can compute required by information for sync database packages. The behavior seems sane; for a given package, the -Sii required by will show all packages in *any* sync database that require it. Implements FS#16244. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 742d0f59..f1682cbc 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -555,6 +555,21 @@ int SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
return pkg->scriptlet;
}
+static void find_requiredby(pmpkg_t *pkg, pmdb_t *db, alpm_list_t **reqs)
+{
+ const alpm_list_t *i;
+ for(i = _alpm_db_get_pkgcache(db); i; i = i->next) {
+ if(!i->data) {
+ continue;
+ }
+ pmpkg_t *cachepkg = i->data;
+ if(_alpm_dep_edge(cachepkg, pkg)) {
+ const char *cachepkgname = cachepkg->name;
+ *reqs = alpm_list_add(*reqs, strdup(cachepkgname));
+ }
+ }
+}
+
/**
* @brief Compute the packages requiring a given package.
* @param pkg a package
@@ -564,16 +579,23 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
{
const alpm_list_t *i;
alpm_list_t *reqs = NULL;
+ pmdb_t *db;
- pmdb_t *localdb = alpm_option_get_localdb();
- for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
- if(!i->data) {
- continue;
- }
- pmpkg_t *cachepkg = i->data;
- if(_alpm_dep_edge(cachepkg, pkg)) {
- const char *cachepkgname = cachepkg->name;
- reqs = alpm_list_add(reqs, strdup(cachepkgname));
+ if(pkg->origin == PKG_FROM_FILE) {
+ /* The sane option; search locally for things that require this. */
+ db = alpm_option_get_localdb();
+ find_requiredby(pkg, db, &reqs);
+ } else {
+ /* We have a DB package. if it is a local package, then we should
+ * only search the local DB; else search all known sync databases. */
+ db = pkg->origin_data.db;
+ if(db->is_local) {
+ find_requiredby(pkg, db, &reqs);
+ } else {
+ for(i = handle->dbs_sync; i; i = i->next) {
+ db = i->data;
+ find_requiredby(pkg, db, &reqs);
+ }
}
}
return(reqs);