diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index b83fd0c4..7d4c9082 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -329,9 +329,9 @@ main(int argc, char **argv) usage(xhp); if (strcasecmp(argv[1], "all") == 0) - rv = xbps_configure_packages(); + rv = xbps_configure_packages(true); else - rv = xbps_configure_pkg(argv[1], NULL, true, false); + rv = xbps_configure_pkg(argv[1], NULL, true, false, true); } else if (strcasecmp(argv[0], "show-deps") == 0) { /* diff --git a/include/xbps_api.h b/include/xbps_api.h index 1df9f451..ee96669f 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2008-2011 Juan Romero Pardines. + * Copyright (c) 2008-2012 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.3" -#define XBPS_API_VERSION "20111229" +#define XBPS_API_VERSION "20120104" #define XBPS_VERSION "0.12" /** @@ -608,20 +608,23 @@ struct xbps_handle *xbps_handle_get(void); * @param[in] check_state Set it to true to check that package is * in unpacked state. * @param[in] update Set it to true if this package is being updated. + * @param[in] flush Set it to true to flush state to regpkgdb. * * @return 0 on success, otherwise an errno value. */ int xbps_configure_pkg(const char *pkgname, const char *version, bool check_state, - bool update); + bool update, + bool flush); /** * Configure (or force reconfiguration of) all packages. + * @param[in] flush Set it to true to flush state to regpkgdb. * * @return 0 on success, otherwise an errno value. */ -int xbps_configure_packages(void); +int xbps_configure_packages(bool flush); /*@}*/ diff --git a/lib/package_configure.c b/lib/package_configure.c index 244aa46c..97747c63 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2009-2011 Juan Romero Pardines. + * Copyright (c) 2009-2012 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,20 +57,28 @@ configure_pkgs_cb(prop_object_t obj, void *arg, bool *done) prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(obj, "version", &version); - return xbps_configure_pkg(pkgname, version, true, false); + return xbps_configure_pkg(pkgname, version, true, false, false); } int -xbps_configure_packages(void) +xbps_configure_packages(bool flush) { - return xbps_regpkgdb_foreach_pkg_cb(configure_pkgs_cb, NULL); + struct xbps_handle *xhp = xbps_handle_get(); + int rv; + + rv = xbps_regpkgdb_foreach_pkg_cb(configure_pkgs_cb, &flush); + if (rv == 0) + rv = xbps_regpkgdb_update(xhp, true); + + return rv; } int xbps_configure_pkg(const char *pkgname, const char *version, bool check_state, - bool update) + bool update, + bool flush) { struct xbps_handle *xhp; prop_dictionary_t pkgd; @@ -160,6 +168,8 @@ xbps_configure_pkg(const char *pkgname, pkgver, strerror(rv)); } free(pkgver); + if (flush) + rv = xbps_regpkgdb_update(xhp, true); return rv; } diff --git a/lib/package_register.c b/lib/package_register.c index 6000ff48..3402ceb2 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2008-2011 Juan Romero Pardines. + * Copyright (c) 2008-2012 Juan Romero Pardines. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -76,24 +76,24 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush) } if (!prop_dictionary_set_cstring_nocopy(pkgd, "version", version)) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: invalid version for %s\n", __func__, pkgname); rv = EINVAL; goto out; } if (!prop_dictionary_set_cstring_nocopy(pkgd, "pkgver", pkgver)) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: invalid pkgver for %s\n", __func__, pkgname); rv = EINVAL; goto out; } if (!prop_dictionary_set_cstring_nocopy(pkgd, "short_desc", desc)) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: invalid short_desc for %s\n", __func__, pkgname); rv = EINVAL; goto out; } if (reqby && !prop_dictionary_set(pkgd, "requiredby", reqby)) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: invalid requiredby for %s\n", __func__, pkgname); rv = EINVAL; goto out; } @@ -105,13 +105,14 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush) if (!prop_dictionary_set_bool(pkgd, "automatic-install", autoinst)) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: invalid autoinst for %s\n", __func__, pkgname); rv = EINVAL; goto out; } if (provides) { if (!prop_dictionary_set(pkgd, "provides", provides)) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: invalid provides for %s\n", + __func__, pkgname); rv = EINVAL; goto out; } @@ -121,14 +122,18 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush) */ if (pkgrd && xbps_pkg_has_rundeps(pkgrd)) { if ((rv = xbps_requiredby_pkg_add(xhp, pkgrd)) != 0) { - prop_object_release(pkgd); + xbps_dbg_printf("%s: requiredby add failed for %s\n", + __func__, pkgname); goto out; } } array = prop_dictionary_get(xhp->regpkgdb, "packages"); rv = xbps_array_replace_dict_by_name(array, pkgd, pkgname); - if (rv != 0) + if (rv != 0) { + xbps_dbg_printf("%s: failed to replace pkgd dict for %s\n", + __func__, pkgname); goto out; + } if (flush) rv = xbps_regpkgdb_update(xhp, true); diff --git a/lib/transaction_commit.c b/lib/transaction_commit.c index 5f94648f..9aa0c0ec 100644 --- a/lib/transaction_commit.c +++ b/lib/transaction_commit.c @@ -224,7 +224,8 @@ xbps_transaction_commit(prop_dictionary_t transd) /* * Reconfigure pending package. */ - rv = xbps_configure_pkg(pkgname, version, false, false); + rv = xbps_configure_pkg(pkgname, version, + false, false, false); if (rv != 0) goto out; } else { @@ -305,7 +306,7 @@ xbps_transaction_commit(prop_dictionary_t transd) if (strcmp(tract, "update") == 0) update = true; - rv = xbps_configure_pkg(pkgname, version, false, update); + rv = xbps_configure_pkg(pkgname, version, false, update, false); if (rv != 0) goto out; /*