libxbps: modify xbps_get_binpkg_repo_uri() to accept repository URL as 2nd arg.

This commit is contained in:
Juan RP 2011-01-20 16:41:49 +01:00
parent 6f8b2ca33a
commit 84b578b0e4
7 changed files with 22 additions and 20 deletions

View File

@ -120,7 +120,7 @@ again:
prop_dictionary_get_cstring_nocopy(obj, prop_dictionary_get_cstring_nocopy(obj,
"filename-sha256", &sha256); "filename-sha256", &sha256);
binfile = xbps_get_binpkg_repo_uri(obj); binfile = xbps_get_binpkg_repo_uri(obj, repoloc);
if (binfile == NULL) if (binfile == NULL)
return errno; return errno;
/* /*
@ -153,7 +153,7 @@ again:
return -1; return -1;
} }
free(binfile); free(binfile);
binfile = xbps_get_binpkg_repo_uri(obj); binfile = xbps_get_binpkg_repo_uri(obj, repoloc);
if (binfile == NULL) if (binfile == NULL)
return errno; return errno;

View File

@ -71,7 +71,7 @@ static int
find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done) find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
{ {
prop_dictionary_t pkg_filesd; prop_dictionary_t pkg_filesd;
prop_array_t repo_pkgs, files_keys; prop_array_t files_keys;
prop_object_t obj; prop_object_t obj;
prop_object_iterator_t iter; prop_object_iterator_t iter;
const char *pkgname, *pkgver, *pattern = arg; const char *pkgname, *pkgver, *pattern = arg;
@ -81,17 +81,13 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
(void)done; (void)done;
repo_pkgs = prop_dictionary_get(rpi->rpi_repod, "packages"); iter = xbps_get_array_iter_from_dict(rpi->rpi_repod, "packages");
if (repo_pkgs == NULL)
return -1;
iter = prop_array_iterator(repo_pkgs);
if (iter == NULL) if (iter == NULL)
return -1; return -1;
printf("Looking in repository '%s', please wait...\n", rpi->rpi_uri); printf("Looking in repository '%s', please wait...\n", rpi->rpi_uri);
while ((obj = prop_object_iterator_next(iter))) { while ((obj = prop_object_iterator_next(iter))) {
url = xbps_get_binpkg_repo_uri(obj); url = xbps_get_binpkg_repo_uri(obj, rpi->rpi_uri);
if (url == NULL) { if (url == NULL) {
rv = -1; rv = -1;
break; break;

View File

@ -250,7 +250,7 @@ show_pkg_info_from_repolist(const char *pkgname)
return errno; return errno;
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc); prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
url = xbps_get_binpkg_repo_uri(pkgd); url = xbps_get_binpkg_repo_uri(pkgd, repoloc);
if (url == NULL) { if (url == NULL) {
prop_object_release(pkgd); prop_object_release(pkgd);
return errno; return errno;

View File

@ -942,12 +942,13 @@ bool xbps_check_is_repo_string_remote(const char *uri);
* repository location object "repository" in its dictionary. * repository location object "repository" in its dictionary.
* *
* @param[in] pkgd Package dictionary stored in a transaction dictionary. * @param[in] pkgd Package dictionary stored in a transaction dictionary.
* @param[in] repoloc Repository URL location string.
* *
* @return A pointer to a malloc(3)ed string, NULL otherwise and * @return A pointer to a malloc(3)ed string, NULL otherwise and
* errno is set appropiately. The pointer should be free(3)d when it's * errno is set appropiately. The pointer should be free(3)d when it's
* no longer needed. * no longer needed.
*/ */
char *xbps_get_binpkg_repo_uri(prop_dictionary_t pkgd); char *xbps_get_binpkg_repo_uri(prop_dictionary_t pkgd, const char *repoloc);
/** /**
* Gets the full path to a repository package index plist file, as * Gets the full path to a repository package index plist file, as

View File

@ -409,7 +409,7 @@ out:
int int
xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod) xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
{ {
const char *pkgname, *version; const char *pkgname, *version, *repoloc;
struct archive *ar = NULL; struct archive *ar = NULL;
char *binfile = NULL; char *binfile = NULL;
int pkg_fd, rv = 0; int pkg_fd, rv = 0;
@ -418,8 +418,9 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(pkg_repod, "version", &version); prop_dictionary_get_cstring_nocopy(pkg_repod, "version", &version);
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
binfile = xbps_get_binpkg_repo_uri(pkg_repod); binfile = xbps_get_binpkg_repo_uri(pkg_repod, repoloc);
if (binfile == NULL) if (binfile == NULL)
return EINVAL; return EINVAL;

View File

@ -194,6 +194,7 @@ prop_dictionary_t
xbps_repository_get_pkg_plist_dict(const char *pkgname, const char *plistf) xbps_repository_get_pkg_plist_dict(const char *pkgname, const char *plistf)
{ {
prop_dictionary_t pkgd = NULL, plistd = NULL; prop_dictionary_t pkgd = NULL, plistd = NULL;
const char *repoloc;
char *url; char *url;
int rv = 0; int rv = 0;
@ -214,7 +215,8 @@ xbps_repository_get_pkg_plist_dict(const char *pkgname, const char *plistf)
if (pkgd == NULL) if (pkgd == NULL)
goto out; goto out;
url = xbps_get_binpkg_repo_uri(pkgd); prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
url = xbps_get_binpkg_repo_uri(pkgd, repoloc);
if (url == NULL) { if (url == NULL) {
errno = EINVAL; errno = EINVAL;
goto out; goto out;

View File

@ -374,14 +374,17 @@ xbps_get_pkg_index_plist(const char *uri)
} }
char * char *
xbps_get_binpkg_repo_uri(prop_dictionary_t pkg_repod) xbps_get_binpkg_repo_uri(prop_dictionary_t pkg_repod, const char *repoloc)
{ {
const char *filen, *arch, *cdir, *repoloc; const char *filen, *arch, *cdir;
char *lbinpkg = NULL; char *lbinpkg = NULL;
prop_dictionary_get_cstring_nocopy(pkg_repod, "filename", &filen); if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
prop_dictionary_get_cstring_nocopy(pkg_repod, "architecture", &arch); "filename", &filen))
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc); return NULL;
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
"architecture", &arch))
return NULL;
cdir = xbps_get_cachedir(); cdir = xbps_get_cachedir();
if (cdir == NULL) if (cdir == NULL)
@ -398,7 +401,6 @@ xbps_get_binpkg_repo_uri(prop_dictionary_t pkg_repod)
return lbinpkg; return lbinpkg;
free(lbinpkg); free(lbinpkg);
/* /*
* Local and remote repositories use the same path. * Local and remote repositories use the same path.
*/ */