summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-07 18:42:44 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-01-07 18:42:44 +0000
commit86e5c8bc0649a6df814bdff850a787826612f366 (patch)
tree0c81099af96848c8c87f6a305fea2f64cd0e020d
parente405204915600340180cef61471471929fb0c275 (diff)
downloadpacman-86e5c8bc0649a6df814bdff850a787826612f366.tar.xz
sync_commit can now return conflicting files with a trans_prepare like data structure (patch from VMiklos <vmiklos@frugalware.org>)
-rw-r--r--lib/libalpm/alpm.c4
-rw-r--r--lib/libalpm/alpm.h2
-rw-r--r--lib/libalpm/sync.c11
-rw-r--r--lib/libalpm/sync.h2
-rw-r--r--lib/libalpm/trans.c4
-rw-r--r--lib/libalpm/trans.h2
-rw-r--r--src/pacman/add.c2
-rw-r--r--src/pacman/pacman.c2
-rw-r--r--src/pacman/remove.c2
-rw-r--r--src/pacman/sync.c13
10 files changed, 27 insertions, 17 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 819807c6..610c3f64 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -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()
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 59ea151c..321bdc5a 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -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);
/*
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index fc962a36..fe655b8b 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -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;
}
diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h
index 5e4cae73..f8859977 100644
--- a/lib/libalpm/sync.h
+++ b/lib/libalpm/sync.h
@@ -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 */
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 8830a1ec..12441f01 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -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);
}
diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h
index bc0ed2fa..aa0633b8 100644
--- a/lib/libalpm/trans.h
+++ b/lib/libalpm/trans.h
@@ -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 */
diff --git a/src/pacman/add.c b/src/pacman/add.c
index fb6c4a58..10c618eb 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -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);
}
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 646f7e9e..e1dff655 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -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);
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 6dc3758c..b730dd9b 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -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;
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 7a76dea0..74733e06 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -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;
}