summaryrefslogtreecommitdiff
path: root/src/pacman/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-07-29 15:35:59 -0500
committerDan McGee <dan@archlinux.org>2011-09-28 04:52:37 -0500
commit7edeb276b63efeea7e8f266dfee792e2709ba412 (patch)
tree2f4b52b2c12b564b99825c99ec9ad874d8ed945a /src/pacman/util.c
parentbd83c8e7562a2d6794d4322845c23cc21985979a (diff)
Keep track of explicitly added and removed packages
This allows us to sort the output list by showing all pulled dependencies first, followed by the explicitly specified targets. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 2c02d963..aa93357e 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -892,6 +892,10 @@ static int target_cmp(const void *p1, const void *p2)
{
const pm_target_t *targ1 = p1;
const pm_target_t *targ2 = p2;
+ /* explicit are always sorted after implicit (e.g. deps, pulled targets) */
+ if(targ1->is_explicit != targ2->is_explicit) {
+ return targ1->is_explicit > targ2->is_explicit;
+ }
const char *name1 = targ1->install ?
alpm_pkg_get_name(targ1->install) : alpm_pkg_get_name(targ1->remove);
const char *name2 = targ2->install ?
@@ -899,6 +903,14 @@ static int target_cmp(const void *p1, const void *p2)
return strcmp(name1, name2);
}
+static int pkg_cmp(const void *p1, const void *p2)
+{
+ /* explicit cast due to (un)necessary removal of const */
+ alpm_pkg_t *pkg1 = (alpm_pkg_t *)p1;
+ alpm_pkg_t *pkg2 = (alpm_pkg_t *)p2;
+ return strcmp(alpm_pkg_get_name(pkg1), alpm_pkg_get_name(pkg2));
+}
+
void display_targets(void)
{
alpm_list_t *i, *targets = NULL;
@@ -910,6 +922,9 @@ void display_targets(void)
if(!targ) return;
targ->install = pkg;
targ->remove = alpm_db_get_pkg(db_local, alpm_pkg_get_name(pkg));
+ if(alpm_list_find(config->explicit_adds, pkg, pkg_cmp)) {
+ targ->is_explicit = 1;
+ }
targets = alpm_list_add(targets, targ);
}
for(i = alpm_trans_get_remove(config->handle); i; i = alpm_list_next(i)) {
@@ -917,6 +932,9 @@ void display_targets(void)
pm_target_t *targ = calloc(1, sizeof(pm_target_t));
if(!targ) return;
targ->remove = pkg;
+ if(alpm_list_find(config->explicit_removes, pkg, pkg_cmp)) {
+ targ->is_explicit = 1;
+ }
targets = alpm_list_add(targets, targ);
}