From b55346ae64224b14bdc0e33b3a2817308a653255 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 14 Feb 2009 03:25:55 +0100 Subject: [PATCH] Show an informative error if binpkg cannot be found in repos. --HG-- extra : convert_revision : 0c1e639cb598b19d258c1e1413dd1cb5930c4c61 --- bin/xbps-bin/main.c | 15 ++++++++++----- lib/install.c | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/xbps-bin/main.c b/bin/xbps-bin/main.c index bd2254f0d6..bd6d747daa 100644 --- a/bin/xbps-bin/main.c +++ b/bin/xbps-bin/main.c @@ -138,8 +138,13 @@ main(int argc, char **argv) if (strcasecmp(argv[0], "install") == 0) { rv = xbps_install_binary_pkg(argv[1], root); if (rv) { - printf("ERROR: unable to install %s.\n", argv[1]); - exit(rv); + if (rv == ENOENT) + printf("Unable to locate %s in " + "repository pool.\n", argv[1]); + else + printf("Unable to install %s (%s).\n", + argv[1], strerror(rv)); + exit(EXIT_FAILURE); } printf("Package %s installed successfully.\n", argv[1]); } else { @@ -149,9 +154,9 @@ main(int argc, char **argv) printf("Package %s is not installed.\n", argv[1]); else - printf("ERROR: unable to remove %s.\n", - argv[1]); - exit(rv); + printf("Unable to remove %s (%s).\n", + argv[1], strerror(rv)); + exit(EXIT_FAILURE); } printf("Package %s removed successfully.\n", argv[1]); } diff --git a/lib/install.c b/lib/install.c index 6bf72c21b1..66838bf682 100644 --- a/lib/install.c +++ b/lib/install.c @@ -87,6 +87,8 @@ xbps_install_binary_pkg(const char *pkgname, const char *destdir) */ rv = xbps_callback_array_iter_in_repolist(install_binpkg_repo_cb, (void *)&cb); + if (errno == ENOENT) + rv = ENOENT; return rv; } @@ -120,6 +122,7 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done) pkgrd = xbps_find_pkg_in_dict(repod, "packages", pkgname); if (pkgrd == NULL) { prop_object_release(repod); + errno = ENOENT; return 0; }