This applies to a case such as when /lib is a symlink to /usr/lib. If a
package is installed which contains /lib/libfoo.so, pacman will complain
if this package is then "fixed" to contain /usr/lib/libfoo.so. Since
these have the same effective path and it exists within the same
package, ignore the conflict.

Fixes FS#30681.

Pactest-by: Dave Reisner <[email protected]>
Signed-off-by: Allan McRae <[email protected]>
---
 lib/libalpm/conflict.c               | 23 ++++++++++++++++-------
 test/pacman/tests/fileconflict013.py | 20 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 7 deletions(-)
 create mode 100644 test/pacman/tests/fileconflict013.py

diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index faee7bd..7f867b4 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -639,6 +639,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t 
*handle,
                alpm_list_t *j;
                alpm_filelist_t tmpfiles;
                alpm_pkg_t *dbpkg;
+               alpm_filelist_t *dbpkg_filelist;
                size_t filenum;
 
                alpm_filelist_t *p1_filelist = resolved_filelist(handle, 
alpm_pkg_get_files(p1));
@@ -682,10 +683,6 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t 
*handle,
                        }
                }
 
-               if(p1_filelist != alpm_pkg_get_files(p1)) {
-                       free_filelist(p1_filelist);
-               }
-
                /* CHECK 2: check every target against the filesystem */
                _alpm_log(handle, ALPM_LOG_DEBUG, "searching for filesystem 
conflicts: %s\n",
                                p1->name);
@@ -698,16 +695,16 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t 
*handle,
                 * be freed. */
                if(dbpkg) {
                        alpm_list_t *difference;
+                       dbpkg_filelist = resolved_filelist(handle, 
alpm_pkg_get_files(dbpkg));
                        /* older ver of package currently installed */
-                       difference = filelist_difference(alpm_pkg_get_files(p1),
-                                       alpm_pkg_get_files(dbpkg));
+                       difference = filelist_difference(p1_filelist, 
dbpkg_filelist);
                        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);
+                       tmpfiles = *p1_filelist;
                }
 
                for(filenum = 0; filenum < tmpfiles.count; filenum++) {
@@ -834,6 +831,12 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t 
*handle,
                                        if(dbpkg) {
                                                /* only freed if it was 
generated from filelist_difference() */
                                                free(tmpfiles.files);
+                                               if(dbpkg_filelist != 
alpm_pkg_get_files(dbpkg)) {
+                                                       
free_filelist(dbpkg_filelist);
+                                               }
+                                       }
+                                       if(p1_filelist != 
alpm_pkg_get_files(p1)) {
+                                               free_filelist(p1_filelist);
                                        }
                                        return NULL;
                                }
@@ -842,6 +845,12 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t 
*handle,
                if(dbpkg) {
                        /* only freed if it was generated from 
filelist_difference() */
                        free(tmpfiles.files);
+                       if(dbpkg_filelist != alpm_pkg_get_files(dbpkg)) {
+                               free_filelist(dbpkg_filelist);
+                       }
+               }
+               if(p1_filelist != alpm_pkg_get_files(p1)) {
+                       free_filelist(p1_filelist);
                }
        }
        PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
diff --git a/test/pacman/tests/fileconflict013.py 
b/test/pacman/tests/fileconflict013.py
new file mode 100644
index 0000000..a83923c
--- /dev/null
+++ b/test/pacman/tests/fileconflict013.py
@@ -0,0 +1,20 @@
+self.description = "file->file path change with same effective path (/lib as 
symlink)"
+
+lp1 = pmpkg("filesystem", "1.0-1")
+lp1.files = ["usr/",
+             "usr/lib/",
+             "lib -> usr/lib/"]
+self.addpkg2db("local", lp1)
+
+lp2 = pmpkg("pkg1", "1.0-1")
+lp2.files = ["lib/libfoo.so"]
+self.addpkg2db("local", lp2)
+
+sp1 = pmpkg("pkg1", "1.0-2")
+sp1.files = ["usr/lib/libfoo.so"]
+self.addpkg2db("sync", sp1)
+
+self.args = "-Su"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=pkg1|1.0-2")
-- 
1.7.11.2


Reply via email to