conflict: include owner for filesystem conflicts
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
This commit is contained in:
parent
16b91f798f
commit
6d1dcf7937
4 changed files with 45 additions and 7 deletions
|
@ -278,12 +278,15 @@ static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
|
||||||
|
|
||||||
STRDUP(conflict->target, pkg1->name, goto error);
|
STRDUP(conflict->target, pkg1->name, goto error);
|
||||||
STRDUP(conflict->file, filestr, goto error);
|
STRDUP(conflict->file, filestr, goto error);
|
||||||
if(pkg2) {
|
if(!pkg2) {
|
||||||
conflict->type = ALPM_FILECONFLICT_TARGET;
|
|
||||||
STRDUP(conflict->ctarget, pkg2->name, goto error);
|
|
||||||
} else {
|
|
||||||
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
|
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
|
||||||
STRDUP(conflict->ctarget, "", goto error);
|
STRDUP(conflict->ctarget, "", goto error);
|
||||||
|
} else if(pkg2->origin == ALPM_PKG_FROM_LOCALDB) {
|
||||||
|
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
|
||||||
|
STRDUP(conflict->ctarget, pkg2->name, goto error);
|
||||||
|
} else {
|
||||||
|
conflict->type = ALPM_FILECONFLICT_TARGET;
|
||||||
|
STRDUP(conflict->ctarget, pkg2->name, goto error);
|
||||||
}
|
}
|
||||||
|
|
||||||
conflicts = alpm_list_add(conflicts, conflict);
|
conflicts = alpm_list_add(conflicts, conflict);
|
||||||
|
@ -385,6 +388,17 @@ static alpm_list_t *alpm_db_find_file_owners(alpm_db_t* db, const char *path)
|
||||||
return owners;
|
return owners;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static alpm_pkg_t *_alpm_find_file_owner(alpm_handle_t *handle, const char *path)
|
||||||
|
{
|
||||||
|
alpm_list_t *i;
|
||||||
|
for(i = alpm_db_get_pkgcache(handle->db_local); i; i = i->next) {
|
||||||
|
if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) {
|
||||||
|
return i->data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path)
|
static int _alpm_can_overwrite_file(alpm_handle_t *handle, const char *path)
|
||||||
{
|
{
|
||||||
return handle->trans->flags & ALPM_TRANS_FLAG_FORCE
|
return handle->trans->flags & ALPM_TRANS_FLAG_FORCE
|
||||||
|
@ -668,7 +682,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!resolved_conflict) {
|
if(!resolved_conflict) {
|
||||||
conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
|
conflicts = add_fileconflict(handle, conflicts, path, p1,
|
||||||
|
_alpm_find_file_owner(handle, relative_path));
|
||||||
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
||||||
alpm_list_free_inner(conflicts,
|
alpm_list_free_inner(conflicts,
|
||||||
(alpm_list_fn_free) alpm_conflict_free);
|
(alpm_list_fn_free) alpm_conflict_free);
|
||||||
|
|
|
@ -823,8 +823,13 @@ int sync_prepare_execute(void)
|
||||||
conflict->file, conflict->target, conflict->ctarget);
|
conflict->file, conflict->target, conflict->ctarget);
|
||||||
break;
|
break;
|
||||||
case ALPM_FILECONFLICT_FILESYSTEM:
|
case ALPM_FILECONFLICT_FILESYSTEM:
|
||||||
printf(_("%s: %s exists in filesystem\n"),
|
if(conflict->ctarget[0]) {
|
||||||
conflict->target, conflict->file);
|
printf(_("%s: %s exists in filesystem (owned by %s)\n"),
|
||||||
|
conflict->target, conflict->file, conflict->ctarget);
|
||||||
|
} else {
|
||||||
|
printf(_("%s: %s exists in filesystem\n"),
|
||||||
|
conflict->target, conflict->file);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
alpm_fileconflict_free(conflict);
|
alpm_fileconflict_free(conflict);
|
||||||
|
|
|
@ -28,6 +28,7 @@ TESTS += test/pacman/tests/epoch005.py
|
||||||
TESTS += test/pacman/tests/epoch010.py
|
TESTS += test/pacman/tests/epoch010.py
|
||||||
TESTS += test/pacman/tests/epoch011.py
|
TESTS += test/pacman/tests/epoch011.py
|
||||||
TESTS += test/pacman/tests/epoch012.py
|
TESTS += test/pacman/tests/epoch012.py
|
||||||
|
TESTS += test/pacman/tests/file-conflict-with-installed-pkg.py
|
||||||
TESTS += test/pacman/tests/fileconflict001.py
|
TESTS += test/pacman/tests/fileconflict001.py
|
||||||
TESTS += test/pacman/tests/fileconflict002.py
|
TESTS += test/pacman/tests/fileconflict002.py
|
||||||
TESTS += test/pacman/tests/fileconflict003.py
|
TESTS += test/pacman/tests/fileconflict003.py
|
||||||
|
|
17
test/pacman/tests/file-conflict-with-installed-pkg.py
Normal file
17
test/pacman/tests/file-conflict-with-installed-pkg.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
self.description = "File conflict with an installed package"
|
||||||
|
|
||||||
|
lp = pmpkg("foobar")
|
||||||
|
lp.files = ["conflicting-file"]
|
||||||
|
self.addpkg2db("local", lp)
|
||||||
|
|
||||||
|
p1 = pmpkg("pkg1")
|
||||||
|
p1.files = ["conflicting-file"]
|
||||||
|
self.addpkg(p1)
|
||||||
|
|
||||||
|
self.args = "-U %s" % (p1.filename())
|
||||||
|
|
||||||
|
self.addrule("!PACMAN_RETCODE=0")
|
||||||
|
self.addrule("PKG_EXIST=foobar")
|
||||||
|
self.addrule("!PKG_EXIST=pkg1")
|
||||||
|
self.addrule("FILE_EXIST=conflicting-file")
|
||||||
|
self.addrule("PACMAN_OUTPUT=foobar")
|
Loading…
Add table
Reference in a new issue