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

@ -77,8 +77,6 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
printf("%s: configuring ...\n", xscd->arg); printf("%s: configuring ...\n", xscd->arg);
break; break;
case XBPS_STATE_XBPS_UPDATE: case XBPS_STATE_XBPS_UPDATE:
case XBPS_STATE_REGISTER:
case XBPS_STATE_UNREGISTER:
case XBPS_STATE_CONFIGURE_DONE: case XBPS_STATE_CONFIGURE_DONE:
/* empty */ /* empty */
break; break;
@ -132,8 +130,6 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata)
case XBPS_STATE_UNPACK_FAIL: case XBPS_STATE_UNPACK_FAIL:
case XBPS_STATE_UPDATE_FAIL: case XBPS_STATE_UPDATE_FAIL:
case XBPS_STATE_CONFIGURE_FAIL: case XBPS_STATE_CONFIGURE_FAIL:
case XBPS_STATE_REGISTER_FAIL:
case XBPS_STATE_UNREGISTER_FAIL:
case XBPS_STATE_REMOVE_FAIL: case XBPS_STATE_REMOVE_FAIL:
case XBPS_STATE_VERIFY_FAIL: case XBPS_STATE_VERIFY_FAIL:
case XBPS_STATE_DOWNLOAD_FAIL: case XBPS_STATE_DOWNLOAD_FAIL:

View File

@ -76,8 +76,6 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
switch (xscd->state) { switch (xscd->state) {
/* notifications */ /* notifications */
case XBPS_STATE_UNREGISTER:
break;
case XBPS_STATE_REMOVE: case XBPS_STATE_REMOVE:
printf("Removing `%s' ...\n", xscd->arg); printf("Removing `%s' ...\n", xscd->arg);
break; break;
@ -99,7 +97,6 @@ state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata)
xscd->xhp->rootdir); xscd->xhp->rootdir);
break; break;
/* errors */ /* errors */
case XBPS_STATE_UNREGISTER_FAIL:
case XBPS_STATE_REMOVE_FAIL: case XBPS_STATE_REMOVE_FAIL:
xbps_error_printf("%s\n", xscd->desc); xbps_error_printf("%s\n", xscd->desc);
if (syslog_enabled) if (syslog_enabled)

View File

