Simplify xbps_transaction_prepare()/commit() and related API changes.

- xbps_handle::transd -> new member with transaction dictionary.
- xbps_transaction_prepare: returns an int.
- xbps_transaction_commit: doesn't need any arg now.
- xbps_repository_pool_sync: doesn't need any arg now.
- xbps_pkgdb_update: removed xbps_handle * arg.
- xbps_transaction_missingdeps_get: removed, missing_deps array is in
  xbps_handle::transd("missing_deps") array object.
This commit is contained in:
Juan RP
2012-01-22 10:00:46 +01:00
parent 38db570c19
commit a166d6a2a3
14 changed files with 183 additions and 235 deletions

View File

@ -180,9 +180,9 @@ download_binpkgs(struct xbps_handle *xhp, prop_object_iterator_t iter)
}
int
xbps_transaction_commit(prop_dictionary_t transd)
xbps_transaction_commit(void)
{
struct xbps_handle *xhp;
struct xbps_handle *xhp = xbps_handle_get();
prop_object_t obj;
prop_object_iterator_t iter;
size_t i;
@ -190,11 +190,10 @@ xbps_transaction_commit(prop_dictionary_t transd)
int rv = 0;
bool update, install;
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
assert(prop_object_type(xhp->transd) == PROP_TYPE_DICTIONARY);
update = install = false;
xhp = xbps_handle_get();
iter = xbps_array_iter_from_dict(transd, "packages");
iter = xbps_array_iter_from_dict(xhp->transd, "packages");
if (iter == NULL)
return EINVAL;
/*
@ -219,7 +218,7 @@ xbps_transaction_commit(prop_dictionary_t transd)
while ((obj = prop_object_iterator_next(iter)) != NULL) {
if ((xhp->transaction_frequency_flush > 0) &&
(++i >= xhp->transaction_frequency_flush)) {
rv = xbps_pkgdb_update(xhp, true);
rv = xbps_pkgdb_update(true);
if (rv != 0 && rv != ENOENT)
goto out;
@ -295,7 +294,7 @@ xbps_transaction_commit(prop_dictionary_t transd)
prop_object_iterator_reset(iter);
/* force a flush now packages were removed/unpacked */
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
if ((rv = xbps_pkgdb_update(true)) != 0)
goto out;
/* if there are no packages to install or update we are done */
@ -310,7 +309,7 @@ xbps_transaction_commit(prop_dictionary_t transd)
while ((obj = prop_object_iterator_next(iter)) != NULL) {
if (xhp->transaction_frequency_flush > 0 &&
++i >= xhp->transaction_frequency_flush) {
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
if ((rv = xbps_pkgdb_update(true)) != 0)
goto out;
i = 0;
@ -344,7 +343,7 @@ xbps_transaction_commit(prop_dictionary_t transd)
}
/* Force a flush now that packages are configured */
rv = xbps_pkgdb_update(xhp, true);
rv = xbps_pkgdb_update(true);
out:
prop_object_iterator_release(iter);