Improve 869466278b55 even more; it detects installs/updates correctly now.

This commit is contained in:
Juan RP 2014-05-22 12:19:35 +02:00
parent ac5aa94e58
commit 889e5d665e

View File

@ -229,16 +229,16 @@ find_repo_deps(struct xbps_handle *xhp,
break; break;
} }
free(pkgname); free(pkgname);
/* Required pkgdep not installed */ /* Required dependency not installed */
xbps_dbg_printf_append(xhp, "not installed "); xbps_dbg_printf_append(xhp, "not installed ");
reason = "install"; reason = "install";
state = XBPS_PKG_STATE_NOT_INSTALLED; state = XBPS_PKG_STATE_NOT_INSTALLED;
} else { } else {
/* /*
* Check if installed version matches the required pkgdep version. * Required dependency is installed, check if its version can
* satisfy the requirements.
*/ */
xbps_dictionary_get_cstring_nocopy(curpkgd, xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
"pkgver", &pkgver_q);
/* Check its state */ /* Check its state */
if ((rv = xbps_pkg_state_dictionary(curpkgd, &state)) != 0) { if ((rv = xbps_pkg_state_dictionary(curpkgd, &state)) != 0) {
@ -257,57 +257,33 @@ find_repo_deps(struct xbps_handle *xhp,
} }
rv = xbps_pkgpattern_match(pkgver_q, reqpkg); rv = xbps_pkgpattern_match(pkgver_q, reqpkg);
if (rv == 0) { if (rv == 0) {
if (foundvpkg) { char *curpkgname;
/* /*
* Dependency is installed and is a virtual package; check * The version requirement is not satisfied.
* if the virtual package should replace it and then
* update it, otherwise install dependency.
*/ */
xbps_array_t replaces; curpkgname = xbps_pkg_name(pkgver_q);
const char *pkgdep; assert(curpkgname);
char *pkgdepname; if (strcmp(pkgname, curpkgname)) {
bool matching_vpkg = false; xbps_dbg_printf_append(xhp, "not installed `%s (vpkg)'", pkgver_q);
replaces = xbps_dictionary_get(curpkgd, "replaces");
for (unsigned int x = 0; x < xbps_array_count(replaces); x++) {
xbps_array_get_cstring_nocopy(replaces, x, &pkgdep);
pkgdepname = xbps_pkgpattern_name(pkgdep);
assert(pkgdepname);
if (strcmp(pkgname, pkgdepname) == 0) {
matching_vpkg = true;
free(pkgdepname);
break;
}
free(pkgdepname);
}
if (matching_vpkg) {
xbps_dbg_printf_append(xhp, "installed `%s', must be updated.", pkgver_q);
if (xbps_dictionary_get(curpkgd, "hold")) { if (xbps_dictionary_get(curpkgd, "hold")) {
xbps_dbg_printf_append(xhp, " on hold state! ignoring update.\n"); xbps_dbg_printf_append(xhp, " on hold state! ignoring package.\n");
} else { } else {
xbps_dbg_printf_append(xhp, "\n");
reason = "update";
}
} else {
xbps_dbg_printf_append(xhp, "installed `%s (vpkg)', but does not replace it.\n", pkgver_q);
reason = "install"; reason = "install";
} }
} else { } else {
xbps_dbg_printf_append(xhp, "installed `%s', must be updated.", pkgver_q); xbps_dbg_printf_append(xhp, "installed `%s', must be updated", pkgver_q);
/*
* Dependency is installed but its version does not
* satisfy the requirements, update it to a greater version.
*/
if (xbps_dictionary_get(curpkgd, "hold")) { if (xbps_dictionary_get(curpkgd, "hold")) {
xbps_dbg_printf_append(xhp, " on hold state! ignoring update.\n"); xbps_dbg_printf_append(xhp, " on hold state! ignoring package.\n");
} else { } else {
xbps_dbg_printf_append(xhp, "\n");
reason = "update"; reason = "update";
} }
} }
free(curpkgname);
free(pkgname); free(pkgname);
} else if (rv == 1) { } else if (rv == 1) {
/*
* The version requirement is satisfied.
*/
free(pkgname); free(pkgname);
rv = 0; rv = 0;
if (state == XBPS_PKG_STATE_UNPACKED) { if (state == XBPS_PKG_STATE_UNPACKED) {
@ -400,18 +376,16 @@ find_repo_deps(struct xbps_handle *xhp,
if (xhp->flags & XBPS_FLAG_DEBUG) { if (xhp->flags & XBPS_FLAG_DEBUG) {
xbps_dbg_printf(xhp, ""); xbps_dbg_printf(xhp, "");
for (unsigned short x = 0; x < *depth; x++) for (unsigned short x = 0; x < *depth; x++) {
xbps_dbg_printf_append(xhp, " "); xbps_dbg_printf_append(xhp, " ");
}
xbps_dbg_printf_append(xhp, xbps_dbg_printf_append(xhp, "%s: finding dependencies:\n", pkgver_q);
"%s: finding dependencies:\n", pkgver_q);
} }
/* /*
* Recursively find rundeps for current pkg dictionary. * Recursively find rundeps for current pkg dictionary.
*/ */
(*depth)++; (*depth)++;
rv = find_repo_deps(xhp, unsorted, curpkgrdeps, rv = find_repo_deps(xhp, unsorted, curpkgrdeps, curpkgprovides, pkgver_q, depth);
curpkgprovides, pkgver_q, depth);
if (rv != 0) { if (rv != 0) {
xbps_dbg_printf(xhp, "Error checking %s for rundeps: %s\n", reqpkg, strerror(rv)); xbps_dbg_printf(xhp, "Error checking %s for rundeps: %s\n", reqpkg, strerror(rv));
break; break;