summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJudd Vinet <judd@archlinux.org>2005-10-09 08:09:57 +0200
committerJudd Vinet <judd@archlinux.org>2005-10-09 08:09:57 +0200
commita36ded25eb9bdea5b73c33f993820b657f9e6623 (patch)
treecd1fede1bf2400edee18bd8542f4a426354550aa /src
parent9a4719d3c5e7d75fda485e3251edba0fb96b5b27 (diff)
downloadpacman-a36ded25eb9bdea5b73c33f993820b657f9e6623.tar.gz
pacman-a36ded25eb9bdea5b73c33f993820b657f9e6623.tar.xz
added conversation callback support for transactions
Diffstat (limited to 'src')
-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.c2
-rw-r--r--src/pacman/trans.c35
-rw-r--r--src/pacman/trans.h5
6 files changed, 42 insertions, 6 deletions
diff --git a/src/pacman/add.c b/src/pacman/add.c
index d5fb73db..bf262b0e 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -59,7 +59,7 @@ int pacman_add(list_t *targets)
/* Step 1: create a new transaction
*/
if(alpm_trans_init((pmo_upgrade == 0) ? PM_TRANS_TYPE_ADD : PM_TRANS_TYPE_UPGRADE,
- pmo_flags, cb_trans) == -1) {
+ pmo_flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "%s\n", alpm_strerror(pm_errno));
return(1);
}
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index eb5a8da8..983d8402 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -287,7 +287,7 @@ int pacman_deptest(list_t *targets)
/* we create a transaction to hold a dummy package to be able to use
* deps checkings from alpm_trans_prepare() */
- if(alpm_trans_init(PM_TRANS_TYPE_ADD, 0, NULL) == -1) {
+ if(alpm_trans_init(PM_TRANS_TYPE_ADD, 0, NULL, NULL) == -1) {
ERR(NL, "%s", alpm_strerror(pm_errno));
return(1);
}
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 586ffac8..fd292151 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -73,7 +73,7 @@ int pacman_remove(list_t *targets)
/* Step 1: create a new transaction
*/
- if(alpm_trans_init(PM_TRANS_TYPE_REMOVE, pmo_flags, cb_trans) == -1) {
+ if(alpm_trans_init(PM_TRANS_TYPE_REMOVE, pmo_flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
goto error;
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 39c5a0d5..0e6d77d9 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -424,7 +424,7 @@ int pacman_sync(list_t *targets)
/* Step 1: create a new transaction...
*/
- if(alpm_trans_init(PM_TRANS_TYPE_SYNC, pmo_flags, cb_trans) == -1) {
+ if(alpm_trans_init(PM_TRANS_TYPE_SYNC, pmo_flags, cb_trans_evt, cb_trans_conv) == -1) {
ERR(NL, "failed to init transaction (%s)\n", alpm_strerror(pm_errno));
retval = 1;
goto cleanup;
diff --git a/src/pacman/trans.c b/src/pacman/trans.c
index 90341770..2840fca2 100644
--- a/src/pacman/trans.c
+++ b/src/pacman/trans.c
@@ -36,7 +36,7 @@
/* Callback to handle transaction events
*/
-void cb_trans(unsigned char event, void *data1, void *data2)
+void cb_trans_evt(unsigned char event, void *data1, void *data2)
{
char str[LOG_STR_LEN] = "";
@@ -93,4 +93,37 @@ void cb_trans(unsigned char event, void *data1, void *data2)
}
}
+void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response)
+{
+ char str[LOG_STR_LEN] = "";
+
+ switch(event) {
+ case PM_TRANS_CONV_INSTALL_IGNOREPKG:
+ snprintf(str, LOG_STR_LEN, ":: %s requires %s, but it is in IgnorePkg. Install anyway? [Y/n] ",
+ (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME),
+ (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME));
+ *response = yesno(str);
+ break;
+ case PM_TRANS_CONV_REPLACE_PKG:
+ snprintf(str, LOG_STR_LEN, ":: Replace %s with %s from \"%s\"? [Y/n] ",
+ (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME),
+ (char *)alpm_pkg_getinfo(data2, PM_PKG_NAME),
+ (char *)data3);
+ *response = yesno(str);
+ break;
+ case PM_TRANS_CONV_LOCAL_NEWER:
+ snprintf(str, LOG_STR_LEN, ":: %s-%s: local version is newer. Upgrade anyway? [Y/n] ",
+ (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME),
+ (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION));
+ *response = yesno(str);
+ break;
+ case PM_TRANS_CONV_LOCAL_UPTODATE:
+ snprintf(str, LOG_STR_LEN, ":: %s-%s: local version is up to date. Upgrade anyway? [Y/n] ",
+ (char *)alpm_pkg_getinfo(data1, PM_PKG_NAME),
+ (char *)alpm_pkg_getinfo(data1, PM_PKG_VERSION));
+ *response = yesno(str);
+ break;
+ }
+}
+
/* vim: set ts=2 sw=2 noet: */
diff --git a/src/pacman/trans.h b/src/pacman/trans.h
index a1df6488..f98282cb 100644
--- a/src/pacman/trans.h
+++ b/src/pacman/trans.h
@@ -22,7 +22,10 @@
#define _PM_TRANS_H
/* callback to handle messages/notifications from pacman transactions */
-void cb_trans(unsigned char event, void *data1, void *data2);
+void cb_trans_evt(unsigned char event, void *data1, void *data2);
+
+/* callback to handle questions from pacman transactions (yes/no) */
+void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response);
#endif /* _PM_TRANS_H */