libxbps: improve returned errnos for repository API functions.

- xbps_repository_update_packages: return ENOENT if regpkgdb is NULL
  (no packages currently registered).
- xbps_repository_update_packages: return EEXIST if no updates are
  available.
- xbps_repository_pool: return ENOTSUP if no repositories were
  registered.
- make xbps-{bin,repo} handle ENOTSUP errors.
This commit is contained in:
Juan RP
2011-07-29 11:17:34 +02:00
parent e71e3e9958
commit 2857214afa
6 changed files with 84 additions and 38 deletions

View File

@@ -192,9 +192,13 @@ autoupdate_pkgs(bool yes, bool show_download_pkglist_url)
if (rv == ENOENT) {
printf("No packages currently registered.\n");
return 0;
} else if (rv == ENXIO) {
} else if (rv == EEXIST) {
printf("All packages are up-to-date.\n");
return 0;
} else if (rv == ENOTSUP) {
xbps_error_printf("xbps-bin: no repositories currently "
"registered!\n");
return -1;
} else {
xbps_error_printf("xbps-bin: unexpected error %s\n",
strerror(rv));
@@ -246,8 +250,11 @@ install_new_pkg(const char *pkg)
}
if ((rv = xbps_repository_install_pkg(pkgpatt)) != 0) {
if (rv == ENOENT) {
fprintf(stderr, "xbps-bin: unable to locate '%s' in "
xbps_error_printf("xbps-bin: unable to locate '%s' in "
"repository pool.\n", pkg);
} else if (rv == ENOTSUP) {
xbps_error_printf("xbps-bin: no repositories "
"currently registered!\n");
} else {
xbps_error_printf("xbps-bin: unexpected error: %s\n",
strerror(rv));
@@ -275,6 +282,9 @@ update_pkg(const char *pkgname)
"repository pool.\n", pkgname);
else if (rv == ENODEV)
printf("Package '%s' not installed.\n", pkgname);
else if (rv == ENOTSUP)
xbps_error_printf("xbps-bin: no repositories currently "
"registered!\n");
else if (rv != 0) {
xbps_error_printf("xbps-bin: unexpected error %s\n",
strerror(rv));