Error and warning messages should go to stderr, make it so.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20100115141916-tpg2rga1i4pm42kj
This commit is contained in:
Juan RP
2010-01-15 15:19:16 +01:00
parent d2a093a401
commit a165d20193
13 changed files with 151 additions and 102 deletions

View File

@@ -109,8 +109,8 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
newpkgd = xbps_repository_get_pkg_plist_dict_from_url(file,
XBPS_PKGPROPS);
if (newpkgd == NULL) {
printf("%s: can't read %s metadata file, skipping!\n",
file, XBPS_PKGPROPS);
fprintf(stderr, "xbps-repo: can't read %s %s metadata "
"file, skipping!\n", file, XBPS_PKGPROPS);
goto out;
}
if (!prop_dictionary_get_cstring_nocopy(newpkgd, "pkgname", &pkgname)) {
@@ -144,7 +144,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
goto out;
}
if (xbps_cmpver(version, regver) <= 0) {
printf("W: skipping %s. %s-%s already "
fprintf(stderr, "W: skipping %s. %s-%s already "
"registered.\n", filen, pkgname, regver);
prop_object_release(newpkgd);
rv = EEXIST;
@@ -168,7 +168,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
goto out;
}
if (remove(oldfilepath) == -1) {
printf("E: Couldn't remove old package file "
fprintf(stderr, "E: Couldn't remove old package file "
"'%s'!\n", oldfilen);
free(oldfilepath);
prop_object_release(newpkgd);
@@ -188,7 +188,8 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
free(tmpstr);
goto out;
}
printf("W: removed outdated binpkg file for '%s'.\n", tmpstr);
fprintf(stderr, "W: removed outdated binpkg file for "
"'%s'.\n", tmpstr);
free(tmpstr);
}
@@ -308,7 +309,8 @@ xbps_repo_genindex(const char *pkgdir)
dirp = opendir(path);
if (dirp == NULL) {
printf("E: unexistent '%s' directory!\n", path);
fprintf(stderr, "E: unexistent '%s' directory!\n",
path);
free(path);
continue;
}

View File

@@ -39,7 +39,8 @@ static void usage(void);
static void
usage(void)
{
printf("Usage: xbps-repo [options] [action] [arguments]\n\n"
fprintf(stderr,
"Usage: xbps-repo [options] [action] [arguments]\n\n"
" Available actions:\n"
" add, genindex, list, remove, search, show, show-deps,\n"
" show-files, sync\n"
@@ -102,7 +103,8 @@ main(int argc, char **argv)
if ((rv = xbps_repository_pool_init()) != 0) {
if (rv != ENOENT) {
printf("E: cannot get repository list pool! %s\n",
fprintf(stderr,
"E: cannot get repository list pool! %s\n",
strerror(rv));
exit(EXIT_FAILURE);
}
@@ -152,7 +154,8 @@ main(int argc, char **argv)
rv = show_pkg_info_from_repolist(argv[1]);
if (rv == 0 && errno == ENOENT) {
printf("Unable to locate package '%s' from "
fprintf(stderr,
"Unable to locate package '%s' from "
"repository pool.\n", argv[1]);
rv = EINVAL;
goto out;
@@ -165,7 +168,8 @@ main(int argc, char **argv)
rv = show_pkg_deps_from_repolist(argv[1]);
if (rv == 0 && errno == ENOENT) {
printf("Unable to locate package '%s' from "
fprintf(stderr,
"Unable to locate package '%s' from "
"repository pool.\n", argv[1]);
rv = EINVAL;
goto out;
@@ -179,7 +183,8 @@ main(int argc, char **argv)
pkgd = xbps_repository_get_pkg_plist_dict(argv[1],
XBPS_PKGFILES);
if (pkgd == NULL) {
printf("E: couldn't read %s: %s.\n", XBPS_PKGFILES,
fprintf(stderr,
"E: couldn't read %s: %s.\n", XBPS_PKGFILES,
strerror(errno));
rv = errno;
goto out;

View File

@@ -46,27 +46,29 @@ pkgindex_verify(const char *plist, const char *uri, bool only_sync)
d = prop_dictionary_internalize_from_file(plist);
if (d == NULL) {
printf("E: repository %s does not contain any "
fprintf(stderr,
"E: repository %s does not contain any "
"xbps pkgindex file.\n", uri);
return errno;
}
if (!prop_dictionary_get_cstring_nocopy(d,
"pkgindex-version", &pkgidx_version)) {
printf("E: missing 'pkgindex-version' object!\n");
fprintf(stderr,
"E: missing 'pkgindex-version' object!\n");
rv = errno;
goto out;
}
if (!prop_dictionary_get_uint64(d, "total-pkgs", &total_pkgs)) {
printf("E: missing 'total-pkgs' object!\n");
fprintf(stderr, "E: missing 'total-pkgs' object!\n");
rv = errno;
goto out;
}
/* Reject empty repositories, how could this happen? :-) */
if (total_pkgs == 0) {
printf("E: empty package list!\n");
fprintf(stderr, "E: empty package list!\n");
rv = EINVAL;
goto out;
}
@@ -77,7 +79,8 @@ pkgindex_verify(const char *plist, const char *uri, bool only_sync)
out:
prop_object_release(d);
if (rv != 0) {
printf("W: removing incorrect pkg index file: '%s' ...\n",
fprintf(stderr,
"W: removing incorrect pkg index file: '%s' ...\n",
plist);
rv = remove(plist);
}
@@ -136,10 +139,10 @@ unregister_repository(const char *uri)
if ((rv = xbps_repository_unregister(idxstr)) != 0) {
if (rv == ENOENT)
printf("Repository '%s' not actually "
fprintf(stderr, "Repository '%s' not actually "
"registered.\n", idxstr);
else
printf("E: couldn't unregister "
fprintf(stderr, "E: couldn't unregister "
"repository (%s)\n", strerror(rv));
}
@@ -159,7 +162,8 @@ register_repository(const char *uri)
printf("Fetching remote package index at %s...\n", uri);
rv = xbps_repository_sync_pkg_index(idxstr);
if (rv == -1) {
printf("Error: could not fetch pkg index file: %s.\n",
fprintf(stderr,
"E: could not fetch pkg index file: %s.\n",
xbps_fetch_error_string());
return rv;
} else if (rv == 0) {
@@ -182,7 +186,8 @@ register_repository(const char *uri)
return errno;
if (xbps_mkpath(metadir, 0755) == -1) {
printf("E: couldn't create metadata dir! (%s)\n",
fprintf(stderr,
"E: couldn't create metadata dir! (%s)\n",
strerror(errno));
free(metadir);
return EXIT_FAILURE;
@@ -198,7 +203,7 @@ register_repository(const char *uri)
goto out;
if ((rv = xbps_repository_register(idxstr)) != 0) {
printf("ERROR: couldn't register repository (%s)\n",
fprintf(stderr, "E: couldn't register repository (%s)\n",
strerror(rv));
goto out;
}
@@ -296,7 +301,7 @@ repository_sync(void)
printf("Syncing package index from: %s\n", rp->rp_uri);
rv = xbps_repository_sync_pkg_index(rp->rp_uri);
if (rv == -1) {
printf("Failed! returned: %s\n",
fprintf(stderr, "E: returned: %s\n",
xbps_fetch_error_string());
break;
} else if (rv == 0) {