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:
parent
47711947dd
commit
0c62b36c19
1 changed files with 8 additions and 1 deletions
|
@ -36,6 +36,8 @@
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#define LOCAL_PREFIX "local/"
|
||||||
|
|
||||||
static char *resolve_path(const char *file)
|
static char *resolve_path(const char *file)
|
||||||
{
|
{
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
|
@ -268,7 +270,7 @@ static int query_search(alpm_list_t *targets)
|
||||||
alpm_pkg_t *pkg = i->data;
|
alpm_pkg_t *pkg = i->data;
|
||||||
|
|
||||||
if(!config->quiet) {
|
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 {
|
} else {
|
||||||
fputs(alpm_pkg_get_name(pkg), stdout);
|
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)) {
|
for(i = targets; i; i = alpm_list_next(i)) {
|
||||||
const char *strname = i->data;
|
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) {
|
if(config->op_q_isfile) {
|
||||||
alpm_pkg_load(config->handle, strname, 1, 0, &pkg);
|
alpm_pkg_load(config->handle, strname, 1, 0, &pkg);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue