summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-11-11 11:30:16 -0600
committerDan McGee <dan@archlinux.org>2007-11-11 11:30:16 -0600
commit8236be9fd8f97ea8cb4999cf775768bdc276e53e (patch)
treedfd350e20b36e4b9b046f31a9e1935715e1d0061 /lib
parent96f8faa6664714943201d86393099dbf7464abc2 (diff)
downloadpacman-8236be9fd8f97ea8cb4999cf775768bdc276e53e.tar.xz
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>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/conflict.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 539e06ab..6de20768 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -274,6 +274,10 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root)
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++) {
alpm_list_t *j, *k, *tmpfiles = NULL;
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 */
- struct stat buf;
+ struct stat lsbuf, sbuf;
char *filestr = NULL;
/* 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);
/* stat the file - if it exists, do some checks */
- if(_alpm_lstat(path, &buf) != 0) {
+ if(_alpm_lstat(path, &lsbuf) != 0) {
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);
+ } 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 {
_alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s\n", path);
/* 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 */
+ /* TODO this seems ripe for a cleanup */
if(dbpkg) {
- struct stat buf2;
+ struct stat pkgbuf;
char str[PATH_MAX+1];
unsigned ok = 0;
for(k = dbpkg->files; k; k = k->next) {
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;
_alpm_log(PM_LOG_DEBUG, "conflict was a symlink: %s\n", path);
break;