Date: Wednesday, February 21, 2007 @ 23:42:59 Author: aaron Path: /home/cvs-pacman/pacman-lib/lib/libalpm Modified: add.c (1.118 -> 1.119) be_files.c (1.29 -> 1.30) cache.c (1.32 -> 1.33) conflict.c (1.40 -> 1.41) package.c (1.73 -> 1.74) * Cleaned up some debug output * Fixed a segfault in the conflict checking code * Added an automatic failure in the case of -A/-U for a replacement of an existing package. This requires a large amount of work and is postponed for now. Example: If ncmpc is installed, pacman -U /path/to/ncmpc-svn.pkg.tar.gz will fail with and appropriate error message ------------+ add.c | 16 ++++++++++++---- be_files.c | 1 - cache.c | 10 ++++++++-- conflict.c | 28 +++++++++++++++++++--------- package.c | 4 ++-- 5 files changed, 41 insertions(+), 18 deletions(-) Index: pacman-lib/lib/libalpm/add.c diff -u pacman-lib/lib/libalpm/add.c:1.118 pacman-lib/lib/libalpm/add.c:1.119 --- pacman-lib/lib/libalpm/add.c:1.118 Tue Feb 20 03:44:32 2007 +++ pacman-lib/lib/libalpm/add.c Wed Feb 21 23:42:59 2007 @@ -216,11 +216,11 @@ /* This is still messy. We have a lot of compare functions, and we should * try to consolidate them as much as we can (between add and sync) */ -static int pkg_cmp(const void *p1, const void *p2) +/*static int deppkg_cmp(const void *p1, const void *p2) { return(strcmp(((pmdepmissing_t *)p1)->target, ((pmdepmissing_t *)p2)->target)); -} +}*/ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) { @@ -255,14 +255,20 @@ _alpm_log(PM_LOG_DEBUG, _("looking for conflicts")); lp = _alpm_checkconflicts(db, trans->packages); for(i = lp; i; i = i->next) { - int skip_this = 0; pmdepmissing_t *miss = i->data; + _alpm_log(PM_LOG_ERROR, _("replacing packages with -A and -U is not supported yet")); + _alpm_log(PM_LOG_ERROR, _("please remove '%s' first, using -Rd"), miss->depend.name); + RET_ERR(PM_ERR_CONFLICTING_DEPS, -1); + /* Attempt to resolve conflicts */ + /* + int skip_this = 0; QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this); if(skip_this) { pmdepmissing_t *pkg = NULL; - lp = alpm_list_remove(lp, (void *)miss, pkg_cmp, (void*)&pkg); + lp = alpm_list_remove(lp, (void *)miss, deppkg_cmp, (void*)&pkg); + */ /* TODO: We remove the conflict from the list but never actually remove * the package. Need to do this to fix FS #3492. The sync code should * provide an example of how to do this, as it handles replaces and @@ -271,11 +277,13 @@ * still not remove the original package designated here for removal. * Better yet, dump all this shitty duplicate code and somehow combine * it with the sync code. */ + /* FREE(pkg); if(lp == NULL) { break; } } + */ } /* Removal code should go here, as described above. Instead of simply * removing items, perhaps throw them in another list to be removed, then Index: pacman-lib/lib/libalpm/be_files.c diff -u pacman-lib/lib/libalpm/be_files.c:1.29 pacman-lib/lib/libalpm/be_files.c:1.30 --- pacman-lib/lib/libalpm/be_files.c:1.29 Wed Feb 21 03:34:36 2007 +++ pacman-lib/lib/libalpm/be_files.c Wed Feb 21 23:42:59 2007 @@ -189,7 +189,6 @@ } } - _alpm_log(PM_LOG_DEBUG, _("db scan found package: %s"), pkg->name); return(pkg); } Index: pacman-lib/lib/libalpm/cache.c diff -u pacman-lib/lib/libalpm/cache.c:1.32 pacman-lib/lib/libalpm/cache.c:1.33 --- pacman-lib/lib/libalpm/cache.c:1.32 Wed Feb 21 03:34:36 2007 +++ pacman-lib/lib/libalpm/cache.c Wed Feb 21 23:42:59 2007 @@ -61,7 +61,7 @@ _alpm_db_rewind(db); while((info = _alpm_db_scan(db, NULL, infolevel)) != NULL) { - _alpm_log(PM_LOG_DEBUG, _("adding '%s' to package cache for db '%s'"), info->name, db->treename); + _alpm_log(PM_LOG_FUNCTION, _("adding '%s' to package cache for db '%s'"), info->name, db->treename); info->origin = PKG_FROM_CACHE; info->data = db; /* add to the collection */ @@ -195,7 +195,13 @@ return(NULL); } - return(_alpm_pkg_isin(target, _alpm_db_get_pkgcache(db, INFRQ_NONE))); + alpm_list_t *pkgcache = _alpm_db_get_pkgcache(db, INFRQ_NONE); + if(!pkgcache) { + _alpm_log(PM_LOG_DEBUG, _("error: pkgcache is NULL for db '%s'"), db->treename); + return(NULL); + } + + return(_alpm_pkg_isin(target, pkgcache)); } /* Returns a new group cache from db. Index: pacman-lib/lib/libalpm/conflict.c diff -u pacman-lib/lib/libalpm/conflict.c:1.40 pacman-lib/lib/libalpm/conflict.c:1.41 --- pacman-lib/lib/libalpm/conflict.c:1.40 Wed Feb 21 01:44:14 2007 +++ pacman-lib/lib/libalpm/conflict.c Wed Feb 21 23:42:59 2007 @@ -329,12 +329,21 @@ } for(i = targets; i; i = i->next) { + pmsyncpkg_t *sync1, *sync2; pmpkg_t *p1, *p2, *dbpkg; char *filestr = NULL; char path[PATH_MAX+1]; struct stat buf; - p1 = (pmpkg_t*)i->data; + sync1 = i->data; + if(!sync1) { + continue; + } + p1 = sync1->pkg; + if(!p1) { + continue; + } + percent = (double)(alpm_list_count(targets) - alpm_list_count(i) + 1) / alpm_list_count(targets); PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), @@ -373,26 +382,25 @@ /* loop over each file to be installed */ for(j = tmpfiles; j; j = j->next) { filestr = j->data; - _alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s", filestr); snprintf(path, PATH_MAX, "%s%s", root, filestr); /* stat the file - if it exists and is not a dir, do some checks */ if(lstat(path, &buf) == 0 && !S_ISDIR(buf.st_mode)) { + _alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s, %s", filestr, path); /* Look at all the targets to see if file has changed hands */ for(k = targets; k; k = k->next) { - pmsyncpkg_t *sync = k->data; - if(!sync) { + sync2 = k->data; + if(!sync2) { continue; } - - p2 = sync->pkg; - - /* Ensure we aren't looking at current package */ - if(p2 == p1) { + p2 = sync2->pkg; + if(!p2 || p2 == p1) { continue; } + + _alpm_log(PM_LOG_DEBUG, _("get pkg %s from %s"), p2->name, db->treename); pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(db, p2->name); /* Check if it used to exist in a package, but doesn't anymore */ if(localp2 && !alpm_list_find_str(alpm_pkg_get_files(p2), filestr) @@ -417,6 +425,8 @@ break; } } + } else { + _alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict", filestr); } } alpm_list_free_inner(tmpfiles, &free); Index: pacman-lib/lib/libalpm/package.c diff -u pacman-lib/lib/libalpm/package.c:1.73 pacman-lib/lib/libalpm/package.c:1.74 --- pacman-lib/lib/libalpm/package.c:1.73 Wed Feb 21 03:34:37 2007 +++ pacman-lib/lib/libalpm/package.c Wed Feb 21 23:42:59 2007 @@ -467,8 +467,8 @@ for(lp = haystack; lp; lp = lp->next) { pmpkg_t *info = lp->data; - if(info && !strcmp(info->name, needle)) { - return(lp->data); + if(info && strcmp(info->name, needle) == 0) { + return(info); } } return(NULL);