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:
parent
c9a673cc11
commit
841c9e2d51
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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",
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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]);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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 <string>-<version>\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 <string>-<version>\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",
|
||||
|
@ -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 <b>foo-2.0:epoch</b>.
|
||||
@ -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 <b>foo-2.0</b>.
|
||||
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user