summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-09 08:00:16 +0200
committerDan McGee <dan@archlinux.org>2011-08-15 19:56:41 +0200
commita628feee46f2200db7d3303091813f050a61d0a3 (patch)
tree47e9924d205098c48a6ef3db33e4424b9845c0fc /src
parentbd5ec9cd8e23bba4334a7b3a5a73843c3667c085 (diff)
downloadpacman-a628feee46f2200db7d3303091813f050a61d0a3.tar.gz
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 'src')
-rw-r--r--src/pacman/package.c34
-rw-r--r--src/pacman/sync.c7
2 files changed, 25 insertions, 16 deletions
diff --git a/src/pacman/package.c b/src/pacman/package.c
index 8c101851..7fe33a9f 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -37,6 +37,22 @@
#define CLBUF_SIZE 4096
+/** Turn a depends list into a text list.
+ * @param deps a list with items of type alpm_depend_t
+ * @return a string list, must be freed
+ */
+static void deplist_display(const char *title,
+ alpm_list_t *deps)
+{
+ alpm_list_t *i, *text = NULL;
+ for(i = deps; i; i = alpm_list_next(i)) {
+ alpm_depend_t *dep = alpm_list_getdata(i);
+ text = alpm_list_add(text, alpm_dep_compute_string(dep));
+ }
+ list_display(title, text);
+ FREELIST(text);
+}
+
/**
* Display the details of a package.
* Extra information entails 'required by' info for sync packages and backup
@@ -52,8 +68,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
char bdatestr[50] = "", idatestr[50] = "";
const char *label;
double size;
- const alpm_list_t *i;
- alpm_list_t *requiredby = NULL, *depstrings = NULL;
+ alpm_list_t *requiredby = NULL;
if(pkg == NULL) {
return;
@@ -81,12 +96,6 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
break;
}
- /* turn depends list into a text list */
- for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
- alpm_depend_t *dep = (alpm_depend_t *)alpm_list_getdata(i);
- depstrings = alpm_list_add(depstrings, alpm_dep_compute_string(dep));
- }
-
if(extra || from == PKG_FROM_LOCALDB) {
/* compute this here so we don't get a pause in the middle of output */
requiredby = alpm_pkg_compute_requiredby(pkg);
@@ -102,14 +111,14 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
string_display(_("URL :"), alpm_pkg_get_url(pkg));
list_display(_("Licenses :"), alpm_pkg_get_licenses(pkg));
list_display(_("Groups :"), alpm_pkg_get_groups(pkg));
- list_display(_("Provides :"), alpm_pkg_get_provides(pkg));
- list_display(_("Depends On :"), depstrings);
+ deplist_display(_("Provides :"), alpm_pkg_get_provides(pkg));
+ deplist_display(_("Depends On :"), alpm_pkg_get_depends(pkg));
list_display_linebreak(_("Optional Deps :"), alpm_pkg_get_optdepends(pkg));
if(extra || from == PKG_FROM_LOCALDB) {
list_display(_("Required By :"), requiredby);
}
- list_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
- list_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
+ deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
+ deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg));
size = humanize_size(alpm_pkg_get_size(pkg), 'K', 1, &label);
if(from == PKG_FROM_SYNCDB) {
@@ -162,7 +171,6 @@ void dump_pkg_full(alpm_pkg_t *pkg, enum pkg_from from, int extra)
/* final newline to separate packages */
printf("\n");
- FREELIST(depstrings);
FREELIST(requiredby);
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 7b50d805..ea32a264 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -779,13 +779,14 @@ int sync_prepare_execute(void)
for(i = data; i; i = alpm_list_next(i)) {
alpm_conflict_t *conflict = alpm_list_getdata(i);
/* only print reason if it contains new information */
- if(strcmp(conflict->package1, conflict->reason) == 0 ||
- strcmp(conflict->package2, conflict->reason) == 0) {
+ if(conflict->reason->mod == ALPM_DEP_MOD_ANY) {
printf(_(":: %s and %s are in conflict\n"),
conflict->package1, conflict->package2);
} else {
+ char *reason = alpm_dep_compute_string(conflict->reason);
printf(_(":: %s and %s are in conflict (%s)\n"),
- conflict->package1, conflict->package2, conflict->reason);
+ conflict->package1, conflict->package2, reason);
+ free(reason);
}
}
break;