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>
This commit is contained in:
parent
ad4efa539d
commit
cdbb90aceb
4 changed files with 44 additions and 20 deletions
|
@ -555,6 +555,21 @@ int SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
|
||||||
return pkg->scriptlet;
|
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.
|
* @brief Compute the packages requiring a given package.
|
||||||
* @param pkg a 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;
|
const alpm_list_t *i;
|
||||||
alpm_list_t *reqs = NULL;
|
alpm_list_t *reqs = NULL;
|
||||||
|
pmdb_t *db;
|
||||||
|
|
||||||
pmdb_t *localdb = alpm_option_get_localdb();
|
if(pkg->origin == PKG_FROM_FILE) {
|
||||||
for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
|
/* The sane option; search locally for things that require this. */
|
||||||
if(!i->data) {
|
db = alpm_option_get_localdb();
|
||||||
continue;
|
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);
|
||||||
}
|
}
|
||||||
pmpkg_t *cachepkg = i->data;
|
|
||||||
if(_alpm_dep_edge(cachepkg, pkg)) {
|
|
||||||
const char *cachepkgname = cachepkg->name;
|
|
||||||
reqs = alpm_list_add(reqs, strdup(cachepkgname));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(reqs);
|
return(reqs);
|
||||||
|
|
|
@ -38,7 +38,9 @@
|
||||||
|
|
||||||
/* Display the content of a package
|
/* Display the content of a package
|
||||||
*
|
*
|
||||||
* level: <0 - sync package [-Si]
|
* levels:
|
||||||
|
* <-1 - sync package, extra information (required by) [-Sii]
|
||||||
|
* -1 - sync package, normal level [-Si]
|
||||||
* =0 - file query [-Qip]
|
* =0 - file query [-Qip]
|
||||||
* 1 - localdb query, normal level [-Qi]
|
* 1 - localdb query, normal level [-Qi]
|
||||||
* >1 - localdb query, extra information (backup files) [-Qii]
|
* >1 - localdb query, extra information (backup files) [-Qii]
|
||||||
|
@ -83,7 +85,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||||
depstrings = alpm_list_add(depstrings, alpm_dep_compute_string(dep));
|
depstrings = alpm_list_add(depstrings, alpm_dep_compute_string(dep));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(level>0) {
|
if(level > 0 || level < -1) {
|
||||||
/* compute this here so we don't get a pause in the middle of output */
|
/* compute this here so we don't get a pause in the middle of output */
|
||||||
requiredby = alpm_pkg_compute_requiredby(pkg);
|
requiredby = alpm_pkg_compute_requiredby(pkg);
|
||||||
}
|
}
|
||||||
|
@ -97,10 +99,8 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||||
list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
|
||||||
list_display(_("Depends On :"), depstrings);
|
list_display(_("Depends On :"), depstrings);
|
||||||
list_display_linebreak(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
|
list_display_linebreak(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
|
||||||
/* Only applicable if installed */
|
if(level > 0 || level < -1) {
|
||||||
if(level > 0) {
|
|
||||||
list_display(_("Required By :"), requiredby);
|
list_display(_("Required By :"), requiredby);
|
||||||
FREELIST(requiredby);
|
|
||||||
}
|
}
|
||||||
list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
|
||||||
list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
|
list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
|
||||||
|
@ -142,17 +142,19 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
FREELIST(depstrings);
|
FREELIST(depstrings);
|
||||||
|
FREELIST(requiredby);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display the content of a sync package
|
/* Display the content of a sync package
|
||||||
*/
|
*/
|
||||||
void dump_pkg_sync(pmpkg_t *pkg, const char *treename)
|
void dump_pkg_sync(pmpkg_t *pkg, const char *treename, int level)
|
||||||
{
|
{
|
||||||
if(pkg == NULL) {
|
if(pkg == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string_display(_("Repository :"), treename);
|
string_display(_("Repository :"), treename);
|
||||||
dump_pkg_full(pkg, -1);
|
/* invert the level since we are a sync package */
|
||||||
|
dump_pkg_full(pkg, -level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display list of backup files and their modification states
|
/* Display list of backup files and their modification states
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <alpm.h>
|
#include <alpm.h>
|
||||||
|
|
||||||
void dump_pkg_full(pmpkg_t *pkg, int level);
|
void dump_pkg_full(pmpkg_t *pkg, int level);
|
||||||
void dump_pkg_sync(pmpkg_t *pkg, const char *treename);
|
void dump_pkg_sync(pmpkg_t *pkg, const char *treename, int level);
|
||||||
|
|
||||||
void dump_pkg_backups(pmpkg_t *pkg);
|
void dump_pkg_backups(pmpkg_t *pkg);
|
||||||
void dump_pkg_files(pmpkg_t *pkg, int quiet);
|
void dump_pkg_files(pmpkg_t *pkg, int quiet);
|
||||||
|
|
|
@ -453,7 +453,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
|
||||||
pmpkg_t *pkg = alpm_list_getdata(k);
|
pmpkg_t *pkg = alpm_list_getdata(k);
|
||||||
|
|
||||||
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
|
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
|
||||||
dump_pkg_sync(pkg, alpm_db_get_name(db));
|
dump_pkg_sync(pkg, alpm_db_get_name(db), config->op_s_info);
|
||||||
foundpkg = 1;
|
foundpkg = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +474,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
|
||||||
pmpkg_t *pkg = alpm_list_getdata(k);
|
pmpkg_t *pkg = alpm_list_getdata(k);
|
||||||
|
|
||||||
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
|
if(strcmp(alpm_pkg_get_name(pkg), pkgstr) == 0) {
|
||||||
dump_pkg_sync(pkg, alpm_db_get_name(db));
|
dump_pkg_sync(pkg, alpm_db_get_name(db), config->op_s_info);
|
||||||
foundpkg = 1;
|
foundpkg = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
|
||||||
pmdb_t *db = alpm_list_getdata(i);
|
pmdb_t *db = alpm_list_getdata(i);
|
||||||
|
|
||||||
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
|
for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
|
||||||
dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db));
|
dump_pkg_sync(alpm_list_getdata(j), alpm_db_get_name(db), config->op_s_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue