diff options
author | Allan McRae <allan@archlinux.org> | 2012-05-19 23:36:30 +1000 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-06-25 23:43:36 -0500 |
commit | 0c62b36c19d67939d7a84159c86a5de73fd9d36f (patch) | |
tree | 32f7189c5c5f9240c06a1b65eb3714bb4d0a54ca | |
parent | 47711947ddf95032334fbe9dd912cbd8d146e174 (diff) | |
download | pacman-0c62b36c19d67939d7a84159c86a5de73fd9d36f.tar.xz |
Allow leading "local/" in query operations
I find that when copying the output of "pacman -Qs foo" into a
"pacman -Qi" operation to get more information on the packages, I
consistently copy the "local/" prefix. It is a minor usability
improvement to strip this if present.
Dan: Pluck out LOCAL_PREFIX and magic numbers.
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r-- | src/pacman/query.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c index 08974105..9b1ea6f1 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -36,6 +36,8 @@ #include "conf.h" #include "util.h" +#define LOCAL_PREFIX "local/" + static char *resolve_path(const char *file) { char *str = NULL; @@ -268,7 +270,7 @@ static int query_search(alpm_list_t *targets) alpm_pkg_t *pkg = i->data; if(!config->quiet) { - printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); + printf(LOCAL_PREFIX "%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg)); } else { fputs(alpm_pkg_get_name(pkg), stdout); } @@ -556,6 +558,11 @@ int pacman_query(alpm_list_t *targets) for(i = targets; i; i = alpm_list_next(i)) { const char *strname = i->data; + /* strip leading part of "local/pkgname" */ + if(strncmp(strname, LOCAL_PREFIX, strlen(LOCAL_PREFIX)) == 0) { + strname += strlen(LOCAL_PREFIX); + } + if(config->op_q_isfile) { alpm_pkg_load(config->handle, strname, 1, 0, &pkg); } else { |