* 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
This commit is contained in:
Aaron Griffin 2007-02-22 04:42:59 +00:00
parent 3595201f5f
commit 871e123cf3
5 changed files with 42 additions and 19 deletions

View file

@ -216,11 +216,11 @@ error:
/* This is still messy. We have a lot of compare functions, and we should /* 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) */ * 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, return(strcmp(((pmdepmissing_t *)p1)->target,
((pmdepmissing_t *)p2)->target)); ((pmdepmissing_t *)p2)->target));
} }*/
int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) 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")); _alpm_log(PM_LOG_DEBUG, _("looking for conflicts"));
lp = _alpm_checkconflicts(db, trans->packages); lp = _alpm_checkconflicts(db, trans->packages);
for(i = lp; i; i = i->next) { for(i = lp; i; i = i->next) {
int skip_this = 0;
pmdepmissing_t *miss = i->data; 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 */ /* Attempt to resolve conflicts */
/*
int skip_this = 0;
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this); QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this);
if(skip_this) { if(skip_this) {
pmdepmissing_t *pkg = NULL; 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 /* 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 * 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 * 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. * still not remove the original package designated here for removal.
* Better yet, dump all this shitty duplicate code and somehow combine * Better yet, dump all this shitty duplicate code and somehow combine
* it with the sync code. */ * it with the sync code. */
/*
FREE(pkg); FREE(pkg);
if(lp == NULL) { if(lp == NULL) {
break; break;
} }
} }
*/
} }
/* Removal code should go here, as described above. Instead of simply /* Removal code should go here, as described above. Instead of simply
* removing items, perhaps throw them in another list to be removed, then * removing items, perhaps throw them in another list to be removed, then

View file

@ -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); return(pkg);
} }

View file

@ -61,7 +61,7 @@ int _alpm_db_load_pkgcache(pmdb_t *db, pmdbinfrq_t infolevel)
_alpm_db_rewind(db); _alpm_db_rewind(db);
while((info = _alpm_db_scan(db, NULL, infolevel)) != NULL) { 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->origin = PKG_FROM_CACHE;
info->data = db; info->data = db;
/* add to the collection */ /* add to the collection */
@ -195,7 +195,13 @@ pmpkg_t *_alpm_db_get_pkgfromcache(pmdb_t *db, char *target)
return(NULL); 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. /* Returns a new group cache from db.

View file

@ -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) { for(i = targets; i; i = i->next) {
pmsyncpkg_t *sync1, *sync2;
pmpkg_t *p1, *p2, *dbpkg; pmpkg_t *p1, *p2, *dbpkg;
char *filestr = NULL; char *filestr = NULL;
char path[PATH_MAX+1]; char path[PATH_MAX+1];
struct stat buf; 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) percent = (double)(alpm_list_count(targets) - alpm_list_count(i) + 1)
/ alpm_list_count(targets); / alpm_list_count(targets);
PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), 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 */ /* loop over each file to be installed */
for(j = tmpfiles; j; j = j->next) { for(j = tmpfiles; j; j = j->next) {
filestr = j->data; filestr = j->data;
_alpm_log(PM_LOG_DEBUG, "checking possible conflict: %s", filestr);
snprintf(path, PATH_MAX, "%s%s", root, filestr); snprintf(path, PATH_MAX, "%s%s", root, filestr);
/* stat the file - if it exists and is not a dir, do some checks */ /* stat the file - if it exists and is not a dir, do some checks */
if(lstat(path, &buf) == 0 && !S_ISDIR(buf.st_mode)) { 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 */ /* Look at all the targets to see if file has changed hands */
for(k = targets; k; k = k->next) { for(k = targets; k; k = k->next) {
pmsyncpkg_t *sync = k->data; sync2 = k->data;
if(!sync) { if(!sync2) {
continue;
}
p2 = sync2->pkg;
if(!p2 || p2 == p1) {
continue; continue;
} }
p2 = sync->pkg; _alpm_log(PM_LOG_DEBUG, _("get pkg %s from %s"), p2->name, db->treename);
/* Ensure we aren't looking at current package */
if(p2 == p1) {
continue;
}
pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(db, p2->name); pmpkg_t *localp2 = _alpm_db_get_pkgfromcache(db, p2->name);
/* Check if it used to exist in a package, but doesn't anymore */ /* 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) 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; break;
} }
} }
} else {
_alpm_log(PM_LOG_DEBUG, "%s is a directory, not a conflict", filestr);
} }
} }
alpm_list_free_inner(tmpfiles, &free); alpm_list_free_inner(tmpfiles, &free);

View file

@ -467,8 +467,8 @@ pmpkg_t *_alpm_pkg_isin(char *needle, alpm_list_t *haystack)
for(lp = haystack; lp; lp = lp->next) { for(lp = haystack; lp; lp = lp->next) {
pmpkg_t *info = lp->data; pmpkg_t *info = lp->data;
if(info && !strcmp(info->name, needle)) { if(info && strcmp(info->name, needle) == 0) {
return(lp->data); return(info);
} }
} }
return(NULL); return(NULL);