2005-03-14 20:51:43 -05:00
|
|
|
/*
|
|
|
|
* deps.c
|
|
|
|
*
|
2006-01-02 14:55:35 -05:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2006-10-15 15:31:03 -04:00
|
|
|
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
|
|
|
|
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
|
2005-03-14 20:51:43 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
* USA.
|
|
|
|
*/
|
|
|
|
|
2007-03-05 17:13:33 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2006-10-15 15:31:03 -04:00
|
|
|
#ifdef __sun__
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
#include <math.h>
|
2007-03-05 17:13:33 -05:00
|
|
|
|
|
|
|
/* libalpm */
|
|
|
|
#include "deps.h"
|
|
|
|
#include "alpm_list.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "util.h"
|
|
|
|
#include "log.h"
|
2005-03-30 17:32:43 -05:00
|
|
|
#include "error.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "package.h"
|
|
|
|
#include "db.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "provide.h"
|
2005-12-26 11:48:37 -05:00
|
|
|
#include "versioncmp.h"
|
2005-04-24 16:06:00 -04:00
|
|
|
#include "handle.h"
|
|
|
|
|
|
|
|
extern pmhandle_t *handle;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-23 22:02:53 -05:00
|
|
|
pmdepmissing_t *_alpm_depmiss_new(const char *target, pmdeptype_t type,
|
|
|
|
pmdepmod_t depmod, const char *depname,
|
|
|
|
const char *depversion)
|
2006-01-15 10:55:16 -05:00
|
|
|
{
|
|
|
|
pmdepmissing_t *miss;
|
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2007-05-14 03:16:55 -04:00
|
|
|
miss = malloc(sizeof(pmdepmissing_t));
|
2006-01-15 10:55:16 -05:00
|
|
|
if(miss == NULL) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
|
2006-03-01 02:51:00 -05:00
|
|
|
RET_ERR(PM_ERR_MEMORY, NULL);
|
2006-01-15 10:55:16 -05:00
|
|
|
}
|
|
|
|
|
2007-04-29 12:03:09 -04:00
|
|
|
strncpy(miss->target, target, PKG_NAME_LEN);
|
2006-01-15 10:55:16 -05:00
|
|
|
miss->type = type;
|
|
|
|
miss->depend.mod = depmod;
|
2007-04-29 12:03:09 -04:00
|
|
|
strncpy(miss->depend.name, depname, PKG_NAME_LEN);
|
2006-01-18 17:37:16 -05:00
|
|
|
if(depversion) {
|
2007-04-29 12:03:09 -04:00
|
|
|
strncpy(miss->depend.version, depversion, PKG_VERSION_LEN);
|
2006-01-18 17:37:16 -05:00
|
|
|
} else {
|
|
|
|
miss->depend.version[0] = 0;
|
|
|
|
}
|
2006-01-15 10:55:16 -05:00
|
|
|
|
|
|
|
return(miss);
|
|
|
|
}
|
|
|
|
|
2007-01-19 04:28:44 -05:00
|
|
|
int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack)
|
2006-01-18 17:37:16 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *i;
|
2006-01-18 17:37:16 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-01-18 17:37:16 -05:00
|
|
|
for(i = haystack; i; i = i->next) {
|
|
|
|
pmdepmissing_t *miss = i->data;
|
|
|
|
if(!memcmp(needle, miss, sizeof(pmdepmissing_t))
|
|
|
|
&& !memcmp(&needle->depend, &miss->depend, sizeof(pmdepend_t))) {
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* Re-order a list of target packages with respect to their dependencies.
|
|
|
|
*
|
2005-03-25 17:09:14 -05:00
|
|
|
* Example (PM_TRANS_TYPE_ADD):
|
2005-03-14 20:51:43 -05:00
|
|
|
* A depends on C
|
|
|
|
* B depends on A
|
|
|
|
* Target order is A,B,C,D
|
|
|
|
*
|
|
|
|
* Should be re-ordered to C,A,B,D
|
|
|
|
*
|
2005-03-25 17:09:14 -05:00
|
|
|
* mode should be either PM_TRANS_TYPE_ADD or PM_TRANS_TYPE_REMOVE. This
|
|
|
|
* affects the dependency order sortbydeps() will use.
|
|
|
|
*
|
2007-01-19 04:28:44 -05:00
|
|
|
* This function returns the new alpm_list_t* target list.
|
2005-03-14 20:51:43 -05:00
|
|
|
*
|
|
|
|
*/
|
2007-01-31 02:14:50 -05:00
|
|
|
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *newtargs = NULL;
|
|
|
|
alpm_list_t *i, *j, *k, *l;
|
2005-03-14 20:51:43 -05:00
|
|
|
int change = 1;
|
|
|
|
int numscans = 0;
|
|
|
|
int numtargs = 0;
|
2007-01-30 00:41:13 -05:00
|
|
|
int maxscans;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if(targets == NULL) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2005-05-04 15:30:00 -04:00
|
|
|
for(i = targets; i; i = i->next) {
|
2007-01-19 04:28:44 -05:00
|
|
|
newtargs = alpm_list_add(newtargs, i->data);
|
2005-05-04 15:30:00 -04:00
|
|
|
numtargs++;
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 00:41:13 -05:00
|
|
|
maxscans = (int)sqrt(numtargs);
|
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("started sorting dependencies"));
|
2005-03-14 20:51:43 -05:00
|
|
|
while(change) {
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *tmptargs = NULL;
|
2005-03-14 20:51:43 -05:00
|
|
|
change = 0;
|
2007-01-30 00:41:13 -05:00
|
|
|
if(numscans > maxscans) {
|
2006-10-15 15:31:03 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("possible dependency cycle detected"));
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
numscans++;
|
|
|
|
/* run thru targets, moving up packages as necessary */
|
2005-05-04 15:30:00 -04:00
|
|
|
for(i = newtargs; i; i = i->next) {
|
2007-03-03 03:13:59 -05:00
|
|
|
pmpkg_t *p = i->data;
|
|
|
|
_alpm_log(PM_LOG_DEBUG, " sorting %s", alpm_pkg_get_name(p));
|
2007-02-20 03:44:32 -05:00
|
|
|
for(j = alpm_pkg_get_depends(p); j; j = j->next) {
|
2007-03-07 02:45:30 -05:00
|
|
|
pmdepend_t *depend = alpm_splitdep(j->data);
|
2005-03-14 20:51:43 -05:00
|
|
|
pmpkg_t *q = NULL;
|
2007-03-03 04:43:16 -05:00
|
|
|
if(depend == NULL) {
|
2005-05-04 15:30:00 -04:00
|
|
|
continue;
|
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
/* look for depend->name -- if it's farther down in the list, then
|
2005-03-14 20:51:43 -05:00
|
|
|
* move it up above p
|
|
|
|
*/
|
2005-05-04 15:30:00 -04:00
|
|
|
for(k = i->next; k; k = k->next) {
|
2007-03-03 03:13:59 -05:00
|
|
|
q = k->data;
|
|
|
|
const char *qname = alpm_pkg_get_name(q);
|
2007-03-03 04:43:16 -05:00
|
|
|
if(!strcmp(depend->name, qname)) {
|
2007-03-03 03:13:59 -05:00
|
|
|
if(!_alpm_pkg_find(qname, tmptargs)) {
|
2005-05-04 15:30:00 -04:00
|
|
|
change = 1;
|
2007-01-19 04:28:44 -05:00
|
|
|
tmptargs = alpm_list_add(tmptargs, q);
|
2005-05-04 15:30:00 -04:00
|
|
|
}
|
|
|
|
break;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
for(l = alpm_pkg_get_provides(q); l; l = l->next) {
|
|
|
|
const char *provname = l->data;
|
2007-03-03 04:43:16 -05:00
|
|
|
if(!strcmp(depend->name, provname)) {
|
2007-04-22 23:01:47 -04:00
|
|
|
if(!_alpm_pkg_find(qname, tmptargs)) {
|
2006-10-15 15:31:03 -04:00
|
|
|
change = 1;
|
2007-01-19 04:28:44 -05:00
|
|
|
tmptargs = alpm_list_add(tmptargs, q);
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
free(depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
if(!_alpm_pkg_find(alpm_pkg_get_name(p), tmptargs)) {
|
2007-01-19 04:28:44 -05:00
|
|
|
tmptargs = alpm_list_add(tmptargs, p);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
2007-04-28 03:54:25 -04:00
|
|
|
alpm_list_free(newtargs);
|
2005-05-04 15:30:00 -04:00
|
|
|
newtargs = tmptargs;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("sorting dependencies finished"));
|
2005-05-04 15:30:00 -04:00
|
|
|
|
2005-03-25 17:09:14 -05:00
|
|
|
if(mode == PM_TRANS_TYPE_REMOVE) {
|
|
|
|
/* we're removing packages, so reverse the order */
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *tmptargs = alpm_list_reverse(newtargs);
|
2005-03-25 17:09:14 -05:00
|
|
|
/* free the old one */
|
2007-04-28 03:54:25 -04:00
|
|
|
alpm_list_free(newtargs);
|
2005-05-04 15:30:00 -04:00
|
|
|
newtargs = tmptargs;
|
2005-03-25 17:09:14 -05:00
|
|
|
}
|
|
|
|
|
2005-05-04 15:30:00 -04:00
|
|
|
return(newtargs);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-02-27 23:00:21 -05:00
|
|
|
/** Checks dependencies and returns missing ones in a list. Dependencies can include versions with depmod operators.
|
|
|
|
* @param trans pointer to the transaction object
|
|
|
|
* @param db pointer to the local package database
|
|
|
|
* @param op transaction type
|
|
|
|
* @param packages an alpm_list_t* of packages to be checked
|
|
|
|
* @return an alpm_list_t* of missing_t pointers.
|
2005-03-14 20:51:43 -05:00
|
|
|
*/
|
2007-01-23 22:02:53 -05:00
|
|
|
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|
|
|
alpm_list_t *packages)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-03-01 02:03:05 -05:00
|
|
|
alpm_list_t *i, *j, *k, *l;
|
2005-03-14 20:51:43 -05:00
|
|
|
int found = 0;
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *baddeps = NULL;
|
2005-03-14 20:51:43 -05:00
|
|
|
pmdepmissing_t *miss = NULL;
|
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if(db == NULL) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(op == PM_TRANS_TYPE_UPGRADE) {
|
|
|
|
/* PM_TRANS_TYPE_UPGRADE handles the backwards dependencies, ie, the packages
|
|
|
|
* listed in the requiredby field.
|
|
|
|
*/
|
|
|
|
for(i = packages; i; i = i->next) {
|
2007-03-01 02:03:05 -05:00
|
|
|
pmpkg_t *newpkg = i->data;
|
2005-04-20 15:46:53 -04:00
|
|
|
pmpkg_t *oldpkg;
|
2007-03-01 02:03:05 -05:00
|
|
|
if(newpkg == NULL) {
|
2006-11-22 04:03:41 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("null package found in package list"));
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
if((oldpkg = _alpm_db_get_pkgfromcache(db, alpm_pkg_get_name(newpkg))) == NULL) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, _("cannot find package installed '%s'"),
|
|
|
|
alpm_pkg_get_name(newpkg));
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
|
|
|
}
|
2007-03-01 02:03:05 -05:00
|
|
|
for(j = alpm_pkg_get_requiredby(oldpkg); j; j = j->next) {
|
2005-03-14 20:51:43 -05:00
|
|
|
pmpkg_t *p;
|
|
|
|
found = 0;
|
2006-02-17 17:35:26 -05:00
|
|
|
if((p = _alpm_db_get_pkgfromcache(db, j->data)) == NULL) {
|
2005-03-14 20:51:43 -05:00
|
|
|
/* hmmm... package isn't installed.. */
|
|
|
|
continue;
|
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
if(_alpm_pkg_find(alpm_pkg_get_name(p), packages)) {
|
2007-01-23 22:02:53 -05:00
|
|
|
/* this package also in the upgrade list, so don't worry about it */
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
|
|
|
}
|
2007-03-01 02:03:05 -05:00
|
|
|
for(k = alpm_pkg_get_depends(p); k; k = k->next) {
|
2007-02-27 23:00:21 -05:00
|
|
|
/* don't break any existing dependencies (possible provides) */
|
2007-03-07 02:45:30 -05:00
|
|
|
pmdepend_t *depend = alpm_splitdep(k->data);
|
2007-03-03 04:43:16 -05:00
|
|
|
if(depend == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-03-01 02:03:05 -05:00
|
|
|
|
|
|
|
/* if oldpkg satisfied this dep, and newpkg doesn't */
|
2007-03-07 02:45:30 -05:00
|
|
|
if(alpm_depcmp(oldpkg, depend) && !alpm_depcmp(newpkg, depend)) {
|
2007-03-01 02:03:05 -05:00
|
|
|
/* we've found a dep that was removed... see if any other package
|
|
|
|
* still contains/provides the dep */
|
|
|
|
int satisfied = 0;
|
|
|
|
for(l = packages; l; l = l->next) {
|
|
|
|
pmpkg_t *pkg = l->data;
|
|
|
|
|
2007-03-07 02:45:30 -05:00
|
|
|
if(alpm_depcmp(pkg, depend)) {
|
2007-03-01 02:03:05 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' has moved from '%s' to '%s'"),
|
2007-03-03 04:43:16 -05:00
|
|
|
depend->name, alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg));
|
2007-03-01 02:03:05 -05:00
|
|
|
satisfied = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!satisfied) {
|
|
|
|
/* worst case... check installed packages to see if anything else
|
|
|
|
* satisfies this... */
|
2007-03-03 03:13:59 -05:00
|
|
|
for(l = _alpm_db_get_pkgcache(db); l; l = l->next) {
|
2007-03-01 02:03:05 -05:00
|
|
|
pmpkg_t *pkg = l->data;
|
|
|
|
|
2007-06-09 18:48:56 -04:00
|
|
|
if(alpm_depcmp(pkg, depend) && !_alpm_pkg_find(alpm_pkg_get_name(pkg), packages)) {
|
|
|
|
/* we ignore packages that will be updated because we know
|
|
|
|
* that the updated ones don't satisfy depend */
|
2007-03-01 02:03:05 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' satisfied by installed package '%s'"),
|
2007-03-03 04:43:16 -05:00
|
|
|
depend->name, alpm_pkg_get_name(pkg));
|
2007-03-01 02:03:05 -05:00
|
|
|
satisfied = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!satisfied) {
|
|
|
|
_alpm_log(PM_LOG_DEBUG, _("checkdeps: updated '%s' won't satisfy a dependency of '%s'"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(p));
|
2007-03-19 00:23:45 -04:00
|
|
|
miss = _alpm_depmiss_new(p->name, PM_DEP_TYPE_DEPEND, depend->mod,
|
2007-03-03 04:43:16 -05:00
|
|
|
depend->name, depend->version);
|
2007-03-01 02:03:05 -05:00
|
|
|
if(!_alpm_depmiss_isin(miss, baddeps)) {
|
|
|
|
baddeps = alpm_list_add(baddeps, miss);
|
|
|
|
} else {
|
|
|
|
FREE(miss);
|
|
|
|
}
|
2007-02-27 23:00:21 -05:00
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
free(depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) {
|
2006-01-15 10:55:16 -05:00
|
|
|
/* DEPENDENCIES -- look for unsatisfied dependencies */
|
2005-03-14 20:51:43 -05:00
|
|
|
for(i = packages; i; i = i->next) {
|
|
|
|
pmpkg_t *tp = i->data;
|
|
|
|
if(tp == NULL) {
|
2006-11-22 04:03:41 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("null package found in package list"));
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
2005-03-14 20:51:43 -05:00
|
|
|
/* split into name/version pairs */
|
2007-03-07 02:45:30 -05:00
|
|
|
pmdepend_t *depend = alpm_splitdep((char*)j->data);
|
2007-03-03 04:43:16 -05:00
|
|
|
if(depend == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
found = 0;
|
2006-10-21 16:16:55 -04:00
|
|
|
/* check other targets */
|
|
|
|
for(k = packages; k && !found; k = k->next) {
|
2007-03-03 03:13:59 -05:00
|
|
|
pmpkg_t *p = k->data;
|
2007-03-07 02:45:30 -05:00
|
|
|
found = alpm_depcmp(p, depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-06-09 19:16:51 -04:00
|
|
|
|
|
|
|
/* check database for satisfying packages */
|
|
|
|
/* we can ignore packages being updated, they were checked above */
|
|
|
|
for(k = _alpm_db_get_pkgcache(db); k && !found; k = k->next) {
|
|
|
|
pmpkg_t *p = k->data;
|
|
|
|
found = alpm_depcmp(p, depend)
|
|
|
|
&& !_alpm_pkg_find(alpm_pkg_get_name(p), packages);
|
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* else if still not found... */
|
|
|
|
if(!found) {
|
2007-02-18 13:29:28 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("missing dependency '%s' for package '%s'"),
|
2007-03-03 04:43:16 -05:00
|
|
|
depend->name, alpm_pkg_get_name(tp));
|
|
|
|
miss = _alpm_depmiss_new(alpm_pkg_get_name(tp), PM_DEP_TYPE_DEPEND, depend->mod,
|
|
|
|
depend->name, depend->version);
|
2006-02-17 17:35:26 -05:00
|
|
|
if(!_alpm_depmiss_isin(miss, baddeps)) {
|
2007-01-19 04:28:44 -05:00
|
|
|
baddeps = alpm_list_add(baddeps, miss);
|
2005-04-20 15:41:54 -04:00
|
|
|
} else {
|
|
|
|
FREE(miss);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
free(depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(op == PM_TRANS_TYPE_REMOVE) {
|
|
|
|
/* check requiredby fields */
|
|
|
|
for(i = packages; i; i = i->next) {
|
2006-01-14 10:05:59 -05:00
|
|
|
pmpkg_t *tp = i->data;
|
|
|
|
if(tp == NULL) {
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
|
|
|
}
|
2006-01-14 10:05:59 -05:00
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
found=0;
|
2007-03-03 03:13:59 -05:00
|
|
|
for(j = alpm_pkg_get_requiredby(tp); j; j = j->next) {
|
2006-12-01 04:51:54 -05:00
|
|
|
/* Search for 'reqname' in packages for removal */
|
2006-12-01 04:32:29 -05:00
|
|
|
char *reqname = j->data;
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *x = NULL;
|
2006-12-01 04:51:54 -05:00
|
|
|
for(x = packages; x; x = x->next) {
|
|
|
|
pmpkg_t *xp = x->data;
|
2007-03-03 03:13:59 -05:00
|
|
|
if(strcmp(reqname, alpm_pkg_get_name(xp)) == 0) {
|
2006-12-01 04:51:54 -05:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
2006-10-15 15:31:03 -04:00
|
|
|
/* check if a package in trans->packages provides this package */
|
2007-03-03 03:13:59 -05:00
|
|
|
for(k = trans->packages; !found && k; k=k->next) {
|
2006-10-15 15:31:03 -04:00
|
|
|
pmpkg_t *spkg = NULL;
|
2006-12-01 04:51:54 -05:00
|
|
|
if(trans->type == PM_TRANS_TYPE_SYNC) {
|
|
|
|
pmsyncpkg_t *sync = k->data;
|
|
|
|
spkg = sync->pkg;
|
|
|
|
} else {
|
|
|
|
spkg = k->data;
|
|
|
|
}
|
|
|
|
if(spkg) {
|
2007-03-03 03:13:59 -05:00
|
|
|
if(alpm_list_find_str(alpm_pkg_get_provides(spkg), tp->name)) {
|
2006-12-01 04:51:54 -05:00
|
|
|
found = 1;
|
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
2007-01-23 22:02:53 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("checkdeps: found %s as required by %s"),
|
2007-03-03 03:13:59 -05:00
|
|
|
reqname, alpm_pkg_get_name(tp));
|
2007-03-19 00:23:45 -04:00
|
|
|
miss = _alpm_depmiss_new(alpm_pkg_get_name(tp), PM_DEP_TYPE_DEPEND,
|
2007-03-03 03:13:59 -05:00
|
|
|
PM_DEP_MOD_ANY, j->data, NULL);
|
2006-10-15 15:31:03 -04:00
|
|
|
if(!_alpm_depmiss_isin(miss, baddeps)) {
|
2007-01-19 04:28:44 -05:00
|
|
|
baddeps = alpm_list_add(baddeps, miss);
|
2006-10-15 15:31:03 -04:00
|
|
|
} else {
|
|
|
|
FREE(miss);
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(baddeps);
|
|
|
|
}
|
|
|
|
|
2007-03-11 17:10:02 -04:00
|
|
|
pmdepend_t SYMEXPORT *alpm_splitdep(const char *depstring)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-03-03 04:43:16 -05:00
|
|
|
pmdepend_t *depend;
|
|
|
|
char *ptr = NULL;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-03-03 04:43:16 -05:00
|
|
|
if(depstring == NULL) {
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2007-05-14 03:16:55 -04:00
|
|
|
depend = malloc(sizeof(pmdepend_t));
|
2007-03-03 04:43:16 -05:00
|
|
|
if(depend == NULL) {
|
|
|
|
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepend_t));
|
|
|
|
return(NULL);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-03-03 04:43:16 -05:00
|
|
|
/* 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. */
|
|
|
|
if((ptr = strstr(depstring, ">="))) {
|
2005-03-29 15:31:03 -05:00
|
|
|
depend->mod = PM_DEP_MOD_GE;
|
2007-03-03 04:43:16 -05:00
|
|
|
*ptr = '\0';
|
|
|
|
ptr += 2;
|
|
|
|
} else if((ptr = strstr(depstring, "<="))) {
|
2005-03-29 15:31:03 -05:00
|
|
|
depend->mod = PM_DEP_MOD_LE;
|
2007-03-03 04:43:16 -05:00
|
|
|
*ptr = '\0';
|
|
|
|
ptr += 2;
|
|
|
|
} else if((ptr = strstr(depstring, "="))) {
|
2005-03-29 15:31:03 -05:00
|
|
|
depend->mod = PM_DEP_MOD_EQ;
|
2007-03-03 04:43:16 -05:00
|
|
|
*ptr = '\0';
|
|
|
|
ptr += 1;
|
2005-03-14 20:51:43 -05:00
|
|
|
} else {
|
2007-03-03 04:43:16 -05:00
|
|
|
/* no version specified - copy in the name and return it */
|
2005-03-29 15:31:03 -05:00
|
|
|
depend->mod = PM_DEP_MOD_ANY;
|
2007-03-03 04:43:16 -05:00
|
|
|
strncpy(depend->name, depstring, PKG_NAME_LEN);
|
|
|
|
depend->version[0] = '\0';
|
|
|
|
return(depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-02-18 13:29:28 -05:00
|
|
|
|
2007-03-03 04:43:16 -05:00
|
|
|
/* if we get here, we have a version comparator, copy the right parts
|
|
|
|
* to the right places */
|
|
|
|
strncpy(depend->name, depstring, PKG_NAME_LEN);
|
|
|
|
strncpy(depend->version, ptr, PKG_VERSION_LEN);
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-03-03 04:43:16 -05:00
|
|
|
return(depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-02-20 03:44:32 -05:00
|
|
|
/* These parameters are messy. We check if this package, given a list of
|
|
|
|
* targets (and a db), is safe to remove. We do NOT remove it if it is in the
|
|
|
|
* target list */
|
|
|
|
static int can_remove_package(pmdb_t *db, pmpkg_t *pkg, alpm_list_t *targets)
|
|
|
|
{
|
|
|
|
alpm_list_t *i;
|
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
if(_alpm_pkg_find(alpm_pkg_get_name(pkg), targets)) {
|
2007-02-20 03:44:32 -05:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* see if it was explicitly installed */
|
|
|
|
if(alpm_pkg_get_reason(pkg) == PM_PKG_REASON_EXPLICIT) {
|
2007-03-03 03:13:59 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("excluding %s -- explicitly installed"), alpm_pkg_get_name(pkg));
|
2007-02-20 03:44:32 -05:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* see if other packages need it */
|
|
|
|
for(i = alpm_pkg_get_requiredby(pkg); i; i = i->next) {
|
|
|
|
pmpkg_t *reqpkg = _alpm_db_get_pkgfromcache(db, i->data);
|
2007-03-03 03:13:59 -05:00
|
|
|
if(reqpkg && !_alpm_pkg_find(alpm_pkg_get_name(reqpkg), targets)) {
|
2007-02-20 03:44:32 -05:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* it's ok to remove */
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
2007-01-19 04:28:44 -05:00
|
|
|
/* return a new alpm_list_t target list containing all packages in the original
|
2005-03-14 20:51:43 -05:00
|
|
|
* target list, as well as all their un-needed dependencies. By un-needed,
|
|
|
|
* I mean dependencies that are *only* required for packages in the target
|
|
|
|
* list, so they can be safely removed. This function is recursive.
|
|
|
|
*/
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *i, *j, *k;
|
|
|
|
alpm_list_t *newtargs = targs;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if(db == NULL) {
|
|
|
|
return(newtargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = targs; i; i = i->next) {
|
2006-10-31 01:39:59 -05:00
|
|
|
pmpkg_t *pkg = i->data;
|
2007-02-20 03:44:32 -05:00
|
|
|
for(j = alpm_pkg_get_depends(pkg); j; j = j->next) {
|
2007-03-07 02:45:30 -05:00
|
|
|
pmdepend_t *depend = alpm_splitdep(j->data);
|
2007-03-03 04:43:16 -05:00
|
|
|
pmpkg_t *deppkg;
|
|
|
|
if(depend == NULL) {
|
2006-01-02 18:13:42 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-03 04:43:16 -05:00
|
|
|
deppkg = _alpm_db_get_pkgfromcache(db, depend->name);
|
|
|
|
if(deppkg == NULL) {
|
2007-02-20 03:44:32 -05:00
|
|
|
/* package not found... look for a provision instead */
|
2007-03-03 04:43:16 -05:00
|
|
|
alpm_list_t *provides = _alpm_db_whatprovides(db, depend->name);
|
2007-02-20 03:44:32 -05:00
|
|
|
if(!provides) {
|
2006-11-24 02:01:27 -05:00
|
|
|
/* Not found, that's fine, carry on */
|
2007-03-03 04:43:16 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("cannot find package \"%s\" or anything that provides it!"), depend->name);
|
2006-01-02 18:13:42 -05:00
|
|
|
continue;
|
|
|
|
}
|
2007-02-20 03:44:32 -05:00
|
|
|
for(k = provides; k; k = k->next) {
|
|
|
|
pmpkg_t *provpkg = k->data;
|
|
|
|
if(can_remove_package(db, provpkg, newtargs)) {
|
2007-03-12 01:55:14 -04:00
|
|
|
pmpkg_t *pkg = _alpm_pkg_dup(provpkg);
|
2006-12-05 02:00:22 -05:00
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("adding '%s' to the targets"), alpm_pkg_get_name(pkg));
|
2006-01-02 18:13:42 -05:00
|
|
|
|
2007-02-20 03:44:32 -05:00
|
|
|
/* add it to the target list */
|
|
|
|
newtargs = alpm_list_add(newtargs, pkg);
|
|
|
|
newtargs = _alpm_removedeps(db, newtargs);
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-04-28 03:54:25 -04:00
|
|
|
alpm_list_free(provides);
|
2007-03-03 04:43:16 -05:00
|
|
|
} else if(can_remove_package(db, deppkg, newtargs)) {
|
2007-03-12 01:55:14 -04:00
|
|
|
pmpkg_t *pkg = _alpm_pkg_dup(deppkg);
|
2007-02-20 03:44:32 -05:00
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("adding '%s' to the targets"), alpm_pkg_get_name(pkg));
|
2007-02-20 03:44:32 -05:00
|
|
|
|
|
|
|
/* add it to the target list */
|
|
|
|
newtargs = alpm_list_add(newtargs, pkg);
|
2006-02-17 17:35:26 -05:00
|
|
|
newtargs = _alpm_removedeps(db, newtargs);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
free(depend);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(newtargs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* populates *list with packages that need to be installed to satisfy all
|
2005-04-06 14:29:17 -04:00
|
|
|
* dependencies (recursive) for syncpkg
|
2005-03-14 20:51:43 -05:00
|
|
|
*
|
|
|
|
* make sure *list and *trail are already initialized
|
|
|
|
*/
|
2007-01-23 22:02:53 -05:00
|
|
|
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
|
|
|
alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
|
|
|
|
alpm_list_t **data)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *i, *j;
|
|
|
|
alpm_list_t *targ;
|
|
|
|
alpm_list_t *deps = NULL;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-04-02 15:30:09 -05:00
|
|
|
if(local == NULL || dbs_sync == NULL || syncpkg == NULL) {
|
|
|
|
return(-1);
|
|
|
|
}
|
2005-03-30 17:32:43 -05:00
|
|
|
|
2006-10-31 01:39:59 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("started resolving dependencies"));
|
2007-01-19 04:28:44 -05:00
|
|
|
targ = alpm_list_add(NULL, syncpkg);
|
2006-10-15 15:31:03 -04:00
|
|
|
deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ);
|
2007-04-28 03:54:25 -04:00
|
|
|
alpm_list_free(targ);
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
if(deps == NULL) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = deps; i; i = i->next) {
|
|
|
|
int found = 0;
|
|
|
|
pmdepmissing_t *miss = i->data;
|
2006-01-15 10:55:16 -05:00
|
|
|
pmpkg_t *sync = NULL;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-01-15 10:55:16 -05:00
|
|
|
/* check if one of the packages in *list already provides this dependency */
|
2006-01-18 17:37:16 -05:00
|
|
|
for(j = list; j && !found; j = j->next) {
|
2007-03-03 03:13:59 -05:00
|
|
|
pmpkg_t *sp = j->data;
|
|
|
|
if(alpm_list_find_str(alpm_pkg_get_provides(sp), miss->depend.name)) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(sp), miss->depend.name);
|
2006-01-18 17:37:16 -05:00
|
|
|
found = 1;
|
2005-10-21 15:55:24 -04:00
|
|
|
}
|
2006-01-15 10:55:16 -05:00
|
|
|
}
|
2006-01-18 17:37:16 -05:00
|
|
|
if(found) {
|
2006-01-15 10:55:16 -05:00
|
|
|
continue;
|
|
|
|
}
|
2005-10-21 15:55:24 -04:00
|
|
|
|
2006-01-15 10:55:16 -05:00
|
|
|
/* find the package in one of the repositories */
|
|
|
|
/* check literals */
|
|
|
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
2006-02-17 17:35:26 -05:00
|
|
|
sync = _alpm_db_get_pkgfromcache(j->data, miss->depend.name);
|
2006-01-15 10:55:16 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
/*TODO this autoresolves the first 'provides' package... we should fix this
|
|
|
|
* somehow */
|
2006-01-15 10:55:16 -05:00
|
|
|
/* check provides */
|
2007-03-03 03:13:59 -05:00
|
|
|
if(!sync) {
|
|
|
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
|
|
|
alpm_list_t *provides;
|
|
|
|
provides = _alpm_db_whatprovides(j->data, miss->depend.name);
|
|
|
|
if(provides) {
|
|
|
|
sync = provides->data;
|
|
|
|
}
|
2007-04-28 03:54:25 -04:00
|
|
|
alpm_list_free(provides);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-01-15 10:55:16 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
|
|
|
|
if(!sync) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)"),
|
2006-01-15 10:55:16 -05:00
|
|
|
miss->target, miss->depend.name);
|
2006-01-21 13:28:38 -05:00
|
|
|
if(data) {
|
2007-05-14 03:16:55 -04:00
|
|
|
if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
|
2006-01-21 13:28:38 -05:00
|
|
|
FREELIST(*data);
|
|
|
|
pm_errno = PM_ERR_MEMORY;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*miss = *(pmdepmissing_t *)i->data;
|
2007-01-19 04:28:44 -05:00
|
|
|
*data = alpm_list_add(*data, miss);
|
2006-01-21 13:28:38 -05:00
|
|
|
}
|
|
|
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
2006-01-15 10:55:16 -05:00
|
|
|
goto error;
|
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
if(_alpm_pkg_find(alpm_pkg_get_name(sync), list)) {
|
2006-01-15 10:55:16 -05:00
|
|
|
/* this dep is already in the target list */
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("dependency %s is already in the target list -- skipping"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(sync));
|
2006-01-15 10:55:16 -05:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
if(!_alpm_pkg_find(alpm_pkg_get_name(sync), trail)) {
|
2006-01-15 10:55:16 -05:00
|
|
|
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
|
|
|
|
* something we're not supposed to.
|
|
|
|
*/
|
|
|
|
int usedep = 1;
|
2007-03-03 03:13:59 -05:00
|
|
|
if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(sync))) {
|
2006-02-17 17:35:26 -05:00
|
|
|
pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL);
|
2006-01-15 10:55:16 -05:00
|
|
|
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
|
2007-04-26 21:08:34 -04:00
|
|
|
_alpm_pkg_free(dummypkg);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-01-15 10:55:16 -05:00
|
|
|
if(usedep) {
|
2007-01-19 04:28:44 -05:00
|
|
|
trail = alpm_list_add(trail, sync);
|
2006-02-17 17:35:26 -05:00
|
|
|
if(_alpm_resolvedeps(local, dbs_sync, sync, list, trail, trans, data)) {
|
2005-03-14 20:51:43 -05:00
|
|
|
goto error;
|
|
|
|
}
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("pulling dependency %s (needed by %s)"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(sync), alpm_pkg_get_name(syncpkg));
|
2007-01-19 04:28:44 -05:00
|
|
|
list = alpm_list_add(list, sync);
|
2005-03-14 20:51:43 -05:00
|
|
|
} else {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("cannot resolve dependencies for \"%s\""), miss->target);
|
2006-01-21 13:28:38 -05:00
|
|
|
if(data) {
|
2007-05-14 03:16:55 -04:00
|
|
|
if((miss = malloc(sizeof(pmdepmissing_t))) == NULL) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmdepmissing_t));
|
2006-01-21 13:28:38 -05:00
|
|
|
FREELIST(*data);
|
|
|
|
pm_errno = PM_ERR_MEMORY;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
*miss = *(pmdepmissing_t *)i->data;
|
2007-01-19 04:28:44 -05:00
|
|
|
*data = alpm_list_add(*data, miss);
|
2006-01-21 13:28:38 -05:00
|
|
|
}
|
|
|
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
2006-01-15 10:55:16 -05:00
|
|
|
goto error;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-01-15 10:55:16 -05:00
|
|
|
} else {
|
|
|
|
/* cycle detected -- skip it */
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("dependency cycle detected: %s"), sync->name);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
2006-10-31 01:39:59 -05:00
|
|
|
|
|
|
|
_alpm_log(PM_LOG_DEBUG, _("finished resolving dependencies"));
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
FREELIST(deps);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
error:
|
|
|
|
FREELIST(deps);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_dep_get_target(pmdepmissing_t *miss)
|
2006-11-22 04:03:41 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(miss != NULL, return(NULL));
|
|
|
|
|
|
|
|
return miss->target;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
pmdeptype_t SYMEXPORT alpm_dep_get_type(pmdepmissing_t *miss)
|
2006-11-22 04:03:41 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(-1));
|
|
|
|
ASSERT(miss != NULL, return(-1));
|
|
|
|
|
|
|
|
return miss->type;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
pmdepmod_t SYMEXPORT alpm_dep_get_mod(pmdepmissing_t *miss)
|
2006-11-22 04:03:41 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(-1));
|
|
|
|
ASSERT(miss != NULL, return(-1));
|
|
|
|
|
|
|
|
return miss->depend.mod;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_dep_get_name(pmdepmissing_t *miss)
|
2006-11-22 04:03:41 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(miss != NULL, return(NULL));
|
|
|
|
|
|
|
|
return miss->depend.name;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_dep_get_version(pmdepmissing_t *miss)
|
2006-11-22 04:03:41 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(miss != NULL, return(NULL));
|
|
|
|
|
|
|
|
return miss->depend.version;
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
/* vim: set ts=2 sw=2 noet: */
|