summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/deps.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c66
1 files changed, 43 insertions, 23 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 0c0a054e..98519bd0 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -1,7 +1,7 @@
/*
* deps.c
*
- * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2012 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -41,6 +39,7 @@ void _alpm_dep_free(alpm_depend_t *dep)
{
FREE(dep->name);
FREE(dep->version);
+ FREE(dep->desc);
FREE(dep);
}
@@ -159,15 +158,17 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
else if(nextchild->state == -1) {
alpm_pkg_t *vertexpkg = vertex->data;
alpm_pkg_t *childpkg = nextchild->data;
- const char *message;
_alpm_log(handle, ALPM_LOG_WARNING, _("dependency cycle detected:\n"));
if(reverse) {
- message =_("%s will be removed after its %s dependency\n");
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("%s will be removed after its %s dependency\n"),
+ vertexpkg->name, childpkg->name);
} else {
- message =_("%s will be installed before its %s dependency\n");
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("%s will be installed before its %s dependency\n"),
+ vertexpkg->name, childpkg->name);
}
- _alpm_log(handle, ALPM_LOG_WARNING, message, vertexpkg->name, childpkg->name);
}
}
if(!found) {
@@ -204,8 +205,10 @@ alpm_list_t *_alpm_sortbydeps(alpm_handle_t *handle,
static int no_dep_version(alpm_handle_t *handle)
{
- int flags = alpm_trans_get_flags(handle);
- return flags != -1 && (flags & ALPM_TRANS_FLAG_NODEPVERSION);
+ if(!handle->trans) {
+ return 0;
+ }
+ return (handle->trans->flags & ALPM_TRANS_FLAG_NODEPVERSION);
}
static alpm_depend_t *filtered_depend(alpm_depend_t *dep, int nodepversion)
@@ -395,7 +398,7 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
/* any version will satisfy the requirement */
satisfy = (provision->name_hash == dep->name_hash
&& strcmp(provision->name, dep->name) == 0);
- } else if (provision->mod == ALPM_DEP_MOD_EQ) {
+ } else if(provision->mod == ALPM_DEP_MOD_EQ) {
/* provision specifies a version, so try it out */
satisfy = (provision->name_hash == dep->name_hash
&& strcmp(provision->name, dep->name) == 0
@@ -409,7 +412,7 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep)
alpm_depend_t *_alpm_splitdep(const char *depstring)
{
alpm_depend_t *depend;
- const char *ptr, *version;
+ const char *ptr, *version, *desc;
size_t deplen;
if(depstring == NULL) {
@@ -417,7 +420,17 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
}
MALLOC(depend, sizeof(alpm_depend_t), return NULL);
- deplen = strlen(depstring);
+
+ /* Note the extra space in ": " to avoid matching the epoch */
+ if((desc = strstr(depstring, ": ")) != NULL) {
+ STRDUP(depend->desc, desc + 2, return NULL);
+ deplen = desc - depstring;
+ } else {
+ /* no description- point desc at NULL at end of string for later use */
+ depend->desc = NULL;
+ deplen = strlen(depstring);
+ desc = depstring + deplen;
+ }
/* Find a version comparator if one exists. If it does, set the type and
* increment the ptr accordingly so we can copy the right strings. */
@@ -442,21 +455,18 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
depend->mod = ALPM_DEP_MOD_EQ;
version = ptr + 1;
} else {
- /* no version specified, leave ptr NULL and set version to NULL */
+ /* no version specified, set ptr to end of string and version to NULL */
+ ptr = depstring + deplen;
depend->mod = ALPM_DEP_MOD_ANY;
depend->version = NULL;
version = NULL;
}
/* copy the right parts to the right places */
- if(ptr) {
- STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
- } else {
- STRDUP(depend->name, depstring, return NULL);
- }
+ STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) {
- STRDUP(depend->version, version, return NULL);
+ STRNDUP(depend->version, version, desc - version, return NULL);
}
return depend;
@@ -468,8 +478,9 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
CALLOC(newdep, 1, sizeof(alpm_depend_t), return NULL);
STRDUP(newdep->name, dep->name, return NULL);
- newdep->name_hash = dep->name_hash;
STRDUP(newdep->version, dep->version, return NULL);
+ STRDUP(newdep->desc, dep->desc, return NULL);
+ newdep->name_hash = dep->name_hash;
newdep->mod = dep->mod;
return newdep;
@@ -792,7 +803,7 @@ int _alpm_resolvedeps(alpm_handle_t *handle, alpm_list_t *localpkgs,
*/
char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
{
- const char *name, *opr, *ver;
+ const char *name, *opr, *ver, *desc_delim, *desc;
char *str;
size_t len;
@@ -834,12 +845,21 @@ char SYMEXPORT *alpm_dep_compute_string(const alpm_depend_t *dep)
ver = "";
}
+ if(dep->desc) {
+ desc_delim = ": ";
+ desc = dep->desc;
+ } else {
+ desc_delim = "";
+ desc = "";
+ }
+
/* we can always compute len and print the string like this because opr
* and ver will be empty when ALPM_DEP_MOD_ANY is the depend type. the
* reassignments above also ensure we do not do a strlen(NULL). */
- len = strlen(name) + strlen(opr) + strlen(ver) + 1;
+ len = strlen(name) + strlen(opr) + strlen(ver)
+ + strlen(desc_delim) + strlen(desc) + 1;
MALLOC(str, len, return NULL);
- snprintf(str, len, "%s%s%s", name, opr, ver);
+ snprintf(str, len, "%s%s%s%s%s", name, opr, ver, desc_delim, desc);
return str;
}