API/ABI break for June 2011.
Rename some functions to reflect its description a bit better. --HG-- rename : lib/repository_plist.c => lib/plist_fetch.c
This commit is contained in:
@ -44,9 +44,9 @@ OBJS += package_purge.o package_replaces.o package_properties.o
|
||||
OBJS += transaction_dictionary.o transaction_sortdeps.o
|
||||
OBJS += cmpver.o download.o fexec.o humanize_number.o plist.o
|
||||
OBJS += plist_archive_entry.o plist_find.o plist_remove.o
|
||||
OBJS += util.o pkgmatch.o mkpath.o initend.o
|
||||
OBJS += plist_fetch.o util.o pkgmatch.o mkpath.o initend.o
|
||||
OBJS += regpkgdb_dictionary.o repository_register.o
|
||||
OBJS += repository_findpkg.o repository_plist.o repository_finddeps.o
|
||||
OBJS += repository_findpkg.o repository_finddeps.o
|
||||
OBJS += repository_pool.o repository_sync_index.o
|
||||
OBJS += $(COMPAT_SRCS)
|
||||
|
||||
|
@ -49,7 +49,7 @@ xbps_entry_is_a_conf_file(prop_dictionary_t propsd,
|
||||
if (!prop_dictionary_get(propsd, "conf_files"))
|
||||
return 0;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(propsd, "conf_files");
|
||||
iter = xbps_array_iter_from_dict(propsd, "conf_files");
|
||||
if (iter == NULL)
|
||||
return -1;
|
||||
|
||||
@ -96,7 +96,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
assert(pkgname != NULL);
|
||||
assert(version != NULL);
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(filesd, "conf_files");
|
||||
iter = xbps_array_iter_from_dict(filesd, "conf_files");
|
||||
if (iter == NULL)
|
||||
return -1;
|
||||
|
||||
@ -107,7 +107,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
xbps_dbg_printf("%s: processing conf_file %s\n",
|
||||
pkgname, entry_pname);
|
||||
|
||||
forigd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
forigd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
if (forigd == NULL) {
|
||||
xbps_dbg_printf("%s: conf_file %s not currently installed\n",
|
||||
pkgname, entry_pname);
|
||||
@ -115,7 +115,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
goto out;
|
||||
}
|
||||
|
||||
iter2 = xbps_get_array_iter_from_dict(forigd, "conf_files");
|
||||
iter2 = xbps_array_iter_from_dict(forigd, "conf_files");
|
||||
if (iter2 != NULL) {
|
||||
while ((obj2 = prop_object_iterator_next(iter2))) {
|
||||
prop_dictionary_get_cstring_nocopy(obj2,
|
||||
@ -163,7 +163,7 @@ xbps_entry_install_conf_file(prop_dictionary_t filesd,
|
||||
buf = NULL;
|
||||
continue;
|
||||
}
|
||||
sha256_cur = xbps_get_file_hash(buf);
|
||||
sha256_cur = xbps_file_hash(buf);
|
||||
free(buf);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256_new);
|
||||
if (sha256_cur == NULL) {
|
||||
|
@ -49,7 +49,7 @@
|
||||
*/
|
||||
|
||||
int
|
||||
xbps_configure_all_pkgs(void)
|
||||
xbps_configure_packages(void)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
prop_object_t obj;
|
||||
@ -60,7 +60,7 @@ xbps_configure_all_pkgs(void)
|
||||
if ((d = xbps_regpkgdb_dictionary_get()) == NULL)
|
||||
return errno;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(d, "packages");
|
||||
iter = xbps_array_iter_from_dict(d, "packages");
|
||||
if (iter == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
@ -98,7 +98,7 @@ xbps_configure_pkg(const char *pkgname,
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
if (check_state) {
|
||||
rv = xbps_get_pkg_state_installed(pkgname, &state);
|
||||
rv = xbps_pkg_state_installed(pkgname, &state);
|
||||
if (rv != 0)
|
||||
return EINVAL;
|
||||
|
||||
|
@ -88,7 +88,7 @@ find_orphan_pkg(prop_object_t obj, void *arg, bool *loop_done)
|
||||
if (!automatic)
|
||||
return 0;
|
||||
|
||||
if ((rv = xbps_get_pkg_state_dictionary(obj, &state)) != 0)
|
||||
if ((rv = xbps_pkg_state_dictionary(obj, &state)) != 0)
|
||||
return rv;
|
||||
/*
|
||||
* Skip packages that aren't fully installed.
|
||||
@ -138,7 +138,7 @@ find_orphan_pkg(prop_object_t obj, void *arg, bool *loop_done)
|
||||
if (od->orphans_user == NULL)
|
||||
continue;
|
||||
|
||||
pkgdepname = xbps_get_pkg_name(pkgdep);
|
||||
pkgdepname = xbps_pkg_name(pkgdep);
|
||||
assert(pkgdepname != NULL);
|
||||
for (i = 0; i < prop_array_count(od->orphans_user); i++) {
|
||||
prop_array_get_cstring_nocopy(od->orphans_user,
|
||||
|
@ -94,7 +94,7 @@ remove_pkg_metadata(const char *pkgname, const char *rootdir)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_purge_all_pkgs(void)
|
||||
xbps_purge_packages(void)
|
||||
{
|
||||
|
||||
prop_dictionary_t d;
|
||||
@ -106,7 +106,7 @@ xbps_purge_all_pkgs(void)
|
||||
if ((d = xbps_regpkgdb_dictionary_get()) == NULL)
|
||||
return errno;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(d, "packages");
|
||||
iter = xbps_array_iter_from_dict(d, "packages");
|
||||
if (iter == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
@ -151,7 +151,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
|
||||
/*
|
||||
* Skip packages that aren't in "config-files" state.
|
||||
*/
|
||||
if ((rv = xbps_get_pkg_state_dictionary(pkgd, &state)) != 0)
|
||||
if ((rv = xbps_pkg_state_dictionary(pkgd, &state)) != 0)
|
||||
goto out;
|
||||
if (state != XBPS_PKG_STATE_CONFIG_FILES)
|
||||
goto out;
|
||||
@ -159,7 +159,7 @@ xbps_purge_pkg(const char *pkgname, bool check_state)
|
||||
/*
|
||||
* Remove unmodified configuration files.
|
||||
*/
|
||||
dict = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
dict = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
if (dict == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
|
@ -92,7 +92,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
|
||||
else if (prop_array_count(array) == 0)
|
||||
return 0;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(dict, key);
|
||||
iter = xbps_array_iter_from_dict(dict, key);
|
||||
if (iter == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
@ -121,7 +121,7 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
|
||||
*/
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"sha256", &sha256);
|
||||
rv = xbps_check_file_hash(path, sha256);
|
||||
rv = xbps_file_hash_check(path, sha256);
|
||||
if (rv == ENOENT) {
|
||||
xbps_warn_printf("'%s' doesn't exist!\n", file);
|
||||
free(path);
|
||||
@ -232,7 +232,7 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
|
||||
/*
|
||||
* Remove links, files and dirs.
|
||||
*/
|
||||
dict = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
dict = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES);
|
||||
if (dict == NULL) {
|
||||
free(buf);
|
||||
return errno;
|
||||
|
@ -53,10 +53,10 @@ xbps_remove_obsoletes(prop_dictionary_t oldd, prop_dictionary_t newd)
|
||||
assert(newd != NULL);
|
||||
|
||||
again:
|
||||
iter = xbps_get_array_iter_from_dict(oldd, array_str);
|
||||
iter = xbps_array_iter_from_dict(oldd, array_str);
|
||||
if (iter == NULL)
|
||||
return errno;
|
||||
iter2 = xbps_get_array_iter_from_dict(newd, array_str);
|
||||
iter2 = xbps_array_iter_from_dict(newd, array_str);
|
||||
if (iter2 == NULL) {
|
||||
prop_object_iterator_release(iter);
|
||||
return errno;
|
||||
@ -82,7 +82,7 @@ again:
|
||||
if (strcmp(array_str, "files") == 0) {
|
||||
prop_dictionary_get_cstring_nocopy(obj,
|
||||
"sha256", &oldhash);
|
||||
rv = xbps_check_file_hash(file, oldhash);
|
||||
rv = xbps_file_hash_check(file, oldhash);
|
||||
if (rv == ENOENT || rv == ERANGE) {
|
||||
/*
|
||||
* Skip unexistent and files that do not
|
||||
|
@ -99,7 +99,7 @@ get_state(prop_dictionary_t dict)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state)
|
||||
xbps_pkg_state_installed(const char *pkgname, pkg_state_t *state)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
|
||||
@ -119,7 +119,7 @@ xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_get_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state)
|
||||
xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state)
|
||||
{
|
||||
assert(dict != NULL);
|
||||
assert(state != NULL);
|
||||
|
@ -160,9 +160,9 @@ remove_file_wrong_hash(prop_dictionary_t d, const char *file)
|
||||
return 0;
|
||||
|
||||
/* Only check for regular files, not symlinks, dirs or conffiles. */
|
||||
hash = xbps_get_file_hash_from_dict(d, "files", file);
|
||||
hash = xbps_file_hash_from_dictionary(d, "files", file);
|
||||
if (hash) {
|
||||
rv = xbps_check_file_hash(file, hash);
|
||||
rv = xbps_file_hash_check(file, hash);
|
||||
if (rv == ERANGE) {
|
||||
(void)unlink(file);
|
||||
xbps_warn_printf("Removed `%s' entry with "
|
||||
@ -319,7 +319,7 @@ unpack_archive(prop_dictionary_t pkg_repod,
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
|
||||
propsd = xbps_get_pkg_dict_from_metadata_plist(
|
||||
propsd = xbps_dictionary_from_metadata_plist(
|
||||
pkgname, XBPS_PKGPROPS);
|
||||
if (propsd == NULL) {
|
||||
rv = errno;
|
||||
@ -518,7 +518,7 @@ xbps_unpack_binary_pkg(prop_dictionary_t pkg_repod)
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
||||
|
||||
bpkg = xbps_get_binpkg_repo_uri(pkg_repod, repoloc);
|
||||
bpkg = xbps_path_from_repository_uri(pkg_repod, repoloc);
|
||||
if (bpkg == NULL) {
|
||||
xbps_error_printf("cannot determine binary pkg file "
|
||||
"for `%s-%s': %s\n", pkgname, version, strerror(errno));
|
||||
|
13
lib/plist.c
13
lib/plist.c
@ -116,7 +116,7 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t dict,
|
||||
assert(key != NULL);
|
||||
assert(fn != NULL);
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(dict, key);
|
||||
iter = xbps_array_iter_from_dict(dict, key);
|
||||
if (iter == NULL)
|
||||
return EINVAL;
|
||||
|
||||
@ -167,7 +167,7 @@ xbps_callback_array_iter_reverse_in_dict(prop_dictionary_t dict,
|
||||
}
|
||||
|
||||
prop_object_iterator_t
|
||||
xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||
xbps_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||
{
|
||||
prop_array_t array;
|
||||
|
||||
@ -184,18 +184,19 @@ xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_get_pkg_dict_from_metadata_plist(const char *pkgn, const char *plist)
|
||||
xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
const char *plist)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
prop_dictionary_t plistd = NULL;
|
||||
char *plistf;
|
||||
|
||||
assert(pkgn != NULL);
|
||||
assert(pkgname != NULL);
|
||||
assert(plist != NULL);
|
||||
xhp = xbps_handle_get();
|
||||
|
||||
plistf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
||||
xhp->rootdir, XBPS_META_PATH, pkgn, plist);
|
||||
xhp->rootdir, XBPS_META_PATH, pkgname, plist);
|
||||
if (plistf == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -203,7 +204,7 @@ xbps_get_pkg_dict_from_metadata_plist(const char *pkgn, const char *plist)
|
||||
free(plistf);
|
||||
if (plistd == NULL) {
|
||||
xbps_dbg_printf("cannot read from plist file %s for %s: %s\n",
|
||||
plist, pkgn, strerror(errno));
|
||||
plist, pkgname, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,9 @@
|
||||
#include "fetch.h"
|
||||
|
||||
/**
|
||||
* @file lib/repository_plist.c
|
||||
* @brief Repository plist file handling routines
|
||||
* @defgroup repo_plist Repository plist file handling functions
|
||||
* @file lib/plist_fetch.c
|
||||
* @brief Package URL metadata files handling
|
||||
* @defgroup plist_fetch Package URL metadata files handling
|
||||
*/
|
||||
|
||||
struct fetch_archive {
|
||||
@ -144,7 +144,7 @@ open_archive(const char *url)
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_repository_plist_find_pkg_dict_from_url(const char *url, const char *plistf)
|
||||
xbps_dictionary_metadata_plist_by_url(const char *url, const char *plistf)
|
||||
{
|
||||
prop_dictionary_t plistd = NULL;
|
||||
struct archive *a;
|
||||
@ -192,50 +192,3 @@ xbps_repository_plist_find_pkg_dict_from_url(const char *url, const char *plistf
|
||||
|
||||
return plistd;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_repository_plist_find_pkg_dict(const char *pkgname, const char *plistf)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL, plistd = NULL;
|
||||
const char *repoloc;
|
||||
char *url;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(plistf != NULL);
|
||||
|
||||
if ((rv = xbps_repository_pool_init()) != 0) {
|
||||
errno = rv;
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
* Iterate over the the repository pool and search for a plist file
|
||||
* in the binary package named 'pkgname'. The plist file will be
|
||||
* internalized to a proplib dictionary.
|
||||
*
|
||||
* The first repository that has it wins and the loop is stopped.
|
||||
* This will work locally and remotely, thanks to libarchive and
|
||||
* libfetch!
|
||||
*/
|
||||
pkgd = xbps_repository_pool_find_pkg(pkgname, false, false);
|
||||
if (pkgd == NULL)
|
||||
goto out;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
|
||||
url = xbps_get_binpkg_repo_uri(pkgd, repoloc);
|
||||
if (url == NULL) {
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
plistd = xbps_repository_plist_find_pkg_dict_from_url(url, plistf);
|
||||
free(url);
|
||||
|
||||
out:
|
||||
xbps_repository_pool_release();
|
||||
if (plistd == NULL)
|
||||
errno = ENOENT;
|
||||
if (pkgd)
|
||||
prop_object_release(pkgd);
|
||||
|
||||
return plistd;
|
||||
}
|
@ -177,7 +177,7 @@ find_virtualpkg_user_in_regpkgdb(const char *virtualpkg, bool bypattern)
|
||||
if ((d = xbps_regpkgdb_dictionary_get()) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((iter = xbps_get_array_iter_from_dict(d, "properties")) == NULL) {
|
||||
if ((iter = xbps_array_iter_from_dict(d, "properties")) == NULL) {
|
||||
xbps_regpkgdb_dictionary_release();
|
||||
return NULL;
|
||||
}
|
||||
@ -315,7 +315,7 @@ xbps_find_pkg_dict_installed(const char *str, bool bypattern)
|
||||
if (pkgd == NULL)
|
||||
goto out;
|
||||
|
||||
if (xbps_get_pkg_state_dictionary(pkgd, &state) != 0)
|
||||
if (xbps_pkg_state_dictionary(pkgd, &state) != 0)
|
||||
goto out;
|
||||
|
||||
switch (state) {
|
||||
@ -363,7 +363,7 @@ find_string_in_array(prop_array_t array, const char *str, int mode)
|
||||
} else if (mode == 1) {
|
||||
/* match by pkgname */
|
||||
pkgdep = prop_string_cstring_nocopy(obj);
|
||||
curpkgname = xbps_get_pkg_name(pkgdep);
|
||||
curpkgname = xbps_pkg_name(pkgdep);
|
||||
if (curpkgname == NULL)
|
||||
break;
|
||||
if (strcmp(curpkgname, str) == 0) {
|
||||
|
@ -60,7 +60,7 @@ remove_string_from_array(prop_array_t array, const char *str, int mode)
|
||||
} else if (mode == 1) {
|
||||
/* match by pkgname, obj is a string */
|
||||
pkgdep = prop_string_cstring_nocopy(obj);
|
||||
curpkgname = xbps_get_pkg_name(pkgdep);
|
||||
curpkgname = xbps_pkg_name(pkgdep);
|
||||
if (curpkgname == NULL)
|
||||
break;
|
||||
if (strcmp(curpkgname, str) == 0) {
|
||||
|
@ -76,7 +76,7 @@ store_dependency(prop_dictionary_t transd, prop_dictionary_t repo_pkgd)
|
||||
* Overwrite package state in dictionary with same state than the
|
||||
* package currently uses, otherwise not-installed.
|
||||
*/
|
||||
if ((rv = xbps_get_pkg_state_installed(pkgname, &state)) != 0) {
|
||||
if ((rv = xbps_pkg_state_installed(pkgname, &state)) != 0) {
|
||||
if (rv != ENOENT) {
|
||||
prop_object_release(dict);
|
||||
return rv;
|
||||
@ -136,14 +136,14 @@ add_missing_reqdep(prop_array_t missing_rdeps, const char *reqpkg)
|
||||
|
||||
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
||||
curdep = prop_string_cstring_nocopy(obj);
|
||||
curver = xbps_get_pkgpattern_version(curdep);
|
||||
pkgver = xbps_get_pkgpattern_version(reqpkg);
|
||||
curver = xbps_pkgpattern_version(curdep);
|
||||
pkgver = xbps_pkgpattern_version(reqpkg);
|
||||
if (curver == NULL || pkgver == NULL)
|
||||
goto out;
|
||||
curpkgnamedep = xbps_get_pkgpattern_name(curdep);
|
||||
curpkgnamedep = xbps_pkgpattern_name(curdep);
|
||||
if (curpkgnamedep == NULL)
|
||||
goto out;
|
||||
pkgnamedep = xbps_get_pkgpattern_name(reqpkg);
|
||||
pkgnamedep = xbps_pkgpattern_name(reqpkg);
|
||||
if (pkgnamedep == NULL) {
|
||||
free(curpkgnamedep);
|
||||
goto out;
|
||||
@ -281,7 +281,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pkgname = xbps_get_pkgpattern_name(reqpkg);
|
||||
pkgname = xbps_pkgpattern_name(reqpkg);
|
||||
if (pkgname == NULL) {
|
||||
prop_object_release(curpkgd);
|
||||
rv = EINVAL;
|
||||
@ -313,7 +313,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
||||
"pkgver", &pkgver_q);
|
||||
|
||||
/* Check its state */
|
||||
rv = xbps_get_pkg_state_installed(pkgname, &state);
|
||||
rv = xbps_pkg_state_installed(pkgname, &state);
|
||||
if (rv != 0) {
|
||||
free(pkgname);
|
||||
prop_object_release(tmpd);
|
||||
|
@ -138,7 +138,7 @@ repository_find_pkg(const char *pattern, const char *reason)
|
||||
* Set package state in dictionary with same state than the
|
||||
* package currently uses, otherwise not-installed.
|
||||
*/
|
||||
if ((rv = xbps_get_pkg_state_installed(pkgname, &state)) != 0) {
|
||||
if ((rv = xbps_pkg_state_installed(pkgname, &state)) != 0) {
|
||||
if (rv != ENOENT)
|
||||
goto out;
|
||||
/* Package not installed, don't error out */
|
||||
@ -191,7 +191,7 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
xbps_repository_update_allpkgs(void)
|
||||
xbps_repository_update_packages(void)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
prop_object_t obj;
|
||||
@ -207,7 +207,7 @@ xbps_repository_update_allpkgs(void)
|
||||
if (dict == NULL)
|
||||
return ENOENT;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(dict, "packages");
|
||||
iter = xbps_array_iter_from_dict(dict, "packages");
|
||||
if (iter == NULL) {
|
||||
xbps_regpkgdb_dictionary_release();
|
||||
return ENOENT;
|
||||
|
@ -111,7 +111,7 @@ xbps_repository_pool_init(void)
|
||||
* for current repository into the queue.
|
||||
*/
|
||||
plist =
|
||||
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||
xbps_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||
if (plist == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
@ -403,3 +403,51 @@ out:
|
||||
|
||||
return pkgd;
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_repository_pool_dictionary_metadata_plist(const char *pkgname,
|
||||
const char *plistf)
|
||||
{
|
||||
prop_dictionary_t pkgd = NULL, plistd = NULL;
|
||||
const char *repoloc;
|
||||
char *url;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(plistf != NULL);
|
||||
|
||||
if ((rv = xbps_repository_pool_init()) != 0) {
|
||||
errno = rv;
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
* Iterate over the the repository pool and search for a plist file
|
||||
* in the binary package named 'pkgname'. The plist file will be
|
||||
* internalized to a proplib dictionary.
|
||||
*
|
||||
* The first repository that has it wins and the loop is stopped.
|
||||
* This will work locally and remotely, thanks to libarchive and
|
||||
* libfetch!
|
||||
*/
|
||||
pkgd = xbps_repository_pool_find_pkg(pkgname, false, false);
|
||||
if (pkgd == NULL)
|
||||
goto out;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "repository", &repoloc);
|
||||
url = xbps_path_from_repository_uri(pkgd, repoloc);
|
||||
if (url == NULL) {
|
||||
errno = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
plistd = xbps_dictionary_metadata_plist_by_url(url, plistf);
|
||||
free(url);
|
||||
|
||||
out:
|
||||
xbps_repository_pool_release();
|
||||
if (plistd == NULL)
|
||||
errno = ENOENT;
|
||||
if (pkgd)
|
||||
prop_object_release(pkgd);
|
||||
|
||||
return plistd;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ xbps_repository_unregister(const char *uri)
|
||||
* file and its directory.
|
||||
*/
|
||||
if (xbps_check_is_repository_uri_remote(uri)) {
|
||||
pkgindex = xbps_get_pkg_index_plist(uri);
|
||||
pkgindex = xbps_pkg_index_plist(uri);
|
||||
if (pkgindex == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
|
@ -109,7 +109,7 @@ compute_transaction_sizes(void)
|
||||
int rv = 0;
|
||||
const char *tract;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(transd, "packages");
|
||||
iter = xbps_array_iter_from_dict(transd, "packages");
|
||||
if (iter == NULL)
|
||||
return EINVAL;
|
||||
|
||||
|
@ -179,7 +179,7 @@ again:
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
}
|
||||
pkgnamedep = xbps_get_pkgpattern_name(str);
|
||||
pkgnamedep = xbps_pkgpattern_name(str);
|
||||
if (pkgnamedep == NULL) {
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
|
32
lib/util.c
32
lib/util.c
@ -72,7 +72,7 @@ digest2string(const uint8_t *digest, char *string, size_t len)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_get_file_hash(const char *file)
|
||||
xbps_file_hash(const char *file)
|
||||
{
|
||||
struct stat st;
|
||||
size_t pgsize = (size_t)sysconf(_SC_PAGESIZE);
|
||||
@ -128,14 +128,14 @@ xbps_get_file_hash(const char *file)
|
||||
}
|
||||
|
||||
int
|
||||
xbps_check_file_hash(const char *file, const char *sha256)
|
||||
xbps_file_hash_check(const char *file, const char *sha256)
|
||||
{
|
||||
char *res;
|
||||
|
||||
assert(file != NULL);
|
||||
assert(sha256 != NULL);
|
||||
|
||||
res = xbps_get_file_hash(file);
|
||||
res = xbps_file_hash(file);
|
||||
if (res == NULL)
|
||||
return errno;
|
||||
|
||||
@ -149,9 +149,9 @@ xbps_check_file_hash(const char *file, const char *sha256)
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_file_hash_from_dict(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file)
|
||||
xbps_file_hash_from_dictionary(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *file)
|
||||
{
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
@ -163,7 +163,7 @@ xbps_get_file_hash_from_dict(prop_dictionary_t d,
|
||||
|
||||
curfile = sha256 = NULL;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(d, key);
|
||||
iter = xbps_array_iter_from_dict(d, key);
|
||||
if (iter == NULL)
|
||||
return NULL;
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
@ -216,7 +216,7 @@ xbps_check_is_installed_pkg_by_pattern(const char *pattern)
|
||||
* Check that package state is fully installed, not
|
||||
* unpacked or something else.
|
||||
*/
|
||||
if (xbps_get_pkg_state_dictionary(dict, &state) != 0) {
|
||||
if (xbps_pkg_state_dictionary(dict, &state) != 0) {
|
||||
prop_object_release(dict);
|
||||
return -1; /* error */
|
||||
}
|
||||
@ -246,7 +246,7 @@ xbps_check_is_installed_pkg_by_name(const char *pkgname)
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_pkg_epoch(const char *pkg)
|
||||
xbps_pkg_epoch(const char *pkg)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
@ -260,7 +260,7 @@ xbps_get_pkg_epoch(const char *pkg)
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_pkg_version(const char *pkg)
|
||||
xbps_pkg_version(const char *pkg)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
@ -275,7 +275,7 @@ xbps_get_pkg_version(const char *pkg)
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_pkg_revision(const char *pkg)
|
||||
xbps_pkg_revision(const char *pkg)
|
||||
{
|
||||
const char *tmp;
|
||||
|
||||
@ -290,7 +290,7 @@ xbps_get_pkg_revision(const char *pkg)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_get_pkg_name(const char *pkg)
|
||||
xbps_pkg_name(const char *pkg)
|
||||
{
|
||||
const char *tmp;
|
||||
char *pkgname;
|
||||
@ -314,7 +314,7 @@ xbps_get_pkg_name(const char *pkg)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_get_pkgpattern_name(const char *pkg)
|
||||
xbps_pkgpattern_name(const char *pkg)
|
||||
{
|
||||
char *res, *pkgname;
|
||||
size_t len;
|
||||
@ -336,7 +336,7 @@ xbps_get_pkgpattern_name(const char *pkg)
|
||||
}
|
||||
|
||||
const char *
|
||||
xbps_get_pkgpattern_version(const char *pkg)
|
||||
xbps_pkgpattern_version(const char *pkg)
|
||||
{
|
||||
char *res;
|
||||
|
||||
@ -374,7 +374,7 @@ get_pkg_index_remote_plist(const char *uri)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_get_pkg_index_plist(const char *uri)
|
||||
xbps_pkg_index_plist(const char *uri)
|
||||
{
|
||||
struct utsname un;
|
||||
|
||||
@ -390,7 +390,7 @@ xbps_get_pkg_index_plist(const char *uri)
|
||||
}
|
||||
|
||||
char *
|
||||
xbps_get_binpkg_repo_uri(prop_dictionary_t pkg_repod, const char *repoloc)
|
||||
xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
|
||||
{
|
||||
const struct xbps_handle *xhp;
|
||||
const char *filen, *arch;
|
||||
|
Reference in New Issue
Block a user