summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c5
-rw-r--r--lib/libalpm/alpm.h1
-rw-r--r--lib/libalpm/deps.c111
-rw-r--r--lib/libalpm/deps.h2
-rw-r--r--lib/libalpm/remove.c1
-rw-r--r--lib/libalpm/sync.c96
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c14
8 files changed, 138 insertions, 94 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 3b7eca72..286c8f2a 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -101,11 +101,8 @@ int add_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
_alpm_log(PM_LOG_WARNING, "replacing older version of %s %s by %s in target list", pkg->name, pkg->version, info->version);
FREEPKG(j->data);
j->data = info;
- return(0);
- } else {
- pm_errno = PM_ERR_TRANS_DUP_TARGET;
- goto error;
}
+ return(0);
}
}
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 6f2980e0..ff61a5e8 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -199,6 +199,7 @@ enum {
#define PM_TRANS_FLAG_CASCADE 0x10
#define PM_TRANS_FLAG_RECURSE 0x20
#define PM_TRANS_FLAG_DBONLY 0x40
+#define PM_TRANS_FLAG_SYSUPG 0x80
/* Events */
enum {
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index a0490d42..63512a82 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -25,6 +25,7 @@
/* pacman */
#include "util.h"
#include "log.h"
+#include "error.h"
#include "list.h"
#include "package.h"
#include "db.h"
@@ -541,13 +542,16 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
*
* make sure *list and *trail are already initialized
*/
-int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list, PMList *trail, PMList **data)
+int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail)
{
PMList *i, *j;
PMList *targ;
PMList *deps = NULL;
+ PMList **data = NULL;
- targ = pm_list_add(NULL, sync->spkg);
+ _alpm_log(PM_LOG_FUNCTION, "%s => %s", __FUNCTION__, syncpkg->name);
+
+ targ = pm_list_add(NULL, syncpkg);
deps = checkdeps(local, PM_TRANS_TYPE_ADD, targ);
FREELISTPTR(targ);
@@ -559,99 +563,68 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
int found = 0;
pmdepmissing_t *miss = i->data;
+ printf("pkg=%s: dep.name=%s\n", miss->target, miss->depend.name);
+
/* XXX: conflicts are now treated specially in the _add and _sync functions */
- /*if(miss->type == CONFLICT) {
+ /*if(miss->type == PM_DEP_TYPE_CONFLICT) {
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (it conflict with %s)", miss->target, miss->depend.name);
return(1);
} else*/
if(miss->type == PM_DEP_TYPE_DEPEND) {
- pmsync_t *sync = NULL;
-
+ pmpkg_t *sync = NULL;
/* find the package in one of the repositories */
-
/* check literals */
- for(j = databases; !sync && j; j = j->next) {
+ for(j = dbs_sync; !sync && j; j = j->next) {
PMList *k;
pmdb_t *dbs = j->data;
-
for(k = db_get_pkgcache(dbs); !sync && k; k = k->next) {
pmpkg_t *pkg = k->data;
-
if(!strcmp(miss->depend.name, pkg->name)) {
- sync = sync_new(PM_SYSUPG_DEPEND, NULL, k->data);
- if(sync == NULL) {
- pm_errno = PM_ERR_MEMORY;
- goto error;
- }
- /* ORE
- sync->pkg->reason = PM_PKG_REASON_DEPEND;*/
+
+ /* re-fetch the package record with dependency info */
+ sync = db_scan(dbs, pkg->name, INFRQ_DESC | INFRQ_DEPENDS);
+ sync->reason = PM_PKG_REASON_DEPEND;
}
}
}
-
/* check provides */
- /* ORE
- for(j = databases; !s && j; j = j->next) {
+ for(j = dbs_sync; !sync && j; j = j->next) {
PMList *provides;
-
- provides = _alpm_db_whatprovides(j->data, miss->depend.name);
+ pmdb_t *dbs = j->data;
+ provides = _alpm_db_whatprovides(dbs, miss->depend.name);
if(provides) {
- s = sync_new(PM_SYSUPG_DEPEND, NULL, !!!provides->data!!!);
- if(s == NULL) {
- pm_errno = PM_ERR_MEMORY;
- goto error;
- }
- sync->pkg->reason = PM_PKG_REASON_DEPEND;
- }
- FREELIST(provides);
- }*/
-
- if(sync == NULL) {
- pmdepmissing_t *m = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t));
- if(m == NULL) {
- /* ORE
- Free memory before leaving */
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ /* re-fetch the package record with dependency info */
+ sync = db_scan(dbs, provides->data, INFRQ_DESC | INFRQ_DEPENDS);
+ sync->reason = PM_PKG_REASON_DEPEND;
}
- *m = *(pmdepmissing_t *)i->data;
- *data = pm_list_add(*data, m);
- continue;
+ FREELISTPTR(provides);
}
-
- if(*data) {
- /* there is at least an unresolvable dep... so we only
- * continue to get the whole list of unresolvable deps */
- continue;
+ if(sync == NULL) {
+ _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set", miss->target, miss->depend.name);
+ return(1);
}
-
found = 0;
for(j = list; j && !found; j = j->next) {
- pmsync_t *tmp = j->data;
-
- if(tmp && !strcmp(tmp->spkg->name, sync->spkg->name)) {
+ pmpkg_t *tmp = j->data;
+ if(tmp && !strcmp(tmp->name, sync->name)) {
found = 1;
}
}
-
if(found) {
/* this dep is already in the target list */
FREE(sync);
continue;
}
-
- _alpm_log(PM_LOG_FLOW2, "resolving %s", sync->spkg->name);
+ _alpm_log(PM_LOG_FLOW2, "resolving %s", sync->name);
found = 0;
for(j = trail; j; j = j->next) {
- pmsync_t *tmp = j->data;
-
- if(tmp && !strcmp(tmp->spkg->name, sync->spkg->name)) {
+ pmpkg_t *tmp = j->data;
+ if(tmp && !strcmp(tmp->name, sync->name)) {
found = 1;
}
}
-
if(!found) {
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
* something we're not supposed to.
@@ -659,8 +632,8 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
int usedep = 1;
found = 0;
/* ORE
- for(j = pmo_ignorepkg; j && !found; j = j->next) {
- if(!strcmp(j->data, sync->pkg->name)) {
+ for(j = handle->ignorepkg; j && !found; j = j->next) {
+ if(!strcmp(j->data, sync->name)) {
found = 1;
}
}
@@ -668,17 +641,18 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
if(!strcmp(j->data, sync->pkg->name)) {
found = 1;
}
- }
+ }*/
if(found) {
+ /* ORE
usedep = yesno("%s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ",
- miss->target, sync->pkg->name);
- }*/
+ miss->target, sync->pkg->name);*/
+ }
if(usedep) {
trail = pm_list_add(trail, sync);
- if(resolvedeps(local, databases, sync, list, trail, data)) {
+ if(resolvedeps(local, dbs_sync, sync, list, trail)) {
goto error;
}
- _alpm_log(PM_LOG_FLOW2, "adding %s-%s", sync->spkg->name, sync->spkg->version);
+ _alpm_log(PM_LOG_FLOW2, "adding %s-%s", sync->name, sync->version);
list = pm_list_add(list, sync);
} else {
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
@@ -687,7 +661,7 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
}
} else {
/* cycle detected -- skip it */
- _alpm_log(PM_LOG_FLOW2, "dependency cycle detected: %s", sync->spkg->name);
+ _alpm_log(PM_LOG_FLOW2, "dependency cycle detected: %s", sync->name);
FREE(sync);
}
}
@@ -695,10 +669,9 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
FREELIST(deps);
- if(*data) {
- pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
- return(-1);
- }
+ /*if(*data) {
+ RET_ERR(PM_ERR_UNRESOLVABLE_DEPS, -1);
+ }*/
return(0);
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index b45fa48c..cc0d891b 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -40,7 +40,7 @@ PMList *sortbydeps(PMList *targets, int mode);
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
int splitdep(char *depstr, pmdepend_t *depend);
PMList *removedeps(pmdb_t *db, PMList *targs);
-int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list, PMList *trail, PMList **data);
+int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail);
#endif /* _ALPM_DEPS_H */
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 9b9f91dc..70bfeecf 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -208,7 +208,6 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans)
_alpm_log(PM_LOG_ERROR, "failed to remove database entry %s/%s-%s", db->treename, info->name, info->version);
}
-
/* update dependency packages' REQUIREDBY fields */
_alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields");
for(lp = info->depends; lp; lp = lp->next) {
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 1d4108dd..8e839b0c 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -26,6 +26,7 @@
/* pacman */
#include "log.h"
#include "util.h"
+#include "error.h"
#include "list.h"
#include "package.h"
#include "db.h"
@@ -53,6 +54,11 @@ pmsync_t *sync_new(int type, pmpkg_t *lpkg, pmpkg_t *spkg)
return(sync);
}
+int sync_parsedb(char *archive)
+{
+ return(0);
+}
+
int sync_sysupgrade(PMList **data)
{
PMList *i, *j, *k;
@@ -121,24 +127,20 @@ int sync_sysupgrade(PMList **data)
/* local version is newer */
_alpm_log(PM_LOG_FLOW1, "%s-%s: local version is newer",
local->name, local->version);
- continue;
} else if(cmp == 0) {
/* versions are identical */
- continue;
} else if(pm_list_is_strin(i->data, handle->ignorepkg)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_FLOW1, "%s-%s: ignoring package upgrade (%s)",
local->name, local->version, spkg->version);
- continue;
- }
-
- sync = sync_new(PM_SYSUPG_UPGRADE, local, spkg);
- if(sync == NULL) {
- pm_errno = PM_ERR_MEMORY;
- goto error;
+ } else {
+ sync = sync_new(PM_SYSUPG_UPGRADE, local, spkg);
+ if(sync == NULL) {
+ pm_errno = PM_ERR_MEMORY;
+ goto error;
+ }
+ targets = pm_list_add(targets, sync);
}
-
- targets = pm_list_add(targets, sync);
}
*data = targets;
@@ -150,8 +152,69 @@ error:
return(-1);
}
-int sync_resolvedeps(PMList **syncs)
+int sync_addtarget(pmdb_t *db, PMList *dbs_sync, pmtrans_t *trans, char *name)
{
+ char targline[(PKG_NAME_LEN-1)+1+(DB_TREENAME_LEN-1)+1];
+ char *targ, *treename;
+ PMList *j;
+ pmpkg_t *local;
+ pmpkg_t *sync = NULL;
+ int cmp;
+
+ ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
+ ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
+ ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
+
+ strncpy(targline, name, (PKG_NAME_LEN-1)+1+(DB_TREENAME_LEN-1)+1);
+ targ = strchr(targline, '/');
+ if(targ) {
+ *targ = '\0';
+ targ++;
+ treename = targline;
+ for(j = dbs_sync; j && !sync; j = j->next) {
+ pmdb_t *dbs = j->data;
+ if(strcmp(dbs->treename, targline) == 0) {
+ sync = alpm_db_readpkg(dbs, targ);
+ }
+ }
+ } else {
+ targ = targline;
+ for(j = dbs_sync; j && !sync; j = j->next) {
+ pmdb_t *dbs = j->data;
+ sync = alpm_db_readpkg(dbs, targ);
+ }
+ }
+
+ if(sync == NULL) {
+ RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
+ }
+
+ /* if not a sysupgrade, compare versions and determine if it is necessary */
+ if(!trans->flags & PM_TRANS_FLAG_SYSUPG) {
+ local = alpm_db_readpkg(db, name);
+ if(local) {
+ cmp = alpm_pkg_vercmp(local->version, sync->version);
+ if(cmp > 0) {
+ /* local version is newer - get confirmation first */
+ /* ORE
+ if(!yesno(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
+ }*/
+ _alpm_log(PM_LOG_WARNING, "%s-%s: local version is newer -- skipping");
+ return(0);
+ } else if(cmp == 0) {
+ /* versions are identical */
+ /* ORE
+ if(!yesno(":: %s-%s: is up to date. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
+ }*/
+ _alpm_log(PM_LOG_WARNING, "%s-%s: is up to date -- skipping");
+ return(0);
+ }
+ }
+ }
+
+ /* add the package to the transaction */
+ trans->packages = pm_list_add(trans->packages, sync);
+
return(0);
}
@@ -159,10 +222,12 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
{
PMList *i;
PMList *trail = NULL;
+ PMList *list = NULL;
/* Resolve targets dependencies */
- for(i = trans->targets; i; i = i->next) {
- if(resolvedeps(handle->db_local, handle->dbs_sync, i->data, trans->targets, trail, data) == -1) {
+ for(i = trans->packages; i; i = i->next) {
+ pmpkg_t *sync = i->data;
+ if(resolvedeps(handle->db_local, handle->dbs_sync, sync, list, trail) == -1) {
/* pm_errno is set by resolvedeps */
goto error;
}
@@ -204,11 +269,8 @@ int sync_commit(pmdb_t *db, pmtrans_t *trans)
for(i = files; i; i = i->next) {
trans_addtarget(tr, i->data);
}
-
trans_prepare(tr, &data);
-
trans_commit(tr);
-
trans_free(tr);
/* propagate replaced packages' requiredby fields to their new owners */
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index 00bd7c57..667dc4f4 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -39,6 +39,8 @@ pmsyncpkg_t *find_pkginsync(char *needle, PMList *haystack);
PMList *rm_pkginsync(char *needle, PMList *haystack);*/
int sync_sysupgrade(PMList **data);
+
+int sync_addtarget(pmdb_t *db, PMList *dbs_sync, pmtrans_t *trans, char *name);
int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data);
int sync_commit(pmdb_t *db, pmtrans_t *trans);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 7bd37e1f..6e278cd7 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -61,7 +61,12 @@ void trans_free(pmtrans_t *trans)
}
FREELIST(trans->targets);
- FREELISTPKGS(trans->packages);
+ /* ORE - ugly */
+ if(trans->type == PM_TRANS_TYPE_SYNC) {
+ FREELISTPTR(trans->packages);
+ } else {
+ FREELISTPKGS(trans->packages);
+ }
free(trans);
}
@@ -109,9 +114,14 @@ int trans_addtarget(pmtrans_t *trans, char *target)
return(-1);
}
break;
+ case PM_TRANS_TYPE_SYNC:
+ if(sync_addtarget(handle->db_local, handle->dbs_sync, trans, target) == -1) {
+ /* pm_errno is set by add_loadtarget() */
+ return(-1);
+ }
+ break;
}
trans->targets = pm_list_add(trans->targets, strdup(target));
- trans->state = STATE_INITIALIZED;
return(0);
}