bin/xbps-install/transaction.c: simplify.

This commit is contained in:
Juan RP 2014-07-13 09:34:54 +02:00
parent 20e5b07b8b
commit ad28774f2f

View File

@ -46,18 +46,7 @@ struct transaction {
}; };
static void static void
show_missing_deps(xbps_array_t a) print_array(xbps_array_t a)
{
const char *str;
for (unsigned int i = 0; i < xbps_array_count(a); i++) {
xbps_array_get_cstring_nocopy(a, i, &str);
fprintf(stderr, "%s\n", str);
}
}
static void
show_conflicts(xbps_array_t a)
{ {
const char *str; const char *str;
@ -260,7 +249,7 @@ update_pkg(struct xbps_handle *xhp, const char *pkgname)
int int
exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun) exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
{ {
xbps_array_t mdeps, cflicts; xbps_array_t array;
struct transaction *trans; struct transaction *trans;
int rv = 0; int rv = 0;
@ -270,17 +259,16 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
if ((rv = xbps_transaction_prepare(xhp)) != 0) { if ((rv = xbps_transaction_prepare(xhp)) != 0) {
if (rv == ENODEV) { if (rv == ENODEV) {
mdeps = array = xbps_dictionary_get(xhp->transd, "missing_deps");
xbps_dictionary_get(xhp->transd, "missing_deps");
/* missing packages */ /* missing packages */
show_missing_deps(mdeps); print_array(array);
fprintf(stderr, "Transaction aborted due to missing/conflicting packages.\n"); fprintf(stderr, "Transaction aborted due to missing packages.\n");
goto out; goto out;
} else if (rv == EAGAIN) { } else if (rv == EAGAIN) {
/* conflicts */ /* conflicts */
cflicts = xbps_dictionary_get(xhp->transd, "conflicts"); array = xbps_dictionary_get(xhp->transd, "conflicts");
show_conflicts(cflicts); print_array(array);
fprintf(stderr, "Transaction aborted due to missing/conflicting packages.\n"); fprintf(stderr, "Transaction aborted due to conflicting packages.\n");
goto out; goto out;
} }
xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n", xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n",