Major API/ABI cleanup bringing performance improvements and fixes.

These are the core interfaces in the new API:

rpool - Interface to interact with the repository pool.
rindex - Interface to interact with repository indexes.
pkgdb - Interface to interact with local packages.
transaction - Interface to interact with a transaction.

This also brings new repository index format, making the index file
per architecture and being incompatible with previous versions.

The transaction frequency flush option has been removed, and due to
the nature of package states it was causing more harm than good.

More changes coming soon, but the API shall remain stable from now on.
This commit is contained in:
Juan RP
2012-11-30 07:11:51 +01:00
parent 16e18313da
commit 63c1883201
57 changed files with 1437 additions and 2640 deletions

View File

@ -47,7 +47,7 @@
* @defgroup util Utility functions
*/
bool
xbps_check_is_repository_uri_remote(const char *uri)
xbps_repository_is_remote(const char *uri)
{
assert(uri != NULL);
@ -60,23 +60,17 @@ xbps_check_is_repository_uri_remote(const char *uri)
}
int
xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
const char *pattern)
xbps_pkg_is_installed(struct xbps_handle *xhp, const char *pkg)
{
prop_dictionary_t dict;
pkg_state_t state;
assert(pattern != NULL);
assert(xhp);
assert(pkg);
dict = xbps_find_virtualpkg_dict_installed(xhp, pattern, true);
if (dict == NULL) {
dict = xbps_find_pkg_dict_installed(xhp, pattern, true);
if (dict == NULL) {
if (errno == ENOENT)
return 0; /* not installed */
return -1; /* error */
}
}
if (((dict = xbps_pkgdb_get_virtualpkg(xhp, pkg)) == NULL) &&
((dict = xbps_pkgdb_get_pkg(xhp, pkg)) == NULL))
return 0; /* not installed */
/*
* Check that package state is fully installed, not
* unpacked or something else.
@ -89,21 +83,6 @@ xbps_check_is_installed_pkg_by_pattern(struct xbps_handle *xhp,
return 1;
}
bool
xbps_check_is_installed_pkg_by_name(struct xbps_handle *xhp,
const char *pkgname)
{
prop_dictionary_t pkgd;
assert(pkgname != NULL);
if (((pkgd = xbps_find_pkg_dict_installed(xhp, pkgname, false)) == NULL) &&
((pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false)) == NULL))
return false;
return true;
}
const char *
xbps_pkg_version(const char *pkg)
{
@ -208,47 +187,54 @@ get_pkg_index_remote_plist(struct xbps_handle *xhp,
char *
xbps_pkg_index_plist(struct xbps_handle *xhp, const char *uri)
{
assert(xhp);
assert(uri != NULL);
if (xbps_check_is_repository_uri_remote(uri))
if (xbps_repository_is_remote(uri))
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX);
return xbps_xasprintf("%s/%s", uri, XBPS_PKGINDEX);
return xbps_xasprintf("%s/%s-%s", uri, xhp->un_machine, XBPS_PKGINDEX);
}
char *
xbps_pkg_index_files_plist(struct xbps_handle *xhp, const char *uri)
{
assert(xhp);
assert(uri != NULL);
if (xbps_check_is_repository_uri_remote(uri))
if (xbps_repository_is_remote(uri))
return get_pkg_index_remote_plist(xhp, uri, XBPS_PKGINDEX_FILES);
return xbps_xasprintf("%s/%s", uri, XBPS_PKGINDEX_FILES);
return xbps_xasprintf("%s/%s-%s", uri,
xhp->un_machine, XBPS_PKGINDEX_FILES);
}
char *
xbps_path_from_repository_uri(struct xbps_handle *xhp,
prop_dictionary_t pkg_repod,
const char *repoloc)
char HIDDEN *
xbps_repository_pkg_path(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
{
const char *filen;
const char *filen, *repoloc;
char *lbinpkg = NULL;
assert(xhp);
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
assert(repoloc != NULL);
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
"filename", &filen))
return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
"repository", &repoloc))
return NULL;
/*
* First check if binpkg is available in cachedir.
*/
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
if (access(lbinpkg, R_OK) == 0)
return lbinpkg;
if (xbps_repository_is_remote(repoloc)) {
/*
* First check if binpkg is available in cachedir.
*/
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
if (access(lbinpkg, R_OK) == 0)
return lbinpkg;
free(lbinpkg);
free(lbinpkg);
}
/*
* Local and remote repositories use the same path.
*/