Make xbps_remove_pkg_from_* return int rather than bool.
--HG-- extra : convert_revision : 9f413873669b552a4d7a6e25e667fe5ff43f6a78
This commit is contained in:
parent
147a8af559
commit
625a77883c
6 changed files with 36 additions and 40 deletions
|
@ -155,14 +155,13 @@ main(int argc, char **argv)
|
|||
if (argc != 3)
|
||||
usage();
|
||||
|
||||
if (!xbps_remove_pkg_dict_from_file(argv[1], plist)) {
|
||||
if (errno == ENODEV)
|
||||
printf("=> ERROR: %s not registered "
|
||||
"in database.\n", argv[1]);
|
||||
else
|
||||
printf("=> ERROR: couldn't unregister %s "
|
||||
"from database (%s)\n", argv[1],
|
||||
strerror(errno));
|
||||
rv = xbps_remove_pkg_dict_from_file(argv[1], plist);
|
||||
if (rv == ENOENT) {
|
||||
printf("=> ERROR: %s not registered in database.\n",
|
||||
argv[1]);
|
||||
} else {
|
||||
printf("=> ERROR: couldn't unregister %s "
|
||||
"from database (%s)\n", argv[1], strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
|
@ -176,10 +176,10 @@ repoidx_addpkg(const char *file, const char *filename, const char *pkgdir)
|
|||
* registered actually, remove old package from
|
||||
* the index.
|
||||
*/
|
||||
if (!xbps_remove_pkg_from_dict(idxdict,
|
||||
"packages", pkgname)) {
|
||||
rv = xbps_remove_pkg_from_dict(idxdict,
|
||||
"packages", pkgname);
|
||||
if (rv != 0) {
|
||||
prop_object_release(newpkgd);
|
||||
rv = EINVAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ bool xbps_find_string_in_array(prop_array_t, const char *);
|
|||
prop_object_iterator_t xbps_get_array_iter_from_dict(prop_dictionary_t,
|
||||
const char *);
|
||||
|
||||
bool xbps_remove_pkg_dict_from_file(const char *, const char *);
|
||||
bool xbps_remove_pkg_from_dict(prop_dictionary_t, const char *,
|
||||
int xbps_remove_pkg_dict_from_file(const char *, const char *);
|
||||
int xbps_remove_pkg_from_dict(prop_dictionary_t, const char *,
|
||||
const char *);
|
||||
int xbps_remove_string_from_array(prop_array_t, const char *);
|
||||
|
||||
|
|
|
@ -341,13 +341,12 @@ find_pkg_missing_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg)
|
|||
if ((rv = store_dependency(pkg, curpkgd, repo)) != 0)
|
||||
break;
|
||||
/*
|
||||
* Remove package from missing now.
|
||||
* Remove package from missing_deps array now.
|
||||
*/
|
||||
if (!xbps_remove_pkg_from_dict(chaindeps,
|
||||
"missing_deps", pkgname)) {
|
||||
if (errno != 0 && errno != ENOENT)
|
||||
break;
|
||||
}
|
||||
rv = xbps_remove_pkg_from_dict(chaindeps,
|
||||
"missing_deps", pkgname);
|
||||
if (rv != 0 && rv != ENOENT)
|
||||
break;
|
||||
|
||||
prop_object_iterator_reset(iter);
|
||||
}
|
||||
|
@ -444,12 +443,11 @@ find_pkg_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg,
|
|||
/*
|
||||
* Remove package from missing_deps now it's been found.
|
||||
*/
|
||||
if (!xbps_remove_pkg_from_dict(chaindeps,
|
||||
"missing_deps", pkgname)) {
|
||||
if (errno != 0 && errno != ENOENT) {
|
||||
free(pkgname);
|
||||
break;
|
||||
}
|
||||
rv = xbps_remove_pkg_from_dict(chaindeps,
|
||||
"missing_deps", pkgname);
|
||||
if (rv != 0 && rv != ENOENT) {
|
||||
free(pkgname);
|
||||
break;
|
||||
}
|
||||
free(pkgname);
|
||||
|
||||
|
|
25
lib/plist.c
25
lib/plist.c
|
@ -276,7 +276,7 @@ xbps_remove_string_from_array(prop_array_t array, const char *str)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
int
|
||||
xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *key,
|
||||
const char *pkgname)
|
||||
{
|
||||
|
@ -293,11 +293,11 @@ xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *key,
|
|||
|
||||
array = prop_dictionary_get(dict, key);
|
||||
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||
return false;
|
||||
return EINVAL;
|
||||
|
||||
iter = prop_array_iterator(array);
|
||||
if (iter == NULL)
|
||||
return false;
|
||||
return errno;
|
||||
|
||||
/* Iterate over the array of dictionaries to find its index. */
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
|
@ -313,35 +313,36 @@ xbps_remove_pkg_from_dict(prop_dictionary_t dict, const char *key,
|
|||
if (found == true)
|
||||
prop_array_remove(array, i);
|
||||
else
|
||||
errno = ENOENT;
|
||||
return ENOENT;
|
||||
|
||||
return found;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
int
|
||||
xbps_remove_pkg_dict_from_file(const char *pkg, const char *plist)
|
||||
{
|
||||
prop_dictionary_t pdict;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkg != NULL);
|
||||
assert(plist != NULL);
|
||||
|
||||
pdict = prop_dictionary_internalize_from_file(plist);
|
||||
if (pdict == NULL)
|
||||
return false;
|
||||
return errno;
|
||||
|
||||
if (!xbps_remove_pkg_from_dict(pdict, "packages", pkg)) {
|
||||
rv = xbps_remove_pkg_from_dict(pdict, "packages", pkg);
|
||||
if (rv != 0) {
|
||||
prop_object_release(pdict);
|
||||
errno = ENODEV;
|
||||
return false;
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!prop_dictionary_externalize_to_file(pdict, plist)) {
|
||||
prop_object_release(pdict);
|
||||
return false;
|
||||
return errno;
|
||||
}
|
||||
|
||||
prop_object_release(pdict);
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -53,9 +53,7 @@ xbps_unregister_pkg(const char *pkgname)
|
|||
if (plist == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if (!xbps_remove_pkg_dict_from_file(pkgname, plist))
|
||||
rv = errno;
|
||||
|
||||
rv = xbps_remove_pkg_dict_from_file(pkgname, plist);
|
||||
free(plist);
|
||||
|
||||
return rv;
|
||||
|
|
Loading…
Reference in a new issue