summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/add.c5
-rw-r--r--src/pacman/query.c15
-rw-r--r--src/pacman/remove.c4
-rw-r--r--src/pacman/sync.c2
-rw-r--r--src/pacman/util.c28
-rw-r--r--src/pacman/util.h1
6 files changed, 46 insertions, 9 deletions
diff --git a/src/pacman/add.c b/src/pacman/add.c
index 975d26be..debe5c47 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -115,8 +115,9 @@ int pacman_add(alpm_list_t *targets)
for(i = targets; i; i = alpm_list_next(i)) {
char *targ = alpm_list_getdata(i);
if(alpm_trans_addtarget(targ) == -1) {
- fprintf(stderr, _("error: failed to add target '%s' (%s)"), targ,
- alpm_strerrorlast());
+ printf("failed.\n");
+ fprintf(stderr, _("error: '%s': %s\n"),
+ targ, alpm_strerrorlast());
add_cleanup();
return(1);
}
diff --git a/src/pacman/query.c b/src/pacman/query.c
index fd2f7927..e999a328 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -70,6 +70,7 @@ static int query_fileowner(alpm_list_t *targets)
int found = 0;
char *filename = alpm_list_getdata(t);
char *bname;
+ char *dname;
char *rpath;
struct stat buf;
alpm_list_t *i, *j;
@@ -88,10 +89,14 @@ static int query_fileowner(alpm_list_t *targets)
}
bname = mbasename(filename);
+ dname = mdirname(filename);
+ rpath = resolve_path(dname);
+ free(dname);
- if(!(rpath = resolve_path(filename))) {
+ if(!rpath) {
fprintf(stderr, _("error: cannot determine real path for '%s': %s\n"),
filename, strerror(errno));
+ free(rpath);
ret++;
continue;
}
@@ -100,7 +105,7 @@ static int query_fileowner(alpm_list_t *targets)
pmpkg_t *info = alpm_list_getdata(i);
for(j = alpm_pkg_get_files(info); j && !found; j = alpm_list_next(j)) {
- char path[PATH_MAX], *ppath;
+ char path[PATH_MAX], *ppath, *pdname;
snprintf(path, PATH_MAX, "%s%s",
alpm_option_get_root(), (const char *)alpm_list_getdata(j));
@@ -109,10 +114,12 @@ static int query_fileowner(alpm_list_t *targets)
continue;
}
- ppath = resolve_path(path);
+ pdname = mdirname(path);
+ ppath = resolve_path(pdname);
+ free(pdname);
if(ppath && strcmp(ppath, rpath) == 0) {
- printf(_("%s is owned by %s %s\n"), rpath,
+ printf(_("%s is owned by %s %s\n"), filename,
alpm_pkg_get_name(info), alpm_pkg_get_version(info));
found = 1;
}
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 56837fa2..0722057f 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -108,8 +108,8 @@ int pacman_remove(alpm_list_t *targets)
char *targ = alpm_list_getdata(i);
if(alpm_trans_addtarget(targ) == -1) {
printf("failed.\n");
- fprintf(stderr, _("error: failed to add target '%s' (%s)\n"), targ,
- alpm_strerrorlast());
+ fprintf(stderr, _("error: '%s': %s\n"),
+ targ, alpm_strerrorlast());
remove_cleanup();
FREELIST(finaltargs);
return(1);
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 582192a4..27218d61 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -568,7 +568,7 @@ static int sync_trans(alpm_list_t *targets, int sync_only)
}
if(pm_errno != PM_ERR_PKG_NOT_FOUND) {
fprintf(stderr, _("error: '%s': %s\n"),
- (char *)i->data, alpm_strerrorlast());
+ targ, alpm_strerrorlast());
retval = 1;
goto cleanup;
}
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 42b0c98d..2dae832f 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -187,6 +187,34 @@ char *mbasename(const char *path)
return (char *)p;
}
+/** Parse the dirname of a program from a path.
+* The path returned should be freed.
+* @param path path to parse dirname from
+*
+* @return everything preceding the final '/'
+*/
+char *mdirname(const char *path)
+{
+ char *ret, *last;
+
+ /* null or empty path */
+ if(path == NULL || path == '\0') {
+ return(strdup("."));
+ }
+
+ ret = strdup(path);
+ last = strrchr(ret, '/');
+
+ if(last != NULL) {
+ /* we found a '/', so terminate our string */
+ *last = '\0';
+ return(ret);
+ }
+ /* no slash found */
+ free(ret);
+ return(strdup("."));
+}
+
/* output a string, but wrap words properly with a specified indentation
*/
void indentprint(const char *str, int indent)
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 00c88949..0273512e 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -41,6 +41,7 @@ int getcols();
int makepath(const char *path);
int rmrf(const char *path);
char *mbasename(const char *path);
+char *mdirname(const char *path);
void indentprint(const char *str, int indent);
char *strtoupper(char *str);
char *strtrim(char *str);