1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-05 00:55:04 -05:00

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>
This commit is contained in:
Allan McRae 2012-05-19 23:36:30 +10:00 committed by Dan McGee
parent 47711947dd
commit 0c62b36c19

View File

@ -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 {