remove dupes from group lists in sync
This commit is contained in:
parent
3929450d62
commit
958f7ee860
3 changed files with 36 additions and 7 deletions
|
@ -170,4 +170,26 @@ void PM_LIST_display(const char *title, PM_LIST *list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Filter out any duplicate strings in a PM_LIST
|
||||||
|
*
|
||||||
|
* Not the most efficient way, but simple to implement -- we assemble
|
||||||
|
* a new list, using is_in() to check for dupes at each iteration.
|
||||||
|
*
|
||||||
|
* This function takes a PM_LIST* and returns a list_t*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
list_t *PM_LIST_remove_dupes(PM_LIST *list)
|
||||||
|
{
|
||||||
|
PM_LIST *i;
|
||||||
|
list_t *newlist = NULL;
|
||||||
|
|
||||||
|
for(i = alpm_list_first(list); i; i = alpm_list_next(i)) {
|
||||||
|
char *data = alpm_list_getdata(i);
|
||||||
|
if(!list_is_strin(data, newlist)) {
|
||||||
|
newlist = list_add(newlist, strdup(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newlist;
|
||||||
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
|
|
@ -39,6 +39,7 @@ int list_is_strin(char *needle, list_t *haystack);
|
||||||
void list_display(const char *title, list_t *list);
|
void list_display(const char *title, list_t *list);
|
||||||
|
|
||||||
void PM_LIST_display(const char *title, PM_LIST *list);
|
void PM_LIST_display(const char *title, PM_LIST *list);
|
||||||
|
list_t *PM_LIST_remove_dupes(PM_LIST *list);
|
||||||
|
|
||||||
#endif /* _PM_LIST_H */
|
#endif /* _PM_LIST_H */
|
||||||
|
|
||||||
|
|
|
@ -474,22 +474,28 @@ int pacman_sync(list_t *targets)
|
||||||
sync_t *sync = j->data;
|
sync_t *sync = j->data;
|
||||||
grp = alpm_db_readgrp(sync->db, targ);
|
grp = alpm_db_readgrp(sync->db, targ);
|
||||||
if(grp) {
|
if(grp) {
|
||||||
PM_LIST *k, *pkgs;
|
PM_LIST *pmpkgs;
|
||||||
|
list_t *k, *pkgs;
|
||||||
MSG(NL, ":: group %s:\n", targ);
|
MSG(NL, ":: group %s:\n", targ);
|
||||||
pkgs = alpm_grp_getinfo(grp, PM_GRP_PKGNAMES);
|
pmpkgs = alpm_grp_getinfo(grp, PM_GRP_PKGNAMES);
|
||||||
PM_LIST_display(" ", pkgs);
|
/* remove dupe entries in case a package exists in multiple repos */
|
||||||
|
/* (the dupe function takes a PM_LIST* and returns a list_t*) */
|
||||||
|
pkgs = PM_LIST_remove_dupes(pmpkgs);
|
||||||
|
/* */
|
||||||
|
list_display(" ", pkgs);
|
||||||
if(yesno(":: Install whole content? [Y/n] ")) {
|
if(yesno(":: Install whole content? [Y/n] ")) {
|
||||||
for(k = alpm_list_first(pkgs); k; k = alpm_list_next(k)) {
|
for(k = pkgs; k; k = k->next) {
|
||||||
targets = list_add(targets, strdup(alpm_list_getdata(k)));
|
targets = list_add(targets, strdup(k->data));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(k = alpm_list_first(pkgs); k; k = alpm_list_next(k)) {
|
for(k = pkgs; k; k = k->next) {
|
||||||
char *pkgname = alpm_list_getdata(k);
|
char *pkgname = k->data;
|
||||||
if(yesno(":: Install %s from group %s? [Y/n] ", pkgname, targ)) {
|
if(yesno(":: Install %s from group %s? [Y/n] ", pkgname, targ)) {
|
||||||
targets = list_add(targets, strdup(pkgname));
|
targets = list_add(targets, strdup(pkgname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FREELIST(pkgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(grp == NULL) {
|
if(grp == NULL) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue