1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-15 22:05:02 -05:00

sync_commit can now return conflicting files with a trans_prepare like data structure (patch from VMiklos <vmiklos@frugalware.org>)

This commit is contained in:
Aurelien Foret 2006-01-07 18:42:44 +00:00
parent e405204915
commit 86e5c8bc06
10 changed files with 27 additions and 17 deletions

View File

@ -619,7 +619,7 @@ int alpm_trans_prepare(PMList **data)
return(trans_prepare(handle->trans, data));
}
int alpm_trans_commit()
int alpm_trans_commit(PMList **data)
{
pmtrans_t *trans;
@ -633,7 +633,7 @@ int alpm_trans_commit()
/* Check for database R/W permission */
ASSERT(handle->access == PM_ACCESS_RW, RET_ERR(PM_ERR_BADPERMS, -1));
return(trans_commit(handle->trans));
return(trans_commit(handle->trans, data));
}
int alpm_trans_release()

View File

@ -262,7 +262,7 @@ int alpm_trans_init(unsigned char type, unsigned char flags, alpm_trans_cb_event
int alpm_trans_sysupgrade(void);
int alpm_trans_addtarget(char *target);
int alpm_trans_prepare(PM_LIST **data);
int alpm_trans_commit(void);
int alpm_trans_commit(PM_LIST **data);
int alpm_trans_release(void);
/*

View File

@ -616,10 +616,9 @@ error:
return(-1);
}
int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
int sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data)
{
PMList *i;
PMList *data;
pmtrans_t *tr = NULL;
int replaces = 0;
int removal = 0;
@ -665,13 +664,13 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
}
if(replaces+removal != 0) {
_alpm_log(PM_LOG_FLOW1, "removing conflicting and to-be-replaced packages");
if(trans_prepare(tr, &data) == -1) {
if(trans_prepare(tr, data) == -1) {
_alpm_log(PM_LOG_ERROR, "could not prepare removal transaction");
goto error;
}
/* we want the frontend to be aware of commit details */
tr->cb_event = trans->cb_event;
if(trans_commit(tr) == -1) {
if(trans_commit(tr, NULL) == -1) {
_alpm_log(PM_LOG_ERROR, "could not commit removal transaction");
goto error;
}
@ -709,13 +708,13 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
spkg->reason = PM_PKG_REASON_EXPLICIT;
}
}
if(trans_prepare(tr, &data) == -1) {
if(trans_prepare(tr, data) == -1) {
_alpm_log(PM_LOG_ERROR, "could not prepare transaction");
goto error;
}
/* we want the frontend to be aware of commit details */
tr->cb_event = trans->cb_event;
if(trans_commit(tr) == -1) {
if(trans_commit(tr, NULL) == -1) {
_alpm_log(PM_LOG_ERROR, "could not commit transaction");
goto error;
}

View File

@ -41,7 +41,7 @@ PMList *sync_load_dbarchive(char *archive);
int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync);
int sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, char *name);
int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **data);
int sync_commit(pmtrans_t *trans, pmdb_t *db_local);
int sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data);
#endif /* _ALPM_SYNC_H */

View File

@ -179,7 +179,7 @@ int trans_prepare(pmtrans_t *trans, PMList **data)
return(0);
}
int trans_commit(pmtrans_t *trans)
int trans_commit(pmtrans_t *trans, PMList **data)
{
/* Sanity checks */
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
@ -204,7 +204,7 @@ int trans_commit(pmtrans_t *trans)
}
break;
case PM_TRANS_TYPE_SYNC:
if(sync_commit(trans, handle->db_local) == -1) {
if(sync_commit(trans, handle->db_local, data) == -1) {
/* pm_errno is set by sync_commit() */
return(-1);
}

View File

@ -67,7 +67,7 @@ int trans_init(pmtrans_t *trans, unsigned char type, unsigned char flags, alpm_t
int trans_sysupgrade(pmtrans_t *trans);
int trans_addtarget(pmtrans_t *trans, char *target);
int trans_prepare(pmtrans_t *trans, PMList **data);
int trans_commit(pmtrans_t *trans);
int trans_commit(pmtrans_t *trans, PMList **data);
#endif /* _ALPM_TRANS_H */

View File

@ -122,7 +122,7 @@ int pacman_add(list_t *targets)
/* Step 3: actually perform the installation
*/
if(alpm_trans_commit() == -1) {
if(alpm_trans_commit(NULL) == -1) {
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
return(1);
}

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
return(1);
}
config->op = PM_OP_MAIN;
config->debug |= PM_LOG_WARNING | PM_LOG_ERROR;
config->debug |= PM_LOG_WARNING;
/* parse the command line */
ret = parseargs(argc, argv);

View File

@ -126,7 +126,7 @@ int pacman_remove(list_t *targets)
/* Step 3: actually perform the removal
*/
if(alpm_trans_commit() == -1) {
if(alpm_trans_commit(NULL) == -1) {
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
goto error;
}

View File

@ -756,8 +756,19 @@ int pacman_sync(list_t *targets)
}
/* Step 3: actually perform the installation */
if(alpm_trans_commit() == -1) {
if(alpm_trans_commit(&data) == -1) {
ERR(NL, "failed to commit transaction (%s)\n", alpm_strerror(pm_errno));
switch(pm_errno) {
case PM_ERR_FILE_CONFLICTS:
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
MSG(NL, ":: %s\n", (char *)alpm_list_getdata(lp));
}
alpm_list_free(data);
MSG(NL, "\nerrors occurred, no packages were upgraded.\n");
break;
default:
break;
}
retval = 1;
goto cleanup;
}