xbps_remove_pkg: handle all cases where pkg meta plist is unavail.

This commit is contained in:
Juan RP 2012-11-19 14:08:01 +01:00
parent 1147e7ce3c
commit 5397dd4937

View File

@ -225,6 +225,9 @@ xbps_remove_pkg(struct xbps_handle *xhp,
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0) if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0)
goto out; goto out;
xbps_dbg_printf(xhp, "attempting to remove %s state %d\n",
pkgname, state);
if (!update) if (!update)
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE, 0, pkgname, version, NULL); xbps_set_cb_state(xhp, XBPS_STATE_REMOVE, 0, pkgname, version, NULL);
@ -240,7 +243,8 @@ xbps_remove_pkg(struct xbps_handle *xhp,
} }
pkgd = xbps_metadir_get_pkgd(xhp, pkgname); pkgd = xbps_metadir_get_pkgd(xhp, pkgname);
if (pkgd == NULL) if (pkgd == NULL)
goto out1; xbps_dbg_printf(xhp, "WARNING: metaplist for %s "
"doesn't exist!\n", pkgname);
/* If package was "half-removed", remove it fully. */ /* If package was "half-removed", remove it fully. */
if (state == XBPS_PKG_STATE_HALF_REMOVED) if (state == XBPS_PKG_STATE_HALF_REMOVED)
@ -248,15 +252,17 @@ xbps_remove_pkg(struct xbps_handle *xhp,
/* /*
* Run the pre remove action. * Run the pre remove action.
*/ */
rv = xbps_pkg_exec_script(xhp, pkgd, "remove", "pre", update); if (pkgd) {
if (rv != 0) { rv = xbps_pkg_exec_script(xhp, pkgd, "remove", "pre", update);
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL, if (rv != 0) {
errno, pkgname, version, xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
"%s: [remove] REMOVE script failed to " errno, pkgname, version,
"execute pre ACTION: %s", "%s: [remove] REMOVE script failed to "
pkgver, strerror(errno)); "execute pre ACTION: %s",
rv = errno; pkgver, strerror(errno));
goto out; rv = errno;
goto out;
}
} }
/* /*
* If updating a package, we just need to execute the current * If updating a package, we just need to execute the current
@ -288,18 +294,18 @@ xbps_remove_pkg(struct xbps_handle *xhp,
/* Remove dirs */ /* Remove dirs */
if ((rv = xbps_remove_pkg_files(xhp, pkgd, "dirs", pkgver)) != 0) if ((rv = xbps_remove_pkg_files(xhp, pkgd, "dirs", pkgver)) != 0)
goto out; goto out;
} /*
/* * Execute the post REMOVE action if file exists and we aren't
* Execute the post REMOVE action if file exists and we aren't * updating the package.
* updating the package. */
*/ rv = xbps_pkg_exec_script(xhp, pkgd, "remove-script", "post", false);
rv = xbps_pkg_exec_script(xhp, pkgd, "remove-script", "post", false); if (rv != 0) {
if (rv != 0) { xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL, rv, pkgname, version,
rv, pkgname, version, "%s: [remove] REMOVE script failed to execute "
"%s: [remove] REMOVE script failed to execute " "post ACTION: %s", pkgver, strerror(rv));
"post ACTION: %s", pkgver, strerror(rv)); goto out;
goto out; }
} }
/* /*
* Update the requiredby array of all required dependencies. * Update the requiredby array of all required dependencies.
@ -330,15 +336,17 @@ purge:
/* /*
* Execute the purge REMOVE action if file exists. * Execute the purge REMOVE action if file exists.
*/ */
rv = xbps_pkg_exec_script(xhp, pkgd, "remove-script", "purge", false); if (pkgd) {
if (rv != 0) { rv = xbps_pkg_exec_script(xhp, pkgd, "remove-script", "purge", false);
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL, if (rv != 0) {
rv, pkgname, version, xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
"%s: REMOVE script failed to execute " rv, pkgname, version,
"purge ACTION: %s", pkgver, strerror(rv)); "%s: REMOVE script failed to execute "
goto out; "purge ACTION: %s", pkgver, strerror(rv));
goto out;
}
} }
out1:
/* /*
* Remove package metadata plist. * Remove package metadata plist.
*/ */