Use prop iterators when needed to retain the obj.
This could explain the strange issues seen in buildbot builds that have been happening since 0.18; this should fix completely this.
This commit is contained in:
parent
9715d8a6a1
commit
b9136c61c9
@ -50,20 +50,23 @@ int
|
|||||||
xbps_configure_packages(struct xbps_handle *xhp, bool flush)
|
xbps_configure_packages(struct xbps_handle *xhp, bool flush)
|
||||||
{
|
{
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
|
prop_object_iterator_t iter;
|
||||||
const char *pkgname;
|
const char *pkgname;
|
||||||
size_t i;
|
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if ((rv = xbps_pkgdb_init(xhp)) != 0)
|
if ((rv = xbps_pkgdb_init(xhp)) != 0)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(xhp->pkgdb); i++) {
|
iter = prop_array_iterator(xhp->pkgdb);
|
||||||
obj = prop_array_get(xhp->pkgdb, i);
|
assert(iter);
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
rv = xbps_configure_pkg(xhp, pkgname, true, false, false);
|
rv = xbps_configure_pkg(xhp, pkgname, true, false, false);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
if (flush)
|
if (flush)
|
||||||
rv = xbps_pkgdb_update(xhp, true);
|
rv = xbps_pkgdb_update(xhp, true);
|
||||||
|
|
||||||
|
@ -38,9 +38,10 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
|
|||||||
{
|
{
|
||||||
prop_array_t pkg_cflicts, trans_cflicts;
|
prop_array_t pkg_cflicts, trans_cflicts;
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
|
prop_object_t obj;
|
||||||
|
prop_object_iterator_t iter;
|
||||||
const char *cfpkg, *repopkgver, *pkgver;
|
const char *cfpkg, *repopkgver, *pkgver;
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t i;
|
|
||||||
|
|
||||||
pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts");
|
pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts");
|
||||||
if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0)
|
if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0)
|
||||||
@ -49,8 +50,10 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
|
|||||||
trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts");
|
trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts");
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
|
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(pkg_cflicts); i++) {
|
iter = prop_array_iterator(trans_cflicts);
|
||||||
prop_array_get_cstring_nocopy(pkg_cflicts, i, &cfpkg);
|
assert(iter);
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
cfpkg = prop_string_cstring_nocopy(obj);
|
||||||
/*
|
/*
|
||||||
* Check if current pkg conflicts with an installed package.
|
* Check if current pkg conflicts with an installed package.
|
||||||
*/
|
*/
|
||||||
@ -78,4 +81,5 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
}
|
}
|
||||||
|
@ -35,12 +35,14 @@ static prop_dictionary_t
|
|||||||
get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
|
get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
|
||||||
{
|
{
|
||||||
prop_object_t obj = NULL;
|
prop_object_t obj = NULL;
|
||||||
|
prop_object_iterator_t iter;
|
||||||
const char *pkgver, *dpkgn;
|
const char *pkgver, *dpkgn;
|
||||||
size_t i;
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(array); i++) {
|
iter = prop_array_iterator(array);
|
||||||
obj = prop_array_get(array, i);
|
assert(iter);
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
if (virtual) {
|
if (virtual) {
|
||||||
/*
|
/*
|
||||||
* Check if package pattern matches
|
* Check if package pattern matches
|
||||||
@ -82,6 +84,8 @@ get_pkg_in_array(prop_array_t array, const char *str, bool virtual)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
return found ? obj : NULL;
|
return found ? obj : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,28 +62,40 @@ bool
|
|||||||
xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
||||||
prop_array_t provides)
|
prop_array_t provides)
|
||||||
{
|
{
|
||||||
|
prop_object_t obj, obj2;
|
||||||
|
prop_object_iterator_t iter, iter2;
|
||||||
const char *vpkgver, *pkgpattern;
|
const char *vpkgver, *pkgpattern;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
size_t i, x;
|
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(provides); i++) {
|
iter = prop_array_iterator(provides);
|
||||||
|
assert(iter);
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
prop_array_get_cstring_nocopy(provides, i, &vpkgver);
|
vpkgver = prop_string_cstring_nocopy(obj);
|
||||||
if (strchr(vpkgver, '_') == NULL) {
|
if (strchr(vpkgver, '_') == NULL) {
|
||||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||||
vpkgver = tmp;
|
vpkgver = tmp;
|
||||||
}
|
}
|
||||||
for (x = 0; x < prop_array_count(rundeps); x++) {
|
iter2 = prop_array_iterator(rundeps);
|
||||||
prop_array_get_cstring_nocopy(rundeps, x, &pkgpattern);
|
assert(iter2);
|
||||||
|
while ((obj2 = prop_object_iterator_next(iter2))) {
|
||||||
|
pkgpattern = prop_string_cstring_nocopy(obj2);
|
||||||
if (xbps_pkgpattern_match(vpkgver, pkgpattern)) {
|
if (xbps_pkgpattern_match(vpkgver, pkgpattern)) {
|
||||||
if (tmp != NULL)
|
if (tmp != NULL)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
|
prop_object_iterator_release(iter2);
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter2);
|
||||||
if (tmp != NULL)
|
if (tmp != NULL)
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +112,7 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
|||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
iter = prop_array_iterator(array);
|
||||||
if (iter == NULL)
|
assert(iter);
|
||||||
return false;
|
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter))) {
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
|
@ -142,11 +142,10 @@ vpkg_user_conf(struct xbps_handle *xhp,
|
|||||||
prop_dictionary_t
|
prop_dictionary_t
|
||||||
xbps_rindex_get_virtualpkg(struct xbps_rindex *rpi, const char *pkg)
|
xbps_rindex_get_virtualpkg(struct xbps_rindex *rpi, const char *pkg)
|
||||||
{
|
{
|
||||||
prop_array_t allkeys;
|
prop_object_t obj;
|
||||||
prop_dictionary_keysym_t ksym;
|
prop_object_iterator_t iter;
|
||||||
prop_dictionary_t pkgd = NULL;
|
prop_dictionary_t pkgd = NULL;
|
||||||
const char *vpkg;
|
const char *vpkg;
|
||||||
size_t i;
|
|
||||||
bool found = false, bypattern = false;
|
bool found = false, bypattern = false;
|
||||||
|
|
||||||
if (xbps_pkgpattern_version(pkg))
|
if (xbps_pkgpattern_version(pkg))
|
||||||
@ -169,16 +168,17 @@ xbps_rindex_get_virtualpkg(struct xbps_rindex *rpi, const char *pkg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ... otherwise match the first one in dictionary */
|
/* ... otherwise match the first one in dictionary */
|
||||||
allkeys = prop_dictionary_all_keys(rpi->repod);
|
iter = prop_dictionary_iterator(rpi->repod);
|
||||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
assert(iter);
|
||||||
ksym = prop_array_get(allkeys, i);
|
|
||||||
pkgd = prop_dictionary_get_keysym(rpi->repod, ksym);
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
pkgd = prop_dictionary_get_keysym(rpi->repod, obj);
|
||||||
if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) {
|
if (xbps_match_virtual_pkg_in_dict(pkgd, pkg, bypattern)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prop_object_release(allkeys);
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (found) {
|
if (found) {
|
||||||
|
@ -153,9 +153,11 @@ find_repo_deps(struct xbps_handle *xhp,
|
|||||||
size_t *depth) /* max recursion depth */
|
size_t *depth) /* max recursion depth */
|
||||||
{
|
{
|
||||||
prop_dictionary_t curpkgd, tmpd;
|
prop_dictionary_t curpkgd, tmpd;
|
||||||
|
prop_object_t obj;
|
||||||
|
prop_object_iterator_t iter;
|
||||||
prop_array_t curpkgrdeps;
|
prop_array_t curpkgrdeps;
|
||||||
pkg_state_t state;
|
pkg_state_t state;
|
||||||
size_t i, x;
|
size_t x;
|
||||||
const char *reqpkg, *pkgver_q, *reason = NULL;
|
const char *reqpkg, *pkgver_q, *reason = NULL;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
@ -166,8 +168,11 @@ find_repo_deps(struct xbps_handle *xhp,
|
|||||||
* Iterate over the list of required run dependencies for
|
* Iterate over the list of required run dependencies for
|
||||||
* current package.
|
* current package.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < prop_array_count(pkg_rdeps_array); i++) {
|
iter = prop_array_iterator(pkg_rdeps_array);
|
||||||
prop_array_get_cstring_nocopy(pkg_rdeps_array, i, &reqpkg);
|
assert(iter);
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
reqpkg = prop_string_cstring_nocopy(obj);
|
||||||
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
||||||
xbps_dbg_printf(xhp, "");
|
xbps_dbg_printf(xhp, "");
|
||||||
for (x = 0; x < *depth; x++)
|
for (x = 0; x < *depth; x++)
|
||||||
@ -343,6 +348,7 @@ find_repo_deps(struct xbps_handle *xhp,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
(*depth)--;
|
(*depth)--;
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -175,16 +175,19 @@ int
|
|||||||
xbps_transaction_update_packages(struct xbps_handle *xhp)
|
xbps_transaction_update_packages(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
|
prop_object_iterator_t iter;
|
||||||
const char *pkgname, *holdpkg;
|
const char *pkgname, *holdpkg;
|
||||||
bool foundhold = false, newpkg_found = false;
|
bool foundhold = false, newpkg_found = false;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
size_t i, x;
|
size_t x;
|
||||||
|
|
||||||
if ((rv = xbps_pkgdb_init(xhp)) != 0)
|
if ((rv = xbps_pkgdb_init(xhp)) != 0)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
for (i = 0; i < prop_array_count(xhp->pkgdb); i++) {
|
iter = prop_array_iterator(xhp->pkgdb);
|
||||||
obj = prop_array_get(xhp->pkgdb, i);
|
assert(iter);
|
||||||
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
|
|
||||||
for (x = 0; x < cfg_size(xhp->cfg, "PackagesOnHold"); x++) {
|
for (x = 0; x < cfg_size(xhp->cfg, "PackagesOnHold"); x++) {
|
||||||
@ -212,6 +215,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp)
|
|||||||
rv = 0;
|
rv = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
return newpkg_found ? rv : EEXIST;
|
return newpkg_found ? rv : EEXIST;
|
||||||
}
|
}
|
||||||
|
@ -37,28 +37,31 @@ int HIDDEN
|
|||||||
xbps_transaction_package_replace(struct xbps_handle *xhp)
|
xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
prop_array_t replaces, instd_reqby, unsorted;
|
prop_array_t replaces, instd_reqby, unsorted;
|
||||||
prop_dictionary_t instd, pkg_repod, reppkgd, filesd;
|
prop_dictionary_t instd, reppkgd, filesd;
|
||||||
prop_object_t obj;
|
prop_object_t obj, obj2;
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter, iter2;
|
||||||
const char *pattern, *pkgname, *curpkgname, *pkgver, *curpkgver;
|
const char *pattern, *pkgname, *curpkgname, *pkgver, *curpkgver;
|
||||||
char *buf;
|
char *buf;
|
||||||
bool instd_auto, sr;
|
bool instd_auto, sr;
|
||||||
size_t idx;
|
|
||||||
|
|
||||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||||
|
|
||||||
for (idx = 0; idx < prop_array_count(unsorted); idx++) {
|
iter = prop_array_iterator(unsorted);
|
||||||
pkg_repod = prop_array_get(unsorted, idx);
|
assert(iter);
|
||||||
replaces = prop_dictionary_get(pkg_repod, "replaces");
|
|
||||||
|
while ((obj = prop_object_iterator_next(iter))) {
|
||||||
|
replaces = prop_dictionary_get(obj, "replaces");
|
||||||
if (replaces == NULL || prop_array_count(replaces) == 0)
|
if (replaces == NULL || prop_array_count(replaces) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
iter = prop_array_iterator(replaces);
|
iter2 = prop_array_iterator(replaces);
|
||||||
if (iter == NULL)
|
if (iter2 == NULL) {
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
while ((obj2 = prop_object_iterator_next(iter2)) != NULL) {
|
||||||
pattern = prop_string_cstring_nocopy(obj);
|
pattern = prop_string_cstring_nocopy(obj2);
|
||||||
assert(pattern != NULL);
|
assert(pattern != NULL);
|
||||||
/*
|
/*
|
||||||
* Find the installed package that matches the pattern
|
* Find the installed package that matches the pattern
|
||||||
@ -74,9 +77,9 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
if (instd == NULL)
|
if (instd == NULL)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod,
|
prop_dictionary_get_cstring_nocopy(obj,
|
||||||
"pkgname", &pkgname);
|
"pkgname", &pkgname);
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod,
|
prop_dictionary_get_cstring_nocopy(obj,
|
||||||
"pkgver", &pkgver);
|
"pkgver", &pkgver);
|
||||||
prop_dictionary_get_cstring_nocopy(instd,
|
prop_dictionary_get_cstring_nocopy(instd,
|
||||||
"pkgname", &curpkgname);
|
"pkgname", &curpkgname);
|
||||||
@ -126,16 +129,16 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
* its requiredby and automatic-install objects, so copy
|
* its requiredby and automatic-install objects, so copy
|
||||||
* them to the pkg's dictionary in transaction.
|
* them to the pkg's dictionary in transaction.
|
||||||
*/
|
*/
|
||||||
if (xbps_match_virtual_pkg_in_dict(pkg_repod,
|
if (xbps_match_virtual_pkg_in_dict(obj,
|
||||||
pattern, true) ||
|
pattern, true) ||
|
||||||
xbps_match_virtual_pkg_in_dict(instd,
|
xbps_match_virtual_pkg_in_dict(instd,
|
||||||
pkgname, false)) {
|
pkgname, false)) {
|
||||||
if (instd_reqby &&
|
if (instd_reqby &&
|
||||||
prop_array_count(instd_reqby)) {
|
prop_array_count(instd_reqby)) {
|
||||||
prop_dictionary_set(pkg_repod,
|
prop_dictionary_set(obj,
|
||||||
"requiredby", instd_reqby);
|
"requiredby", instd_reqby);
|
||||||
}
|
}
|
||||||
prop_dictionary_set_bool(pkg_repod,
|
prop_dictionary_set_bool(obj,
|
||||||
"automatic-install", instd_auto);
|
"automatic-install", instd_auto);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -146,14 +149,14 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
* obsolete files.
|
* obsolete files.
|
||||||
*/
|
*/
|
||||||
sr = false;
|
sr = false;
|
||||||
prop_dictionary_get_bool(pkg_repod, "softreplace", &sr);
|
prop_dictionary_get_bool(obj, "softreplace", &sr);
|
||||||
if (sr) {
|
if (sr) {
|
||||||
if (instd_reqby &&
|
if (instd_reqby &&
|
||||||
prop_array_count(instd_reqby)) {
|
prop_array_count(instd_reqby)) {
|
||||||
prop_dictionary_set(pkg_repod,
|
prop_dictionary_set(obj,
|
||||||
"requiredby", instd_reqby);
|
"requiredby", instd_reqby);
|
||||||
}
|
}
|
||||||
prop_dictionary_set_bool(pkg_repod,
|
prop_dictionary_set_bool(obj,
|
||||||
"automatic-install", instd_auto);
|
"automatic-install", instd_auto);
|
||||||
prop_dictionary_set_bool(instd,
|
prop_dictionary_set_bool(instd,
|
||||||
"softreplace", true);
|
"softreplace", true);
|
||||||
@ -168,6 +171,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
free(buf);
|
free(buf);
|
||||||
prop_object_release(filesd);
|
prop_object_release(filesd);
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter);
|
||||||
|
prop_object_iterator_release(iter2);
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
prop_object_release(filesd);
|
prop_object_release(filesd);
|
||||||
@ -181,8 +185,9 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
|||||||
"transaction", "remove");
|
"transaction", "remove");
|
||||||
prop_array_add(unsorted, instd);
|
prop_array_add(unsorted, instd);
|
||||||
}
|
}
|
||||||
prop_object_iterator_release(iter);
|
prop_object_iterator_release(iter2);
|
||||||
}
|
}
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user