more work for sync_commit()
This commit is contained in:
parent
35762528df
commit
31da982deb
1 changed files with 28 additions and 5 deletions
|
@ -402,28 +402,51 @@ error:
|
||||||
int sync_commit(pmdb_t *db, pmtrans_t *trans)
|
int sync_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
{
|
{
|
||||||
PMList *i, *j = NULL;
|
PMList *i, *j = NULL;
|
||||||
PMList *final = NULL;
|
|
||||||
PMList *rmtargs = NULL;
|
|
||||||
PMList *data;
|
PMList *data;
|
||||||
pmtrans_t *tr;
|
pmtrans_t *tr;
|
||||||
|
char ldir[PATH_MAX];
|
||||||
|
|
||||||
|
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
||||||
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||||
|
|
||||||
|
/* ORE
|
||||||
|
set CACHEDIR as a library option? */
|
||||||
|
#define PM_CACHEDIR "var/cache/pacman/pkg"
|
||||||
|
snprintf(ldir, PATH_MAX, "%s" PM_CACHEDIR, handle->root);
|
||||||
|
#undef CACHEDIR
|
||||||
|
|
||||||
/* remove any conflicting packages (WITHOUT dep checks) */
|
/* remove any conflicting packages (WITHOUT dep checks) */
|
||||||
/* ORE - alpm does not handle removal of conflicting pkgs for now */
|
/* ORE - alpm does not handle removal of conflicting pkgs for now */
|
||||||
|
|
||||||
/* remove to-be-replaced packages */
|
/* remove to-be-replaced packages */
|
||||||
|
tr = trans_new(PM_TRANS_TYPE_REMOVE, PM_TRANS_FLAG_NODEPS);
|
||||||
|
/* ORE */
|
||||||
|
if(tr == NULL) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
for(i = trans->packages; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
pmsyncpkg_t *sync = i->data;
|
pmsyncpkg_t *sync = i->data;
|
||||||
for(j = sync->replaces; j; j = j->next) {
|
for(j = sync->replaces; j; j = j->next) {
|
||||||
pmpkg_t *pkg = j->data;
|
pmpkg_t *pkg = j->data;
|
||||||
rmtargs = pm_list_add(rmtargs, strdup(pkg->name));
|
if(trans_addtarget(tr, pkg->name)) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
trans_free(tr);
|
||||||
|
|
||||||
/* install targets */
|
/* install targets */
|
||||||
/* ORE - need for a flag specifying that deps have already been checked */
|
/* ORE - need for a flag specifying that deps have already been checked */
|
||||||
tr = trans_new(PM_TRANS_TYPE_UPGRADE, PM_TRANS_FLAG_NODEPS);
|
tr = trans_new(PM_TRANS_TYPE_UPGRADE, PM_TRANS_FLAG_NODEPS);
|
||||||
|
if(tr == NULL) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
for(i = trans->packages; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
if(trans_addtarget(tr, i->data) == -1) {
|
pmsyncpkg_t *sync = i->data;
|
||||||
|
pmpkg_t *spkg = sync->spkg;
|
||||||
|
char str[PATH_MAX];
|
||||||
|
snprintf(str, PATH_MAX, "%s/%s-%s" PM_EXT_PKG, ldir, spkg->name, spkg->version);
|
||||||
|
if(trans_addtarget(tr, str) == -1) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,7 +459,7 @@ int sync_commit(pmdb_t *db, pmtrans_t *trans)
|
||||||
trans_free(tr);
|
trans_free(tr);
|
||||||
|
|
||||||
/* propagate replaced packages' requiredby fields to their new owners */
|
/* propagate replaced packages' requiredby fields to their new owners */
|
||||||
for(i = final; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
/*syncpkg_t *sync = (syncpkg_t*)i->data;
|
/*syncpkg_t *sync = (syncpkg_t*)i->data;
|
||||||
if(sync->replaces) {
|
if(sync->replaces) {
|
||||||
pkginfo_t *new = db_scan(db, sync->pkg->name, INFRQ_DEPENDS);
|
pkginfo_t *new = db_scan(db, sync->pkg->name, INFRQ_DEPENDS);
|
||||||
|
|
Loading…
Add table
Reference in a new issue