Register binary package if unpacking was successful.

--HG--
extra : convert_revision : ac984d640acb340e3a8db2ac07e41d15b1eea89e
This commit is contained in:
Juan RP 2008-12-26 10:13:03 +01:00
parent df5fc95e28
commit d309f54ff1
5 changed files with 322 additions and 167 deletions

View file

@ -61,6 +61,7 @@ usage(void)
"\n"
" Examples:\n"
" $ xbps-bin install klibc\n"
" $ xbps-bin install klibc /path/to/directory\n"
" $ xbps-bin repo-add /path/to/directory\n"
" $ xbps-bin repo-add http://www.location.org/xbps-repo\n"
" $ xbps-bin repo-list\n"
@ -223,7 +224,7 @@ main(int argc, char **argv)
usage();
dict = getrepolist_dict();
xbps_callback_array_iter_in_dict(dict,
(void)xbps_callback_array_iter_in_dict(dict,
"repository-list", xbps_list_strings_in_array, NULL);
prop_object_release(dict);
@ -251,7 +252,7 @@ main(int argc, char **argv)
usage();
dict = getrepolist_dict();
xbps_callback_array_iter_in_dict(dict,
(void)xbps_callback_array_iter_in_dict(dict,
"repository-list", xbps_search_string_in_pkgs, argv[2]);
prop_object_release(dict);
@ -261,8 +262,8 @@ main(int argc, char **argv)
usage();
dict = getrepolist_dict();
if (!xbps_callback_array_iter_in_dict(dict, "repository-list",
xbps_show_pkg_info_from_repolist, argv[2])) {
if (xbps_callback_array_iter_in_dict(dict, "repository-list",
xbps_show_pkg_info_from_repolist, argv[2]) != 0) {
prop_object_release(dict);
printf("ERROR: unable to locate package '%s'.\n",
argv[2]);
@ -283,8 +284,10 @@ main(int argc, char **argv)
rv = xbps_install_binary_pkg(argv[2], argv[3]);
}
if (rv)
if (rv) {
printf("ERROR: unable to install %s.\n", argv[2]);
exit(rv);
}
} else {
usage();
}

View file

@ -63,9 +63,9 @@ xbps_add_obj_to_array(prop_array_t, prop_object_t);
*
* Returns true on success, false otherwise and the loop is terminated.
*/
bool
int
xbps_callback_array_iter_in_dict(prop_dictionary_t, const char *,
bool (*func)(prop_object_t, void *, bool *),
int (*func)(prop_object_t, void *, bool *),
void *);
/*
@ -143,24 +143,25 @@ void xbps_show_pkg_info(prop_dictionary_t);
/*
* Internal functions.
*/
bool xbps_list_pkgs_in_dict(prop_object_t, void *, bool *);
bool xbps_list_strings_in_array(prop_object_t, void *, bool *);
bool xbps_list_strings_in_array2(prop_object_t, void *, bool *);
bool xbps_remove_string_from_array(prop_object_t, void *, bool *);
bool xbps_show_pkg_info_from_repolist(prop_object_t obj, void *, bool *);
bool xbps_show_pkg_namedesc(prop_object_t, void *, bool *);
bool xbps_search_string_in_pkgs(prop_object_t, void *, bool *);
int xbps_list_pkgs_in_dict(prop_object_t, void *, bool *);
int xbps_list_strings_in_array(prop_object_t, void *, bool *);
int xbps_list_strings_in_array2(prop_object_t, void *, bool *);
int xbps_remove_string_from_array(prop_object_t, void *, bool *);
int xbps_show_pkg_info_from_repolist(prop_object_t obj, void *, bool *);
int xbps_show_pkg_namedesc(prop_object_t, void *, bool *);
int xbps_search_string_in_pkgs(prop_object_t, void *, bool *);
/* Utils */
bool xbps_append_full_path(char *, const char *, const char *);
int xbps_check_is_installed_pkg(const char *, const char *);
int xbps_check_is_installed_pkg(const char *);
int xbps_cmpver_packages(const char *, const char *);
int xbps_cmpver_versions(const char *, const char *);
const char * xbps_get_pkg_version(const char *);
char * xbps_get_pkg_name(const char *);
int xbps_install_pkg_deps(prop_array_t, prop_dictionary_t);
int xbps_install_pkg_deps(prop_dictionary_t);
int xbps_install_binary_pkg(const char *, const char *);
bool xbps_install_binary_pkg_from_repolist(prop_object_t, void *, bool *);
int xbps_install_binary_pkg_from_repolist(prop_object_t, void *, bool *);
int xbps_register_pkg(const char *, const char *, const char *);
int xbps_unpack_binary_pkg(prop_dictionary_t, prop_dictionary_t,
int (*cb)(struct archive *));
int xbps_unpack_archive_cb(struct archive *);

View file

@ -35,6 +35,7 @@
struct pkg_dependency {
LIST_ENTRY(pkg_dependency) deps;
prop_dictionary_t repo;
const char *namever;
char *name;
};
@ -42,12 +43,18 @@ static LIST_HEAD(, pkg_dependency) pkg_deps_list =
LIST_HEAD_INITIALIZER(pkg_deps_list);
int
xbps_check_is_installed_pkg(const char *plist, const char *pkg)
xbps_check_is_installed_pkg(const char *pkg)
{
prop_dictionary_t dict, pkgdict;
prop_object_t obj;
const char *reqver, *instver;
char *pkgname;
char plist[PATH_MAX], *pkgname;
int rv = 0;
assert(pkg != NULL);
if (!xbps_append_full_path(plist, NULL, XBPS_REGPKGDB))
return EINVAL;
pkgname = xbps_get_pkg_name(pkg);
reqver = xbps_get_pkg_version(pkg);
@ -56,7 +63,7 @@ xbps_check_is_installed_pkg(const char *plist, const char *pkg)
dict = prop_dictionary_internalize_from_file(plist);
if (dict == NULL) {
free(pkgname);
return XBPS_PKG_EEMPTY;
return 1; /* not installed */
}
pkgdict = xbps_find_pkg_in_dict(dict, pkgname);
@ -72,10 +79,14 @@ xbps_check_is_installed_pkg(const char *plist, const char *pkg)
assert(prop_object_type(obj) == PROP_TYPE_STRING);
instver = prop_string_cstring_nocopy(obj);
assert(instver != NULL);
/* Compare installed and required version. */
rv = xbps_cmpver_versions(instver, reqver) > 0 ? 1 : 0;
free(pkgname);
prop_object_release(dict);
return (xbps_cmpver_versions(instver, reqver) > 0) ? 1 : 0;
return rv;
}
void
@ -91,18 +102,23 @@ xbps_clean_pkg_depslist(void)
}
void
xbps_add_pkg_dependency(const char *pkgname, prop_dictionary_t repo)
xbps_add_pkg_dependency(const char *pkg, prop_dictionary_t repo)
{
struct pkg_dependency *dep;
size_t len = 0;
char *pkgname;
assert(repo != NULL);
assert(pkgname != NULL);
assert(pkgdict != NULL);
assert(pkg != NULL);
LIST_FOREACH(dep, &pkg_deps_list, deps)
if (strcmp(dep->name, pkgname) == 0)
pkgname = xbps_get_pkg_name(pkg);
LIST_FOREACH(dep, &pkg_deps_list, deps) {
if (strcmp(dep->name, pkgname) == 0) {
free(pkgname);
return;
}
}
dep = NULL;
dep = malloc(sizeof(*dep));
@ -114,7 +130,9 @@ xbps_add_pkg_dependency(const char *pkgname, prop_dictionary_t repo)
memcpy(dep->name, pkgname, len - 1);
dep->name[len - 1] = '\0';
free(pkgname);
dep->repo = prop_dictionary_copy(repo);
dep->namever = pkg;
LIST_INSERT_HEAD(&pkg_deps_list, dep, deps);
}
@ -157,7 +175,7 @@ find_deps_in_pkg(prop_dictionary_t repo, prop_dictionary_t pkg)
/*
* Package is on repo, add it into the list.
*/
xbps_add_pkg_dependency(pkgname, repo);
xbps_add_pkg_dependency(reqpkg, repo);
free(pkgname);
/* Iterate on required pkg to find more deps */
@ -174,23 +192,36 @@ find_deps_in_pkg(prop_dictionary_t repo, prop_dictionary_t pkg)
}
int
xbps_install_pkg_deps(prop_array_t repolist, prop_dictionary_t pkg)
xbps_install_pkg_deps(prop_dictionary_t pkg)
{
prop_dictionary_t repo, pkgdict;
prop_dictionary_t repolistd, repod, pkgd;
prop_array_t array;
prop_object_iterator_t iter;
prop_object_t obj;
prop_string_t pkgname, version;
struct pkg_dependency *dep;
size_t required_deps = 0, deps_found = 0;
const char *reqpkg, *verstr;
const char *reqpkg, *version, *pkgname, *desc;
char plist[PATH_MAX], *namestr;
int rv = 0;
bool dep_found = false;
iter = prop_array_iterator(repolist);
if (iter == NULL)
assert(pkg != NULL);
if (!xbps_append_full_path(plist, NULL, XBPS_REPOLIST))
return EINVAL;
repolistd = prop_dictionary_internalize_from_file(plist);
if (repolistd == NULL)
return EINVAL;
array = prop_dictionary_get(repolistd, "repository-list");
assert(array != NULL);
iter = prop_array_iterator(array);
if (iter == NULL) {
prop_object_release(repolistd);
return ENOMEM;
}
/*
* Iterate over the repository list and find out if we have
@ -206,21 +237,21 @@ xbps_install_pkg_deps(prop_array_t repolist, prop_dictionary_t pkg)
goto out;
}
repo = prop_dictionary_internalize_from_file(plist);
if (repo == NULL) {
repod = prop_dictionary_internalize_from_file(plist);
if (repod == NULL) {
prop_object_iterator_release(iter);
rv = errno;
goto out;
}
rv = find_deps_in_pkg(repo, pkg);
rv = find_deps_in_pkg(repod, pkg);
if (rv == -1) {
prop_object_release(repo);
prop_object_release(repod);
prop_object_iterator_release(iter);
goto out;
}
prop_object_release(repo);
prop_object_release(repod);
}
prop_object_iterator_release(iter);
@ -240,7 +271,7 @@ xbps_install_pkg_deps(prop_array_t repolist, prop_dictionary_t pkg)
required_deps++;
reqpkg = prop_string_cstring_nocopy(obj);
namestr = xbps_get_pkg_name(reqpkg);
verstr = xbps_get_pkg_version(reqpkg);
version = xbps_get_pkg_version(reqpkg);
LIST_FOREACH(dep, &pkg_deps_list, deps) {
if (strcmp(dep->name, namestr) == 0) {
@ -251,7 +282,7 @@ xbps_install_pkg_deps(prop_array_t repolist, prop_dictionary_t pkg)
}
if (dep_found == false) {
printf("Cannot find %s >= %s in repository list.\n",
namestr, verstr);
namestr, version);
(void)fflush(stdout);
}
free(namestr);
@ -267,26 +298,41 @@ xbps_install_pkg_deps(prop_array_t repolist, prop_dictionary_t pkg)
* Iterate over the list of dependencies and install them.
*/
LIST_FOREACH(dep, &pkg_deps_list, deps) {
pkgdict = xbps_find_pkg_in_dict(dep->repo, dep->name);
if (pkgdict == NULL) {
pkgd = xbps_find_pkg_in_dict(dep->repo, dep->name);
if (pkgd == NULL) {
rv = EINVAL;
break;
}
pkgname = prop_dictionary_get(pkgdict, "pkgname");
version = prop_dictionary_get(pkgdict, "version");
printf("Required package: %s >= %s\n",
prop_string_cstring_nocopy(pkgname),
prop_string_cstring_nocopy(version));
rv = xbps_check_is_installed_pkg(dep->namever);
if (rv == -1) {
rv = EINVAL;
break;
} else if (rv == 0) {
/* Dependency is already installed. */
continue;
}
prop_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
prop_dictionary_get_cstring_nocopy(pkgd, "version", &version);
prop_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc);
printf("Required package: %s >= %s\n", pkgname, version);
(void)fflush(stdout);
rv = xbps_unpack_binary_pkg(dep->repo, pkgdict,
rv = xbps_unpack_binary_pkg(dep->repo, pkgd,
xbps_unpack_archive_cb);
if (rv != 0)
break;
rv = xbps_register_pkg(pkgname, version, desc);
if (rv != 0)
break;
}
out:
prop_object_release(repolistd);
xbps_clean_pkg_depslist();
return rv;
}

View file

@ -32,13 +32,86 @@
#include <xbps_api.h>
int
xbps_install_binary_pkg_from_repolist(prop_object_t obj, void *arg,
bool *loop_done)
{
prop_dictionary_t repod, pkgrd;
const char *pkgname = arg, *version, *desc;
char plist[PATH_MAX];
int rv = 0;
/*
* Get the dictionary from a repository's index file.
*/
memset(plist, 0, sizeof(&plist));
if (!xbps_append_full_path(plist,
prop_string_cstring_nocopy(obj), XBPS_PKGINDEX))
return EINVAL;
repod = prop_dictionary_internalize_from_file(plist);
if (repod == NULL)
return EINVAL;
/*
* Get the package dictionary from current repository.
*/
pkgrd = xbps_find_pkg_in_dict(repod, pkgname);
if (pkgrd == NULL) {
prop_object_release(repod);
return XBPS_PKG_ENOTINREPO;
}
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version);
prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
assert(version != NULL);
assert(desc != NULL);
/*
* Check if this package needs dependencies.
*/
if (!xbps_pkg_has_rundeps(pkgrd)) {
/* pkg has no deps, just install it. */
rv = xbps_unpack_binary_pkg(repod, pkgrd,
xbps_unpack_archive_cb);
if (rv == 0) {
rv = xbps_register_pkg(pkgname, version, desc);
if (rv == EEXIST)
rv = 0;
}
prop_object_release(repod);
*loop_done = true;
return rv;
}
/*
* Install all required dependencies.
*/
rv = xbps_install_pkg_deps(pkgrd);
if (rv != 0) {
prop_object_release(repod);
return rv;
}
/*
* Finally install the package, now that all
* required dependencies were installed.
*/
rv = xbps_unpack_binary_pkg(repod, pkgrd, xbps_unpack_archive_cb);
if (rv == 0) {
rv = xbps_register_pkg(pkgname, version, desc);
if (rv == EEXIST)
rv = 0;
}
prop_object_release(repod);
*loop_done = true;
return rv;
}
int
xbps_install_binary_pkg(const char *pkgname, const char *destdir)
{
prop_array_t array;
prop_dictionary_t repolistd, repod, pkgrd;
prop_object_t obj;
prop_object_iterator_t iter;
prop_dictionary_t repolistd;
char plist[PATH_MAX];
int rv = 0;
@ -48,7 +121,10 @@ xbps_install_binary_pkg(const char *pkgname, const char *destdir)
return XBPS_PKG_ECHDIRDEST;
}
/* Get the dictionary with list of repositories. */
/*
* Get the dictionary with the list of registered
* repositories.
*/
if (!xbps_append_full_path(plist, NULL, XBPS_REPOLIST))
return EINVAL;
@ -56,98 +132,128 @@ xbps_install_binary_pkg(const char *pkgname, const char *destdir)
if (repolistd == NULL)
return EINVAL;
/* Iterate over the list of repositories to find a pkg. */
array = prop_dictionary_get(repolistd, "repository-list");
if (array == NULL || prop_array_count(array) == 0) {
prop_object_release(repolistd);
return EINVAL;
}
iter = prop_array_iterator(array);
if (iter == NULL) {
prop_object_release(repolistd);
return ENOMEM;
}
while ((obj = prop_object_iterator_next(iter)) != NULL) {
/*
* Get the dictionary from a repository's index file.
*/
assert(prop_object_type(obj) == PROP_TYPE_STRING);
memset(plist, 0, sizeof(&plist));
if (!xbps_append_full_path(plist,
prop_string_cstring_nocopy(obj), XBPS_PKGINDEX)) {
prop_object_iterator_release(iter);
prop_object_release(repolistd);
return EINVAL;
}
repod = prop_dictionary_internalize_from_file(plist);
if (repod == NULL) {
prop_object_iterator_release(iter);
prop_object_release(repolistd);
return EINVAL;
}
/*
* Get the package dictionary from current repository.
*/
pkgrd = xbps_find_pkg_in_dict(repod, pkgname);
if (pkgrd == NULL) {
prop_object_release(repod);
continue;
}
/*
* Check if pkg needs deps.
*/
if (!xbps_pkg_has_rundeps(pkgrd)) {
/* pkg has no deps, just install it. */
rv = xbps_unpack_binary_pkg(repod, pkgrd,
xbps_unpack_archive_cb);
prop_object_release(repolistd);
prop_object_release(repod);
break;
}
/*
* Install all required dependencies.
*/
rv = xbps_install_pkg_deps(array, pkgrd);
if (rv != 0) {
prop_object_release(repolistd);
prop_object_release(repod);
break;
}
/*
* Finally install the package, now that all
* required dependencies were installed.
*/
rv = xbps_unpack_binary_pkg(repod, pkgrd,
xbps_unpack_archive_cb);
prop_object_release(repolistd);
prop_object_release(repod);
break;
}
prop_object_iterator_release(iter);
/*
* Iterate over the repositories to find the binary packages
* required by this package.
*/
rv = xbps_callback_array_iter_in_dict(repolistd, "repository-list",
xbps_install_binary_pkg_from_repolist, (void *)pkgname);
prop_object_release(repolistd);
return rv;
}
static prop_dictionary_t
make_dict_from_pkg(const char *name, const char *ver, const char *desc)
{
prop_dictionary_t dict;
dict = prop_dictionary_create();
assert(dict != NULL);
prop_dictionary_set_cstring_nocopy(dict, "pkgname", name);
prop_dictionary_set_cstring_nocopy(dict, "version", ver);
prop_dictionary_set_cstring_nocopy(dict, "short_desc", desc);
return dict;
}
int
xbps_register_pkg(const char *pkgname, const char *version, const char *desc)
{
prop_dictionary_t dict, pkgd;
prop_array_t array;
char plist[PATH_MAX];
int rv = 0;
assert(pkgname != NULL);
assert(version != NULL);
assert(desc != NULL);
if (!xbps_append_full_path(plist, NULL, XBPS_REGPKGDB))
return EINVAL;
dict = prop_dictionary_internalize_from_file(plist);
if (dict == NULL) {
/* No packages registered yet. */
dict = prop_dictionary_create();
if (dict == NULL)
return ENOMEM;
array = prop_array_create();
if (array == NULL) {
prop_object_release(dict);
return ENOMEM;
}
pkgd = make_dict_from_pkg(pkgname, version, desc);
if (!xbps_add_obj_to_array(array, pkgd)) {
prop_object_release(array);
prop_object_release(dict);
prop_object_release(pkgd);
return EINVAL;
}
if (!xbps_add_obj_to_dict(dict, array, "packages")) {
prop_object_release(array);
prop_object_release(dict);
return EINVAL;
}
} else {
/* Check if package is already registered. */
pkgd = xbps_find_pkg_in_dict(dict, pkgname);
if (pkgd != NULL) {
prop_object_release(dict);
return EEXIST;
}
pkgd = make_dict_from_pkg(pkgname, version, desc);
array = prop_dictionary_get(dict, "packages");
assert(array != NULL);
if (!xbps_add_obj_to_array(array, pkgd)) {
prop_object_release(pkgd);
prop_object_release(dict);
return EINVAL;
}
}
if (!prop_dictionary_externalize_to_file(dict, plist))
rv = errno;
prop_object_release(dict);
return rv;
}
/*
* Flags for extracting files in binary packages.
*/
#define EXTRACT_FLAGS ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | \
ARCHIVE_EXTRACT_TIME | \
ARCHIVE_EXTRACT_SECURE_NODOTDOT | \
ARCHIVE_EXTRACT_SECURE_SYMLINKS | \
ARCHIVE_EXTRACT_UNLINK
int
xbps_unpack_archive_cb(struct archive *ar)
{
struct archive_entry *entry;
static bool first;
int rv = 0;
int rv = 0, flags;
if (geteuid() == 0)
flags = EXTRACT_FLAGS;
else
flags = 0;
while (archive_read_next_header(ar, &entry) == ARCHIVE_OK) {
if ((rv = archive_read_extract(ar, entry, 0)) != 0) {
if (!first)
printf("\n");
first = true;
printf("couldn't write %s (%s), ignoring!\n",
if ((rv = archive_read_extract(ar, entry, flags)) != 0) {
printf("\ncouldn't unpack %s (%s), exiting!\n",
archive_entry_pathname(entry), strerror(errno));
break;
}
}

View file

@ -67,32 +67,31 @@ xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
return true;
}
bool
int
xbps_callback_array_iter_in_dict(prop_dictionary_t dict, const char *key,
bool (*func)(prop_object_t, void *, bool *),
int (*func)(prop_object_t, void *, bool *),
void *arg)
{
prop_object_iterator_t iter;
prop_object_t obj;
bool run, ret, cbloop_done;
int rv = 0;
bool run, cbloop_done;
run = ret = cbloop_done = false;
run = cbloop_done = false;
assert(func != NULL);
iter = xbps_get_array_iter_from_dict(dict, key);
if (iter == NULL)
return false;
return EINVAL;
while ((obj = prop_object_iterator_next(iter))) {
run = (*func)(obj, arg, &cbloop_done);
if (run && cbloop_done) {
ret = true;
rv = (*func)(obj, arg, &cbloop_done);
if (rv == 0 && cbloop_done)
break;
}
}
prop_object_iterator_release(iter);
return ret;
return rv;
}
prop_dictionary_t
@ -230,7 +229,7 @@ wr_plist:
return true;
}
bool
int
xbps_remove_string_from_array(prop_object_t obj, void *arg, bool *loop_done)
{
static int64_t idx;
@ -241,11 +240,11 @@ xbps_remove_string_from_array(prop_object_t obj, void *arg, bool *loop_done)
if (prop_string_equals_cstring(obj, cb->string)) {
cb->number = idx;
*loop_done = true;
return true;
return 0;
}
idx++;
return false;
return EINVAL;
}
bool
@ -366,7 +365,7 @@ xbps_unregister_repository(const char *uri)
done = xbps_callback_array_iter_in_dict(dict, "repository-list",
xbps_remove_string_from_array, cb);
if (done && cb->number >= 0) {
if (done == 0 && cb->number >= 0) {
/* Found, remove it. */
prop_array_remove(array, cb->number);
@ -469,7 +468,7 @@ xbps_show_pkg_info(prop_dictionary_t dict)
printf(" %s\n", prop_string_cstring_nocopy(obj));
}
bool
int
xbps_show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
{
const char *pkgname, *desc, *ver, *string = arg;
@ -485,10 +484,10 @@ xbps_show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
if ((strstr(pkgname, string) || strstr(desc, string)))
printf(" %s-%s - %s\n", pkgname, ver, desc);
return true;
return 0;
}
bool
int
xbps_search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done)
{
prop_dictionary_t dict;
@ -502,21 +501,21 @@ xbps_search_string_in_pkgs(prop_object_t obj, void *arg, bool *loop_done)
assert(repofile != NULL);
if (!xbps_append_full_path(plist, repofile, XBPS_PKGINDEX))
return false;
return EINVAL;
dict = prop_dictionary_internalize_from_file(plist);
if (dict == NULL)
return false;
return EINVAL;
printf("From %s repository ...\n", repofile);
xbps_callback_array_iter_in_dict(dict, "packages",
xbps_show_pkg_namedesc, arg);
prop_object_release(dict);
return true;
return 0;
}
bool
int
xbps_show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
{
prop_dictionary_t dict, pkgdict;
@ -531,16 +530,16 @@ xbps_show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
/* Get string for pkg-index.plist with full path. */
if (!xbps_append_full_path(plist, repofile, XBPS_PKGINDEX))
return false;
return EINVAL;
dict = prop_dictionary_internalize_from_file(plist);
if (dict == NULL || prop_dictionary_count(dict) == 0)
return false;
return EINVAL;
pkgdict = xbps_find_pkg_in_dict(dict, arg);
if (pkgdict == NULL) {
prop_object_release(dict);
return false;
return XBPS_PKG_ENOTINREPO;
}
oloc = prop_dictionary_get(dict, "location-remote");
@ -551,7 +550,7 @@ xbps_show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
repoloc = prop_string_cstring_nocopy(oloc);
else {
prop_object_release(dict);
return false;
return EINVAL;
}
printf("Repository: %s\n", repoloc);
@ -559,10 +558,10 @@ xbps_show_pkg_info_from_repolist(prop_object_t obj, void *arg, bool *loop_done)
*loop_done = true;
prop_object_release(dict);
return true;
return 0;
}
bool
int
xbps_list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
{
const char *pkgname, *version, *short_desc;
@ -574,13 +573,13 @@ xbps_list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
prop_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc);
if (pkgname && version && short_desc) {
printf("%s (%s)\t%s\n", pkgname, version, short_desc);
return true;
return 0;
}
return false;
return EINVAL;
}
bool
int
xbps_list_strings_in_array2(prop_object_t obj, void *arg, bool *loop_done)
{
static uint16_t count;
@ -602,15 +601,15 @@ xbps_list_strings_in_array2(prop_object_t obj, void *arg, bool *loop_done)
printf("%s%s", prop_string_cstring_nocopy(obj), sep);
count++;
return true;
return 0;
}
bool
int
xbps_list_strings_in_array(prop_object_t obj, void *arg, bool *loop_done)
{
assert(prop_object_type(obj) == PROP_TYPE_STRING);
printf("%s\n", prop_string_cstring_nocopy(obj));
return true;
return 0;
}