diff options
author | Allan McRae <allan@archlinux.org> | 2015-06-20 09:26:22 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-07-15 02:57:31 +0200 |
commit | 3c410309644ecc4800a9aa6d96693a5630515701 (patch) | |
tree | a29ef5148245a9254323c4fd4c08c4337261aa41 /src | |
parent | fd9ff672b0010650297e645c4fd1bd1cc320e3ef (diff) | |
download | pacman-3c410309644ecc4800a9aa6d96693a5630515701.tar.gz pacman-3c410309644ecc4800a9aa6d96693a5630515701.tar.xz |
Handle repo/pkg style arguments to sync repo file listing
Passing "-Fl pkg" will print the filelist for the first occurance of "pkg"
in the sync repos. Other version of the package can be printed using
"-Fl repo/pkg".
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/files.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/pacman/files.c b/src/pacman/files.c index 5156e466..22509943 100644 --- a/src/pacman/files.c +++ b/src/pacman/files.c @@ -171,22 +171,45 @@ static int files_list(alpm_list_t *syncs, alpm_list_t *targets) { if(targets != NULL) { for(i = targets; i; i = alpm_list_next(i)) { - /* TODO: handle repo/pkg stype arguements */ char *targ = i->data; - + char *repo = NULL; + char *c = strchr(targ, '/'); + + if(c) { + if(! *(c + 1)) { + pm_printf(ALPM_LOG_ERROR, + _("invalid package: '%s'\n"), targ); + ret += 1; + continue; + } + + repo = strndup(targ, c - targ); + targ = c + 1; + } + for(j = syncs; j; j = alpm_list_next(j)) { alpm_pkg_t *pkg; alpm_db_t *db = j->data; + + if(repo) { + if(strcmp(alpm_db_get_name(db), repo) != 0) { + continue; + } + } + if((pkg = alpm_db_get_pkg(db, targ)) != NULL) { found = 1; dump_pkg_files(pkg, config->quiet); + break; } } if(!found) { + targ = i->data; pm_printf(ALPM_LOG_ERROR, _("package '%s' was not found\n"), targ); ret += 1; } + free(repo); } } else { for(i = syncs; i; i = alpm_list_next(i)) { |