summaryrefslogtreecommitdiff
path: root/src/pacman/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-04-26 14:27:13 -0400
committerDan McGee <dan@archlinux.org>2007-04-26 14:27:13 -0400
commitda3286a80d10ea3896ae09e9e753dc4f19fa3bf6 (patch)
tree5f97e590636c2b9edffd138e8b5d960379fdcff5 /src/pacman/sync.c
parent085e5898aef2c318e92af440504e12377ba23887 (diff)
Allow sync search to work without arguments
Enable an -Ss operation to work without a target list. This allows all package information to be printed (as opposed to individual -Sl operations on repositories). Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r--src/pacman/sync.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index fa781c10..e8399625 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -235,41 +235,45 @@ static int sync_synctree(int level, alpm_list_t *syncs)
static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
{
alpm_list_t *i, *j, *ret;
+ int freelist;
for(i = syncs; i; i = alpm_list_next(i)) {
- pmdb_t *db = (pmdb_t *)alpm_list_getdata(i);
+ pmdb_t *db = alpm_list_getdata(i);
+ /* if we have a targets list, search for packages matching it */
if(targets) {
ret = alpm_db_search(db, targets);
- if(ret == NULL) {
- continue;
- }
- for(j = ret; j; j = alpm_list_next(j)) {
- char *group = NULL;
- alpm_list_t *grp;
- pmpkg_t *pkg = alpm_list_getdata(j);
+ freelist = 1;
+ } else {
+ ret = alpm_db_getpkgcache(db);
+ freelist = 0;
+ }
+ if(ret == NULL) {
+ continue;
+ }
+ for(j = ret; j; j = alpm_list_next(j)) {
+ /* print repo/name (group) info about each package in our list */
+ char *group = NULL;
+ alpm_list_t *grp;
+ pmpkg_t *pkg = alpm_list_getdata(j);
- printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
- alpm_pkg_get_version(pkg));
+ printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
+ alpm_pkg_get_version(pkg));
- if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
- group = alpm_list_getdata(grp);
- printf(" (%s)\n ", (char *)alpm_list_getdata(grp));
- } else {
- printf("\n ");
- }
-
- indentprint(alpm_pkg_get_desc(pkg), 4);
+ if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
+ group = alpm_list_getdata(grp);
+ printf(" (%s)\n", (char *)alpm_list_getdata(grp));
+ } else {
printf("\n");
}
- alpm_list_free(ret);
- } else {
- for(j = alpm_db_getpkgcache(db); j; j = alpm_list_next(j)) {
- pmpkg_t *pkg = alpm_list_getdata(j);
- MSG(NL, "%s/%s %s\n ", alpm_db_get_name(db), alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- indentprint(alpm_pkg_get_desc(pkg), 4);
- MSG(NL, "\n");
- }
+ /* we need an initial indent first */
+ printf(" ");
+ indentprint(alpm_pkg_get_desc(pkg), 4);
+ printf("\n");
+ }
+ /* we only want to free if the list was a search list */
+ if(freelist) {
+ alpm_list_free(ret);
}
}