bin/: use xbps logging functions more
This commit is contained in:
parent
7391a7b213
commit
1271a3dbed
@ -243,7 +243,7 @@ main(int argc, char **argv)
|
||||
if (set_mode) {
|
||||
/* in set mode pkgdb must be locked and flushed on success */
|
||||
if ((rv = xbps_pkgdb_lock(&xh)) != 0) {
|
||||
fprintf(stderr, "failed to lock pkgdb: %s\n", strerror(rv));
|
||||
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((rv = xbps_alternatives_set(&xh, pkg, group)) == 0)
|
||||
|
@ -66,7 +66,7 @@ xstrdup(const char *src)
|
||||
{
|
||||
char *p;
|
||||
if (!(p = strdup(src))) {
|
||||
fprintf(stderr, "Error: %s\n", strerror(errno));
|
||||
xbps_error_printf("%s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
return p;
|
||||
@ -155,7 +155,7 @@ rcv_load_file(rcv_t *rcv, const char *fname)
|
||||
|
||||
if ((file = fopen(rcv->fname, "r")) == NULL) {
|
||||
if (!rcv->manual) {
|
||||
fprintf(stderr, "FileError: can't open '%s': %s\n",
|
||||
xbps_error_printf("FileError: can't open '%s': %s\n",
|
||||
rcv->fname, strerror(errno));
|
||||
}
|
||||
return false;
|
||||
@ -174,7 +174,7 @@ rcv_load_file(rcv_t *rcv, const char *fname)
|
||||
if (rcv->buf == NULL) {
|
||||
rcv->bufsz = rcv->len+1;
|
||||
if (!(rcv->buf = calloc(rcv->bufsz, sizeof(char)))) {
|
||||
fprintf(stderr, "MemError: can't allocate memory: %s\n",
|
||||
xbps_error_printf("MemError: can't allocate memory: %s\n",
|
||||
strerror(errno));
|
||||
fclose(file);
|
||||
return false;
|
||||
@ -182,7 +182,7 @@ rcv_load_file(rcv_t *rcv, const char *fname)
|
||||
} else if (rcv->bufsz <= rcv->len) {
|
||||
rcv->bufsz = rcv->len+1;
|
||||
if (!(rcv->buf = realloc(rcv->buf, rcv->bufsz))) {
|
||||
fprintf(stderr, "MemError: can't allocate memory: %s\n",
|
||||
xbps_error_printf("MemError: can't allocate memory: %s\n",
|
||||
strerror(errno));
|
||||
fclose(file);
|
||||
return false;
|
||||
@ -260,7 +260,7 @@ rcv_sh_substitute(rcv_t *rcv, const char *str, size_t len)
|
||||
}
|
||||
if (reflen) {
|
||||
if (reflen >= sizeof buf) {
|
||||
fprintf(stderr, "out of memory\n");
|
||||
xbps_error_printf("out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
strncpy(buf, ref, reflen);
|
||||
@ -283,10 +283,10 @@ rcv_sh_substitute(rcv_t *rcv, const char *str, size_t len)
|
||||
return ret;
|
||||
|
||||
err1:
|
||||
fprintf(stderr, "syntax error: in file '%s'\n", rcv->fname);
|
||||
xbps_error_printf("syntax error: in file '%s'\n", rcv->fname);
|
||||
exit(1);
|
||||
err2:
|
||||
fprintf(stderr,
|
||||
xbps_error_printf(
|
||||
"Shell cmd failed: '%s' for "
|
||||
"template '%s'",
|
||||
cmd, rcv->fname);
|
||||
@ -365,12 +365,11 @@ rcv_get_pkgver(rcv_t *rcv)
|
||||
|
||||
if (!xbps_dictionary_set(rcv->env, key,
|
||||
xbps_string_create_cstring(val))) {
|
||||
fprintf(stderr, "error: xbps_dictionary_set");
|
||||
xbps_error_printf("xbps_dictionary_set failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (rcv->xhp.flags & XBPS_FLAG_DEBUG)
|
||||
fprintf(stderr, "%s: %s %s\n", rcv->fname, key, val);
|
||||
xbps_dbg_printf("%s: %s %s\n", rcv->fname, key, val);
|
||||
|
||||
free(key);
|
||||
free(val);
|
||||
@ -432,7 +431,7 @@ update:
|
||||
if (!xbps_dictionary_get_cstring_nocopy(rcv->env, "pkgname", &pkgname) ||
|
||||
!xbps_dictionary_get_cstring_nocopy(rcv->env, "version", &version) ||
|
||||
!xbps_dictionary_get_cstring_nocopy(rcv->env, "revision", &revision)) {
|
||||
fprintf(stderr, "ERROR: '%s':"
|
||||
xbps_error_printf("'%s':"
|
||||
" missing required variable (pkgname, version or revision)!",
|
||||
fname);
|
||||
exit(1);
|
||||
@ -540,22 +539,22 @@ rcv_check_version(rcv_t *rcv)
|
||||
assert(rcv);
|
||||
|
||||
if ((rcv->have_vars & GOT_PKGNAME_VAR) == 0) {
|
||||
fprintf(stderr, "ERROR: '%s': missing pkgname variable!\n", rcv->fname);
|
||||
xbps_error_printf("'%s': missing pkgname variable!\n", rcv->fname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((rcv->have_vars & GOT_VERSION_VAR) == 0) {
|
||||
fprintf(stderr, "ERROR: '%s': missing version variable!\n", rcv->fname);
|
||||
xbps_error_printf("'%s': missing version variable!\n", rcv->fname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((rcv->have_vars & GOT_REVISION_VAR) == 0) {
|
||||
fprintf(stderr, "ERROR: '%s': missing revision variable!\n", rcv->fname);
|
||||
xbps_error_printf("'%s': missing revision variable!\n", rcv->fname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!xbps_dictionary_get_cstring_nocopy(rcv->env, "pkgname", &pkgname) ||
|
||||
!xbps_dictionary_get_cstring_nocopy(rcv->env, "version", &version) ||
|
||||
!xbps_dictionary_get_cstring_nocopy(rcv->env, "revision", &revision)) {
|
||||
fprintf(stderr, "error:\n");
|
||||
xbps_error_printf("couldn't get pkgname, version, and/or revision\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -646,7 +645,7 @@ rcv_process_dir(rcv_t *rcv, rcv_proc_func process)
|
||||
if ((closedir(dir)) != -1)
|
||||
return ret;
|
||||
error:
|
||||
fprintf(stderr, "Error: while processing dir '%s/srcpkgs': %s\n",
|
||||
xbps_error_printf("while processing dir '%s/srcpkgs': %s\n",
|
||||
rcv->distdir, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
@ -779,7 +778,7 @@ main(int argc, char **argv)
|
||||
char *tmp = rcv.distdir;
|
||||
rcv.distdir = realpath(tmp, NULL);
|
||||
if (rcv.distdir == NULL) {
|
||||
fprintf(stderr, "Error: realpath(%s): %s\n", tmp, strerror(errno));
|
||||
xbps_error_printf("realpath(%s): %s\n", tmp, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
free(tmp);
|
||||
@ -793,7 +792,7 @@ main(int argc, char **argv)
|
||||
rcv_init(&rcv, prog);
|
||||
|
||||
if (chdir(rcv.distdir) == -1 || chdir("srcpkgs") == -1) {
|
||||
fprintf(stderr, "Error: while changing directory to '%s/srcpkgs': %s\n",
|
||||
xbps_error_printf("while changing directory to '%s/srcpkgs': %s\n",
|
||||
rcv.distdir, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (mode && strcmp(mode, "sha256")) {
|
||||
/* sha256 is the only supported mode currently */
|
||||
fprintf(stderr, "%s: unsupported digest mode\n", progname);
|
||||
xbps_error_printf("%s: unsupported digest mode\n", progname);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ main(int argc, char **argv)
|
||||
} else {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (!xbps_file_sha256(sha256, sizeof sha256, argv[i])) {
|
||||
fprintf(stderr,
|
||||
xbps_error_printf(
|
||||
"%s: couldn't get hash for %s (%s)\n",
|
||||
progname, argv[i], strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -371,7 +371,7 @@ runBuilds(const char *bpath)
|
||||
*/
|
||||
item->xcode = -98;
|
||||
fp = fopen(logpath, "a");
|
||||
fprintf(fp, "xbps-fbulk: unable to fork/exec xbps-src\n");
|
||||
xbps_error_printf("xbps-fbulk: unable to fork/exec xbps-src\n");
|
||||
fclose(fp);
|
||||
processCompletion(item);
|
||||
} else {
|
||||
@ -634,7 +634,7 @@ main(int argc, char **argv)
|
||||
|
||||
tmp = xbps_xasprintf("%s/masterdir/.xbps_chroot_init", bpath);
|
||||
if (access(tmp, R_OK) == -1) {
|
||||
fprintf(stderr, "ERROR: %s/masterdir wasn't initialized, "
|
||||
xbps_error_printf("%s/masterdir wasn't initialized, "
|
||||
"run binary-bootstrap first.\n", bpath);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -652,7 +652,7 @@ main(int argc, char **argv)
|
||||
tmp = strdup(LogDir);
|
||||
}
|
||||
if (xbps_mkpath(tmp, 0755) != 0) {
|
||||
fprintf(stderr, "ERROR: failed to create %s logdir: %s\n",
|
||||
xbps_error_printf("failed to create %s logdir: %s\n",
|
||||
tmp, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -664,7 +664,7 @@ main(int argc, char **argv)
|
||||
const char *p = logdirs[i];
|
||||
tmp = xbps_xasprintf("%s/%s", LogDir, p);
|
||||
if (xbps_mkpath(tmp, 0755) != 0) {
|
||||
fprintf(stderr, "ERROR: failed to create %s logdir: %s\n",
|
||||
xbps_error_printf("failed to create %s logdir: %s\n",
|
||||
tmp, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -678,13 +678,13 @@ main(int argc, char **argv)
|
||||
if (RebuildSystem) {
|
||||
rv = xbps_init(&xh);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "ERROR: failed to initialize libxbps: %s", strerror(rv));
|
||||
xbps_error_printf("failed to initialize libxbps: %s", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
array = xbps_array_create();
|
||||
rv = xbps_pkgdb_foreach_cb_multi(&xh, pkgdb_get_pkgs_cb, &array);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "ERROR: xbps_pkgdb_foreach_cb_multi: %s", strerror(rv));
|
||||
xbps_error_printf("xbps_pkgdb_foreach_cb_multi: %s", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
for (unsigned int i = 0; i < xbps_array_count(array); i++) {
|
||||
@ -704,7 +704,7 @@ main(int argc, char **argv)
|
||||
* many packages will be built.
|
||||
*/
|
||||
if (chdir(rpath) == -1) {
|
||||
fprintf(stderr, "ERROR: failed to chdir to %s: %s\n",
|
||||
xbps_error_printf("failed to chdir to %s: %s\n",
|
||||
rpath, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ main(int argc, char **argv)
|
||||
failure = true;
|
||||
continue;
|
||||
} else if (rv == 0) {
|
||||
fprintf(stderr, "%s: file is identical with remote.\n", argv[i]);
|
||||
xbps_warn_printf("%s: %s: file is identical with remote.\n", progname, argv[i]);
|
||||
if (shasum) {
|
||||
if (!xbps_file_sha256_raw(digest, sizeof digest, filename)) {
|
||||
xbps_error_printf("%s: failed to hash: %s: %s\n",
|
||||
|
@ -87,7 +87,7 @@ repo_import_key_cb(struct xbps_repo *repo, void *arg UNUSED, bool *done UNUSED)
|
||||
int rv;
|
||||
|
||||
if ((rv = xbps_repo_key_import(repo)) != 0)
|
||||
fprintf(stderr, "Failed to import pubkey from %s: %s\n",
|
||||
xbps_error_printf("Failed to import pubkey from %s: %s\n",
|
||||
repo->uri, strerror(rv));
|
||||
|
||||
return rv;
|
||||
@ -245,7 +245,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (!(xh.flags & XBPS_FLAG_DOWNLOAD_ONLY) && !drun) {
|
||||
if ((rv = xbps_pkgdb_lock(&xh)) != 0) {
|
||||
fprintf(stderr, "Failed to lock the pkgdb: %s\n", strerror(rv));
|
||||
xbps_error_printf("Failed to lock the pkgdb: %s\n", strerror(rv));
|
||||
exit(rv);
|
||||
}
|
||||
}
|
||||
|
@ -257,22 +257,22 @@ dist_upgrade(struct xbps_handle *xhp, unsigned int cols, bool yes, bool drun)
|
||||
|
||||
rv = xbps_transaction_update_packages(xhp);
|
||||
if (rv == ENOENT) {
|
||||
printf("No packages currently registered.\n");
|
||||
xbps_error_printf("No packages currently registered.\n");
|
||||
return 0;
|
||||
} else if (rv == EBUSY) {
|
||||
if (drun) {
|
||||
rv = 0;
|
||||
} else {
|
||||
printf("The 'xbps' package must be updated, please run `xbps-install -u xbps`\n");
|
||||
xbps_error_printf("The 'xbps' package must be updated, please run `xbps-install -u xbps`\n");
|
||||
return rv;
|
||||
}
|
||||
} else if (rv == EEXIST) {
|
||||
return 0;
|
||||
} else if (rv == ENOTSUP) {
|
||||
fprintf(stderr, "No repositories currently registered!\n");
|
||||
xbps_error_printf("No repositories currently registered!\n");
|
||||
return rv;
|
||||
} else if (rv != 0) {
|
||||
fprintf(stderr, "Unexpected error %s\n", strerror(rv));
|
||||
xbps_error_printf("Unexpected error: %s\n", strerror(rv));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -286,17 +286,17 @@ install_new_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
|
||||
|
||||
rv = xbps_transaction_install_pkg(xhp, pkg, force);
|
||||
if (rv == EEXIST)
|
||||
printf("Package `%s' already installed.\n", pkg);
|
||||
xbps_error_printf("Package `%s' already installed.\n", pkg);
|
||||
else if (rv == ENOENT)
|
||||
fprintf(stderr, "Package '%s' not found in repository pool.\n", pkg);
|
||||
xbps_error_printf("Package '%s' not found in repository pool.\n", pkg);
|
||||
else if (rv == ENOTSUP)
|
||||
fprintf(stderr, "No repositories currently registered!\n");
|
||||
xbps_error_printf("No repositories currently registered!\n");
|
||||
else if (rv == ENXIO)
|
||||
fprintf(stderr, "Package `%s' contains invalid dependencies, exiting.\n", pkg);
|
||||
xbps_error_printf("Package `%s' contains invalid dependencies, exiting.\n", pkg);
|
||||
else if (rv == EBUSY)
|
||||
fprintf(stderr, "The 'xbps' package must be updated, please run `xbps-install -u xbps`\n");
|
||||
xbps_error_printf("The 'xbps' package must be updated, please run `xbps-install -u xbps`\n");
|
||||
else if (rv != 0) {
|
||||
fprintf(stderr, "Unexpected error: %s\n", strerror(rv));
|
||||
xbps_error_printf("Unexpected error: %s\n", strerror(rv));
|
||||
rv = -1;
|
||||
}
|
||||
return rv;
|
||||
@ -311,17 +311,17 @@ update_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
|
||||
if (rv == EEXIST)
|
||||
printf("Package '%s' is up to date.\n", pkg);
|
||||
else if (rv == ENOENT)
|
||||
fprintf(stderr, "Package '%s' not found in repository pool.\n", pkg);
|
||||
xbps_error_printf("Package '%s' not found in repository pool.\n", pkg);
|
||||
else if (rv == ENODEV)
|
||||
fprintf(stderr, "Package '%s' not installed.\n", pkg);
|
||||
xbps_error_printf("Package '%s' not installed.\n", pkg);
|
||||
else if (rv == ENOTSUP)
|
||||
fprintf(stderr, "No repositories currently registered!\n");
|
||||
xbps_error_printf("No repositories currently registered!\n");
|
||||
else if (rv == ENXIO)
|
||||
fprintf(stderr, "Package `%s' contains invalid dependencies, exiting.\n", pkg);
|
||||
xbps_error_printf("Package `%s' contains invalid dependencies, exiting.\n", pkg);
|
||||
else if (rv == EBUSY)
|
||||
fprintf(stderr, "The 'xbps' package must be updated, please run `xbps-install -u xbps`\n");
|
||||
xbps_error_printf("The 'xbps' package must be updated, please run `xbps-install -u xbps`\n");
|
||||
else if (rv != 0) {
|
||||
fprintf(stderr, "Unexpected error: %s\n", strerror(rv));
|
||||
xbps_error_printf("Unexpected error: %s\n", strerror(rv));
|
||||
return -1;
|
||||
}
|
||||
return rv;
|
||||
@ -346,20 +346,20 @@ exec_transaction(struct xbps_handle *xhp, unsigned int maxcols, bool yes, bool d
|
||||
if (xbps_array_count(array)) {
|
||||
/* missing dependencies */
|
||||
print_array(array);
|
||||
fprintf(stderr, "Transaction aborted due to unresolved dependencies.\n");
|
||||
xbps_error_printf("Transaction aborted due to unresolved dependencies.\n");
|
||||
}
|
||||
} else if (rv == ENOEXEC) {
|
||||
array = xbps_dictionary_get(xhp->transd, "missing_shlibs");
|
||||
if (xbps_array_count(array)) {
|
||||
/* missing shlibs */
|
||||
print_array(array);
|
||||
fprintf(stderr, "Transaction aborted due to unresolved shlibs.\n");
|
||||
xbps_error_printf("Transaction aborted due to unresolved shlibs.\n");
|
||||
}
|
||||
} else if (rv == EAGAIN) {
|
||||
/* conflicts */
|
||||
array = xbps_dictionary_get(xhp->transd, "conflicts");
|
||||
print_array(array);
|
||||
fprintf(stderr, "Transaction aborted due to conflicting packages.\n");
|
||||
xbps_error_printf("Transaction aborted due to conflicting packages.\n");
|
||||
} else if (rv == ENOSPC) {
|
||||
/* not enough free space */
|
||||
xbps_dictionary_get_uint64(xhp->transd,
|
||||
@ -378,7 +378,7 @@ exec_transaction(struct xbps_handle *xhp, unsigned int maxcols, bool yes, bool d
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
fprintf(stderr, "Transaction aborted due to insufficient disk "
|
||||
xbps_error_printf("Transaction aborted due to insufficient disk "
|
||||
"space (need %s, got %s free).\n", instsize, freesize);
|
||||
if (drun) {
|
||||
goto proceed;
|
||||
@ -440,7 +440,7 @@ proceed:
|
||||
trans->rm_pkgcnt,
|
||||
trans->hold_pkgcnt);
|
||||
} else {
|
||||
fprintf(stderr, "Transaction failed! see above for errors.\n");
|
||||
xbps_error_printf("Transaction failed! see above for errors.\n");
|
||||
}
|
||||
out:
|
||||
if (trans->iter)
|
||||
|
@ -97,7 +97,7 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
assert(buf);
|
||||
filesd = xbps_plist_dictionary_from_file(buf);
|
||||
if (filesd == NULL) {
|
||||
fprintf(stderr, "%s: cannot read %s, ignoring...\n",
|
||||
xbps_error_printf("%s: cannot read %s, ignoring...\n",
|
||||
pkgname, buf);
|
||||
free(buf);
|
||||
return -1;
|
||||
@ -106,11 +106,11 @@ check_pkg_integrity(struct xbps_handle *xhp,
|
||||
free(buf);
|
||||
if (rv == ENOENT) {
|
||||
xbps_dictionary_remove(opkgd, "metafile-sha256");
|
||||
fprintf(stderr, "%s: unexistent metafile, "
|
||||
xbps_error_printf("%s: unexistent metafile, "
|
||||
"updating pkgdb.\n", pkgname);
|
||||
} else if (rv == ERANGE) {
|
||||
xbps_object_release(filesd);
|
||||
fprintf(stderr, "%s: metadata file has been "
|
||||
xbps_error_printf("%s: metadata file has been "
|
||||
"modified!\n", pkgname);
|
||||
return 1;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if ((rv = xbps_pkgdb_lock(&xh)) != 0) {
|
||||
fprintf(stderr, "failed to lock pkgdb: %s\n", strerror(rv));
|
||||
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (update_format) {
|
||||
@ -163,7 +163,7 @@ main(int argc, char **argv)
|
||||
goto out;
|
||||
} else if (instmode) {
|
||||
if (argc == optind) {
|
||||
fprintf(stderr,
|
||||
xbps_error_printf(
|
||||
"xbps-pkgdb: missing PKGNAME argument\n");
|
||||
xbps_end(&xh);
|
||||
exit(EXIT_FAILURE);
|
||||
@ -171,7 +171,7 @@ main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
rv = change_pkg_mode(&xh, argv[i], instmode);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "xbps-pkgdb: failed to "
|
||||
xbps_error_printf("xbps-pkgdb: failed to "
|
||||
"change to %s mode to %s: %s\n",
|
||||
instmode, argv[i], strerror(rv));
|
||||
xbps_end(&xh);
|
||||
@ -184,7 +184,7 @@ main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
rv = check_pkg_integrity(&xh, NULL, argv[i]);
|
||||
if (rv != 0)
|
||||
fprintf(stderr, "Failed to check "
|
||||
xbps_error_printf("Failed to check "
|
||||
"`%s': %s\n", argv[i], strerror(rv));
|
||||
}
|
||||
}
|
||||
|
@ -247,14 +247,14 @@ search(struct xbps_handle *xhp, bool repo_mode, const char *pat, const char *pro
|
||||
if (repo_mode) {
|
||||
rv = xbps_rpool_foreach(xhp, search_repo_cb, &sd);
|
||||
if (rv != 0 && rv != ENOTSUP) {
|
||||
fprintf(stderr, "Failed to initialize rpool: %s\n",
|
||||
xbps_error_printf("Failed to initialize rpool: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
rv = xbps_pkgdb_foreach_cb(xhp, search_array_cb, &sd);
|
||||
if (rv != 0) {
|
||||
fprintf(stderr, "Failed to initialize pkgdb: %s\n",
|
||||
xbps_error_printf("Failed to initialize pkgdb: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ repo_show_pkg_files(struct xbps_handle *xhp, const char *pkg)
|
||||
pkgd = xbps_rpool_get_pkg_plist(xhp, pkg, "/files.plist");
|
||||
if (pkgd == NULL) {
|
||||
if (errno != ENOTSUP && errno != ENOENT) {
|
||||
fprintf(stderr, "Unexpected error: %s\n", strerror(errno));
|
||||
xbps_error_printf("Unexpected error: %s\n", strerror(errno));
|
||||
}
|
||||
return errno;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!drun && (rv = xbps_pkgdb_lock(&xh)) != 0) {
|
||||
fprintf(stderr, "failed to lock pkgdb: %s\n", strerror(rv));
|
||||
xbps_error_printf("failed to lock pkgdb: %s\n", strerror(rv));
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ main(int argc, char **argv)
|
||||
if ((rv = xbps_transaction_autoremove_pkgs(&xh)) != 0) {
|
||||
xbps_end(&xh);
|
||||
if (rv != ENOENT) {
|
||||
fprintf(stderr, "Failed to queue package "
|
||||
xbps_error_printf("Failed to queue package "
|
||||
"orphans: %s\n", strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -215,14 +215,14 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force
|
||||
|
||||
repodir = dirname(tmprepodir);
|
||||
if (!xbps_repo_lock(xhp, repodir, &rlockfd, &rlockfname)) {
|
||||
fprintf(stderr, "xbps-rindex: cannot lock repository "
|
||||
xbps_error_printf("xbps-rindex: cannot lock repository "
|
||||
"%s: %s\n", repodir, strerror(errno));
|
||||
rv = -1;
|
||||
goto earlyout;
|
||||
}
|
||||
repo = xbps_repo_public_open(xhp, repodir);
|
||||
if (repo == NULL && errno != ENOENT) {
|
||||
fprintf(stderr, "xbps-rindex: cannot open/lock repository "
|
||||
xbps_error_printf("xbps-rindex: cannot open/lock repository "
|
||||
"%s: %s\n", repodir, strerror(errno));
|
||||
rv = -1;
|
||||
goto earlyout;
|
||||
@ -236,7 +236,7 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force
|
||||
}
|
||||
stage = xbps_repo_stage_open(xhp, repodir);
|
||||
if (stage == NULL && errno != ENOENT) {
|
||||
fprintf(stderr, "xbps-rindex: cannot open/lock stage repository "
|
||||
xbps_error_printf("xbps-rindex: cannot open/lock stage repository "
|
||||
"%s: %s\n", repodir, strerror(errno));
|
||||
rv = -1;
|
||||
goto earlyout;
|
||||
@ -262,7 +262,7 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force
|
||||
*/
|
||||
binpkgd = xbps_archive_fetch_plist(pkg, "/props.plist");
|
||||
if (binpkgd == NULL) {
|
||||
fprintf(stderr, "index: failed to read %s metadata for "
|
||||
xbps_error_printf("index: failed to read %s metadata for "
|
||||
"`%s', skipping!\n", XBPS_PKGPROPS, pkg);
|
||||
continue;
|
||||
}
|
||||
@ -377,7 +377,7 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force
|
||||
* Generate repository data files.
|
||||
*/
|
||||
if (!repodata_commit(xhp, repodir, idx, idxmeta, idxstage, compression)) {
|
||||
fprintf(stderr, "%s: failed to write repodata: %s\n",
|
||||
xbps_error_printf("%s: failed to write repodata: %s\n",
|
||||
_XBPS_RINDEX, strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ cleanup_repo(struct xbps_handle *xhp, const char *repodir, struct xbps_repo *rep
|
||||
if (!xbps_dictionary_equals(dest, repo->idx)) {
|
||||
if (!repodata_flush(xhp, repodir, reponame, dest, repo->idxmeta, compression)) {
|
||||
rv = errno;
|
||||
fprintf(stderr, "failed to write repodata: %s\n",
|
||||
xbps_error_printf("failed to write repodata: %s\n",
|
||||
strerror(errno));
|
||||
return rv;
|
||||
}
|
||||
@ -140,7 +140,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir, const bool hashcheck,
|
||||
|
||||
if (!xbps_repo_lock(xhp, repodir, &rlockfd, &rlockfname)) {
|
||||
rv = errno;
|
||||
fprintf(stderr, "%s: cannot lock repository: %s\n",
|
||||
xbps_error_printf("%s: cannot lock repository: %s\n",
|
||||
_XBPS_RINDEX, strerror(rv));
|
||||
return rv;
|
||||
}
|
||||
@ -151,14 +151,14 @@ index_clean(struct xbps_handle *xhp, const char *repodir, const bool hashcheck,
|
||||
xbps_repo_unlock(rlockfd, rlockfname);
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "%s: cannot read repository data: %s\n",
|
||||
xbps_error_printf("%s: cannot read repository data: %s\n",
|
||||
_XBPS_RINDEX, strerror(errno));
|
||||
xbps_repo_unlock(rlockfd, rlockfname);
|
||||
return rv;
|
||||
}
|
||||
stage = xbps_repo_stage_open(xhp, repodir);
|
||||
if (repo->idx == NULL || (stage && stage->idx == NULL)) {
|
||||
fprintf(stderr, "%s: incomplete repository data file!\n", _XBPS_RINDEX);
|
||||
xbps_error_printf("%s: incomplete repository data file!\n", _XBPS_RINDEX);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ main(int argc, char **argv)
|
||||
(rm_mode && (add_mode || clean_mode || sign_mode || sign_pkg_mode)) ||
|
||||
(sign_mode && (add_mode || clean_mode || rm_mode || sign_pkg_mode)) ||
|
||||
(sign_pkg_mode && (add_mode || clean_mode || rm_mode || sign_mode))) {
|
||||
fprintf(stderr, "Only one mode can be specified: add, clean, "
|
||||
xbps_error_printf("Only one mode can be specified: add, clean, "
|
||||
"remove-obsoletes, sign or sign-pkg.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -154,7 +154,7 @@ main(int argc, char **argv)
|
||||
memset(&xh, 0, sizeof(xh));
|
||||
xh.flags = flags;
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
fprintf(stderr, "failed to initialize libxbps: %s\n",
|
||||
xbps_error_printf("failed to initialize libxbps: %s\n",
|
||||
strerror(rv));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ remove_pkg(const char *repodir, const char *file)
|
||||
if (remove(filepath) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
rv = errno;
|
||||
fprintf(stderr, "xbps-rindex: failed to remove "
|
||||
xbps_error_printf("xbps-rindex: failed to remove "
|
||||
"package `%s': %s\n", file, strerror(rv));
|
||||
}
|
||||
}
|
||||
if (remove(sigpath) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
rv = errno;
|
||||
fprintf(stderr, "xbps-rindex: failed to remove "
|
||||
xbps_error_printf("xbps-rindex: failed to remove "
|
||||
"package signature `%s': %s\n", sigpath, strerror(rv));
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
repo = xbps_repo_public_open(xhp, repodir);
|
||||
if (repo == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
fprintf(stderr, "xbps-rindex: cannot read repository data: %s\n",
|
||||
xbps_error_printf("xbps-rindex: cannot read repository data: %s\n",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
@ -129,13 +129,13 @@ remove_obsoletes(struct xbps_handle *xhp, const char *repodir)
|
||||
}
|
||||
stage = xbps_repo_stage_open(xhp, repodir);
|
||||
if (chdir(repodir) == -1) {
|
||||
fprintf(stderr, "xbps-rindex: cannot chdir to %s: %s\n",
|
||||
xbps_error_printf("xbps-rindex: cannot chdir to %s: %s\n",
|
||||
repodir, strerror(errno));
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
if ((dirp = opendir(".")) == NULL) {
|
||||
fprintf(stderr, "xbps-rindex: failed to open %s: %s\n",
|
||||
xbps_error_printf("xbps-rindex: failed to open %s: %s\n",
|
||||
repodir, strerror(errno));
|
||||
rv = errno;
|
||||
goto out;
|
||||
|
@ -73,7 +73,7 @@ pubkey_from_privkey(RSA *rsa)
|
||||
assert(bp);
|
||||
|
||||
if (!PEM_write_bio_RSA_PUBKEY(bp, rsa)) {
|
||||
fprintf(stderr, "error writing public key: %s\n",
|
||||
xbps_error_printf("error writing public key: %s\n",
|
||||
ERR_error_string(ERR_get_error(), NULL));
|
||||
BIO_free(bp);
|
||||
return NULL;
|
||||
@ -130,7 +130,7 @@ load_rsa_key(const char *privkey)
|
||||
defprivkey = strdup(privkey);
|
||||
|
||||
if ((rsa = load_rsa_privkey(defprivkey)) == NULL) {
|
||||
fprintf(stderr, "%s: failed to read the RSA privkey\n", _XBPS_RINDEX);
|
||||
xbps_error_printf("%s: failed to read the RSA privkey\n", _XBPS_RINDEX);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
free(defprivkey);
|
||||
@ -161,7 +161,7 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
|
||||
bool flush_failed = false, flush = false;
|
||||
|
||||
if (signedby == NULL) {
|
||||
fprintf(stderr, "--signedby unset! cannot initialize signed repository\n");
|
||||
xbps_error_printf("--signedby unset! cannot initialize signed repository\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -171,12 +171,12 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
|
||||
repo = xbps_repo_open(xhp, repodir);
|
||||
if (repo == NULL) {
|
||||
rv = errno;
|
||||
fprintf(stderr, "%s: cannot read repository data: %s\n",
|
||||
xbps_error_printf("%s: cannot read repository data: %s\n",
|
||||
_XBPS_RINDEX, strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
if (xbps_dictionary_count(repo->idx) == 0) {
|
||||
fprintf(stderr, "%s: invalid repository, existing!\n", _XBPS_RINDEX);
|
||||
xbps_error_printf("%s: invalid repository, exiting!\n", _XBPS_RINDEX);
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@ -223,14 +223,14 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
|
||||
/* lock repository to write repodata file */
|
||||
if (!xbps_repo_lock(xhp, repodir, &rlockfd, &rlockfname)) {
|
||||
rv = errno;
|
||||
fprintf(stderr, "%s: cannot lock repository: %s\n",
|
||||
xbps_error_printf("%s: cannot lock repository: %s\n",
|
||||
_XBPS_RINDEX, strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
flush_failed = repodata_flush(xhp, repodir, "repodata", repo->idx, meta, compression);
|
||||
xbps_repo_unlock(rlockfd, rlockfname);
|
||||
if (!flush_failed) {
|
||||
fprintf(stderr, "failed to write repodata: %s\n", strerror(errno));
|
||||
xbps_error_printf("failed to write repodata: %s\n", strerror(errno));
|
||||
goto out;
|
||||
}
|
||||
printf("Initialized signed repository (%u package%s)\n",
|
||||
@ -273,7 +273,7 @@ sign_pkg(struct xbps_handle *xhp, const char *binpkg, const char *privkey, bool
|
||||
*/
|
||||
rsa = load_rsa_key(privkey);
|
||||
if (!rsa_sign_file(rsa, binpkg, &sig, &siglen)) {
|
||||
fprintf(stderr, "failed to sign %s: %s\n", binpkg, strerror(errno));
|
||||
xbps_error_printf("failed to sign %s: %s\n", binpkg, strerror(errno));
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@ -286,13 +286,13 @@ sign_pkg(struct xbps_handle *xhp, const char *binpkg, const char *privkey, bool
|
||||
sigfile_fd = creat(sigfile, 0644);
|
||||
|
||||
if (sigfile_fd == -1) {
|
||||
fprintf(stderr, "failed to create %s: %s\n", sigfile, strerror(errno));
|
||||
xbps_error_printf("failed to create %s: %s\n", sigfile, strerror(errno));
|
||||
rv = EINVAL;
|
||||
free(sig);
|
||||
goto out;
|
||||
}
|
||||
if (write(sigfile_fd, sig, siglen) != (ssize_t)siglen) {
|
||||
fprintf(stderr, "failed to write %s: %s\n", sigfile, strerror(errno));
|
||||
xbps_error_printf("failed to write %s: %s\n", sigfile, strerror(errno));
|
||||
rv = EINVAL;
|
||||
free(sig);
|
||||
goto out;
|
||||
|
@ -127,7 +127,7 @@ ftw_cb(const char *fpath, const struct stat *sb)
|
||||
sverrno = errno;
|
||||
}
|
||||
if (sverrno != 0) {
|
||||
fprintf(stderr, "Failed to remove %s: %s\n", fpath, strerror(sverrno));
|
||||
xbps_error_printf("Failed to remove %s: %s\n", fpath, strerror(sverrno));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -189,7 +189,7 @@ cleanup_overlayfs(void)
|
||||
|
||||
/* recursively remove the temporary dir */
|
||||
if (walk_dir(tmpdir, ftw_cb) != 0) {
|
||||
fprintf(stderr, "Failed to remove directory tree %s: %s\n",
|
||||
xbps_error_printf("Failed to remove directory tree %s: %s\n",
|
||||
tmpdir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -361,8 +361,8 @@ main(int argc, char **argv)
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!xbps_file_sha256(sha256, sizeof sha256, argv[i])) {
|
||||
fprintf(stderr,
|
||||
"E: couldn't get hash for %s (%s)\n",
|
||||
xbps_error_printf(
|
||||
"couldn't get hash for %s (%s)\n",
|
||||
argv[i], strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -378,7 +378,7 @@ main(int argc, char **argv)
|
||||
rv = xbps_fetch_file_dest(&xh, argv[i], filename, "v");
|
||||
|
||||
if (rv == -1) {
|
||||
fprintf(stderr, "%s: %s\n", argv[i],
|
||||
xbps_error_printf("%s: %s\n", argv[i],
|
||||
xbps_fetch_error_string());
|
||||
} else if (rv == 0) {
|
||||
printf("%s: file is identical with remote.\n", argv[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user