From e6503b98cc218864c37c32a8232a77d245f5710b Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 16 Dec 2010 00:25:53 +0100 Subject: [PATCH] xbps-uhelper: fix the 'unregister' target, wasn't updated for 0.7.0 API changes. --- NEWS | 5 +++++ bin/xbps-uhelper/main.c | 29 ++++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 1bfda460..5ab855c2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +xbps-0.7.1 (?): + + * Fixed the xbps-uhelper 'unregister' target that was using the old returned + type to check for errors. + xbps-0.7.0 (2010-12-15): * xbps-repo(8): implemented the 'find-files' target to print which packages diff --git a/bin/xbps-uhelper/main.c b/bin/xbps-uhelper/main.c index 6aabb449..488be3b2 100644 --- a/bin/xbps-uhelper/main.c +++ b/bin/xbps-uhelper/main.c @@ -104,7 +104,7 @@ main(int argc, char **argv) { prop_dictionary_t dict; const char *version; - char *plist, *pkgname, *pkgver, *in_chroot_env, *root = "", *hash; + char *plist, *pkgname, *pkgver, *in_chroot_env, *hash; bool in_chroot = false; int i, c, rv = 0; @@ -112,10 +112,7 @@ main(int argc, char **argv) switch (c) { case 'r': /* To specify the root directory */ - root = strdup(optarg); - if (root == NULL) - exit(EXIT_FAILURE); - xbps_set_rootdir(root); + xbps_set_rootdir(optarg); break; case 'V': printf("%s\n", XBPS_RELVER); @@ -132,9 +129,10 @@ main(int argc, char **argv) if (argc < 1) usage(); - xbps_init(false); + xbps_init(true); - plist = xbps_xasprintf("%s/%s/%s", root, XBPS_META_PATH, XBPS_REGPKGDB); + plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), + XBPS_META_PATH, XBPS_REGPKGDB); if (plist == NULL) { fprintf(stderr, "%s=> ERROR: couldn't find regpkdb file (%s)%s\n", @@ -189,14 +187,15 @@ main(int argc, char **argv) if (argc != 3) usage(); - rv = xbps_remove_pkg_dict_from_file(argv[1], plist); - if (rv == ENOENT) { - fprintf(stderr, "%s=> ERROR: %s not registered " - "in database.%s\n", MSG_WARN, argv[1], MSG_RESET); - } else if (rv != 0) { - fprintf(stderr, "%s=> ERROR: couldn't unregister %s " - "from database (%s)%s\n", MSG_ERROR, - argv[1], strerror(rv), MSG_RESET); + if (!xbps_remove_pkg_dict_from_file(argv[1], plist)) { + if (errno == ENOENT) + fprintf(stderr, "%s=> ERROR: %s not registered " + "in database.%s\n", MSG_WARN, argv[1], MSG_RESET); + else + fprintf(stderr, "%s=> ERROR: couldn't unregister %s " + "from database (%s)%s\n", MSG_ERROR, + argv[1], strerror(errno), MSG_RESET); + exit(EXIT_FAILURE); }