diff --git a/lib/package_register.c b/lib/package_register.c index 7aaa9b57..f2e0c874 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -35,15 +35,11 @@ int HIDDEN xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) { xbps_array_t replaces; - xbps_dictionary_t pkgd, pkgdbd; - xbps_object_t obj; + xbps_dictionary_t pkgd; time_t t; - struct tm tm; - struct tm *tmp; + struct tm tm, *tmp; const char *pkgver, *pkgname; - char sha256[XBPS_SHA256_SIZE]; - char outstr[64]; - char *buf; + char sha256[XBPS_SHA256_SIZE], outstr[64], *buf; int rv = 0; 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); } 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. */ diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index e0964bd8..1eb16da9 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -56,13 +56,13 @@ static int trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall) { xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod = NULL; + xbps_object_t obj; xbps_array_t pkgs; pkg_state_t state = 0; xbps_trans_type_t ttype; const char *repoloc, *repopkgver, *instpkgver, *pkgname; char buf[XBPS_NAME_SIZE] = {0}; int rv = 0; - bool autoinst = false, repolock = false; assert(pkg != NULL); @@ -97,8 +97,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall) } else { ttype = XBPS_TRANS_UPDATE; } - xbps_dictionary_get_bool(pkg_pkgdb, "repolock", &repolock); - if (repolock) { + if (xbps_dictionary_get(pkg_pkgdb, "repolock")) { struct xbps_repo *repo; /* find update from repo */ 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 (xbps_dictionary_get_bool(pkg_pkgdb, "automatic-install", &autoinst)) - xbps_dictionary_set_bool(pkg_repod, "automatic-install", autoinst); - if (xbps_dictionary_get_bool(pkg_pkgdb, "repolock", &repolock)) - xbps_dictionary_set_bool(pkg_repod, "repolock", repolock); + if ((obj = xbps_dictionary_get(pkg_pkgdb, "automatic-install"))) + xbps_dictionary_set(pkg_repod, "automatic-install", obj); + if ((obj = xbps_dictionary_get(pkg_pkgdb, "hold"))) + 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.