Skip to content

Commit

Permalink
lib: keep pkgdb props on updates in the proper place.
Browse files Browse the repository at this point in the history
Improve f906f5a
  • Loading branch information
Juan RP committed Apr 22, 2020
1 parent 7a1f542 commit 6b6b394
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
27 changes: 3 additions & 24 deletions lib/package_register.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
*/
Expand Down
15 changes: 8 additions & 7 deletions lib/transaction_ops.c
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down

2 comments on commit 6b6b394

@Duncaen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks better.

@Duncaen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think so too.

Please sign in to comment.