From 9acec7883b76b3eb94f616135cabfc765d2f4bbc Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 21 May 2012 23:03:29 +0200 Subject: [PATCH] xbps_remove_pkg: do not error out if files.plist not found, just continue. --- NEWS | 4 ++++ include/xbps_api.h | 2 +- lib/package_remove.c | 50 +++++++++++++++++++------------------------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/NEWS b/NEWS index 0e57506f..3913b956 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ xbps-0.16 (???): + * libxbps: when removing package files and if metadata files.plist wasn't + found, do not error out and rather just continue until the package is + fully removed. + * xbps-bin(8): renamed "autoupdate" target to "dist-upgrade" and "autoremove" to "remove-orphans". For compatibility with previous versions the old targets are still kept, but will be removed in future diff --git a/include/xbps_api.h b/include/xbps_api.h index d5dffb74..2d032a52 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -56,7 +56,7 @@ */ #define XBPS_PKGINDEX_VERSION "1.4" -#define XBPS_API_VERSION "20120508" +#define XBPS_API_VERSION "20120521" #define XBPS_VERSION "0.16" /** diff --git a/lib/package_remove.c b/lib/package_remove.c index a776d16c..45cf0053 100644 --- a/lib/package_remove.c +++ b/lib/package_remove.c @@ -328,38 +328,31 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update) } pkgd = xbps_dictionary_from_metadata_plist(pkgname, XBPS_PKGFILES); - if (pkgd == NULL) { - rv = errno; - goto out; + if (pkgd) { + /* Remove links */ + if ((rv = xbps_remove_pkg_files(pkgd, "links", pkgver)) != 0) + goto out; + /* Remove regular files */ + if ((rv = xbps_remove_pkg_files(pkgd, "files", pkgver)) != 0) + goto out; + /* Remove configuration files */ + if ((rv = xbps_remove_pkg_files(pkgd, "conf_files", pkgver)) != 0) + goto out; + /* Remove dirs */ + if ((rv = xbps_remove_pkg_files(pkgd, "dirs", pkgver)) != 0) + goto out; } - /* Remove links */ - if ((rv = xbps_remove_pkg_files(pkgd, "links", pkgver)) != 0) - goto out; - - /* Remove regular files */ - if ((rv = xbps_remove_pkg_files(pkgd, "files", pkgver)) != 0) - goto out; - - /* Remove configuration files */ - if ((rv = xbps_remove_pkg_files(pkgd, "conf_files", pkgver)) != 0) - goto out; - - /* Remove dirs */ - if ((rv = xbps_remove_pkg_files(pkgd, "dirs", pkgver)) != 0) - goto out; - /* * Execute the post REMOVE action if file exists and we aren't * updating the package. */ if (rmfile_exists && - (xbps_file_exec(buf, "post", pkgname, version, "no", - xhp->conffile, NULL) != 0)) { + ((rv = xbps_file_exec(buf, "post", pkgname, version, "no", + xhp->conffile, NULL)) != 0)) { xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL, - errno, pkgname, version, + rv, pkgname, version, "%s: [remove] REMOVE script failed to execute " - "post ACTION: %s", pkgver, strerror(errno)); - rv = errno; + "post ACTION: %s", pkgver, strerror(rv)); goto out; } /* @@ -390,13 +383,12 @@ purge: * Execute the purge REMOVE action if file exists. */ if (access(buf, X_OK) == 0) { - if (xbps_file_exec(buf, "purge", pkgname, version, "no", - xhp->conffile, NULL) != 0) { - rv = errno; + if ((rv = xbps_file_exec(buf, "purge", pkgname, version, "no", + xhp->conffile, NULL)) != 0) { xbps_set_cb_state(XBPS_STATE_REMOVE_FAIL, - errno, pkgname, version, + rv, pkgname, version, "%s: REMOVE script failed to execute " - "purge ACTION: %s", pkgver, strerror(errno)); + "purge ACTION: %s", pkgver, strerror(rv)); goto out; } }