From 0bc06918e4b93cae874c09f4b1d487865ca44fbd Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 30 Jan 2007 05:41:13 +0000 Subject: * Remove -fno-strict-aliasing as it is now unnecessary to compile. * Fix up add.c a bit better than it was in regards to FS #3492. * Optimized the sqrt call in dependency cycle checking to a single call. * Removal of an outdated comment. --- lib/libalpm/add.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'lib/libalpm/add.c') diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 678da620..f034131b 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -211,9 +211,12 @@ error: } -static int name_cmp(const void *p1, const void *p2) +/* 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) { - return(strcmp(((pmpkg_t *)p1)->name, (const char *)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) @@ -253,11 +256,26 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data) /* Attempt to resolve conflicts */ QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &skip_this); if(skip_this) { - pmpkg_t **pkg = NULL; - lp = alpm_list_remove(lp, (void *)miss->depend.name, name_cmp, (void **)pkg); - FREEPKG(*pkg); - } - } + pmdepmissing_t *pkg = NULL; + lp = alpm_list_remove(lp, (void *)miss, pkg_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 + * removes. We run into problems because we do a file conflict check + * below and it fails there. A force flag will skip that part, but + * 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 + * proceed as sync.c would? I'm not sure because I'm not familiar enough + * with the codebase. */ if(lp != NULL) { if(data) { *data = lp; -- cgit v1.2.3