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

@ -129,17 +129,20 @@ xbps_check_pkg_integrity(const char *pkgname)
propsd = prop_dictionary_internalize_from_file(path);
free(path);
if (propsd == NULL) {
printf("%s: unexistent %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: unexistent %s metadata file.\n", pkgname,
XBPS_PKGPROPS);
rv = errno;
goto out;
} else if (prop_object_type(propsd) != PROP_TYPE_DICTIONARY) {
printf("%s: invalid %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: invalid %s metadata file.\n", pkgname,
XBPS_PKGPROPS);
rv = EINVAL;
goto out1;
} else if (prop_dictionary_count(propsd) == 0) {
printf("%s: incomplete %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: incomplete %s metadata file.\n", pkgname,
XBPS_PKGPROPS);
rv = EINVAL;
goto out1;
@ -158,24 +161,28 @@ xbps_check_pkg_integrity(const char *pkgname)
filesd = prop_dictionary_internalize_from_file(path);
free(path);
if (filesd == NULL) {
printf("%s: unexistent %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: unexistent %s metadata file.\n", pkgname,
XBPS_PKGPROPS);
rv = ENOENT;
goto out1;
} else if (prop_object_type(filesd) != PROP_TYPE_DICTIONARY) {
printf("%s: invalid %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: invalid %s metadata file.\n", pkgname,
XBPS_PKGFILES);
rv = EINVAL;
goto out2;
} else if (prop_dictionary_count(filesd) == 0) {
printf("%s: incomplete %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: incomplete %s metadata file.\n", pkgname,
XBPS_PKGFILES);
rv = EINVAL;
goto out2;
} else if (((array = prop_dictionary_get(filesd, "files")) == NULL) ||
((array = prop_dictionary_get(filesd, "links")) == NULL) ||
((array = prop_dictionary_get(filesd, "dirs")) == NULL)) {
printf("%s: incomplete %s metadata file.\n", pkgname,
fprintf(stderr,
"E: %s: incomplete %s metadata file.\n", pkgname,
XBPS_PKGFILES);
rv = EINVAL;
goto out2;
@ -218,17 +225,18 @@ xbps_check_pkg_integrity(const char *pkgname)
case 0:
break;
case ENOENT:
printf("%s: unexistent file %s.\n",
fprintf(stderr, "%s: unexistent file %s.\n",
pkgname, file);
files_broken = true;
break;
case ERANGE:
printf("%s: hash mismatch for %s.\n",
fprintf(stderr, "%s: hash mismatch for %s.\n",
pkgname, file);
files_broken = true;
break;
default:
printf("%s: unexpected error for %s (%s)\n",
fprintf(stderr,
"%s: unexpected error for %s (%s)\n",
pkgname, file, strerror(rv));
break;
}
@ -268,11 +276,13 @@ xbps_check_pkg_integrity(const char *pkgname)
}
if ((rv = access(path, R_OK)) == -1) {
if (errno == ENOENT) {
printf("%s: unexistent file %s\n",
fprintf(stderr,
"%s: unexistent file %s\n",
pkgname, file);
broken = true;
} else
printf("%s: unexpected error for "
fprintf(stderr,
"%s: unexpected error for "
"%s (%s)\n", pkgname, file,
strerror(errno));
}

View File

@ -47,7 +47,8 @@ static void show_package_list(prop_object_iterator_t, const char *);
static void
show_missing_deps(prop_dictionary_t d)
{
printf("Unable to locate some required packages:\n");
fprintf(stderr,
"xbps-bin: unable to locate some required packages:\n");
(void)xbps_callback_array_iter_in_dict(d, "missing_deps",
show_missing_dep_cb, NULL);
}
@ -64,7 +65,7 @@ show_missing_dep_cb(prop_object_t obj, void *arg, bool *loop_done)
if (reqpkg == NULL)
return EINVAL;
printf(" * Missing binary package for: %s\n", reqpkg);
fprintf(stderr, " * Missing binary package for: %s\n", reqpkg);
return 0;
}
@ -78,10 +79,11 @@ check_binpkg_hash(const char *path, const char *filename,
rv = xbps_check_file_hash(path, sha256);
errno = rv;
if (rv != 0 && rv != ERANGE) {
printf("unexpected error: %s\n", strerror(rv));
fprintf(stderr, "xbps-bin: unexpected error: %s\n",
strerror(rv));
return false;
} else if (rv == ERANGE) {
printf("hash mismatch!.\n");
fprintf(stderr, "xbps-bin: hash mismatch!.\n");
return false;
}
printf("OK.\n");
@ -165,13 +167,15 @@ download_package_list(prop_object_iterator_t iter)
rv = xbps_fetch_file(binfile, cachedir, false, NULL);
free(binfile);
if (rv == -1) {
printf("Couldn't download %s from %s (%s)\n",
filename, repoloc, xbps_fetch_error_string());
fprintf(stderr, "xbps-bin: couldn't download %s "
"from %s (%s)\n", filename, repoloc,
xbps_fetch_error_string());
free(lbinfile);
return errno;
}
if (!check_binpkg_hash(lbinfile, filename, sha256)) {
printf("W: removing wrong %s file ...\n", filename);
fprintf(stderr, "W: removing wrong %s file ...\n",
filename);
(void)remove(lbinfile);
free(lbinfile);
return errno;
@ -279,15 +283,15 @@ show_transaction_sizes(prop_object_iterator_t iter)
*/
if (xbps_humanize_number(size, 5, (int64_t)dlsize,
"", HN_AUTOSCALE, HN_B|HN_DECIMAL|HN_NOSPACE) == -1) {
printf("error: humanize_number returns %s\n",
strerror(errno));
fprintf(stderr, "xbps-bin: error: humanize_number returns "
"%s\n", strerror(errno));
return -1;
}
printf("Total download size: %s\n", size);
if (xbps_humanize_number(size, 5, (int64_t)instsize,
"", HN_AUTOSCALE, HN_B|HN_DECIMAL|HN_NOSPACE) == -1) {
printf("error: humanize_number2 returns %s\n",
strerror(errno));
fprintf(stderr, "xbps-bin: error: humanize_number2 returns "
"%s\n", strerror(errno));
return -1;
}
printf("Total installed size: %s\n\n", size);
@ -399,11 +403,13 @@ xbps_install_new_pkg(const char *pkg)
}
rv = xbps_repository_install_pkg(pkg, pkgmatch);
if (rv == EAGAIN) {
printf("Unable to locate '%s' in "
fprintf(stderr, "xbps-bin: unable to locate '%s' in "
"repository pool.\n", pkg);
rv = 0;
rv = 1;
} else if (rv != 0 && rv != ENOENT) {
printf("Unexpected error: %s", strerror(errno));
fprintf(stderr, "xbps-bin: unexpected error: %s",
strerror(errno));
rv = -1;
}
if (pkgmatch)
@ -426,7 +432,7 @@ xbps_update_pkg(const char *pkgname)
printf("Package '%s' is up to date.\n", pkgname);
rv = 0;
} else if (rv == ENOENT) {
printf("Package '%s' not found in "
fprintf(stderr, "Package '%s' not found in "
"repository pool.\n", pkgname);
rv = 0;
}
@ -451,10 +457,8 @@ xbps_exec_transaction(bool yes)
goto out;
trans->dict = xbps_repository_get_transaction_dict();
if (trans->dict == NULL) {
printf("Empty transaction, exiting.\n");
goto out1;
}
if (trans->dict == NULL)
goto out;
/*
* Bail out if there are unresolved deps.
@ -462,7 +466,7 @@ xbps_exec_transaction(bool yes)
array = prop_dictionary_get(trans->dict, "missing_deps");
if (prop_array_count(array) > 0) {
show_missing_deps(trans->dict);
goto out2;
goto out;
}
DPRINTF(("%s", prop_dictionary_externalize(trans->dict)));
@ -471,8 +475,9 @@ xbps_exec_transaction(bool yes)
* Sort the package transaction dictionary.
*/
if ((rv = xbps_sort_pkg_deps(trans->dict)) != 0) {
printf("Error while sorting packages: %s\n", strerror(rv));
goto out2;
fprintf(stderr, "xbps-bin: error while sorting "
"packages: %s\n", strerror(rv));
goto out;
}
/*
@ -480,20 +485,21 @@ xbps_exec_transaction(bool yes)
*/
trans->iter = xbps_get_array_iter_from_dict(trans->dict, "packages");
if (trans->iter == NULL) {
printf("error: allocating array mem! (%s)\n",
fprintf(stderr, "xbps-bin: error allocating array mem! (%s)\n",
strerror(errno));
goto out2;
goto out;
}
trans->yes = yes;
rv = exec_transaction(trans);
prop_object_iterator_release(trans->iter);
out2:
prop_object_release(trans->dict);
out1:
free(trans);
out:
if (trans->iter)
prop_object_iterator_release(trans->iter);
if (trans->dict)
prop_object_release(trans->dict);
if (trans)
free(trans);
return rv;
}
@ -522,12 +528,12 @@ replace_packages(prop_object_iterator_t iter, const char *pkgver)
reppkgn, pkgver);
version = xbps_get_pkg_version(pkgver);
if ((rv = xbps_remove_pkg(reppkgn, version, false)) != 0) {
printf("Couldn't remove %s (%s)\n",
fprintf(stderr, "xbps-bin: couldn't remove %s (%s)\n",
reppkgn, strerror(rv));
return rv;
}
if ((rv = xbps_purge_pkg(reppkgn, false)) != 0) {
printf("Couldn't purge %s (%s)\n",
fprintf(stderr, "xbps-bin: couldn't purge %s (%s)\n",
reppkgn, strerror(rv));
return rv;
}
@ -616,8 +622,9 @@ exec_transaction(struct transaction *trans)
if (replaces_iter != NULL) {
rv = replace_packages(replaces_iter, pkgver);
if (rv != 0) {
printf("Couldn't replace some packages! "
"(%s)\n", strerror(rv));
fprintf(stderr,
"xbps-bin: couldn't replace some "
"packages! (%s)\n", strerror(rv));
return rv;
}
replaces_iter = NULL;
@ -626,8 +633,8 @@ exec_transaction(struct transaction *trans)
if (strcmp(tract, "update") == 0) {
instpkgd = xbps_find_pkg_installed_from_plist(pkgname);
if (instpkgd == NULL) {
printf("error: unable to find %s installed "
"dict!\n", pkgname);
fprintf(stderr, "xbps-bin: error: unable to "
"find %s installed dict!\n", pkgname);
return EINVAL;
}
@ -646,7 +653,8 @@ exec_transaction(struct transaction *trans)
if (essential) {
rv = xbps_requiredby_pkg_remove(pkgname);
if (rv != 0) {
printf("error: couldn't remove reqby"
fprintf(stderr, "xbps-bin: error: "
"couldn't remove reqby"
" entries for %s-%s (%s)\n",
pkgname, instver, strerror(rv));
return rv;
@ -656,7 +664,8 @@ exec_transaction(struct transaction *trans)
pkgname, instver);
rv = xbps_remove_pkg(pkgname, version, true);
if (rv != 0) {
printf("error: removing %s-%s (%s)\n",
fprintf(stderr, "xbps-bin: error "
"removing %s-%s (%s)\n",
pkgname, instver, strerror(rv));
return rv;
}
@ -667,16 +676,16 @@ exec_transaction(struct transaction *trans)
*/
printf("Unpacking %s (from .../%s) ...\n", pkgver, filename);
if ((rv = xbps_unpack_binary_pkg(obj)) != 0) {
printf("error: unpacking %s (%s)\n", pkgver,
strerror(rv));
fprintf(stderr, "xbps-bin: error unpacking %s "
"(%s)\n", pkgver, strerror(rv));
return rv;
}
/*
* Register binary package.
*/
if ((rv = xbps_register_pkg(obj, autoinst)) != 0) {
printf("error: registering %s! (%s)\n",
pkgver, strerror(rv));
fprintf(stderr, "xbps-bin: error registering %s "
"(%s)\n", pkgver, strerror(rv));
return rv;
}
autoinst = false;
@ -700,8 +709,8 @@ exec_transaction(struct transaction *trans)
update = true;
rv = xbps_configure_pkg(pkgname, version, false, update);
if (rv != 0) {
printf("Error configuring package %s (%s)\n",
pkgname, strerror(rv));
fprintf(stderr, "xbps-bin: error configuring "
"package %s (%s)\n", pkgname, strerror(rv));
return rv;
}
}

View File

@ -41,7 +41,8 @@ static int list_pkgs_in_dict(prop_object_t, void *, bool *);
static void
usage(void)
{
printf("Usage: xbps-bin [options] [target] [arguments]\n\n"
fprintf(stderr,
"Usage: xbps-bin [options] [target] [arguments]\n\n"
" Available targets:\n"
" autoremove\n"
" autoupdate\n"
@ -167,7 +168,8 @@ main(int argc, char **argv)
if ((dict = xbps_regpkgs_dictionary_init()) == NULL) {
if (errno != ENOENT) {
rv = errno;
printf("Couldn't initialized regpkgdb dict: %s\n",
fprintf(stderr,
"E: couldn't initialize regpkgdb dict: %s\n",
strerror(errno));
goto out;
}

View File

@ -186,7 +186,7 @@ xbps_remove_installed_pkgs(int argc, char **argv, bool force)
prop_dictionary_get_cstring_nocopy(dict, "version", &version);
printf("Removing package %s-%s ...\n", argv[i], version);
if ((rv = xbps_remove_pkg(argv[i], version, false)) != 0) {
printf("Unable to remove %s-%s (%s).\n",
fprintf(stderr, "E: unable to remove %s-%s (%s).\n",
argv[i], version, strerror(errno));
return rv;
}

View File

@ -59,7 +59,8 @@ xbps_show_pkg_deps(const char *pkgname)
propsd = prop_dictionary_internalize_from_file(path);
free(path);
if (propsd == NULL) {
printf("%s: unexistent %s metadata file.\n", pkgname,
fprintf(stderr,
"%s: unexistent %s metadata file.\n", pkgname,
XBPS_PKGPROPS);
return errno;
}

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) {

View File

@ -56,7 +56,8 @@ write_plist_file(prop_dictionary_t dict, const char *file)
static void
usage(void)
{
printf("usage: xbps-uhelper [options] [action] [args]\n"
fprintf(stderr,
"usage: xbps-uhelper [options] [action] [args]\n"
"\n"
" Available actions:\n"
" cmpver, digest, fetch, getpkgdepname, getpkgname, getpkgrevision,\n"
@ -131,7 +132,8 @@ main(int argc, char **argv)
plist = xbps_xasprintf("%s/%s/%s", root, XBPS_META_PATH, XBPS_REGPKGDB);
if (plist == NULL) {
printf("%s=> ERROR: couldn't find regpkdb file (%s)%s\n",
fprintf(stderr,
"%s=> ERROR: couldn't find regpkdb file (%s)%s\n",
MSG_ERROR, strerror(errno), MSG_RESET);
exit(EXIT_FAILURE);
}
@ -168,7 +170,7 @@ main(int argc, char **argv)
in_chroot ? "[chroot] " : "", argv[1], argv[2],
MSG_RESET);
} else if (rv != 0) {
printf("%s%s=> couldn't register %s-%s "
fprintf(stderr, "%s%s=> couldn't register %s-%s "
"(%s).%s\n", MSG_ERROR,
in_chroot ? "[chroot] " : "" , argv[1], argv[2],
strerror(rv), MSG_RESET);
@ -185,10 +187,10 @@ main(int argc, char **argv)
rv = xbps_remove_pkg_dict_from_file(argv[1], plist);
if (rv == ENOENT) {
printf("%s=> ERROR: %s not registered "
fprintf(stderr, "%s=> ERROR: %s not registered "
"in database.%s\n", MSG_WARN, argv[1], MSG_RESET);
} else if (rv != 0) {
printf("%s=> ERROR: couldn't unregister %s "
fprintf(stderr, "%s=> ERROR: couldn't unregister %s "
"from database (%s)%s\n", MSG_ERROR,
argv[1], strerror(rv), MSG_RESET);
exit(EXIT_FAILURE);
@ -221,7 +223,8 @@ main(int argc, char **argv)
dict = prop_dictionary_internalize_from_file(argv[1]);
if (dict == NULL) {
printf("=> ERROR: couldn't sanitize %s plist file "
fprintf(stderr,
"=> ERROR: couldn't sanitize %s plist file "
"(%s)\n", argv[1], strerror(errno));
exit(EXIT_FAILURE);
}
@ -234,7 +237,8 @@ main(int argc, char **argv)
version = xbps_get_pkg_version(argv[1]);
if (version == NULL) {
printf("Invalid string, expected <string>-<version>\n");
fprintf(stderr,
"Invalid string, expected <string>-<version>\n");
exit(EXIT_FAILURE);
}
printf("%s\n", version);
@ -246,7 +250,8 @@ main(int argc, char **argv)
pkgname = xbps_get_pkg_name(argv[1]);
if (pkgname == NULL) {
printf("Invalid string, expected <string>-<version>\n");
fprintf(stderr,
"Invalid string, expected <string>-<version>\n");
exit(EXIT_FAILURE);
}
printf("%s\n", pkgname);
@ -300,7 +305,8 @@ main(int argc, char **argv)
for (i = 1; i < argc; i++) {
hash = xbps_get_file_hash(argv[i]);
if (hash == NULL) {
printf("Couldn't get hash for %s (%s)\n",
fprintf(stderr,
"E: couldn't get hash for %s (%s)\n",
argv[i], strerror(errno));
exit(EXIT_FAILURE);
}

View File

@ -145,8 +145,8 @@ xbps_configure_pkg(const char *pkgname, const char *version, bool check_state,
if ((rv = xbps_file_chdir_exec(rootdir, buf, "post",
pkgname, lver, update ? "yes" : "no", NULL)) != 0) {
free(buf);
printf("%s: post INSTALL action returned: %s\n",
pkgname, strerror(errno));
fprintf(stderr, "%s: post INSTALL action "
"returned: %s\n", pkgname, strerror(errno));
return rv;
}
} else {

View File

@ -79,13 +79,15 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
}
rv = xbps_check_file_hash(path, sha256);
if (rv == ENOENT) {
printf("WARNING: '%s' doesn't exist!\n", file);
fprintf(stderr,
"WARNING: '%s' doesn't exist!\n", file);
free(path);
rv = 0;
continue;
} else if (rv == ERANGE) {
if (flags & XBPS_FLAG_VERBOSE)
printf("WARNING: '%s' SHA256 mismatch, "
fprintf(stderr,
"WARNING: '%s' SHA256 mismatch, "
"preserving...\n", file);
rv = 0;
free(path);
@ -102,7 +104,8 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
continue;
}
if (flags & XBPS_FLAG_VERBOSE) {
printf("WARNING: can't remove "
fprintf(stderr,
"WARNING: can't remove "
"directory %s (%s)\n", file,
strerror(errno));
free(path);
@ -113,7 +116,8 @@ xbps_remove_pkg_files(prop_dictionary_t dict, const char *key)
if (strcmp(key, "dirs")) {
if ((rv = remove(path)) == -1) {
if (flags & XBPS_FLAG_VERBOSE)
printf("WARNING: can't remove %s "
fprintf(stderr,
"WARNING: can't remove %s "
"(%s)\n", file, strerror(errno));
rv = 0;
@ -171,7 +175,8 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
rv = xbps_file_chdir_exec(rootdir, buf, "pre", pkgname,
version, update ? "yes" : "no", NULL);
if (rv != 0) {
printf("%s: prerm action target error (%s)\n", pkgname,
fprintf(stderr,
"%s: prerm action target error (%s)\n", pkgname,
strerror(errno));
free(buf);
return rv;
@ -223,7 +228,8 @@ xbps_remove_pkg(const char *pkgname, const char *version, bool update)
if (update == false && prepostf) {
if ((rv = xbps_file_chdir_exec(rootdir, buf, "post",
pkgname, version, NULL)) != 0) {
printf("%s: postrm action target error (%s)\n",
fprintf(stderr,
"%s: postrm action target error (%s)\n",
pkgname, strerror(errno));
free(buf);
return rv;

View File

@ -90,7 +90,8 @@ again:
goto out;
}
if (remove(buf) == -1) {
printf("WARNING: couldn't remove obsolete %s: %s\n",
fprintf(stderr,
"WARNING: couldn't remove obsolete %s: %s\n",
dolinks ? "link" : "file",
prop_string_cstring_nocopy(oldstr));
free(buf);

View File

@ -203,7 +203,8 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
pkgname, version, update ? "yes" : "no",
NULL)) != 0) {
free(buf);
printf("%s: preinst action target error %s\n",
fprintf(stderr,
"%s: preinst action target error %s\n",
pkgname, strerror(errno));
return rv;
}
@ -271,12 +272,13 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg)
if (archive_read_extract(ar, entry, lflags) != 0) {
rv = archive_errno(ar);
if (rv != EEXIST) {
printf("ERROR: %s...exiting!\n",
fprintf(stderr, "ERROR: %s...exiting!\n",
archive_error_string(ar));
return rv;;
} else if (rv == EEXIST) {
if (flags & XBPS_FLAG_VERBOSE) {
printf("WARNING: ignoring existent "
fprintf(stderr,
"WARNING: ignoring existent "
"path: %s\n",
archive_entry_pathname(entry));
}