diff options
author | Aaron Griffin <aaron@archlinux.org> | 2007-02-22 04:42:59 +0000 |
---|---|---|
committer | Aaron Griffin <aaron@archlinux.org> | 2007-02-22 04:42:59 +0000 |
commit | 871e123cf3fafe5aff734e2c5cf1ce89a203f719 (patch) | |
tree | 540028fd906e924bea504d4ff79d22eb43e5a43e /lib | |
parent | 3595201f5f3c1274786844c541ef82edba6984f8 (diff) |
* 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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/add.c | 16 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 1 | ||||
-rw-r--r-- | lib/libalpm/cache.c | 10 | ||||
-rw-r--r-- | lib/libalpm/conflict.c | 28 | ||||
-rw-r--r-- | lib/libalpm/package.c | 4 |
5 files changed, 41 insertions, 18 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index a2d79eb4..3fe77b19 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -216,11 +216,11 @@ error: /* 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 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) _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 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) * 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 diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index faa1f300..8830ea5c 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -189,7 +189,6 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, pmdbinfrq_t inforeq) } } - _alpm_log(PM_LOG_DEBUG, _("db scan found package: %s"), pkg->name); return(pkg); } diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c index 456c98bd..e3df2fd2 100644 --- a/lib/libalpm/cache.c +++ b/lib/libalpm/cache.c @@ -61,7 +61,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel) _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 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target) 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. diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 2846d9e8..4907793e 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -329,12 +329,21 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root) } 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 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root) /* 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 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root) break; } } + } else { + _alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict", filestr); } } alpm_list_free_inner(tmpfiles, &free); diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index d5738703..09161dba 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -467,8 +467,8 @@ pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack) 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); |