summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-02-15 19:22:15 -0500
committerAllan McRae <allan@archlinux.org>2013-02-24 13:11:54 +1000
commit083ac51816323d69fcf2e271ccd52add3cdd6d22 (patch)
tree868f31977c4229cdf5801cb4e725d2ea96818176
parent9995510dc81ab75fbb7ad7ca4fffedf8a5318bef (diff)
downloadpacman-083ac51816323d69fcf2e271ccd52add3cdd6d22.tar.xz
return resolved paths from filelist_difference
We were comparing files based on resolved paths but returning the original file_t structures, which were not necessarily in the same order. The extra file_t information was only being used to determine if the file was a directory which can be accomplished by testing for a trailing slash, so just return the resolved path. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/conflict.c36
-rw-r--r--lib/libalpm/filelist.c10
-rw-r--r--test/pacman/tests/fileconflict024.py2
-rw-r--r--test/pacman/tests/fileconflict025.py2
4 files changed, 18 insertions, 32 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 54e79fe3..ba642dde 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -426,9 +426,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
for(current = 0, i = upgrade; i; i = i->next, current++) {
alpm_pkg_t *p1 = i->data;
alpm_list_t *j;
- alpm_filelist_t tmpfiles;
+ alpm_list_t *tmpfiles = NULL;
alpm_pkg_t *dbpkg;
- size_t filenum;
int percent = (current * 100) / numtargs;
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", percent,
@@ -472,23 +471,21 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
* that the former list needs to be freed while the latter list should NOT
* be freed. */
if(dbpkg) {
- _alpm_filelist_resolve(handle, alpm_pkg_get_files(dbpkg));
- alpm_list_t *difference;
/* older ver of package currently installed */
- difference = _alpm_filelist_difference(alpm_pkg_get_files(p1),
+ _alpm_filelist_resolve(handle, alpm_pkg_get_files(dbpkg));
+ tmpfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
alpm_pkg_get_files(dbpkg));
- tmpfiles.count = alpm_list_count(difference);
- tmpfiles.files = alpm_list_to_array(difference, tmpfiles.count,
- sizeof(alpm_file_t));
- alpm_list_free(difference);
} else {
/* no version of package currently installed */
- tmpfiles = *alpm_pkg_get_files(p1);
+ alpm_filelist_t *fl = alpm_pkg_get_files(p1);
+ size_t filenum;
+ for(filenum = 0; filenum < fl->count; filenum++) {
+ tmpfiles = alpm_list_add(tmpfiles, fl->resolved_path[filenum]);
+ }
}
- for(filenum = 0; filenum < tmpfiles.count; filenum++) {
- alpm_file_t *file = tmpfiles.files + filenum;
- const char *filestr = file->name;
+ for(j = tmpfiles; j; j = j->next) {
+ const char *filestr = j->data;
const char *relative_path;
alpm_list_t *k;
/* have we acted on this conflict? */
@@ -506,7 +503,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
- if(S_ISDIR(file->mode)) {
+ if(filestr[strlen(filestr) - 1] == '/') {
struct stat sbuf;
if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
@@ -529,6 +526,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
/* Check remove list (will we remove the conflicting local file?) */
for(k = rem; k && !resolved_conflict; k = k->next) {
alpm_pkg_t *rempkg = k->data;
+ _alpm_filelist_resolve(handle, alpm_pkg_get_files(rempkg));
if(rempkg && alpm_filelist_contains(alpm_pkg_get_files(rempkg),
relative_path)) {
_alpm_log(handle, ALPM_LOG_DEBUG,
@@ -607,18 +605,12 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
if(handle->pm_errno == ALPM_ERR_MEMORY) {
FREELIST(conflicts);
- if(dbpkg) {
- /* only freed if it was generated from _alpm_filelist_difference() */
- free(tmpfiles.files);
- }
+ alpm_list_free(tmpfiles);
return NULL;
}
}
}
- if(dbpkg) {
- /* only freed if it was generated from _alpm_filelist_difference() */
- free(tmpfiles.files);
- }
+ alpm_list_free(tmpfiles);
}
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
numtargs, current);
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c
index 5c5f017b..b0dcee4e 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -229,14 +229,13 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
size_t ctrA = 0, ctrB = 0;
while(ctrA < filesA->count && ctrB < filesB->count) {
- alpm_file_t *fileA = filesA->files + ctrA;
- const char *strA = filesA->resolved_path[ctrA];
- const char *strB = filesB->resolved_path[ctrB];
+ char *strA = filesA->resolved_path[ctrA];
+ char *strB = filesB->resolved_path[ctrB];
int cmp = strcmp(strA, strB);
if(cmp < 0) {
/* item only in filesA, qualifies as a difference */
- ret = alpm_list_add(ret, fileA);
+ ret = alpm_list_add(ret, strA);
ctrA++;
} else if(cmp > 0) {
ctrB++;
@@ -248,8 +247,7 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
/* ensure we have completely emptied pA */
while(ctrA < filesA->count) {
- alpm_file_t *fileA = filesA->files + ctrA;
- ret = alpm_list_add(ret, fileA);
+ ret = alpm_list_add(ret, filesA->resolved_path[ctrA]);
ctrA++;
}
diff --git a/test/pacman/tests/fileconflict024.py b/test/pacman/tests/fileconflict024.py
index 1dcb5ade..17394db2 100644
--- a/test/pacman/tests/fileconflict024.py
+++ b/test/pacman/tests/fileconflict024.py
@@ -15,5 +15,3 @@ self.args = "-S %s" % sp1.name
self.addrule("PACMAN_RETCODE=1")
self.addrule("PKG_EXIST=foo|1-1")
-
-self.expectfailure = True
diff --git a/test/pacman/tests/fileconflict025.py b/test/pacman/tests/fileconflict025.py
index efd027e1..3c6f0638 100644
--- a/test/pacman/tests/fileconflict025.py
+++ b/test/pacman/tests/fileconflict025.py
@@ -16,5 +16,3 @@ self.args = "-S %s --ask=4" % sp1.name
self.addrule("PACMAN_RETCODE=0")
self.addrule("!PKG_EXIST=foo")
self.addrule("PKG_EXIST=bar")
-
-self.expectfailure = True