diff options
author | Aurelien Foret <aurelien@archlinux.org> | 2005-03-25 22:09:14 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2005-03-25 22:09:14 +0000 |
commit | 7c847fd7d4fee0fa5e0314f409eb06cfda2c289b (patch) | |
tree | 0e9d02aaf7284066f506fef81a758276ba466b56 /lib/libalpm/deps.c | |
parent | 6e63ccfd0fdd19b6d710eb8dc84c85aaf25c3006 (diff) | |
download | pacman-7c847fd7d4fee0fa5e0314f409eb06cfda2c289b.tar.xz |
Backport from pacman 2.9.5
- list_remove, list_check and list_reverse
- sortbydeps(mode)
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r-- | lib/libalpm/deps.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index eb9a983d..0e210b4e 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -35,17 +35,20 @@ /* Re-order a list of target packages with respect to their dependencies. * - * Example: + * Example (PM_TRANS_TYPE_ADD): * A depends on C * B depends on A * Target order is A,B,C,D * * Should be re-ordered to C,A,B,D * + * mode should be either PM_TRANS_TYPE_ADD or PM_TRANS_TYPE_REMOVE. This + * affects the dependency order sortbydeps() will use. + * * This function returns the new PMList* target list. * */ -PMList *sortbydeps(PMList *targets) +PMList *sortbydeps(PMList *targets, int mode) { PMList *newtargs = NULL; PMList *i, *j, *k; @@ -104,11 +107,22 @@ PMList *sortbydeps(PMList *targets) for(i = targets; i; i = i->next) { i->data = NULL; } - pm_list_free(targets); + FREELIST(targets); } targets = newtargs; clean = 1; } + if(mode == PM_TRANS_TYPE_REMOVE) { + /* we're removing packages, so reverse the order */ + newtargs = _alpm_list_reverse(targets); + /* free the old one */ + for(i = targets; i; i = i->next) { + i->data = NULL; + } + FREELIST(targets); + targets = newtargs; + } + return(targets); } |