Merge branch 'maint'

Conflicts:
	lib/libalpm/conflict.c
This commit is contained in:
Dan McGee 2011-06-27 09:33:27 -05:00
commit 77a09c92c6
2 changed files with 43 additions and 13 deletions

View file

@ -275,10 +275,10 @@ static alpm_list_t *filelist_operation(alpm_list_t *filesA, alpm_list_t *filesB,
return ret; return ret;
} }
/* Adds pmfileconflict_t to a conflicts list. Pass the conflicts list, type (either /* Adds pmfileconflict_t to a conflicts list. Pass the conflicts list, type
* PM_FILECONFLICT_TARGET or PM_FILECONFLICT_FILESYSTEM), a file string, and either * (either PM_FILECONFLICT_TARGET or PM_FILECONFLICT_FILESYSTEM), a file
* two package names or one package name and NULL. This is a wrapper for former * string, and either two package names or one package name and NULL. This is
* functionality that was done inline. * a wrapper for former functionality that was done inline.
*/ */
static alpm_list_t *add_fileconflict(pmhandle_t *handle, static alpm_list_t *add_fileconflict(pmhandle_t *handle,
alpm_list_t *conflicts, pmfileconflicttype_t type, const char *filestr, alpm_list_t *conflicts, pmfileconflicttype_t type, const char *filestr,
@ -440,7 +440,9 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
for(j = tmpfiles; j; j = j->next) { for(j = tmpfiles; j; j = j->next) {
struct stat lsbuf; struct stat lsbuf;
const char *filestr = j->data; const char *filestr = j->data, *relative_path;
/* have we acted on this conflict? */
int resolved_conflict = 0;
snprintf(path, PATH_MAX, "%s%s", handle->root, filestr); snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
@ -449,7 +451,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
continue; continue;
} }
if(path[strlen(path)-1] == '/') { if(path[strlen(path) - 1] == '/') {
struct stat sbuf; struct stat sbuf;
if(S_ISDIR(lsbuf.st_mode)) { if(S_ISDIR(lsbuf.st_mode)) {
_alpm_log(handle, PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path); _alpm_log(handle, PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
@ -461,17 +463,22 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
"%s is a symlink to a dir, hopefully not a conflict\n", path); "%s is a symlink to a dir, hopefully not a conflict\n", path);
continue; continue;
} }
/* if we made it to here, we want all subsequent path comparisons to
* not include the trailing slash. This allows things like file ->
* directory replacements. */
path[strlen(path) - 1] = '\0';
} }
_alpm_log(handle, PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
int resolved_conflict = 0; /* have we acted on this conflict? */ _alpm_log(handle, PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
relative_path = path + strlen(handle->root);
/* Check remove list (will we remove the conflicting local file?) */ /* Check remove list (will we remove the conflicting local file?) */
for(k = remove; k && !resolved_conflict; k = k->next) { for(k = remove; k && !resolved_conflict; k = k->next) {
pmpkg_t *rempkg = k->data; pmpkg_t *rempkg = k->data;
if(rempkg && alpm_list_find_str(alpm_pkg_get_files(rempkg), filestr)) { if(alpm_list_find_str(alpm_pkg_get_files(rempkg), relative_path)) {
_alpm_log(handle, PM_LOG_DEBUG, _alpm_log(handle, PM_LOG_DEBUG,
"local file will be removed, not a conflict: %s\n", filestr); "local file will be removed, not a conflict: %s\n",
relative_path);
resolved_conflict = 1; resolved_conflict = 1;
} }
} }
@ -492,7 +499,8 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
handle->trans->skip_remove = handle->trans->skip_remove =
alpm_list_add(handle->trans->skip_remove, strdup(filestr)); alpm_list_add(handle->trans->skip_remove, strdup(filestr));
_alpm_log(handle, PM_LOG_DEBUG, _alpm_log(handle, PM_LOG_DEBUG,
"file changed packages, adding to remove skiplist: %s\n", filestr); "file changed packages, adding to remove skiplist: %s\n",
filestr);
resolved_conflict = 1; resolved_conflict = 1;
} }
} }
@ -512,12 +520,13 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
if(!resolved_conflict && dbpkg) { if(!resolved_conflict && dbpkg) {
char *rpath = calloc(PATH_MAX, sizeof(char)); char *rpath = calloc(PATH_MAX, sizeof(char));
const char *relative_rpath;
if(!realpath(path, rpath)) { if(!realpath(path, rpath)) {
free(rpath); free(rpath);
continue; continue;
} }
char *filestr = rpath + strlen(handle->root); relative_rpath = rpath + strlen(handle->root);
if(alpm_list_find_str(alpm_pkg_get_files(dbpkg), filestr)) { if(alpm_list_find_str(alpm_pkg_get_files(dbpkg), relative_rpath)) {
resolved_conflict = 1; resolved_conflict = 1;
} }
free(rpath); free(rpath);

View file

@ -0,0 +1,21 @@
self.description = "Fileconflict file -> dir on package replacement (FS#24904)"
lp = pmpkg("dummy")
lp.files = ["dir/filepath",
"dir/file"]
self.addpkg2db("local", lp)
p1 = pmpkg("replace")
p1.provides = ["dummy"]
p1.replaces = ["dummy"]
p1.files = ["dir/filepath/",
"dir/filepath/file",
"dir/file",
"dir/file2"]
self.addpkg2db("sync", p1)
self.args = "-Su"
self.addrule("PACMAN_RETCODE=0")
self.addrule("!PKG_EXIST=dummy")
self.addrule("PKG_EXIST=replace")