libxbps: modify the API, new func xbps_get_binpkg_repo_uri().

This function replaces xbps_repository_get_path_from_pkg_dict() and
xbps_get_binpkg_local_path(). It takes a pkg dictionary as returned
by a repository pkg index or a transaction dictionary and returns
a string with the full path to the binary pkg, either in local
repos, cachedir or remote repos.

Update all code to use this function... sorry I broke ABI compatiblity.
This commit is contained in:
Juan RP
2011-01-18 18:21:55 +01:00
parent 6d7121c5bd
commit fe15380e1b
7 changed files with 79 additions and 126 deletions

View File

@ -404,7 +404,7 @@ out:
int
xbps_unpack_binary_pkg(prop_dictionary_t pkg)
{
const char *pkgname, *repoloc, *version;
const char *pkgname, *version;
struct archive *ar = NULL;
char *binfile = NULL;
int pkg_fd, rv = 0;
@ -412,10 +412,9 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg)
assert(pkg != NULL);
prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(pkg, "repository", &repoloc);
prop_dictionary_get_cstring_nocopy(pkg, "version", &version);
binfile = xbps_get_binpkg_local_path(pkg, repoloc);
binfile = xbps_get_binpkg_repo_uri(pkg);
if (binfile == NULL)
return EINVAL;
@ -423,8 +422,10 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg)
rv = errno;
xbps_dbg_printf("cannot open '%s' for unpacking %s\n",
binfile, strerror(errno));
free(binfile);
goto out;
}
free(binfile);
ar = archive_read_new();
if (ar == NULL) {
@ -457,8 +458,6 @@ out:
archive_read_finish(ar);
if (pkg_fd != -1)
(void)close(pkg_fd);
if (binfile)
free(binfile);
return rv;
}