fulldeptree: return a proper error if deps can't be resolved.

xbps_get_pkg_fulldeptree() now returns NULL and sets errno to ENODEV
when there are missing dependencies, rather than assert()ing.

Added another test case to check returned error codes.

Signed-off-by: Juan RP <xtraeme@gmail.com>
This commit is contained in:
Juan RP
2019-06-15 17:53:02 +02:00
parent 3a70495ba6
commit a9a889c54d
5 changed files with 61 additions and 12 deletions

View File

@@ -156,7 +156,12 @@ ordered_depends(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool)
if (curpkgd == NULL)
continue;
}
assert(curpkgd);
if (curpkgd == NULL) {
/* package depends on missing dependencies */
xbps_dbg_printf(xhp, "%s: missing dependency '%s'\n", pkgver, curdep);
errno = ENODEV;
return NULL;
}
if ((curdepname = xbps_pkgpattern_name(curdep)) == NULL)
curdepname = xbps_pkg_name(curdep);
@@ -212,7 +217,8 @@ xbps_get_pkg_fulldeptree(struct xbps_handle *xhp, const char *pkg, bool rpool)
((pkgd = xbps_pkgdb_get_virtualpkg(xhp, pkg)) == NULL))
return NULL;
}
(void)ordered_depends(xhp, pkgd, rpool);
if (ordered_depends(xhp, pkgd, rpool) == NULL)
return NULL;
return result;
}

View File

@@ -1,5 +1,5 @@
/*-
* Copyright (c) 2009-2015 Juan Romero Pardines.
* Copyright (c) 2009-2019 Juan Romero Pardines.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -121,6 +121,9 @@ add_orphans:
pkgd = xbps_array_get(array, i);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &curpkgver);
rdeps = xbps_pkgdb_get_pkg_fulldeptree(xhp, curpkgver);
if (rdeps == NULL)
return NULL;
for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) {
cnt = 0;
xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver);