lib: keep pkgdb props on updates in the proper place.

Improve f906f5a83d
This commit is contained in:
Juan RP 2020-04-22 12:20:38 +02:00
parent 7a1f5424f6
commit 6b6b394686
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368
2 changed files with 11 additions and 31 deletions

View File

@ -35,15 +35,11 @@ int HIDDEN
xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
{ {
xbps_array_t replaces; xbps_array_t replaces;
xbps_dictionary_t pkgd, pkgdbd; xbps_dictionary_t pkgd;
xbps_object_t obj;
time_t t; time_t t;
struct tm tm; struct tm tm, *tmp;
struct tm *tmp;
const char *pkgver, *pkgname; const char *pkgver, *pkgname;
char sha256[XBPS_SHA256_SIZE]; char sha256[XBPS_SHA256_SIZE], outstr[64], *buf;
char outstr[64];
char *buf;
int rv = 0; int rv = 0;
bool autoinst = false; bool autoinst = false;
@ -106,23 +102,6 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256); xbps_dictionary_set_cstring(pkgd, "metafile-sha256", sha256);
} }
free(buf); free(buf);
/*
* Keep objects stored in pkgdb (if found).
*/
if ((pkgdbd = xbps_pkgdb_get_pkg(xhp, pkgname))) {
obj = xbps_dictionary_get(pkgdbd, "hold");
if (obj) {
xbps_dictionary_set(pkgd, "hold", obj);
}
obj = xbps_dictionary_get(pkgdbd, "repolock");
if (obj) {
xbps_dictionary_set(pkgd, "repolock", obj);
}
obj = xbps_dictionary_get(pkgdbd, "automatic-install");
if (obj) {
xbps_dictionary_set(pkgd, "automatic-install", obj);
}
}
/* /*
* Remove self replacement when applicable. * Remove self replacement when applicable.
*/ */

View File

@ -56,13 +56,13 @@ static int
trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall) trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall)
{ {
xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod = NULL; xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod = NULL;
xbps_object_t obj;
xbps_array_t pkgs; xbps_array_t pkgs;
pkg_state_t state = 0; pkg_state_t state = 0;
xbps_trans_type_t ttype; xbps_trans_type_t ttype;
const char *repoloc, *repopkgver, *instpkgver, *pkgname; const char *repoloc, *repopkgver, *instpkgver, *pkgname;
char buf[XBPS_NAME_SIZE] = {0}; char buf[XBPS_NAME_SIZE] = {0};
int rv = 0; int rv = 0;
bool autoinst = false, repolock = false;
assert(pkg != NULL); assert(pkg != NULL);
@ -97,8 +97,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall)
} else { } else {
ttype = XBPS_TRANS_UPDATE; ttype = XBPS_TRANS_UPDATE;
} }
xbps_dictionary_get_bool(pkg_pkgdb, "repolock", &repolock); if (xbps_dictionary_get(pkg_pkgdb, "repolock")) {
if (repolock) {
struct xbps_repo *repo; struct xbps_repo *repo;
/* find update from repo */ /* find update from repo */
xbps_dictionary_get_cstring_nocopy(pkg_pkgdb, "repository", &repoloc); xbps_dictionary_get_cstring_nocopy(pkg_pkgdb, "repository", &repoloc);
@ -152,10 +151,12 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall)
/* /*
* If pkg is already installed, respect some properties. * If pkg is already installed, respect some properties.
*/ */
if (xbps_dictionary_get_bool(pkg_pkgdb, "automatic-install", &autoinst)) if ((obj = xbps_dictionary_get(pkg_pkgdb, "automatic-install")))
xbps_dictionary_set_bool(pkg_repod, "automatic-install", autoinst); xbps_dictionary_set(pkg_repod, "automatic-install", obj);
if (xbps_dictionary_get_bool(pkg_pkgdb, "repolock", &repolock)) if ((obj = xbps_dictionary_get(pkg_pkgdb, "hold")))
xbps_dictionary_set_bool(pkg_repod, "repolock", repolock); xbps_dictionary_set(pkg_repod, "hold", obj);
if ((obj = xbps_dictionary_get(pkg_pkgdb, "repolock")))
xbps_dictionary_set(pkg_repod, "repolock", obj);
} }
/* /*
* Prepare transaction dictionary. * Prepare transaction dictionary.