Use xbps_{error,warn}_printf() everywhere.
This commit is contained in:
@@ -98,9 +98,9 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
XBPS_PKGFILES);
|
||||
free(url);
|
||||
if (pkg_filesd == NULL) {
|
||||
fprintf(stderr, "E: couldn't get '%s' from '%s' "
|
||||
"in repo '%s: %s'\n", XBPS_PKGFILES, pkgname, rpi->rpi_uri,
|
||||
strerror(errno));
|
||||
xbps_error_printf("xbps-repo: couldn't read '%s' "
|
||||
"from '%s (%s)': %s\n", XBPS_PKGFILES, pkgname,
|
||||
rpi->rpi_uri, strerror(errno));
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
newpkgd = xbps_repository_plist_find_pkg_dict_from_url(file,
|
||||
XBPS_PKGPROPS);
|
||||
if (newpkgd == NULL) {
|
||||
fprintf(stderr, "xbps-repo: can't read %s %s metadata "
|
||||
xbps_error_printf("xbps-repo: can't read %s %s metadata "
|
||||
"file, skipping!\n", file, XBPS_PKGPROPS);
|
||||
goto out;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
} else if (curpkgd) {
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd, "version", ®ver);
|
||||
if (xbps_cmpver(version, regver) <= 0) {
|
||||
fprintf(stderr, "W: skipping %s. %s-%s already "
|
||||
xbps_warn_printf("skipping %s. %s-%s already "
|
||||
"registered.\n", filen, pkgname, regver);
|
||||
prop_object_release(newpkgd);
|
||||
rv = EEXIST;
|
||||
@@ -149,8 +149,9 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
goto out;
|
||||
}
|
||||
if (remove(oldfilepath) == -1) {
|
||||
fprintf(stderr, "E: Couldn't remove old package file "
|
||||
"'%s'! (%s)\n", oldfilepath, strerror(errno));
|
||||
xbps_error_printf("xbps-repo: couldn't remove old "
|
||||
"package file `%s': %s\n", oldfilepath,
|
||||
strerror(errno));
|
||||
free(oldfilepath);
|
||||
prop_object_release(newpkgd);
|
||||
rv = errno;
|
||||
@@ -165,13 +166,13 @@ xbps_repo_addpkg_index(prop_dictionary_t idxdict, const char *filedir,
|
||||
}
|
||||
if (!xbps_remove_pkg_from_dict_by_name(idxdict,
|
||||
"packages", pkgname)) {
|
||||
fprintf(stderr, "E: couldn't remove %s dict from "
|
||||
"index (%s)\n", pkgname, strerror(errno));
|
||||
xbps_error_printf("xbps-repo: couldn't remove `%s' "
|
||||
"from plist index: %s\n", pkgname, strerror(errno));
|
||||
prop_object_release(newpkgd);
|
||||
free(tmpstr);
|
||||
goto out;
|
||||
}
|
||||
fprintf(stderr, "W: removed outdated binpkg file for "
|
||||
xbps_warn_printf("xbps-repo: removed outdated binpkg file for "
|
||||
"'%s'.\n", tmpstr);
|
||||
free(tmpstr);
|
||||
}
|
||||
@@ -292,8 +293,8 @@ xbps_repo_genindex(const char *pkgdir)
|
||||
|
||||
dirp = opendir(path);
|
||||
if (dirp == NULL) {
|
||||
fprintf(stderr, "E: unexistent '%s' directory!\n",
|
||||
path);
|
||||
xbps_error_printf("xbps-repo: unexistent '%s' "
|
||||
"directory!\n", path);
|
||||
free(path);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -113,8 +113,8 @@ main(int argc, char **argv)
|
||||
|
||||
if ((rv = xbps_repository_pool_init()) != 0) {
|
||||
if (rv != ENOENT) {
|
||||
fprintf(stderr, "E: cannot get repository list pool! %s\n",
|
||||
strerror(rv));
|
||||
xbps_error_printf("xbps-repo: failed to initialize "
|
||||
"repository pool: %s\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -158,9 +158,9 @@ main(int argc, char **argv)
|
||||
|
||||
rv = show_pkg_info_from_repolist(argv[1]);
|
||||
if (rv == 0 && errno == ENOENT) {
|
||||
fprintf(stderr,
|
||||
"Unable to locate package '%s' from "
|
||||
"repository pool.\n", argv[1]);
|
||||
xbps_error_printf("xbps-repo: unable to locate "
|
||||
"`%s' from repository pool: %s\n", argv[1],
|
||||
strerror(rv));
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -172,9 +172,9 @@ main(int argc, char **argv)
|
||||
|
||||
rv = show_pkg_deps_from_repolist(argv[1]);
|
||||
if (rv == 0 && errno == ENOENT) {
|
||||
fprintf(stderr,
|
||||
"Unable to locate package '%s' from "
|
||||
"repository pool.\n", argv[1]);
|
||||
xbps_error_printf("xbps-repo: unable to locate "
|
||||
"`%s' from repository pool: %s\n", argv[1],
|
||||
strerror(rv));
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -188,13 +188,12 @@ main(int argc, char **argv)
|
||||
XBPS_PKGFILES);
|
||||
if (pkgd == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
fprintf(stderr, "xbps-repo: unexpected "
|
||||
xbps_error_printf("xbps-repo: unexpected "
|
||||
"error '%s' searching for '%s'\n",
|
||||
strerror(errno), argv[1]);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Package '%s' not found in repository "
|
||||
"pool.\n", argv[1]);
|
||||
xbps_error_printf("xbps-repo: `%s' not found "
|
||||
"in repository pool.\n", argv[1]);
|
||||
}
|
||||
rv = errno;
|
||||
goto out;
|
||||
|
||||
@@ -91,8 +91,8 @@ pkgindex_verify(const char *plist, const char *uri)
|
||||
|
||||
d = prop_dictionary_internalize_from_zfile(plist);
|
||||
if (d == NULL) {
|
||||
fprintf(stderr, "E: failed to add '%s' repository: %s\n",
|
||||
uri, strerror(errno));
|
||||
xbps_error_printf("xbps-repo: failed to add `%s' "
|
||||
"repository: %s\n", uri, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -103,22 +103,22 @@ pkgindex_verify(const char *plist, const char *uri)
|
||||
|
||||
if (!prop_dictionary_get_cstring(d,
|
||||
"pkgindex-version", &rpi->pkgidxver)) {
|
||||
fprintf(stderr,
|
||||
"E: missing 'pkgindex-version' object!\n");
|
||||
xbps_error_printf("xbps-repo: missing 'pkgindex-version' "
|
||||
"object!\n");
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!prop_dictionary_get_uint64(d, "total-pkgs",
|
||||
&rpi->totalpkgs)) {
|
||||
fprintf(stderr, "E: missing 'total-pkgs' object!\n");
|
||||
xbps_error_printf("xbps-repo: missing 'total-pkgs' object!\n");
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Reject empty repositories, how could this happen? :-) */
|
||||
if (rpi->totalpkgs == 0) {
|
||||
fprintf(stderr, "E: empty package list!\n");
|
||||
xbps_error_printf("xbps-repo: `%s' empty package list!\n", uri);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@@ -126,9 +126,8 @@ pkgindex_verify(const char *plist, const char *uri)
|
||||
out:
|
||||
prop_object_release(d);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr,
|
||||
"W: removing incorrect pkg index file: '%s' ...\n",
|
||||
plist);
|
||||
xbps_error_printf("xbps-repo: removing incorrect "
|
||||
"pkg-index file for `%s'.\n", uri);
|
||||
(void)remove(plist);
|
||||
if (rpi) {
|
||||
free(rpi);
|
||||
@@ -151,11 +150,11 @@ unregister_repository(const char *uri)
|
||||
return 0;
|
||||
|
||||
if (rv == ENOENT) {
|
||||
fprintf(stderr, "Repository '%s' not actually "
|
||||
xbps_error_printf("Repository '%s' not "
|
||||
"registered.\n", idxstr);
|
||||
} else {
|
||||
fprintf(stderr, "E: couldn't unregister "
|
||||
"repository (%s)\n", strerror(rv));
|
||||
xbps_error_printf("xbps-repo: couldn't unregister "
|
||||
"repository: %s\n", strerror(rv));
|
||||
}
|
||||
|
||||
return rv;
|
||||
@@ -178,9 +177,8 @@ register_repository(const char *uri)
|
||||
rv = xbps_repository_sync_pkg_index(idxstr,
|
||||
fetch_file_progress_cb, &xfpd);
|
||||
if (rv == -1) {
|
||||
fprintf(stderr,
|
||||
"E: could not fetch pkg index file: %s.\n",
|
||||
xbps_fetch_error_string());
|
||||
xbps_error_printf("xbps-repo: couldn't fetch pkg-index"
|
||||
"file: %s.\n", xbps_fetch_error_string());
|
||||
return rv;
|
||||
} else if (rv == 0) {
|
||||
printf("Package index file is already "
|
||||
@@ -199,9 +197,8 @@ register_repository(const char *uri)
|
||||
return errno;
|
||||
|
||||
if (xbps_mkpath(metadir, 0755) == -1) {
|
||||
fprintf(stderr,
|
||||
"E: couldn't create metadata dir! (%s)\n",
|
||||
strerror(errno));
|
||||
xbps_error_printf("xbps-repo: couldn't create metadata "
|
||||
"directory: %s.\n", strerror(errno));
|
||||
free(metadir);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -217,10 +214,10 @@ register_repository(const char *uri)
|
||||
|
||||
if ((rv = xbps_repository_register(idxstr)) != 0) {
|
||||
if (rv == EEXIST) {
|
||||
fprintf(stderr, "W: repository already registered.\n");
|
||||
xbps_warn_printf("repository already registered.\n");
|
||||
} else {
|
||||
fprintf(stderr, "E: couldn't register repository "
|
||||
"(%s)\n", strerror(errno));
|
||||
xbps_error_printf("xbps-repo: couldn't register "
|
||||
"repository: %s.\n", strerror(errno));
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
@@ -313,7 +310,8 @@ repo_sync_pkg_index_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
rv = xbps_repository_sync_pkg_index(rpi->rpi_uri,
|
||||
fetch_file_progress_cb, &xfpd);
|
||||
if (rv == -1) {
|
||||
fprintf(stderr, "E: returned: %s\n", xbps_fetch_error_string());
|
||||
xbps_error_printf("xbps-repo: failed to sync `%s': %s\n",
|
||||
rpi->rpi_uri, xbps_fetch_error_string());
|
||||
return rv;
|
||||
} else if (rv == 0) {
|
||||
printf("Package index file is already up to date.\n");
|
||||
|
||||
Reference in New Issue
Block a user