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:
@@ -63,14 +63,13 @@ cb_pkg_integrity(prop_object_t obj, void *arg, bool *done)
|
||||
int
|
||||
check_pkg_integrity_all(void)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
struct checkpkg cpkg;
|
||||
int rv;
|
||||
|
||||
memset(&cpkg, 0, sizeof(cpkg));
|
||||
(void)xbps_pkgdb_foreach_cb(cb_pkg_integrity, &cpkg);
|
||||
if (cpkg.flush) {
|
||||
if ((rv = xbps_pkgdb_update(xhp, true)) != 0) {
|
||||
if ((rv = xbps_pkgdb_update(true)) != 0) {
|
||||
xbps_error_printf("failed to write pkgdb: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
|
@@ -368,30 +368,32 @@ remove_pkg(const char *pkgname, bool recursive)
|
||||
int
|
||||
exec_transaction(bool yes, bool show_download_urls)
|
||||
{
|
||||
prop_array_t mdeps;
|
||||
struct transaction *trans;
|
||||
prop_array_t array;
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
int rv = 0;
|
||||
|
||||
trans = calloc(1, sizeof(*trans));
|
||||
if (trans == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if ((trans->d = xbps_transaction_prepare()) == NULL) {
|
||||
if (errno == ENODEV) {
|
||||
if ((rv = xbps_transaction_prepare()) != 0) {
|
||||
if (rv == ENODEV) {
|
||||
mdeps =
|
||||
prop_dictionary_get(xhp->transd, "missing_deps");
|
||||
/* missing packages */
|
||||
array = xbps_transaction_missingdeps_get();
|
||||
show_missing_deps(array);
|
||||
rv = errno;
|
||||
show_missing_deps(mdeps);
|
||||
goto out;
|
||||
}
|
||||
xbps_dbg_printf("Empty transaction dictionary: %s\n",
|
||||
strerror(errno));
|
||||
return errno;
|
||||
return rv;
|
||||
}
|
||||
xbps_dbg_printf("Dictionary before transaction happens:\n");
|
||||
xbps_dbg_printf_append("%s", prop_dictionary_externalize(trans->d));
|
||||
xbps_dbg_printf_append("%s", prop_dictionary_externalize(xhp->transd));
|
||||
|
||||
trans->iter = xbps_array_iter_from_dict(trans->d, "packages");
|
||||
trans->d = xhp->transd;
|
||||
trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages");
|
||||
if (trans->iter == NULL) {
|
||||
rv = errno;
|
||||
xbps_error_printf("xbps-bin: error allocating array mem! (%s)\n",
|
||||
@@ -420,8 +422,7 @@ exec_transaction(bool yes, bool show_download_urls)
|
||||
/*
|
||||
* It's time to run the transaction!
|
||||
*/
|
||||
rv = xbps_transaction_commit(trans->d);
|
||||
if (rv == 0) {
|
||||
if ((rv = xbps_transaction_commit()) == 0) {
|
||||
printf("\nxbps-bin: %u installed, %u updated, "
|
||||
"%u configured, %u removed.\n", trans->inst_pkgcnt,
|
||||
trans->up_pkgcnt, trans->cf_pkgcnt + trans->inst_pkgcnt,
|
||||
@@ -430,8 +431,6 @@ exec_transaction(bool yes, bool show_download_urls)
|
||||
out:
|
||||
if (trans->iter)
|
||||
prop_object_iterator_release(trans->iter);
|
||||
if (trans->d)
|
||||
prop_object_release(trans->d);
|
||||
if (trans)
|
||||
free(trans);
|
||||
|
||||
|
@@ -241,7 +241,7 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
rv = xbps_repository_pool_sync(&xh);
|
||||
rv = xbps_repository_pool_sync();
|
||||
if (rv == ENOTSUP) {
|
||||
xbps_error_printf("xbps-repo: no repositories "
|
||||
"currently registered!\n");
|
||||
|
@@ -389,7 +389,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
xh.pkgdb = prop_array_copy(array);
|
||||
prop_object_release(dict);
|
||||
rv = xbps_pkgdb_update(&xh, true);
|
||||
rv = xbps_pkgdb_update(true);
|
||||
if (rv == 0) {
|
||||
printf("Migrated regpkgdb to pkgdb "
|
||||
"successfully.\n");
|
||||
|
Reference in New Issue
Block a user