started the work on "pacman_sync"
This commit is contained in:
parent
b009c5bafa
commit
4d21e4f721
9 changed files with 193 additions and 212 deletions
|
@ -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);
|
_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);
|
FREEPKG(j->data);
|
||||||
j->data = info;
|
j->data = info;
|
||||||
return(0);
|
|
||||||
} else {
|
|
||||||
pm_errno = PM_ERR_TRANS_DUP_TARGET;
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,7 @@ enum {
|
||||||
#define PM_TRANS_FLAG_CASCADE 0x10
|
#define PM_TRANS_FLAG_CASCADE 0x10
|
||||||
#define PM_TRANS_FLAG_RECURSE 0x20
|
#define PM_TRANS_FLAG_RECURSE 0x20
|
||||||
#define PM_TRANS_FLAG_DBONLY 0x40
|
#define PM_TRANS_FLAG_DBONLY 0x40
|
||||||
|
#define PM_TRANS_FLAG_SYSUPG 0x80
|
||||||
|
|
||||||
/* Events */
|
/* Events */
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "error.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
@ -541,13 +542,16 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
|
||||||
*
|
*
|
||||||
* make sure *list and *trail are already initialized
|
* 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 *i, *j;
|
||||||
PMList *targ;
|
PMList *targ;
|
||||||
PMList *deps = NULL;
|
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);
|
deps = checkdeps(local, PM_TRANS_TYPE_ADD, targ);
|
||||||
FREELISTPTR(targ);
|
FREELISTPTR(targ);
|
||||||
|
|
||||||
|
@ -559,99 +563,68 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
|
||||||
int found = 0;
|
int found = 0;
|
||||||
pmdepmissing_t *miss = i->data;
|
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 */
|
/* 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);
|
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (it conflict with %s)", miss->target, miss->depend.name);
|
||||||
return(1);
|
return(1);
|
||||||
} else*/
|
} else*/
|
||||||
|
|
||||||
if(miss->type == PM_DEP_TYPE_DEPEND) {
|
if(miss->type == PM_DEP_TYPE_DEPEND) {
|
||||||
pmsync_t *sync = NULL;
|
pmpkg_t *sync = NULL;
|
||||||
|
|
||||||
/* find the package in one of the repositories */
|
/* find the package in one of the repositories */
|
||||||
|
|
||||||
/* check literals */
|
/* check literals */
|
||||||
for(j = databases; !sync && j; j = j->next) {
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
||||||
PMList *k;
|
PMList *k;
|
||||||
pmdb_t *dbs = j->data;
|
pmdb_t *dbs = j->data;
|
||||||
|
|
||||||
for(k = db_get_pkgcache(dbs); !sync && k; k = k->next) {
|
for(k = db_get_pkgcache(dbs); !sync && k; k = k->next) {
|
||||||
pmpkg_t *pkg = k->data;
|
pmpkg_t *pkg = k->data;
|
||||||
|
|
||||||
if(!strcmp(miss->depend.name, pkg->name)) {
|
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 */
|
/* check provides */
|
||||||
/* ORE
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
||||||
for(j = databases; !s && j; j = j->next) {
|
|
||||||
PMList *provides;
|
PMList *provides;
|
||||||
|
pmdb_t *dbs = j->data;
|
||||||
provides = _alpm_db_whatprovides(j->data, miss->depend.name);
|
provides = _alpm_db_whatprovides(dbs, miss->depend.name);
|
||||||
if(provides) {
|
if(provides) {
|
||||||
s = sync_new(PM_SYSUPG_DEPEND, NULL, !!!provides->data!!!);
|
/* re-fetch the package record with dependency info */
|
||||||
if(s == NULL) {
|
sync = db_scan(dbs, provides->data, INFRQ_DESC | INFRQ_DEPENDS);
|
||||||
pm_errno = PM_ERR_MEMORY;
|
sync->reason = PM_PKG_REASON_DEPEND;
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
sync->pkg->reason = PM_PKG_REASON_DEPEND;
|
FREELISTPTR(provides);
|
||||||
}
|
}
|
||||||
FREELIST(provides);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if(sync == NULL) {
|
if(sync == NULL) {
|
||||||
pmdepmissing_t *m = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set", miss->target, miss->depend.name);
|
||||||
if(m == NULL) {
|
return(1);
|
||||||
/* ORE
|
|
||||||
Free memory before leaving */
|
|
||||||
pm_errno = PM_ERR_MEMORY;
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
*m = *(pmdepmissing_t *)i->data;
|
|
||||||
*data = pm_list_add(*data, m);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*data) {
|
|
||||||
/* there is at least an unresolvable dep... so we only
|
|
||||||
* continue to get the whole list of unresolvable deps */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
found = 0;
|
found = 0;
|
||||||
for(j = list; j && !found; j = j->next) {
|
for(j = list; j && !found; j = j->next) {
|
||||||
pmsync_t *tmp = j->data;
|
pmpkg_t *tmp = j->data;
|
||||||
|
if(tmp && !strcmp(tmp->name, sync->name)) {
|
||||||
if(tmp && !strcmp(tmp->spkg->name, sync->spkg->name)) {
|
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(found) {
|
if(found) {
|
||||||
/* this dep is already in the target list */
|
/* this dep is already in the target list */
|
||||||
FREE(sync);
|
FREE(sync);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "resolving %s", sync->name);
|
||||||
_alpm_log(PM_LOG_FLOW2, "resolving %s", sync->spkg->name);
|
|
||||||
found = 0;
|
found = 0;
|
||||||
for(j = trail; j; j = j->next) {
|
for(j = trail; j; j = j->next) {
|
||||||
pmsync_t *tmp = j->data;
|
pmpkg_t *tmp = j->data;
|
||||||
|
if(tmp && !strcmp(tmp->name, sync->name)) {
|
||||||
if(tmp && !strcmp(tmp->spkg->name, sync->spkg->name)) {
|
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!found) {
|
if(!found) {
|
||||||
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
|
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
|
||||||
* something we're not supposed to.
|
* 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;
|
int usedep = 1;
|
||||||
found = 0;
|
found = 0;
|
||||||
/* ORE
|
/* ORE
|
||||||
for(j = pmo_ignorepkg; j && !found; j = j->next) {
|
for(j = handle->ignorepkg; j && !found; j = j->next) {
|
||||||
if(!strcmp(j->data, sync->pkg->name)) {
|
if(!strcmp(j->data, sync->name)) {
|
||||||
found = 1;
|
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)) {
|
if(!strcmp(j->data, sync->pkg->name)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(found) {
|
|
||||||
usedep = yesno("%s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ",
|
|
||||||
miss->target, sync->pkg->name);
|
|
||||||
}*/
|
}*/
|
||||||
|
if(found) {
|
||||||
|
/* ORE
|
||||||
|
usedep = yesno("%s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ",
|
||||||
|
miss->target, sync->pkg->name);*/
|
||||||
|
}
|
||||||
if(usedep) {
|
if(usedep) {
|
||||||
trail = pm_list_add(trail, sync);
|
trail = pm_list_add(trail, sync);
|
||||||
if(resolvedeps(local, databases, sync, list, trail, data)) {
|
if(resolvedeps(local, dbs_sync, sync, list, trail)) {
|
||||||
goto error;
|
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);
|
list = pm_list_add(list, sync);
|
||||||
} else {
|
} else {
|
||||||
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
|
_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 {
|
} else {
|
||||||
/* cycle detected -- skip it */
|
/* 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);
|
FREE(sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,10 +669,9 @@ int resolvedeps(pmdb_t *local, PMList *databases, pmsync_t *sync, PMList *list,
|
||||||
|
|
||||||
FREELIST(deps);
|
FREELIST(deps);
|
||||||
|
|
||||||
if(*data) {
|
/*if(*data) {
|
||||||
pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
|
RET_ERR(PM_ERR_UNRESOLVABLE_DEPS, -1);
|
||||||
return(-1);
|
}*/
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ PMList *sortbydeps(PMList *targets, int mode);
|
||||||
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
|
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
|
||||||
int splitdep(char *depstr, pmdepend_t *depend);
|
int splitdep(char *depstr, pmdepend_t *depend);
|
||||||
PMList *removedeps(pmdb_t *db, PMList *targs);
|
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 */
|
#endif /* _ALPM_DEPS_H */
|
||||||
|
|
||||||
|
|
|
@ -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);
|
_alpm_log(PM_LOG_ERROR, "failed to remove database entry %s/%s-%s", db->treename, info->name, info->version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* update dependency packages' REQUIREDBY fields */
|
/* update dependency packages' REQUIREDBY fields */
|
||||||
_alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields");
|
_alpm_log(PM_LOG_FLOW2, "updating dependency packages 'requiredby' fields");
|
||||||
for(lp = info->depends; lp; lp = lp->next) {
|
for(lp = info->depends; lp; lp = lp->next) {
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "error.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
@ -53,6 +54,11 @@ pmsync_t *sync_new(int type, pmpkg_t *lpkg, pmpkg_t *spkg)
|
||||||
return(sync);
|
return(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sync_parsedb(char *archive)
|
||||||
|
{
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
int sync_sysupgrade(PMList **data)
|
int sync_sysupgrade(PMList **data)
|
||||||
{
|
{
|
||||||
PMList *i, *j, *k;
|
PMList *i, *j, *k;
|
||||||
|
@ -121,25 +127,21 @@ int sync_sysupgrade(PMList **data)
|
||||||
/* local version is newer */
|
/* local version is newer */
|
||||||
_alpm_log(PM_LOG_FLOW1, "%s-%s: local version is newer",
|
_alpm_log(PM_LOG_FLOW1, "%s-%s: local version is newer",
|
||||||
local->name, local->version);
|
local->name, local->version);
|
||||||
continue;
|
|
||||||
} else if(cmp == 0) {
|
} else if(cmp == 0) {
|
||||||
/* versions are identical */
|
/* versions are identical */
|
||||||
continue;
|
|
||||||
} else if(pm_list_is_strin(i->data, handle->ignorepkg)) {
|
} else if(pm_list_is_strin(i->data, handle->ignorepkg)) {
|
||||||
/* package should be ignored (IgnorePkg) */
|
/* package should be ignored (IgnorePkg) */
|
||||||
_alpm_log(PM_LOG_FLOW1, "%s-%s: ignoring package upgrade (%s)",
|
_alpm_log(PM_LOG_FLOW1, "%s-%s: ignoring package upgrade (%s)",
|
||||||
local->name, local->version, spkg->version);
|
local->name, local->version, spkg->version);
|
||||||
continue;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
sync = sync_new(PM_SYSUPG_UPGRADE, local, spkg);
|
sync = sync_new(PM_SYSUPG_UPGRADE, local, spkg);
|
||||||
if(sync == NULL) {
|
if(sync == NULL) {
|
||||||
pm_errno = PM_ERR_MEMORY;
|
pm_errno = PM_ERR_MEMORY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
targets = pm_list_add(targets, sync);
|
targets = pm_list_add(targets, sync);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*data = targets;
|
*data = targets;
|
||||||
|
|
||||||
|
@ -150,8 +152,69 @@ error:
|
||||||
return(-1);
|
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);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +222,12 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||||
{
|
{
|
||||||
PMList *i;
|
PMList *i;
|
||||||
PMList *trail = NULL;
|
PMList *trail = NULL;
|
||||||
|
PMList *list = NULL;
|
||||||
|
|
||||||
/* Resolve targets dependencies */
|
/* Resolve targets dependencies */
|
||||||
for(i = trans->targets; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
if(resolvedeps(handle->db_local, handle->dbs_sync, i->data, trans->targets, trail, data) == -1) {
|
pmpkg_t *sync = i->data;
|
||||||
|
if(resolvedeps(handle->db_local, handle->dbs_sync, sync, list, trail) == -1) {
|
||||||
/* pm_errno is set by resolvedeps */
|
/* pm_errno is set by resolvedeps */
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -204,11 +269,8 @@ int sync_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
for(i = files; i; i = i->next) {
|
for(i = files; i; i = i->next) {
|
||||||
trans_addtarget(tr, i->data);
|
trans_addtarget(tr, i->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
trans_prepare(tr, &data);
|
trans_prepare(tr, &data);
|
||||||
|
|
||||||
trans_commit(tr);
|
trans_commit(tr);
|
||||||
|
|
||||||
trans_free(tr);
|
trans_free(tr);
|
||||||
|
|
||||||
/* propagate replaced packages' requiredby fields to their new owners */
|
/* propagate replaced packages' requiredby fields to their new owners */
|
||||||
|
|
|
@ -39,6 +39,8 @@ pmsyncpkg_t *find_pkginsync(char *needle, PMList *haystack);
|
||||||
PMList *rm_pkginsync(char *needle, PMList *haystack);*/
|
PMList *rm_pkginsync(char *needle, PMList *haystack);*/
|
||||||
|
|
||||||
int sync_sysupgrade(PMList **data);
|
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_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data);
|
||||||
int sync_commit(pmdb_t *db, pmtrans_t *trans);
|
int sync_commit(pmdb_t *db, pmtrans_t *trans);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,12 @@ void trans_free(pmtrans_t *trans)
|
||||||
}
|
}
|
||||||
|
|
||||||
FREELIST(trans->targets);
|
FREELIST(trans->targets);
|
||||||
|
/* ORE - ugly */
|
||||||
|
if(trans->type == PM_TRANS_TYPE_SYNC) {
|
||||||
|
FREELISTPTR(trans->packages);
|
||||||
|
} else {
|
||||||
FREELISTPKGS(trans->packages);
|
FREELISTPKGS(trans->packages);
|
||||||
|
}
|
||||||
|
|
||||||
free(trans);
|
free(trans);
|
||||||
}
|
}
|
||||||
|
@ -109,9 +114,14 @@ int trans_addtarget(pmtrans_t *trans, char *target)
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
break;
|
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->targets = pm_list_add(trans->targets, strdup(target));
|
||||||
trans->state = STATE_INITIALIZED;
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -364,7 +364,7 @@ static int sync_list(list_t *syncs, list_t *targets)
|
||||||
|
|
||||||
int pacman_sync(list_t *targets)
|
int pacman_sync(list_t *targets)
|
||||||
{
|
{
|
||||||
int allgood = 1, confirm = 0;
|
int confirm = 0;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
list_t *final = NULL;
|
list_t *final = NULL;
|
||||||
list_t *i, *j;
|
list_t *i, *j;
|
||||||
|
@ -420,19 +420,19 @@ int pacman_sync(list_t *targets)
|
||||||
return(sync_list(pmc_syncs, targets));
|
return(sync_list(pmc_syncs, targets));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Step 1: create a new transaction...
|
||||||
|
*/
|
||||||
|
if(alpm_trans_init(PM_TRANS_TYPE_SYNC, pmo_flags, NULL) == -1) {
|
||||||
|
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
|
||||||
|
retval = 1;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if(pmo_s_upgrade) {
|
if(pmo_s_upgrade) {
|
||||||
alpm_logaction("starting full system upgrade");
|
alpm_logaction("starting full system upgrade");
|
||||||
|
|
||||||
if(alpm_sync_sysupgrade(&data) == -1) {
|
if(alpm_sync_sysupgrade(&data) == -1) {
|
||||||
if(pm_errno == PM_ERR_UNRESOLVABLE_DEPS) {
|
|
||||||
ERR(NL, "cannot resolve dependencies\n");
|
|
||||||
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
|
|
||||||
PM_DEPMISS *miss = alpm_list_getdata(lp);
|
|
||||||
ERR(NL, " %s: \"%s\" is not in the package set\n", alpm_dep_getinfo(miss, PM_DEP_TARGET), alpm_dep_getinfo(miss, PM_DEP_NAME));
|
|
||||||
}
|
|
||||||
alpm_list_free(data);
|
|
||||||
} else {
|
|
||||||
ERR(NL, "%s\n", alpm_strerror(pm_errno));
|
ERR(NL, "%s\n", alpm_strerror(pm_errno));
|
||||||
}
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,13 +446,15 @@ int pacman_sync(list_t *targets)
|
||||||
PM_SYNC *sync = alpm_list_getdata(lp);
|
PM_SYNC *sync = alpm_list_getdata(lp);
|
||||||
|
|
||||||
if(!strcmp("pacman", alpm_pkg_getinfo(alpm_sync_getinfo(sync, PM_SYNC_SYNCPKG), PM_PKG_NAME))) {
|
if(!strcmp("pacman", alpm_pkg_getinfo(alpm_sync_getinfo(sync, PM_SYNC_SYNCPKG), PM_PKG_NAME))) {
|
||||||
ERR(NL, "\n:: pacman has detected a newer version of the \"pacman\" package.\n");
|
MSG(NL, "\n:: pacman has detected a newer version of the \"pacman\" package.\n");
|
||||||
ERR(NL, ":: It is recommended that you allow pacman to upgrade itself\n");
|
MSG(NL, ":: It is recommended that you allow pacman to upgrade itself\n");
|
||||||
ERR(NL, ":: first, then you can re-run the operation with the newer version.\n");
|
MSG(NL, ":: first, then you can re-run the operation with the newer version.\n");
|
||||||
ERR(NL, "::\n");
|
MSG(NL, "::\n");
|
||||||
if(yesno(":: Upgrade pacman first? [Y/n] ")) {
|
if(yesno(":: Upgrade pacman first? [Y/n] ")) {
|
||||||
|
/* ORE
|
||||||
|
we should substitute existing targets with "pacman" */
|
||||||
alpm_list_free(data);
|
alpm_list_free(data);
|
||||||
data = NULL;
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,56 +474,30 @@ int pacman_sync(list_t *targets)
|
||||||
|
|
||||||
switch((int)alpm_sync_getinfo(sync, PM_SYNC_TYPE)) {
|
switch((int)alpm_sync_getinfo(sync, PM_SYNC_TYPE)) {
|
||||||
case PM_SYSUPG_REPLACE:
|
case PM_SYSUPG_REPLACE:
|
||||||
|
MSG(NL, "Replace %s by '%s-%s'\n", lpkgname, spkgname, spkgver);
|
||||||
if(yesno(":: Replace %s with %s from \"%s\"? [Y/n] ", lpkgname, spkgname, NULL/*dbs->db->treename*/)) {
|
if(yesno(":: Replace %s with %s from \"%s\"? [Y/n] ", lpkgname, spkgname, NULL/*dbs->db->treename*/)) {
|
||||||
DBG("adding '%s-%s' to replaces candidates\n", spkgname, spkgver);
|
|
||||||
final = list_add(final, spkg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PM_SYSUPG_UPGRADE:
|
case PM_SYSUPG_UPGRADE:
|
||||||
DBG("Upgrade %s (%s => %s)\n", lpkgname, lpkgver, spkgver);
|
MSG(NL, "Upgrade %s (%s => %s)\n", lpkgname, lpkgver, spkgver);
|
||||||
final = list_add(final, spkg);
|
targets = list_add(targets, strdup(spkgname));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alpm_list_free(data);
|
alpm_list_free(data);
|
||||||
} else {
|
}
|
||||||
/* process targets */
|
|
||||||
|
/* and add targets to it
|
||||||
|
*/
|
||||||
for(i = targets; i; i = i->next) {
|
for(i = targets; i; i = i->next) {
|
||||||
char *treename;
|
char *targ = i->data;
|
||||||
char *targ;
|
|
||||||
char *targline;
|
|
||||||
PM_PKG *local = NULL;
|
|
||||||
|
|
||||||
targline = strdup((char *)i->data);
|
if(alpm_trans_addtarget(targ) == -1) {
|
||||||
targ = index(targline, '/');
|
if(pm_errno == PM_ERR_PKG_NOT_FOUND) {
|
||||||
if(targ) {
|
PM_GRP *grp;
|
||||||
*targ = '\0';
|
|
||||||
targ++;
|
|
||||||
treename = targline;
|
|
||||||
} else {
|
|
||||||
targ = targline;
|
|
||||||
treename = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(treename == NULL) {
|
|
||||||
for(j = pmc_syncs; j && !local; j = j->next) {
|
|
||||||
sync_t *sync = j->data;
|
|
||||||
local = alpm_db_readpkg(sync->db, targ);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(j = pmc_syncs; j && !local; j = j->next) {
|
|
||||||
sync_t *sync = j->data;
|
|
||||||
if(strcmp(sync->treename, treename) == 0) {
|
|
||||||
local = alpm_db_readpkg(sync->db, targ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(local == NULL) {
|
|
||||||
PM_GRP *grp = NULL;
|
|
||||||
/* target not found: check if it's a group */
|
/* target not found: check if it's a group */
|
||||||
for(j = pmc_syncs; j && !grp; j = j->next) {
|
for(j = pmc_syncs; j && !grp; j = j->next) {
|
||||||
sync_t *sync = j->data;
|
sync_t *sync = j->data;
|
||||||
|
@ -548,68 +524,19 @@ int pacman_sync(list_t *targets)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(grp == NULL) {
|
if(grp == NULL) {
|
||||||
ERR(NL, "package \"%s\" not found", targ);
|
ERR(NL, "failed to add target '%s': not found in sync db\n", targ);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
continue;
|
||||||
if(treename) {
|
} else {
|
||||||
FREE(targline);
|
ERR(NL, "failed to add target '%s': %s\n", (char *)i->data, alpm_strerror(pm_errno));
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!pmo_s_downloadonly && !pmo_s_printuris) {
|
|
||||||
/* this is an upgrade, compare versions and determine if it is necessary */
|
|
||||||
for(i = targets; i; i = i->next) {
|
|
||||||
int cmp;
|
|
||||||
PM_PKG *local, *sync;
|
|
||||||
char *lpkgname, *lpkgver, *spkgver;
|
|
||||||
|
|
||||||
local = alpm_db_readpkg(db_local, i->data);
|
|
||||||
lpkgname = alpm_pkg_getinfo(local, PM_PKG_NAME);
|
|
||||||
lpkgver = alpm_pkg_getinfo(local, PM_PKG_VERSION);
|
|
||||||
|
|
||||||
sync = alpm_db_readpkg(db_local, i->data);
|
|
||||||
spkgver = alpm_pkg_getinfo(sync, PM_PKG_VERSION);
|
|
||||||
|
|
||||||
cmp = alpm_pkg_vercmp(lpkgver, spkgver);
|
|
||||||
if(cmp > 0) {
|
|
||||||
/* local version is newer - get confirmation first */
|
|
||||||
if(!yesno(":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
|
|
||||||
/* ORE
|
|
||||||
char *data = list_remove(targets, lpkgname);
|
|
||||||
free(data);*/
|
|
||||||
}
|
|
||||||
} else if(cmp == 0) {
|
|
||||||
/* versions are identical */
|
|
||||||
if(!yesno(":: %s-%s: is up to date. Upgrade anyway? [Y/n] ", lpkgname, lpkgver)) {
|
|
||||||
/* ORE
|
|
||||||
char *data = list_remove(targets, lpkgname);
|
|
||||||
free(data);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Step 1: create a new transaction */
|
|
||||||
if(alpm_trans_init(PM_TRANS_TYPE_SYNC, pmo_flags, NULL) == -1) {
|
|
||||||
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
|
|
||||||
retval = 1;
|
retval = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* and add targets to it */
|
|
||||||
for(i = targets; i; i = i->next) {
|
|
||||||
if(alpm_trans_addtarget(i->data) == -1) {
|
|
||||||
ERR(NL, "failed to add target '%s' (%s)\n", (char *)i->data, alpm_strerror(pm_errno));
|
|
||||||
retval = 1;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PM_LIST_display("target :", alpm_trans_getinfo(PM_TRANS_TARGETS));
|
PM_LIST_display("target :", alpm_trans_getinfo(PM_TRANS_TARGETS));
|
||||||
/* ORE
|
|
||||||
TBD */
|
|
||||||
|
|
||||||
/* Step 2: "compute" the transaction based on targets and flags */
|
/* Step 2: "compute" the transaction based on targets and flags */
|
||||||
if(alpm_trans_prepare(&data) == -1) {
|
if(alpm_trans_prepare(&data) == -1) {
|
||||||
|
@ -761,29 +688,39 @@ int pacman_sync(list_t *targets)
|
||||||
/* Check integrity of files */
|
/* Check integrity of files */
|
||||||
MSG(NL, "checking package integrity... ");
|
MSG(NL, "checking package integrity... ");
|
||||||
|
|
||||||
allgood = 1;
|
|
||||||
for(i = final; i; i = i->next) {
|
for(i = final; i; i = i->next) {
|
||||||
char /*str[PATH_MAX],*/ pkgname[PATH_MAX];
|
char /*str[PATH_MAX],*/ pkgname[PATH_MAX] = "dummy";
|
||||||
char *md5sum1, *md5sum2;
|
char *md5sum1, *md5sum2;
|
||||||
|
|
||||||
snprintf(pkgname, PATH_MAX, "%s-%s"PM_EXT_PKG, "", "");
|
snprintf(pkgname, PATH_MAX, "%s-%s"PM_EXT_PKG, "", "");
|
||||||
|
|
||||||
md5sum1 = NULL;
|
md5sum1 = NULL;
|
||||||
|
/* ORE
|
||||||
|
md5sum1 = sync->pkg->md5sum;
|
||||||
|
if(md5sum1 == NULL) {
|
||||||
|
ERR(NL, "can't get md5 checksum for package %s\n", pkgname);
|
||||||
|
retval = 1;
|
||||||
|
continue;
|
||||||
|
} */
|
||||||
|
|
||||||
md5sum2 = NULL;
|
md5sum2 = NULL;
|
||||||
|
/* ORE
|
||||||
|
md5sum2 = alpm_get_md5sum();
|
||||||
|
if(md5sum2 == NULL) {
|
||||||
|
ERR(NL, "can't get md5 checksum for package %s\n", pkgname);
|
||||||
|
retval = 1;
|
||||||
|
continue;
|
||||||
|
} */
|
||||||
|
|
||||||
if(strcmp(md5sum1, md5sum2) != 0) {
|
if(strcmp(md5sum1, md5sum2) != 0) {
|
||||||
if(allgood) {
|
retval = 1;
|
||||||
printf("\n");
|
ERR(NL, "error: archive %s is corrupted\n", pkgname);
|
||||||
}
|
|
||||||
ERR(NL, "error: archive %s is corrupted\n", "");
|
|
||||||
allgood = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE(md5sum2);
|
FREE(md5sum2);
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!allgood) {
|
if(retval) {
|
||||||
retval = 1;
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
MSG(CL, "done.\n");
|
MSG(CL, "done.\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue