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)
goto out;
xbps_dbg_printf(xhp, "attempting to remove %s state %d\n",
pkgname, state);
if (!update)
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);
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 (state == XBPS_PKG_STATE_HALF_REMOVED)
@ -248,6 +252,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
/*
* Run the pre remove action.
*/
if (pkgd) {
rv = xbps_pkg_exec_script(xhp, pkgd, "remove", "pre", update);
if (rv != 0) {
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
@ -258,6 +263,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
rv = errno;
goto out;
}
}
/*
* If updating a package, we just need to execute the current
* pre-remove action target, unregister its requiredby entries and
@ -288,7 +294,6 @@ xbps_remove_pkg(struct xbps_handle *xhp,
/* Remove dirs */
if ((rv = xbps_remove_pkg_files(xhp, pkgd, "dirs", pkgver)) != 0)
goto out;
}
/*
* Execute the post REMOVE action if file exists and we aren't
* updating the package.
@ -301,6 +306,7 @@ xbps_remove_pkg(struct xbps_handle *xhp,
"post ACTION: %s", pkgver, strerror(rv));
goto out;
}
}
/*
* Update the requiredby array of all required dependencies.
*/
@ -330,6 +336,7 @@ purge:
/*
* Execute the purge REMOVE action if file exists.
*/
if (pkgd) {
rv = xbps_pkg_exec_script(xhp, pkgd, "remove-script", "purge", false);
if (rv != 0) {
xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_FAIL,
@ -338,7 +345,8 @@ purge:
"purge ACTION: %s", pkgver, strerror(rv));
goto out;
}
out1:
}
/*
* Remove package metadata plist.
*/