diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-09 01:00:16 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-15 12:56:41 -0500 |
commit | a628feee46f2200db7d3303091813f050a61d0a3 (patch) | |
tree | 47e9924d205098c48a6ef3db33e4424b9845c0fc /lib/libalpm/conflict.c | |
parent | bd5ec9cd8e23bba4334a7b3a5a73843c3667c085 (diff) | |
download | pacman-a628feee46f2200db7d3303091813f050a61d0a3.tar.xz |
Parse conflicts/provides/replaces at database load time
We did this with depends way back in commit c244cfecf654d3 in 2007. We
can do it with these fields as well.
Of note is the inclusion of provides even though only '=' is supported-
we'll parse other things, but no guarantees are given as to behavior,
which is more or less similar to before since we only looked for the
equals sign.
Also of note is the non-inclusion of optdepends; this will likely be
resolved down the road.
The biggest benefactors of this change will be the resolving code that
formerly had to parse and reparse several of these fields; it only
happens once now at load time. This does lead to the disadvantage that
we will now always be parsing this information up front even if we never
need it in the split form, but as these are uncommon fields and our
parser is quite efficient it shouldn't be a big concern.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/conflict.c')
-rw-r--r-- | lib/libalpm/conflict.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c index 91e6b677..fe182094 100644 --- a/lib/libalpm/conflict.c +++ b/lib/libalpm/conflict.c @@ -42,7 +42,7 @@ #include "deps.h" static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, - const char *reason) + alpm_depend_t *reason) { alpm_conflict_t *conflict; @@ -52,7 +52,7 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, conflict->package2_hash = pkg2->name_hash; STRDUP(conflict->package1, pkg1->name, return NULL); STRDUP(conflict->package2, pkg2->name, return NULL); - STRDUP(conflict->reason, reason, return NULL); + conflict->reason = reason; return conflict; } @@ -61,7 +61,6 @@ void _alpm_conflict_free(alpm_conflict_t *conflict) { FREE(conflict->package2); FREE(conflict->package1); - FREE(conflict->reason); FREE(conflict); } @@ -74,7 +73,7 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict) newconflict->package2_hash = conflict->package2_hash; STRDUP(newconflict->package1, conflict->package1, return NULL); STRDUP(newconflict->package2, conflict->package2, return NULL); - STRDUP(newconflict->reason, conflict->reason, return NULL); + newconflict->reason = conflict->reason; return newconflict; } @@ -103,16 +102,18 @@ static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack) * @param reason reason for this conflict */ static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps, - alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, const char *reason) + alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, alpm_depend_t *reason) { alpm_conflict_t *conflict = conflict_new(pkg1, pkg2, reason); if(!conflict) { return -1; } - _alpm_log(handle, ALPM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n", - pkg1->name, pkg2->name, reason); if(!conflict_isin(conflict, *baddeps)) { + char *conflict_str = alpm_dep_compute_string(reason); *baddeps = alpm_list_add(*baddeps, conflict); + _alpm_log(handle, ALPM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n", + pkg1->name, pkg2->name, conflict_str); + free(conflict_str); } else { _alpm_conflict_free(conflict); } @@ -144,9 +145,8 @@ static void check_conflict(alpm_handle_t *handle, alpm_list_t *j; for(j = alpm_pkg_get_conflicts(pkg1); j; j = j->next) { - const char *conflict = j->data; + alpm_depend_t *conflict = j->data; alpm_list_t *k; - alpm_depend_t *parsed_conflict = _alpm_splitdep(conflict); for(k = list2; k; k = k->next) { alpm_pkg_t *pkg2 = k->data; @@ -157,7 +157,7 @@ static void check_conflict(alpm_handle_t *handle, continue; } - if(_alpm_depcmp(pkg2, parsed_conflict)) { + if(_alpm_depcmp(pkg2, conflict)) { if(order >= 0) { add_conflict(handle, baddeps, pkg1, pkg2, conflict); } else { @@ -165,7 +165,6 @@ static void check_conflict(alpm_handle_t *handle, } } } - _alpm_dep_free(parsed_conflict); } } } |