When reinstalling existing pkgs, remove previous entry in pkgdb's requiredby.

This commit is contained in:
Juan RP
2012-04-04 10:20:29 +02:00
parent 4511e581b2
commit feacc506de
3 changed files with 22 additions and 4 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.15 (???): xbps-0.15 (???):
* When reinstalling existing packages (xbps-bin -f install), make sure
to remove previous entry in the "requiredby" pkgdb's array object.
* When sorting required dependencies make sure that a pkg with * When sorting required dependencies make sure that a pkg with
required version is taken into account, not just the first required version is taken into account, not just the first
one matching its pkgname. one matching its pkgname.

View File

@ -56,7 +56,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.4" #define XBPS_PKGINDEX_VERSION "1.4"
#define XBPS_API_VERSION "20120330" #define XBPS_API_VERSION "20120404"
#define XBPS_VERSION "0.15" #define XBPS_VERSION "0.15"
/** /**

View File

@ -36,6 +36,7 @@ add_pkg_into_reqby(prop_dictionary_t pkgd, const char *pkgver)
{ {
prop_array_t reqby; prop_array_t reqby;
prop_string_t reqstr; prop_string_t reqstr;
char *pkgname;
bool alloc = false; bool alloc = false;
assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY); assert(prop_object_type(pkgd) == PROP_TYPE_DICTIONARY);
@ -46,9 +47,23 @@ add_pkg_into_reqby(prop_dictionary_t pkgd, const char *pkgver)
return ENOMEM; return ENOMEM;
} }
/* the entry already exists, do nothing */ /*
if (xbps_match_string_in_array(reqby, pkgver)) * If an existing entry matching pkgname exists remove it
return 0; * and add new pkgver object.
*/
pkgname = xbps_pkg_name(pkgver);
if (pkgname == NULL)
return ENOMEM;
if (xbps_match_pkgname_in_array(reqby, pkgname)) {
if (!xbps_remove_pkgname_from_array(reqby, pkgname)) {
xbps_dbg_printf("%s: failed to remove %s reqby entry: "
"%s\n", __func__, pkgname, strerror(errno));
free(pkgname);
return EINVAL;
}
}
free(pkgname);
reqstr = prop_string_create_cstring(pkgver); reqstr = prop_string_create_cstring(pkgver);
if (reqstr == NULL) { if (reqstr == NULL) {