libxbps: handle the case to replace a vpkg with a pkg with same name.

This for example fixes reinstalling jpeg and libjpeg-turbo multiple
times. Also if the "automatic-install" obj is in the pkg to be
replaced, copy it to the new pkg to be preserved.

Bumped XBPS_API_VERSION.
This commit is contained in:
Juan RP 2011-10-16 10:28:03 +02:00
parent 0f0c66fafb
commit 104bec27e5
2 changed files with 13 additions and 7 deletions

View File

@ -55,7 +55,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.2" #define XBPS_PKGINDEX_VERSION "1.2"
#define XBPS_API_VERSION "20111015" #define XBPS_API_VERSION "20111016"
#define XBPS_VERSION "0.10.0" #define XBPS_VERSION "0.10.0"
/** /**

View File

@ -41,6 +41,7 @@ xbps_repository_pkg_replaces(prop_dictionary_t transd,
prop_object_t obj; prop_object_t obj;
prop_object_iterator_t iter; prop_object_iterator_t iter;
const char *pattern, *pkgname, *curpkgname; const char *pattern, *pkgname, *curpkgname;
bool instd_auto = false;
replaces = prop_dictionary_get(pkg_repod, "replaces"); replaces = prop_dictionary_get(pkg_repod, "replaces");
if (replaces == NULL || prop_array_count(replaces) == 0) if (replaces == NULL || prop_array_count(replaces) == 0)
@ -93,17 +94,22 @@ xbps_repository_pkg_replaces(prop_dictionary_t transd,
/* /*
* If new package is providing a virtual package to the * If new package is providing a virtual package to the
* package that we want to replace we should respect * package that we want to replace we should respect
* its requiredby object, so copy it to the pkg's dictionary * its requiredby and automatic-install objects, so copy
* 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(pkg_repod, pattern, true) ||
pattern, true)) { xbps_match_virtual_pkg_in_dict(instd, pkgname, false)) {
instd_reqby = prop_dictionary_get(instd, "requiredby"); instd_reqby = prop_dictionary_get(instd, "requiredby");
if (instd_reqby && prop_array_count(instd_reqby)) if (instd_reqby && prop_array_count(instd_reqby)) {
prop_dictionary_set(pkg_repod, prop_dictionary_set(pkg_repod,
"requiredby", instd_reqby); "requiredby", instd_reqby);
}
if (prop_dictionary_get_bool(instd,
"automatic-install", &instd_auto)) {
prop_dictionary_set_bool(pkg_repod,
"automatic-install", instd_auto);
}
} }
/* /*
* Add package dictionary into the transaction and mark it * Add package dictionary into the transaction and mark it
* as to be "removed". * as to be "removed".