This implements FS#14208 -Spq will print package name and version -Spqq will print package name Signed-off-by: Xavier Chantry <shiningxc@gmail.com> --- doc/pacman.8.txt | 4 +++- src/pacman/pacman.c | 2 +- src/pacman/sync.c | 21 ++++++++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index ccff167..420e799 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -311,7 +311,9 @@ linkman:pacman.conf[5]. pacman's output is processed in a script.) Search will only show package names and not repo, version, group, and description information; list will only show package names and omit databases and versions; group will - only show package names and omit group names. + only show package names and omit group names; '\--print-uris' will only + show package names and package versions, and only package names if '-q' is used + twice. *-s, \--search* <'regexp'>:: This will search each package in the sync databases for names or diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 48d45ad..c1b1c2e 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -490,7 +490,7 @@ static int parseargs(int argc, char *argv[]) config->flags |= PM_TRANS_FLAG_NOLOCK; break; case 'q': - config->quiet = 1; + config->quiet++; break; case 'r': config->rootdir = strdup(optarg); diff --git a/src/pacman/sync.c b/src/pacman/sync.c index cb0b8b1..1c3ba32 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -676,14 +676,21 @@ static int sync_trans(alpm_list_t *targets) alpm_list_t *i; for(i = packages; i; i = alpm_list_next(i)) { pmpkg_t *pkg = alpm_list_getdata(i); - pmdb_t *db = alpm_pkg_get_db(pkg); - const char *dburl = alpm_db_get_url(db); - if(dburl) { - printf("%s/%s\n", dburl, alpm_pkg_get_filename(pkg)); + const char *pkgname = alpm_pkg_get_name(pkg); + if(!config->quiet) { + pmdb_t *db = alpm_pkg_get_db(pkg); + const char *dburl = alpm_db_get_url(db); + if(dburl) { + printf("%s/%s\n", dburl, alpm_pkg_get_filename(pkg)); + } else { + /* can't use WARNING here, we don't show warnings in -Sp... */ + pm_fprintf(stderr, PM_LOG_ERROR, _("no database for package: %s\n"), + pkgname); + } + } else if(config->quiet == 1) { + printf("%s %s\n", pkgname, alpm_pkg_get_version(pkg)); } else { - /* can't use WARNING here, we don't show warnings in -Sp... */ - pm_fprintf(stderr, PM_LOG_ERROR, _("no database for package: %s\n"), - alpm_pkg_get_name(pkg)); + printf("%s\n", pkgname); } } -- 1.6.3.3