mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
Add a horrible little hack to get symlink001.py to pass again
This really doesn't give us any regressions in behavior, so it is safe to do although quite ugly. Tell the conflict checking code to ignore symlinks to dirs so that they are not seen as conflicts. Hopefully this entire commit will get factored out soon enough. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
96f8faa666
commit
8236be9fd8
@ -274,6 +274,10 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO this whole function needs a huge change, which hopefully will
|
||||||
|
* be possible with real transactions. Right now we only do half as much
|
||||||
|
* here as we do when we actually extract files in add.c with our 12
|
||||||
|
* different cases. */
|
||||||
for(current = 1, i = targets; i; i = i->next, current++) {
|
for(current = 1, i = targets; i; i = i->next, current++) {
|
||||||
alpm_list_t *j, *k, *tmpfiles = NULL;
|
alpm_list_t *j, *k, *tmpfiles = NULL;
|
||||||
pmpkg_t *p1, *p2, *dbpkg;
|
pmpkg_t *p1, *p2, *dbpkg;
|
||||||
@ -309,7 +313,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* declarations for second check */
|
/* declarations for second check */
|
||||||
struct stat buf;
|
struct stat lsbuf, sbuf;
|
||||||
char *filestr = NULL;
|
char *filestr = NULL;
|
||||||
|
|
||||||
/* CHECK 2: check every target against the filesystem */
|
/* CHECK 2: check every target against the filesystem */
|
||||||
@ -334,23 +338,28 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
|
|||||||
snprintf(path, PATH_MAX, "%s%s", root, filestr);
|
snprintf(path, PATH_MAX, "%s%s", root, filestr);
|
||||||
|
|
||||||
/* stat the file - if it exists, do some checks */
|
/* stat the file - if it exists, do some checks */
|
||||||
if(_alpm_lstat(path, &buf) != 0) {
|
if(_alpm_lstat(path, &lsbuf) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(S_ISDIR(buf.st_mode)) {
|
stat(path, &sbuf);
|
||||||
|
|
||||||
|
if(S_ISDIR(lsbuf.st_mode)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
|
_alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict\n", path);
|
||||||
|
} else if(S_ISLNK(lsbuf.st_mode) && S_ISDIR(sbuf.st_mode)) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "%s is a symlink to a dir, hopefully not a conflict\n", path);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
|
_alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
|
||||||
|
|
||||||
/* Make sure the possible conflict is not a symlink that points to a
|
/* Make sure the possible conflict is not a symlink that points to a
|
||||||
* path in the old package. This is kind of dirty with inode usage */
|
* path in the old package. This is kind of dirty with inode usage */
|
||||||
|
/* TODO this seems ripe for a cleanup */
|
||||||
if(dbpkg) {
|
if(dbpkg) {
|
||||||
struct stat buf2;
|
struct stat pkgbuf;
|
||||||
char str[PATH_MAX+1];
|
char str[PATH_MAX+1];
|
||||||
unsigned ok = 0;
|
unsigned ok = 0;
|
||||||
for(k = dbpkg->files; k; k = k->next) {
|
for(k = dbpkg->files; k; k = k->next) {
|
||||||
snprintf(str, PATH_MAX, "%s%s", root, (char*)k->data);
|
snprintf(str, PATH_MAX, "%s%s", root, (char*)k->data);
|
||||||
if(!_alpm_lstat(str, &buf2) && buf.st_ino == buf2.st_ino) {
|
if(!_alpm_lstat(str, &pkgbuf) && lsbuf.st_ino == pkgbuf.st_ino) {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
_alpm_log(PM_LOG_DEBUG, "conflict was a symlink: %s\n", path);
|
_alpm_log(PM_LOG_DEBUG, "conflict was a symlink: %s\n", path);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user