From 841c9e2d5178bc935d9406ba65ae4105d57a815f Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 1 Jun 2011 09:37:32 +0200 Subject: [PATCH] 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 --- bin/xbps-bin/check.c | 16 ++-- bin/xbps-bin/find-files.c | 2 +- bin/xbps-bin/install.c | 18 ++-- bin/xbps-bin/main.c | 6 +- bin/xbps-bin/show-deps.c | 2 +- bin/xbps-bin/show-info-files.c | 4 +- bin/xbps-bin/util.c | 2 +- bin/xbps-dgraph/main.c | 2 +- bin/xbps-repo/find-files.c | 6 +- bin/xbps-repo/index.c | 9 +- bin/xbps-repo/main.c | 2 +- bin/xbps-repo/repository.c | 6 +- bin/xbps-uhelper/main.c | 12 +-- include/xbps_api.h | 109 +++++++++++----------- lib/Makefile | 4 +- lib/package_config_files.c | 10 +- lib/package_configure.c | 6 +- lib/package_orphans.c | 4 +- lib/package_purge.c | 8 +- lib/package_remove.c | 6 +- lib/package_remove_obsoletes.c | 6 +- lib/package_state.c | 4 +- lib/package_unpack.c | 8 +- lib/plist.c | 13 +-- lib/{repository_plist.c => plist_fetch.c} | 55 +---------- lib/plist_find.c | 6 +- lib/plist_remove.c | 2 +- lib/repository_finddeps.c | 14 +-- lib/repository_findpkg.c | 6 +- lib/repository_pool.c | 50 +++++++++- lib/repository_register.c | 2 +- lib/transaction_dictionary.c | 2 +- lib/transaction_sortdeps.c | 2 +- lib/util.c | 32 +++---- 34 files changed, 219 insertions(+), 217 deletions(-) rename lib/{repository_plist.c => plist_fetch.c} (76%) diff --git a/bin/xbps-bin/check.c b/bin/xbps-bin/check.c index 5f934156..8a8be883 100644 --- a/bin/xbps-bin/check.c +++ b/bin/xbps-bin/check.c @@ -64,7 +64,7 @@ xbps_check_pkg_integrity_all(void) if (d == NULL) return ENODEV; - iter = xbps_get_array_iter_from_dict(d, "packages"); + iter = xbps_array_iter_from_dict(d, "packages"); if (iter == NULL) { rv = ENOENT; goto out; @@ -117,7 +117,7 @@ xbps_check_pkg_integrity(const char *pkgname) /* * Check for props.plist metadata file. */ - propsd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGPROPS); + propsd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS); if (prop_object_type(propsd) != PROP_TYPE_DICTIONARY) { fprintf(stderr, "E: %s: unexistent %s or invalid metadata file.\n", pkgname, @@ -135,7 +135,7 @@ xbps_check_pkg_integrity(const char *pkgname) /* * Check for files.plist metadata file. */ - filesd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES); + filesd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES); if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY) { fprintf(stderr, "E: %s: unexistent %s or invalid metadata file.\n", pkgname, @@ -156,7 +156,7 @@ xbps_check_pkg_integrity(const char *pkgname) array = prop_dictionary_get(filesd, "links"); if ((prop_object_type(array) == PROP_TYPE_ARRAY) && prop_array_count(array) > 0) { - iter = xbps_get_array_iter_from_dict(filesd, "links"); + iter = xbps_array_iter_from_dict(filesd, "links"); if (iter == NULL) { rv = ENOMEM; goto out; @@ -186,7 +186,7 @@ xbps_check_pkg_integrity(const char *pkgname) array = prop_dictionary_get(filesd, "files"); if ((prop_object_type(array) == PROP_TYPE_ARRAY) && prop_array_count(array) > 0) { - iter = xbps_get_array_iter_from_dict(filesd, "files"); + iter = xbps_array_iter_from_dict(filesd, "files"); if (iter == NULL) { rv = ENOMEM; goto out; @@ -201,7 +201,7 @@ xbps_check_pkg_integrity(const char *pkgname) } prop_dictionary_get_cstring_nocopy(obj, "sha256", &sha256); - rv = xbps_check_file_hash(path, sha256); + rv = xbps_file_hash_check(path, sha256); switch (rv) { case 0: break; @@ -236,7 +236,7 @@ xbps_check_pkg_integrity(const char *pkgname) array = prop_dictionary_get(filesd, "conf_files"); if (array && prop_object_type(array) == PROP_TYPE_ARRAY && prop_array_count(array) > 0) { - iter = xbps_get_array_iter_from_dict(filesd, "conf_files"); + iter = xbps_array_iter_from_dict(filesd, "conf_files"); if (iter == NULL) { rv = ENOMEM; goto out; @@ -273,7 +273,7 @@ xbps_check_pkg_integrity(const char *pkgname) * Check for missing run time dependencies. */ if (xbps_pkg_has_rundeps(propsd)) { - iter = xbps_get_array_iter_from_dict(propsd, "run_depends"); + iter = xbps_array_iter_from_dict(propsd, "run_depends"); if (iter == NULL) { rv = ENOMEM; goto out; diff --git a/bin/xbps-bin/find-files.c b/bin/xbps-bin/find-files.c index d0de3288..bf54ff91 100644 --- a/bin/xbps-bin/find-files.c +++ b/bin/xbps-bin/find-files.c @@ -96,7 +96,7 @@ find_files_in_packages(const char *pattern) (strcmp(dp->d_name, "..") == 0)) continue; - pkg_filesd = xbps_get_pkg_dict_from_metadata_plist(dp->d_name, + pkg_filesd = xbps_dictionary_from_metadata_plist(dp->d_name, XBPS_PKGFILES); if (pkg_filesd == NULL) { if (errno == ENOENT) diff --git a/bin/xbps-bin/install.c b/bin/xbps-bin/install.c index d39feeaf..2edfe47f 100644 --- a/bin/xbps-bin/install.c +++ b/bin/xbps-bin/install.c @@ -73,7 +73,7 @@ check_binpkg_hash(const char *path, int rv; printf("Checking %s integrity... ", filename); - rv = xbps_check_file_hash(path, sha256); + rv = xbps_file_hash_check(path, sha256); if (rv != 0 && rv != ERANGE) { xbps_error_printf("\nxbps-bin: unexpected error: %s\n", strerror(rv)); @@ -121,7 +121,7 @@ again: prop_dictionary_get_cstring_nocopy(obj, "filename-sha256", &sha256); - binfile = xbps_get_binpkg_repo_uri(obj, repoloc); + binfile = xbps_path_from_repository_uri(obj, repoloc); if (binfile == NULL) return errno; /* @@ -159,7 +159,7 @@ again: return -1; } free(binfile); - binfile = xbps_get_binpkg_repo_uri(obj, repoloc); + binfile = xbps_path_from_repository_uri(obj, repoloc); if (binfile == NULL) return errno; @@ -285,7 +285,7 @@ xbps_autoupdate_pkgs(bool yes, bool show_download_pkglist_url) * "xbps-bin autoupdate". */ printf("Finding new packages...\n"); - if ((rv = xbps_repository_update_allpkgs()) != 0) { + if ((rv = xbps_repository_update_packages()) != 0) { if (rv == ENOENT) { printf("No packages currently registered.\n"); return 0; @@ -311,7 +311,7 @@ xbps_install_new_pkg(const char *pkg) bool pkgmatch = false; pkg_state_t state; - if (xbps_get_pkgpattern_version(pkg)) { + if (xbps_pkgpattern_version(pkg)) { pkgpatt = __UNCONST(pkg); } else { /* @@ -323,14 +323,14 @@ xbps_install_new_pkg(const char *pkg) if (pkgpatt == NULL) return -1; } - pkgname = xbps_get_pkgpattern_name(pkgpatt); + pkgname = xbps_pkgpattern_name(pkgpatt); if (pkgname == NULL) return -1; /* * Find a package in a repository and prepare for installation. */ if ((pkgd = xbps_find_pkg_dict_installed(pkgname, false))) { - if ((rv = xbps_get_pkg_state_dictionary(pkgd, &state)) != 0) { + if ((rv = xbps_pkg_state_dictionary(pkgd, &state)) != 0) { prop_object_release(pkgd); goto out; } @@ -494,7 +494,7 @@ exec_transaction(struct transaction *trans) * If dependency is already unpacked skip this phase. */ state = 0; - if (xbps_get_pkg_state_dictionary(obj, &state) != 0) + if (xbps_pkg_state_dictionary(obj, &state) != 0) return EINVAL; if (state == XBPS_PKG_STATE_UNPACKED) continue; @@ -603,7 +603,7 @@ xbps_exec_transaction(bool yes, bool show_download_pkglist_url) /* * It's time to run the transaction! */ - trans->iter = xbps_get_array_iter_from_dict(trans->dict, "packages"); + trans->iter = xbps_array_iter_from_dict(trans->dict, "packages"); if (trans->iter == NULL) { rv = errno; xbps_error_printf("xbps-bin: error allocating array mem! (%s)\n", diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index b933799f..feb1532b 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -64,7 +64,7 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done) (void)loop_done; - if (xbps_get_pkg_state_dictionary(obj, &curstate)) + if (xbps_pkg_state_dictionary(obj, &curstate)) return EINVAL; if (lpc->state == 0) { @@ -439,7 +439,7 @@ main(int argc, char **argv) usage(); if (strcasecmp(argv[1], "all") == 0) - rv = xbps_purge_all_pkgs(); + rv = xbps_purge_packages(); else rv = xbps_purge_pkg(argv[1], true); @@ -451,7 +451,7 @@ main(int argc, char **argv) usage(); if (strcasecmp(argv[1], "all") == 0) - rv = xbps_configure_all_pkgs(); + rv = xbps_configure_packages(); else rv = xbps_configure_pkg(argv[1], NULL, true, false); diff --git a/bin/xbps-bin/show-deps.c b/bin/xbps-bin/show-deps.c index eac3ce09..c17dd9f0 100644 --- a/bin/xbps-bin/show-deps.c +++ b/bin/xbps-bin/show-deps.c @@ -52,7 +52,7 @@ xbps_show_pkg_deps(const char *pkgname) /* * Check for props.plist metadata file. */ - propsd = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGPROPS); + propsd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS); if (propsd == NULL) { fprintf(stderr, "%s: unexistent %s metadata file.\n", pkgname, diff --git a/bin/xbps-bin/show-info-files.c b/bin/xbps-bin/show-info-files.c index f7110035..a89307bf 100644 --- a/bin/xbps-bin/show-info-files.c +++ b/bin/xbps-bin/show-info-files.c @@ -39,7 +39,7 @@ show_pkg_info_from_metadir(const char *pkgname) { prop_dictionary_t d, regpkgd, pkgpropsd; - d = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGPROPS); + d = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGPROPS); if (d == NULL) return EINVAL; @@ -71,7 +71,7 @@ show_pkg_files_from_metadir(const char *pkgname) prop_dictionary_t d; int rv = 0; - d = xbps_get_pkg_dict_from_metadata_plist(pkgname, XBPS_PKGFILES); + d = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES); if (d == NULL) return EINVAL; diff --git a/bin/xbps-bin/util.c b/bin/xbps-bin/util.c index cd450e01..4920d948 100644 --- a/bin/xbps-bin/util.c +++ b/bin/xbps-bin/util.c @@ -203,7 +203,7 @@ show_pkg_files(prop_dictionary_t filesd) if (array == NULL || prop_array_count(array) == 0) continue; - iter = xbps_get_array_iter_from_dict(filesd, array_str); + iter = xbps_array_iter_from_dict(filesd, array_str); if (iter == NULL) return EINVAL; diff --git a/bin/xbps-dgraph/main.c b/bin/xbps-dgraph/main.c index 1fd35573..62ed079b 100644 --- a/bin/xbps-dgraph/main.c +++ b/bin/xbps-dgraph/main.c @@ -513,7 +513,7 @@ main(int argc, char **argv) /* * Internalize the plist file of the target installed package. */ - plistd = xbps_get_pkg_dict_from_metadata_plist(argv[0], XBPS_PKGPROPS); + plistd = xbps_dictionary_from_metadata_plist(argv[0], XBPS_PKGPROPS); if (plistd == NULL) die("cannot internalize %s from %s", XBPS_PKGPROPS, argv[0]); diff --git a/bin/xbps-repo/find-files.c b/bin/xbps-repo/find-files.c index 7a3a5796..fe40432e 100644 --- a/bin/xbps-repo/find-files.c +++ b/bin/xbps-repo/find-files.c @@ -81,20 +81,20 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done) (void)done; - iter = xbps_get_array_iter_from_dict(rpi->rpi_repod, "packages"); + iter = xbps_array_iter_from_dict(rpi->rpi_repod, "packages"); if (iter == NULL) return -1; printf("Looking in repository '%s', please wait...\n", rpi->rpi_uri); while ((obj = prop_object_iterator_next(iter))) { - url = xbps_get_binpkg_repo_uri(obj, rpi->rpi_uri); + url = xbps_path_from_repository_uri(obj, rpi->rpi_uri); if (url == NULL) { rv = -1; break; } prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - pkg_filesd = xbps_repository_plist_find_pkg_dict_from_url(url, + pkg_filesd = xbps_dictionary_metadata_plist_by_url(url, XBPS_PKGFILES); free(url); if (pkg_filesd == NULL) { diff --git a/bin/xbps-repo/index.c b/bin/xbps-repo/index.c index ca344bef..3c7db16d 100644 --- a/bin/xbps-repo/index.c +++ b/bin/xbps-repo/index.c @@ -46,7 +46,7 @@ repoidx_getdict(const char *pkgdir) prop_array_t array; char *plist; - plist = xbps_get_pkg_index_plist(pkgdir); + plist = xbps_pkg_index_plist(pkgdir); if (plist == NULL) return NULL; @@ -104,8 +104,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir, goto out; } - newpkgd = xbps_repository_plist_find_pkg_dict_from_url(file, - XBPS_PKGPROPS); + newpkgd = xbps_dictionary_metadata_plist_by_url(file, XBPS_PKGPROPS); if (newpkgd == NULL) { xbps_error_printf("xbps-repo: can't read %s %s metadata " "file, skipping!\n", file, XBPS_PKGPROPS); @@ -186,7 +185,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir, rv = errno; goto out; } - sha256 = xbps_get_file_hash(file); + sha256 = xbps_file_hash(file); if (sha256 == NULL) { prop_object_release(newpkgd); rv = errno; @@ -262,7 +261,7 @@ xbps_repo_genindex(const char *pkgdir) if (idxdict == NULL) return errno; - plist = xbps_get_pkg_index_plist(pkgdir); + plist = xbps_pkg_index_plist(pkgdir); if (plist == NULL) { prop_object_release(idxdict); return errno; diff --git a/bin/xbps-repo/main.c b/bin/xbps-repo/main.c index 5ca89066..40e7b83b 100644 --- a/bin/xbps-repo/main.c +++ b/bin/xbps-repo/main.c @@ -201,7 +201,7 @@ main(int argc, char **argv) if (argc != 2) usage(); - pkgd = xbps_repository_plist_find_pkg_dict(argv[1], + pkgd = xbps_repository_pool_dictionary_metadata_plist(argv[1], XBPS_PKGFILES); if (pkgd == NULL) { if (errno != ENOENT) { diff --git a/bin/xbps-repo/repository.c b/bin/xbps-repo/repository.c index 7c6d0177..9ce7fbde 100644 --- a/bin/xbps-repo/repository.c +++ b/bin/xbps-repo/repository.c @@ -186,7 +186,7 @@ register_repository(const char *uri) return 0; } - plist = xbps_get_pkg_index_plist(idxstr); + plist = xbps_pkg_index_plist(idxstr); } else { /* * Create metadir if necessary. @@ -203,7 +203,7 @@ register_repository(const char *uri) return EXIT_FAILURE; } free(metadir); - plist = xbps_get_pkg_index_plist(idxstr); + plist = xbps_pkg_index_plist(idxstr); } if (plist == NULL) @@ -296,7 +296,7 @@ repo_sync_pkg_index_cb(struct repository_pool_index *rpi, void *arg, bool *done) printf("Package index file is already up to date.\n"); return 0; } - if ((plist = xbps_get_pkg_index_plist(rpi->rpi_uri)) == NULL) + if ((plist = xbps_pkg_index_plist(rpi->rpi_uri)) == NULL) return EINVAL; if ((rp = pkgindex_verify(plist, rpi->rpi_uri)) == NULL) diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 18461a10..8a588247 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -288,7 +288,7 @@ main(int argc, char **argv) if (argc != 2) usage(); - version = xbps_get_pkg_version(argv[1]); + version = xbps_pkg_version(argv[1]); if (version == NULL) { fprintf(stderr, "Invalid string, expected -\n"); @@ -301,7 +301,7 @@ main(int argc, char **argv) if (argc != 2) usage(); - pkgname = xbps_get_pkg_name(argv[1]); + pkgname = xbps_pkg_name(argv[1]); if (pkgname == NULL) { fprintf(stderr, "Invalid string, expected -\n"); @@ -315,7 +315,7 @@ main(int argc, char **argv) if (argc != 2) usage(); - version = xbps_get_pkg_revision(argv[1]); + version = xbps_pkg_revision(argv[1]); if (version == NULL) exit(EXIT_SUCCESS); @@ -326,7 +326,7 @@ main(int argc, char **argv) if (argc != 2) usage(); - pkgname = xbps_get_pkgpattern_name(argv[1]); + pkgname = xbps_pkgpattern_name(argv[1]); if (pkgname == NULL) exit(EXIT_FAILURE); @@ -337,7 +337,7 @@ main(int argc, char **argv) if (argc != 2) usage(); - version = xbps_get_pkgpattern_version(argv[1]); + version = xbps_pkgpattern_version(argv[1]); if (version == NULL) exit(EXIT_FAILURE); @@ -363,7 +363,7 @@ main(int argc, char **argv) usage(); for (i = 1; i < argc; i++) { - hash = xbps_get_file_hash(argv[i]); + hash = xbps_file_hash(argv[i]); if (hash == NULL) { fprintf(stderr, "E: couldn't get hash for %s (%s)\n", diff --git a/include/xbps_api.h b/include/xbps_api.h index 230515bf..654c8715 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -59,7 +59,7 @@ * @def XBPS_RELVER * Current library release date. */ -#define XBPS_RELVER "API: 20110411, Repository index: " XBPS_PKGINDEX_VERSION +#define XBPS_RELVER "API: 20110601 INDEX: " XBPS_PKGINDEX_VERSION /** * @def XBPS_META_PATH @@ -264,7 +264,7 @@ int xbps_configure_pkg(const char *pkgname, * * @return 0 on success, otherwise an errno value. */ -int xbps_configure_all_pkgs(void); +int xbps_configure_packages(void); /*@}*/ @@ -671,21 +671,21 @@ bool xbps_find_string_in_array(prop_array_t array, const char *val); * @return A proplib object iterator on success, NULL otherwise and * errno is set appropiately. */ -prop_object_iterator_t xbps_get_array_iter_from_dict(prop_dictionary_t dict, - const char *key); +prop_object_iterator_t xbps_array_iter_from_dict(prop_dictionary_t dict, + const char *key); /** * Get a proplib object dictionary associated with the installed package - * \a pkgn, by internalizing its plist file defined by \a plist. + * \a pkgname, by internalizing its plist file defined by \a plist. * - * @param[in] pkgn Package name of installed package. + * @param[in] pkgname Package name of installed package. * @param[in] plist Package metadata property list file. * * @return The proplib object dictionary on success, NULL otherwise and * errno is set appropiately. */ -prop_dictionary_t xbps_get_pkg_dict_from_metadata_plist(const char *pkgn, - const char *plist); +prop_dictionary_t xbps_dictionary_from_metadata_plist(const char *pkgname, + const char *plist); /** * Removes the package's proplib dictionary matching \a pkgname @@ -766,7 +766,7 @@ int xbps_purge_pkg(const char *pkgname, bool check_state); * * @return 0 on success, otherwise an errno value. */ -int xbps_purge_all_pkgs(void); +int xbps_purge_packages(void); /*@}*/ @@ -913,7 +913,7 @@ int xbps_repository_update_pkg(const char *pkgname); * * @return 0 on success, otherwise an errno value. */ -int xbps_repository_update_allpkgs(void); +int xbps_repository_update_packages(void); /*@}*/ @@ -948,44 +948,21 @@ prop_array_t xbps_transaction_missingdeps_get(void); /*@}*/ -/** @addtogroup repo_plist */ +/** @addtogroup plist_fetch */ /*@{*/ /** - * 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! - * - * @param[in] pkgname Package name to match. - * @param[in] plistf Plist file name to match. - * - * @return An internalized proplib dictionary, otherwise NULL and - * errno is set appropiately. - * - * @note if NULL is returned and errno is ENOENT, that means that - * binary package file has been found but the plist file could not - * be found. - */ -prop_dictionary_t xbps_repository_plist_find_pkg_dict(const char *pkgname, - const char *plistf); - -/** - * Finds a plist file in a binary package file stored local or + * Internalizes a plist file in a binary package file stored locally or * remotely as specified in the URL. * - * @param[in] url URL to binary package file. - * @param[in] plistf Plist file name to match. + * @param[in] url URL to binary package file (full local or remote path). + * @param[in] plistf Plist file name to internalize. * * @return An internalized proplib dictionary, otherwise NULL and * errno is set appropiately. */ -prop_dictionary_t - xbps_repository_plist_find_pkg_dict_from_url(const char *url, - const char *plistf); +prop_dictionary_t xbps_dictionary_metadata_plist_by_url(const char *url, + const char *plistf); /*@}*/ @@ -1071,6 +1048,30 @@ int xbps_repository_pool_foreach( prop_dictionary_t xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best); +/** + * Iterate over the the repository pool and search for a metadata plist + * file in a binary package named 'pkgname'. If a package is matched by + * \a pkgname, the plist file \a plistf will be internalized into 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! + * + * @param[in] pkgname Package name to match. + * @param[in] plistf Plist file name to match. + * + * @return An internalized proplib dictionary of \a plistf, otherwise NULL + * and errno is set appropiately. + * + * @note if NULL is returned and errno is ENOENT, that means that + * binary package file has been found but the plist file could not + * be found. + */ +prop_dictionary_t + xbps_repository_pool_dictionary_metadata_plist(const char *pkgname, + const char *plistf); + /*@}*/ /** @addtogroup reposync */ @@ -1129,7 +1130,7 @@ typedef enum pkg_state { * * @return 0 on success, otherwise an errno value. */ -int xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state); +int xbps_pkg_state_installed(const char *pkgname, pkg_state_t *state); /** * Gets package state from a package dictionary \a dict, and sets its @@ -1140,7 +1141,7 @@ int xbps_get_pkg_state_installed(const char *pkgname, pkg_state_t *state); * * @return 0 on success, otherwise an errno value. */ -int xbps_get_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state); +int xbps_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t *state); /** * Sets package state \a state in package \a pkgname. @@ -1267,7 +1268,7 @@ char *xbps_xasprintf(const char *fmt, ...); * is set appropiately. The pointer should be free(3)d when it's no * longer needed. */ -char *xbps_get_file_hash(const char *file); +char *xbps_file_hash(const char *file); /** * Returns a string with the sha256 hash for the file specified @@ -1281,9 +1282,9 @@ char *xbps_get_file_hash(const char *file); * @return The sha256 hash string if found, NULL otherwise * and errno is set appropiately. */ -const char *xbps_get_file_hash_from_dict(prop_dictionary_t d, - const char *key, - const char *file); +const char *xbps_file_hash_from_dictionary(prop_dictionary_t d, + const char *key, + const char *file); /** * Compares the sha256 hash of the file \a file with the sha256 @@ -1295,7 +1296,7 @@ const char *xbps_get_file_hash_from_dict(prop_dictionary_t d, * @return 0 if \a file and \a sha256 have the same hash, ERANGE * if it differs, or any other errno value on error. */ -int xbps_check_file_hash(const char *file, const char *sha256); +int xbps_file_hash_check(const char *file, const char *sha256); /** * Checks if a package is currently installed by matching a package @@ -1339,7 +1340,7 @@ bool xbps_check_is_repository_uri_remote(const char *uri); * errno is set appropiately. The pointer should be free(3)d when it's * no longer needed. */ -char *xbps_get_binpkg_repo_uri(prop_dictionary_t pkgd, const char *repoloc); +char *xbps_path_from_repository_uri(prop_dictionary_t pkgd, const char *repoloc); /** * Gets the full path to a repository package index plist file, as @@ -1351,7 +1352,7 @@ char *xbps_get_binpkg_repo_uri(prop_dictionary_t pkgd, const char *repoloc); * errno is set appropiately. The pointer should be free(3)d when it's * no longer needed. */ -char *xbps_get_pkg_index_plist(const char *uri); +char *xbps_pkg_index_plist(const char *uri); /** * Gets the name of a package string. Package strings are composed @@ -1364,7 +1365,7 @@ char *xbps_get_pkg_index_plist(const char *uri); * errno is set appropiately. The pointer should be free(3)d when it's * no longer needed. */ -char *xbps_get_pkg_name(const char *pkg); +char *xbps_pkg_name(const char *pkg); /** * Gets a the package name of a package pattern string specified by @@ -1378,7 +1379,7 @@ char *xbps_get_pkg_name(const char *pkg); * NULL otherwise and errno is set appropiately. The pointer should be * free(3)d when it's no longer needed. */ -char *xbps_get_pkgpattern_name(const char *pattern); +char *xbps_pkgpattern_name(const char *pattern); /** * Gets the package epoch version in a package string, i.e foo-2.0:epoch. @@ -1388,7 +1389,7 @@ char *xbps_get_pkgpattern_name(const char *pattern); * @return A string with the epoch version string, NULL if it couldn't find * the epoch component. */ -const char *xbps_get_pkg_epoch(const char *pkg); +const char *xbps_pkg_epoch(const char *pkg); /** * Gets the package version in a package string, i.e foo-2.0. @@ -1398,7 +1399,7 @@ const char *xbps_get_pkg_epoch(const char *pkg); * @return A string with the version string, NULL if it couldn't * find the version component. */ -const char *xbps_get_pkg_version(const char *pkg); +const char *xbps_pkg_version(const char *pkg); /** * Gets the package version of a package pattern string specified by @@ -1410,7 +1411,7 @@ const char *xbps_get_pkg_version(const char *pkg); * @return A string with the pattern version, NULL otherwise and * errno is set appropiately. */ -const char *xbps_get_pkgpattern_version(const char *pattern); +const char *xbps_pkgpattern_version(const char *pattern); /** * Gets the package version revision in a package string. @@ -1420,7 +1421,7 @@ const char *xbps_get_pkgpattern_version(const char *pattern); * @return A string with the revision number, NULL if it couldn't * find the revision component. */ -const char *xbps_get_pkg_revision(const char *pkg); +const char *xbps_pkg_revision(const char *pkg); /** * Checks if a package has run dependencies. diff --git a/lib/Makefile b/lib/Makefile index 751bbb41..9dca9a91 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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) diff --git a/lib/package_config_files.c b/lib/package_config_files.c index b22ba9aa..c96a3976 100644 --- a/lib/package_config_files.c +++ b/lib/package_config_files.c @@ -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) { diff --git a/lib/package_configure.c b/lib/package_configure.c index 53452223..63bdf1ac 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -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; diff --git a/lib/package_orphans.c b/lib/package_orphans.c index 98a2df79..e7f66d89 100644 --- a/lib/package_orphans.c +++ b/lib/package_orphans.c @@ -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, diff --git a/lib/package_purge.c b/lib/package_purge.c index ed1a3eec..43b1d381 100644 --- a/lib/package_purge.c +++ b/lib/package_purge.c @@ -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; diff --git a/lib/package_remove.c b/lib/package_remove.c index c29ee2f8..5fee39e9 100644 --- a/lib/package_remove.c +++ b/lib/package_remove.c @@ -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; diff --git a/lib/package_remove_obsoletes.c b/lib/package_remove_obsoletes.c index 0a633b25..83cd0c06 100644 --- a/lib/package_remove_obsoletes.c +++ b/lib/package_remove_obsoletes.c @@ -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 diff --git a/lib/package_state.c b/lib/package_state.c index 753350a8..6d6989b5 100644 --- a/lib/package_state.c +++ b/lib/package_state.c @@ -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); diff --git a/lib/package_unpack.c b/lib/package_unpack.c index afe7c838..bb9851c6 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -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)); diff --git a/lib/plist.c b/lib/plist.c index 53238fe2..5ade76c2 100644 --- a/lib/plist.c +++ b/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; } diff --git a/lib/repository_plist.c b/lib/plist_fetch.c similarity index 76% rename from lib/repository_plist.c rename to lib/plist_fetch.c index 14a6d290..582552dd 100644 --- a/lib/repository_plist.c +++ b/lib/plist_fetch.c @@ -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; -} diff --git a/lib/plist_find.c b/lib/plist_find.c index 5d7f2819..85462f0e 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -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) { diff --git a/lib/plist_remove.c b/lib/plist_remove.c index be510b2c..329baed7 100644 --- a/lib/plist_remove.c +++ b/lib/plist_remove.c @@ -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) { diff --git a/lib/repository_finddeps.c b/lib/repository_finddeps.c index 1547f868..390114be 100644 --- a/lib/repository_finddeps.c +++ b/lib/repository_finddeps.c @@ -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); diff --git a/lib/repository_findpkg.c b/lib/repository_findpkg.c index b108994c..2e33a1f9 100644 --- a/lib/repository_findpkg.c +++ b/lib/repository_findpkg.c @@ -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; diff --git a/lib/repository_pool.c b/lib/repository_pool.c index a32d3565..82fdea4a 100644 --- a/lib/repository_pool.c +++ b/lib/repository_pool.c @@ -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; +} diff --git a/lib/repository_register.c b/lib/repository_register.c index 4452bcdb..df8cd29a 100644 --- a/lib/repository_register.c +++ b/lib/repository_register.c @@ -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; diff --git a/lib/transaction_dictionary.c b/lib/transaction_dictionary.c index 1279b96c..55bb5871 100644 --- a/lib/transaction_dictionary.c +++ b/lib/transaction_dictionary.c @@ -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; diff --git a/lib/transaction_sortdeps.c b/lib/transaction_sortdeps.c index 4cad437a..bdbd1dad 100644 --- a/lib/transaction_sortdeps.c +++ b/lib/transaction_sortdeps.c @@ -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; diff --git a/lib/util.c b/lib/util.c index c9f9a74d..21e03495 100644 --- a/lib/util.c +++ b/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;