Respect automatic-install mode from pkgdb in transaction updates.

Also simplify register/unregister and remove useless state definitions.
This commit is contained in:
Juan RP
2013-03-07 10:03:59 +01:00
parent 90b6803825
commit 0a1859987a
8 changed files with 15 additions and 70 deletions

View File

@@ -52,8 +52,6 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
provides = prop_dictionary_get(pkgrd, "provides");
rundeps = prop_dictionary_get(pkgrd, "run_depends");
xbps_set_cb_state(xhp, XBPS_STATE_REGISTER, 0, pkgver, NULL);
assert(pkgver != NULL);
assert(desc != NULL);
@@ -76,11 +74,8 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
rv = EINVAL;
goto out;
}
prop_dictionary_get_bool(pkgd, "automatic-install", &autoinst);
if (xhp->flags & XBPS_FLAG_INSTALL_AUTO)
autoinst = true;
else if (xhp->flags & XBPS_FLAG_INSTALL_MANUAL)
autoinst = false;
if (!prop_dictionary_set_bool(pkgd,
"automatic-install", autoinst)) {
@@ -147,37 +142,11 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
"%s: failed to set pkgd for %s\n", __func__, pkgver);
goto out;
}
(void)xbps_pkgdb_update(xhp, true);
rv = xbps_pkgdb_update(xhp, true);
out:
if (pkgname)
free(pkgname);
if (rv != 0) {
xbps_set_cb_state(xhp, XBPS_STATE_REGISTER_FAIL,
rv, pkgver, "%s: failed to register package: %s",
pkgver, strerror(rv));
}
return rv;
}
int HIDDEN
xbps_unregister_pkg(struct xbps_handle *xhp, const char *pkgver)
{
char *pkgname;
assert(xhp);
assert(pkgver);
xbps_set_cb_state(xhp, XBPS_STATE_UNREGISTER, 0, pkgver, NULL, NULL);
pkgname = xbps_pkg_name(pkgver);
assert(pkgname);
prop_dictionary_remove(xhp->pkgdb, pkgname);
free(pkgname);
(void)xbps_pkgdb_update(xhp, true);
return 0;
}

View File

@@ -319,7 +319,8 @@ purge:
/*
* Unregister package from pkgdb.
*/
if ((rv = xbps_unregister_pkg(xhp, pkgver)) != 0)
prop_dictionary_remove(xhp->pkgdb, pkgname);
if ((rv = xbps_pkgdb_update(xhp, true)) != 0)
goto out;
xbps_dbg_printf(xhp, "[remove] unregister %s returned %d\n", pkgver, rv);

View File

@@ -132,15 +132,6 @@ xbps_set_pkg_state_dictionary(prop_dictionary_t dict, pkg_state_t state)
return set_new_state(dict, state);
}
static int
set_pkg_objs(prop_dictionary_t pkgd, const char *pkgver)
{
if (!prop_dictionary_set_cstring_nocopy(pkgd, "pkgver", pkgver))
return EINVAL;
return 0;
}
int
xbps_set_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgver,
@@ -158,9 +149,10 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
if (pkgd == NULL)
return ENOMEM;
if ((rv = set_pkg_objs(pkgd, pkgver)) != 0) {
if (!prop_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) {
prop_object_release(pkgd);
return rv;
return EINVAL;
}
if ((rv = set_new_state(pkgd, state)) != 0) {
prop_object_release(pkgd);

View File

@@ -66,6 +66,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
char *pkgname;
int rv = 0;
pkg_state_t state = 0;
bool autoinst = false;
assert(pkg != NULL);
@@ -104,6 +105,11 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
repopkgver, instpkgver, repoloc);
return EEXIST;
}
/* respect current install mode from pkgdb */
prop_dictionary_get_bool(pkg_pkgdb, "automatic-install",
&autoinst);
prop_dictionary_set_bool(pkg_repod, "automatic-install",
autoinst);
}
/*
* Prepare transaction dictionary.