Skip to content

Commit

Permalink
pacman/libalpm: ignore file conflicts for foo.exe -> foo renames
Browse files Browse the repository at this point in the history
In case a file "foo.exe" gets renamed to "foo" the msys2 .exe
interpolation makes pacman think an untracker file is replaced.
In case foo and foo.exe are the same file and foo.exe existed
in the old package version we can be sure it's handled by the
old package and ignore the conflict.
  • Loading branch information
lazka committed Feb 28, 2023
1 parent 0d2090e commit a615c1c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/libalpm/conflict.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,32 @@ alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,

_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);

#ifdef __MSYS__
/* In case a file "foo.exe" gets renamed to "foo" the msys2 .exe
* interpolation makes pacman think an untracker file is replaced.
* In case foo and foo.exe are the same file and foo.exe existed
* in the old package version we can be sure it's handled by the
* old package and ignore the conflict */
if(dbpkg) {
char path_exe[PATH_MAX];
struct stat lsbuf2;

strncpy(path_exe, path, sizeof(path_exe) - 4);
strcat(path_exe, ".exe");
if(llstat(path, &lsbuf) == 0 && llstat(path_exe, &lsbuf2) == 0) {
int old_contains_exe = (alpm_filelist_contains(alpm_pkg_get_files(dbpkg), path_exe + rootlen) != NULL);
int same_file = (lsbuf.st_dev == lsbuf2.st_dev && lsbuf.st_ino == lsbuf2.st_ino);

if(same_file && old_contains_exe) {
_alpm_log(handle, ALPM_LOG_DEBUG,
"MSYS2 special case: Found %s which is the same file and included in the old package\n",
path_exe);
continue;
}
}
}
#endif

pfile_isdir = path[pathlen - 1] == '/';
if(pfile_isdir) {
if(S_ISDIR(lsbuf.st_mode)) {
Expand Down

0 comments on commit a615c1c

Please sign in to comment.