@ -48,7 +48,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.7" #define XBPS_PKGINDEX_VERSION "1.7"
#define XBPS_API_VERSION "20130307" #define XBPS_API_VERSION "20130307-1"
#ifndef XBPS_VERSION #ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET" #define XBPS_VERSION "UNSET"
@ -159,18 +159,11 @@
*/ */
#define XBPS_FLAG_INSTALL_AUTO 0x00000010 #define XBPS_FLAG_INSTALL_AUTO 0x00000010
/**
* @def XBPS_FLAG_INSTALL_MANUAL
* Enabled manual install mode for a package and all dependencies
* installed direct and indirectly.
*/
#define XBPS_FLAG_INSTALL_MANUAL 0x00000020
/** /**
* @def XBPS_FLAG_DEBUG * @def XBPS_FLAG_DEBUG
* Enable debug mode to output debugging printfs to stdout/stderr. * Enable debug mode to output debugging printfs to stdout/stderr.
*/ */
#define XBPS_FLAG_DEBUG 0x00000040 #define XBPS_FLAG_DEBUG 0x00000020
/** /**
* @def XBPS_FLAG_FORCE_UNPACK * @def XBPS_FLAG_FORCE_UNPACK
@ -178,7 +171,7 @@
* files will be unpacked overwritting the current ones. * files will be unpacked overwritting the current ones.
* Must be set through the xbps_handle::flags member. * Must be set through the xbps_handle::flags member.
*/ */
#define XBPS_FLAG_FORCE_UNPACK 0x00000080 #define XBPS_FLAG_FORCE_UNPACK 0x00000040
/** /**
* @def XBPS_FETCH_CACHECONN * @def XBPS_FETCH_CACHECONN
@ -233,8 +226,6 @@ extern "C" {
* - XBPS_STATE_CONFIGURE: a package is being configured. * - XBPS_STATE_CONFIGURE: a package is being configured.
* - XBPS_STATE_CONFIGURE_DONE: a package has been configured successfully. * - XBPS_STATE_CONFIGURE_DONE: a package has been configured successfully.
* - XBPS_STATE_CONFIG_FILE: a package configuration file is being processed. * - XBPS_STATE_CONFIG_FILE: a package configuration file is being processed.
* - XBPS_STATE_REGISTER: a package is being registered.
* - XBPS_STATE_UNREGISTER: a package is being unregistered.
* - XBPS_STATE_REPOSYNC: a remote repository's package index is being * - XBPS_STATE_REPOSYNC: a remote repository's package index is being
* synchronized. * synchronized.
* - XBPS_STATE_VERIFY_FAIL: binary package integrity has failed. * - XBPS_STATE_VERIFY_FAIL: binary package integrity has failed.
@ -250,8 +241,6 @@ extern "C" {
* has failed. * has failed.
* - XBPS_STATE_UPDATE_FAIL: package update has failed. * - XBPS_STATE_UPDATE_FAIL: package update has failed.
* - XBPS_STATE_UNPACK_FAIL: package unpack has failed. * - XBPS_STATE_UNPACK_FAIL: package unpack has failed.
* - XBPS_STATE_REGISTER_FAIL: package register has failed.
* - XBPS_STATE_UNREGISTER_FAIL: package unregister has failed.
* - XBPS_STATE_REPOSYNC_FAIL: syncing remote repositories has failed. * - XBPS_STATE_REPOSYNC_FAIL: syncing remote repositories has failed.
*/ */
typedef enum xbps_state { typedef enum xbps_state {
@ -276,8 +265,6 @@ typedef enum xbps_state {
XBPS_STATE_UNPACK, XBPS_STATE_UNPACK,
XBPS_STATE_CONFIGURE, XBPS_STATE_CONFIGURE,
XBPS_STATE_CONFIG_FILE, XBPS_STATE_CONFIG_FILE,
XBPS_STATE_REGISTER,
XBPS_STATE_UNREGISTER,
XBPS_STATE_REPOSYNC, XBPS_STATE_REPOSYNC,
XBPS_STATE_VERIFY_FAIL, XBPS_STATE_VERIFY_FAIL,
XBPS_STATE_DOWNLOAD_FAIL, XBPS_STATE_DOWNLOAD_FAIL,
@ -290,8 +277,6 @@ typedef enum xbps_state {
XBPS_STATE_CONFIG_FILE_FAIL, XBPS_STATE_CONFIG_FILE_FAIL,
XBPS_STATE_UPDATE_FAIL, XBPS_STATE_UPDATE_FAIL,
XBPS_STATE_UNPACK_FAIL, XBPS_STATE_UNPACK_FAIL,
XBPS_STATE_REGISTER_FAIL,
XBPS_STATE_UNREGISTER_FAIL,
XBPS_STATE_REPOSYNC_FAIL, XBPS_STATE_REPOSYNC_FAIL,
XBPS_STATE_XBPS_UPDATE, XBPS_STATE_XBPS_UPDATE,
XBPS_STATE_CONFIGURE_DONE XBPS_STATE_CONFIGURE_DONE

View File

@ -240,7 +240,6 @@ int HIDDEN xbps_remove_pkg_files(struct xbps_handle *, prop_dictionary_t,
* From lib/package_register.c * From lib/package_register.c
*/ */
int HIDDEN xbps_register_pkg(struct xbps_handle *, prop_dictionary_t); int HIDDEN xbps_register_pkg(struct xbps_handle *, prop_dictionary_t);
int HIDDEN xbps_unregister_pkg(struct xbps_handle *, const char *);
/** /**
* @private * @private

View File

@ -52,8 +52,6 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
provides = prop_dictionary_get(pkgrd, "provides"); provides = prop_dictionary_get(pkgrd, "provides");
rundeps = prop_dictionary_get(pkgrd, "run_depends"); rundeps = prop_dictionary_get(pkgrd, "run_depends");
xbps_set_cb_state(xhp, XBPS_STATE_REGISTER, 0, pkgver, NULL);
assert(pkgver != NULL); assert(pkgver != NULL);
assert(desc != NULL); assert(desc != NULL);
@ -76,11 +74,8 @@ xbps_register_pkg(struct xbps_handle *xhp, prop_dictionary_t pkgrd)
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
prop_dictionary_get_bool(pkgd, "automatic-install", &autoinst);
if (xhp->flags & XBPS_FLAG_INSTALL_AUTO) if (xhp->flags & XBPS_FLAG_INSTALL_AUTO)
autoinst = true; autoinst = true;
else if (xhp->flags & XBPS_FLAG_INSTALL_MANUAL)
autoinst = false;
if (!prop_dictionary_set_bool(pkgd, if (!prop_dictionary_set_bool(pkgd,
"automatic-install", autoinst)) { "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); "%s: failed to set pkgd for %s\n", __func__, pkgver);
goto out; goto out;
} }
(void)xbps_pkgdb_update(xhp, true); rv = xbps_pkgdb_update(xhp, true);
out: out:
if (pkgname) if (pkgname)
free(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; 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. * 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; goto out;
xbps_dbg_printf(xhp, "[remove] unregister %s returned %d\n", pkgver, rv); 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); 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 int
xbps_set_pkg_state_installed(struct xbps_handle *xhp, xbps_set_pkg_state_installed(struct xbps_handle *xhp,
const char *pkgver, const char *pkgver,
@ -158,9 +149,10 @@ xbps_set_pkg_state_installed(struct xbps_handle *xhp,
if (pkgd == NULL) if (pkgd == NULL)
return ENOMEM; return ENOMEM;
if ((rv = set_pkg_objs(pkgd, pkgver)) != 0) { if (!prop_dictionary_set_cstring_nocopy(pkgd,
"pkgver", pkgver)) {
prop_object_release(pkgd); prop_object_release(pkgd);
return rv; return EINVAL;
} }
if ((rv = set_new_state(pkgd, state)) != 0) { if ((rv = set_new_state(pkgd, state)) != 0) {
prop_object_release(pkgd); prop_object_release(pkgd);

View File

@ -66,6 +66,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
char *pkgname; char *pkgname;
int rv = 0; int rv = 0;
pkg_state_t state = 0; pkg_state_t state = 0;
bool autoinst = false;
assert(pkg != NULL); assert(pkg != NULL);
@ -104,6 +105,11 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, int action)
repopkgver, instpkgver, repoloc); repopkgver, instpkgver, repoloc);
return EEXIST; 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. * Prepare transaction dictionary.