From de484e936943e2c0c61a9731ea03e99042a7702f Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sat, 24 Dec 2022 13:46:33 +0100 Subject: [PATCH] lib: change xbps_dbg_printf to not require xbps_handle This allows to simplify a lot of code by not having to pass around the xbps handle everywhere just to print some debug information. --- bin/xbps-install/state_cb.c | 3 +- bin/xbps-install/transaction.c | 6 +-- bin/xbps-query/ownedby.c | 2 +- bin/xbps-query/show-info-files.c | 4 +- bin/xbps-remove/clean-cache.c | 4 +- bin/xbps-rindex/index-clean.c | 4 +- include/xbps.h.in | 6 ++- lib/conf.c | 42 +++++++++--------- lib/download.c | 41 +++++++++--------- lib/external/fexec.c | 4 +- lib/initend.c | 27 ++++++------ lib/log.c | 16 +++---- lib/package_alternatives.c | 6 +-- lib/package_config_files.c | 14 +++--- lib/package_configure.c | 10 ++--- lib/package_fulldeptree.c | 6 +-- lib/package_orphans.c | 22 +++++----- lib/package_register.c | 11 +++-- lib/package_remove.c | 8 ++-- lib/package_script.c | 6 +-- lib/package_unpack.c | 16 +++---- lib/pkgdb.c | 30 ++++++------- lib/pkgdb_conversion.c | 12 +++--- lib/plist_find.c | 2 +- lib/proplib_wrapper.c | 4 +- lib/pubkey2fp.c | 6 +-- lib/repo.c | 45 ++++++++----------- lib/rpool.c | 19 ++++---- lib/transaction_check_conflicts.c | 6 +-- lib/transaction_check_replaces.c | 4 +- lib/transaction_check_shlibs.c | 8 ++-- lib/transaction_commit.c | 22 +++++----- lib/transaction_fetch.c | 12 +++--- lib/transaction_files.c | 30 ++++++------- lib/transaction_ops.c | 22 +++++----- lib/transaction_pkg_deps.c | 72 +++++++++++++++---------------- lib/transaction_prepare.c | 20 ++++----- lib/transaction_store.c | 4 +- lib/verifysig.c | 12 +++--- 39 files changed, 288 insertions(+), 300 deletions(-) diff --git a/bin/xbps-install/state_cb.c b/bin/xbps-install/state_cb.c index 495ebb2b..a13ebbaf 100644 --- a/bin/xbps-install/state_cb.c +++ b/bin/xbps-install/state_cb.c @@ -196,8 +196,7 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata UNUSED) if (xscd->desc) printf("%s\n", xscd->desc); else - xbps_dbg_printf(xscd->xhp, - "%s: unknown state %d\n", xscd->arg, xscd->state); + xbps_dbg_printf("%s: unknown state %d\n", xscd->arg, xscd->state); break; } diff --git a/bin/xbps-install/transaction.c b/bin/xbps-install/transaction.c index 16fcdfaf..0dab23f4 100644 --- a/bin/xbps-install/transaction.c +++ b/bin/xbps-install/transaction.c @@ -384,15 +384,15 @@ exec_transaction(struct xbps_handle *xhp, unsigned int maxcols, bool yes, bool d goto proceed; } } else { - xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n", + xbps_dbg_printf("Empty transaction dictionary: %s\n", strerror(errno)); } goto out; } proceed: #ifdef FULL_DEBUG - xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n"); - xbps_dbg_printf_append(xhp, "%s", + xbps_dbg_printf("Dictionary before transaction happens:\n"); + xbps_dbg_printf_append("%s", xbps_dictionary_externalize(xhp->transd)); #endif diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c index 1b95d361..356224ec 100644 --- a/bin/xbps-query/ownedby.c +++ b/bin/xbps-query/ownedby.c @@ -146,7 +146,7 @@ repo_match_cb(struct xbps_handle *xhp, assert(bfile); filesd = xbps_archive_fetch_plist(bfile, "/files.plist"); if (filesd == NULL) { - xbps_dbg_printf(xhp, "%s: couldn't fetch files.plist from %s: %s\n", + xbps_dbg_printf("%s: couldn't fetch files.plist from %s: %s\n", pkgver, bfile, strerror(errno)); return EINVAL; } diff --git a/bin/xbps-query/show-info-files.c b/bin/xbps-query/show-info-files.c index 2acbe922..6f545eda 100644 --- a/bin/xbps-query/show-info-files.c +++ b/bin/xbps-query/show-info-files.c @@ -296,7 +296,7 @@ cat_file(struct xbps_handle *xhp, const char *pkg, const char *file) if (url == NULL) return EINVAL; - xbps_dbg_printf(xhp, "matched pkg at %s\n", url); + xbps_dbg_printf("matched pkg at %s\n", url); rv = xbps_archive_fetch_file_into_fd(url, file, STDOUT_FILENO); free(url); return rv; @@ -317,7 +317,7 @@ repo_cat_file(struct xbps_handle *xhp, const char *pkg, const char *file) if (url == NULL) return EINVAL; - xbps_dbg_printf(xhp, "matched pkg at %s\n", url); + xbps_dbg_printf("matched pkg at %s\n", url); rv = xbps_archive_fetch_file_into_fd(url, file, STDOUT_FILENO); free(url); return rv; diff --git a/bin/xbps-remove/clean-cache.c b/bin/xbps-remove/clean-cache.c index 829078a1..ce62c259 100644 --- a/bin/xbps-remove/clean-cache.c +++ b/bin/xbps-remove/clean-cache.c @@ -88,7 +88,7 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj, } if (strcmp(binpkgarch, xhp->target_arch ? xhp->target_arch : xhp->native_arch) != 0 && strcmp(binpkgarch, "noarch") != 0) { - xbps_dbg_printf(xhp, "%s: ignoring binpkg with unmatched arch\n", binpkg); + xbps_dbg_printf("%s: ignoring binpkg with unmatched arch\n", binpkg); return 0; } @@ -150,7 +150,7 @@ clean_cachedir(struct xbps_handle *xhp, bool drun) if ((ext = strrchr(dp->d_name, '.')) == NULL) continue; if (strcmp(ext, ".xbps")) { - xbps_dbg_printf(xhp, "ignoring unknown file: %s\n", dp->d_name); + xbps_dbg_printf("ignoring unknown file: %s\n", dp->d_name); continue; } xbps_array_add_cstring(array, dp->d_name); diff --git a/bin/xbps-rindex/index-clean.c b/bin/xbps-rindex/index-clean.c index b6c57c95..cbe137eb 100644 --- a/bin/xbps-rindex/index-clean.c +++ b/bin/xbps-rindex/index-clean.c @@ -46,7 +46,7 @@ struct CleanerCbInfo { }; static int -idx_cleaner_cb(struct xbps_handle *xhp, +idx_cleaner_cb(struct xbps_handle *xhp UNUSED, xbps_object_t obj, const char *key UNUSED, void *arg, @@ -59,7 +59,7 @@ idx_cleaner_cb(struct xbps_handle *xhp, xbps_dictionary_get_cstring_nocopy(obj, "architecture", &arch); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); - xbps_dbg_printf(xhp, "%s: checking %s [%s] ...\n", info->repourl, pkgver, arch); + xbps_dbg_printf("%s: checking %s [%s] ...\n", info->repourl, pkgver, arch); filen = xbps_xasprintf("%s/%s.%s.xbps", info->repourl, pkgver, arch); if (access(filen, R_OK) == -1) { diff --git a/include/xbps.h.in b/include/xbps.h.in index fda5ab64..2c2044d2 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -681,8 +681,10 @@ struct xbps_handle { int flags; }; -void xbps_dbg_printf(struct xbps_handle *, const char *, ...) __attribute__ ((format (printf, 2, 3))); -void xbps_dbg_printf_append(struct xbps_handle *, const char *, ...)__attribute__ ((format (printf, 2, 3))); +extern int xbps_debug_level; + +void xbps_dbg_printf(const char *, ...) __attribute__ ((format (printf, 1, 2))); +void xbps_dbg_printf_append(const char *, ...)__attribute__ ((format (printf, 1, 2))); void xbps_error_printf(const char *, ...)__attribute__ ((format (printf, 1, 2))); void xbps_warn_printf(const char *, ...)__attribute__ ((format (printf, 1, 2))); diff --git a/lib/conf.c b/lib/conf.c index 9751e3e4..f9724db8 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -61,7 +61,7 @@ store_virtualpkg(struct xbps_handle *xhp, const char *path, size_t line, char *v */ p = strchr(val, ':'); if (p == NULL || p[1] == '\0') { - xbps_dbg_printf(xhp, "%s: ignoring invalid " + xbps_dbg_printf("%s: ignoring invalid " "virtualpkg option at line %zu\n", path, line); return 0; } @@ -71,7 +71,7 @@ store_virtualpkg(struct xbps_handle *xhp, const char *path, size_t line, char *v return -errno; if (!xbps_dictionary_set_cstring(xhp->vpkgd_conf, val, p)) return -errno; - xbps_dbg_printf(xhp, "%s: added virtualpkg %s for %s\n", path, val, p); + xbps_dbg_printf("%s: added virtualpkg %s for %s\n", path, val, p); return 1; } @@ -95,7 +95,7 @@ store_preserved_file(struct xbps_handle *xhp, const char *file) if (xbps_match_string_in_array(xhp->preserved_files, file)) goto out; xbps_array_add_cstring(xhp->preserved_files, file); - xbps_dbg_printf(xhp, "Added preserved file: %s\n", file); + xbps_dbg_printf("Added preserved file: %s\n", file); goto out; } else if (rv != 0) { goto out; @@ -109,7 +109,7 @@ store_preserved_file(struct xbps_handle *xhp, const char *file) assert(p); xbps_strlcpy(p, globbuf.gl_pathv[i] + strlen(xhp->rootdir), len); xbps_array_add_cstring(xhp->preserved_files, p); - xbps_dbg_printf(xhp, "Added preserved file: %s (expanded from %s)\n", p, file); + xbps_dbg_printf("Added preserved file: %s (expanded from %s)\n", p, file); free(p); } out: @@ -134,7 +134,7 @@ store_ignored_pkg(struct xbps_handle *xhp, const char *pkgname) assert(xhp->ignored_pkgs); } xbps_array_add_cstring(xhp->ignored_pkgs, pkgname); - xbps_dbg_printf(xhp, "Added ignored package: %s\n", pkgname); + xbps_dbg_printf("Added ignored package: %s\n", pkgname); } static void @@ -147,7 +147,7 @@ store_noextract(struct xbps_handle *xhp, const char *value) assert(xhp->noextract); } xbps_array_add_cstring(xhp->noextract, value); - xbps_dbg_printf(xhp, "Added noextract pattern: %s\n", value); + xbps_dbg_printf("Added noextract pattern: %s\n", value); } enum { @@ -288,7 +288,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) return rv; } - xbps_dbg_printf(xhp, "Parsing configuration file: %s\n", path); + xbps_dbg_printf("Parsing configuration file: %s\n", path); while ((rd = getline(&line, &len, fp)) != -1) { char *val = NULL; @@ -310,7 +310,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) switch (parse_option(line, rd, &val, &vallen)) { case KEY_ERROR: - xbps_dbg_printf(xhp, "%s: ignoring invalid option at " + xbps_dbg_printf("%s: ignoring invalid option at " "line %zu\n", path, nlines); continue; case KEY_ROOTDIR: @@ -320,7 +320,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) rv = ENOMEM; break; } - xbps_dbg_printf(xhp, "%s: rootdir set to %s\n", path, val); + xbps_dbg_printf("%s: rootdir set to %s\n", path, val); break; case KEY_CACHEDIR: size = sizeof xhp->cachedir; @@ -329,7 +329,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) rv = ENOMEM; break; } - xbps_dbg_printf(xhp, "%s: cachedir set to %s\n", path, val); + xbps_dbg_printf("%s: cachedir set to %s\n", path, val); break; case KEY_ARCHITECTURE: size = sizeof xhp->native_arch; @@ -338,21 +338,21 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) rv = ENOMEM; break; } - xbps_dbg_printf(xhp, "%s: native architecture set to %s\n", path, + xbps_dbg_printf("%s: native architecture set to %s\n", path, val); break; case KEY_SYSLOG: if (strcasecmp(val, "true") == 0) { xhp->flags &= ~XBPS_FLAG_DISABLE_SYSLOG; - xbps_dbg_printf(xhp, "%s: syslog enabled\n", path); + xbps_dbg_printf("%s: syslog enabled\n", path); } else { xhp->flags |= XBPS_FLAG_DISABLE_SYSLOG; - xbps_dbg_printf(xhp, "%s: syslog disabled\n", path); + xbps_dbg_printf("%s: syslog disabled\n", path); } break; case KEY_REPOSITORY: if (store_repo(xhp, val)) - xbps_dbg_printf(xhp, "%s: added repository %s\n", path, val); + xbps_dbg_printf("%s: added repository %s\n", path, val); break; case KEY_VIRTUALPKG: rv = store_virtualpkg(xhp, path, nlines, val); @@ -368,19 +368,19 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) case KEY_KEEPCONF: if (strcasecmp(val, "true") == 0) { xhp->flags |= XBPS_FLAG_KEEP_CONFIG; - xbps_dbg_printf(xhp, "%s: config preservation enabled\n", path); + xbps_dbg_printf("%s: config preservation enabled\n", path); } else { xhp->flags &= ~XBPS_FLAG_KEEP_CONFIG; - xbps_dbg_printf(xhp, "%s: config preservation disabled\n", path); + xbps_dbg_printf("%s: config preservation disabled\n", path); } break; case KEY_BESTMATCHING: if (strcasecmp(val, "true") == 0) { xhp->flags |= XBPS_FLAG_BESTMATCH; - xbps_dbg_printf(xhp, "%s: pkg best matching enabled\n", path); + xbps_dbg_printf("%s: pkg best matching enabled\n", path); } else { xhp->flags &= ~XBPS_FLAG_BESTMATCH; - xbps_dbg_printf(xhp, "%s: pkg best matching disabled\n", path); + xbps_dbg_printf("%s: pkg best matching disabled\n", path); } break; case KEY_IGNOREPKG: @@ -392,7 +392,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested) case KEY_INCLUDE: /* Avoid double-nested parsing, only allow it once */ if (nested) { - xbps_dbg_printf(xhp, "%s: ignoring nested include\n", path); + xbps_dbg_printf("%s: ignoring nested include\n", path); continue; } dir = strdup(path); @@ -418,12 +418,12 @@ xbps_conf_init(struct xbps_handle *xhp) assert(seen); if (*xhp->confdir) { - xbps_dbg_printf(xhp, "Processing configuration directory: %s\n", xhp->confdir); + xbps_dbg_printf("Processing configuration directory: %s\n", xhp->confdir); if ((rv = parse_files_glob(xhp, seen, xhp->confdir, "*.conf", false))) goto out; } if (*xhp->sysconfdir) { - xbps_dbg_printf(xhp, "Processing system configuration directory: %s\n", xhp->sysconfdir); + xbps_dbg_printf("Processing system configuration directory: %s\n", xhp->sysconfdir); if ((rv = parse_files_glob(xhp, seen, xhp->sysconfdir, "*.conf", false))) goto out; } diff --git a/lib/download.c b/lib/download.c index b3dcc02d..9005efc2 100644 --- a/lib/download.c +++ b/lib/download.c @@ -172,12 +172,12 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char fio = fetchXGet(url, &url_st, fetch_flags); /* debug stuff */ - xbps_dbg_printf(xhp, "st.st_size: %zd\n", (ssize_t)stp->st_size); - xbps_dbg_printf(xhp, "st.st_atime: %s\n", print_time(&stp->st_atime)); - xbps_dbg_printf(xhp, "st.st_mtime: %s\n", print_time(&stp->st_mtime)); - xbps_dbg_printf(xhp, "url_stat.size: %zd\n", (ssize_t)url_st.size); - xbps_dbg_printf(xhp, "url_stat.atime: %s\n", print_time(&url_st.atime)); - xbps_dbg_printf(xhp, "url_stat.mtime: %s\n", print_time(&url_st.mtime)); + xbps_dbg_printf("st.st_size: %zd\n", (ssize_t)stp->st_size); + xbps_dbg_printf("st.st_atime: %s\n", print_time(&stp->st_atime)); + xbps_dbg_printf("st.st_mtime: %s\n", print_time(&stp->st_mtime)); + xbps_dbg_printf("url_stat.size: %zd\n", (ssize_t)url_st.size); + xbps_dbg_printf("url_stat.atime: %s\n", print_time(&url_st.atime)); + xbps_dbg_printf("url_stat.mtime: %s\n", print_time(&url_st.mtime)); if (fio == NULL) { if (fetchLastErrCode == FETCH_UNCHANGED) { @@ -191,7 +191,7 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char goto fetch_file_out; } if (url_st.size == -1) { - xbps_dbg_printf(xhp, "Remote file size is unknown, resume " + xbps_dbg_printf("Remote file size is unknown, resume " "not possible...\n"); restart = false; } else if (stp->st_size > url_st.size) { @@ -199,18 +199,18 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char * Remove local file if bigger than remote, and refetch the * whole shit again. */ - xbps_dbg_printf(xhp, "Local file %s is greater than remote, " + xbps_dbg_printf("Local file %s is greater than remote, " "removing local file and refetching...\n", filename); (void)remove(tempfile); restart = false; } - xbps_dbg_printf(xhp, "url->scheme: %s\n", url->scheme); - xbps_dbg_printf(xhp, "url->host: %s\n", url->host); - xbps_dbg_printf(xhp, "url->port: %d\n", url->port); - xbps_dbg_printf(xhp, "url->doc: %s\n", url->doc); - xbps_dbg_printf(xhp, "url->offset: %zd\n", (ssize_t)url->offset); - xbps_dbg_printf(xhp, "url->length: %zu\n", url->length); - xbps_dbg_printf(xhp, "url->last_modified: %s\n", + xbps_dbg_printf("url->scheme: %s\n", url->scheme); + xbps_dbg_printf("url->host: %s\n", url->host); + xbps_dbg_printf("url->port: %d\n", url->port); + xbps_dbg_printf("url->doc: %s\n", url->doc); + xbps_dbg_printf("url->offset: %zd\n", (ssize_t)url->offset); + xbps_dbg_printf("url->length: %zu\n", url->length); + xbps_dbg_printf("url->last_modified: %s\n", print_time(&url->last_modified)); /* * If restarting, open the file for appending otherwise create it. @@ -235,7 +235,7 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char SHA256_Update(&sha256, buf, bytes_read); } if (bytes_read == -1) { - xbps_dbg_printf(xhp, "IO error while reading %s: %s\n", + xbps_dbg_printf("IO error while reading %s: %s\n", tempfile, strerror(errno)); errno = EIO; rv = -1; @@ -260,8 +260,7 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char SHA256_Update(&sha256, buf, bytes_read); bytes_written = write(fd, buf, (size_t)bytes_read); if (bytes_written != bytes_read) { - xbps_dbg_printf(xhp, - "Couldn't write to %s!\n", tempfile); + xbps_dbg_printf("Couldn't write to %s!\n", tempfile); rv = -1; goto fetch_file_out; } @@ -275,13 +274,13 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char filename, false, true, false); } if (bytes_read == -1) { - xbps_dbg_printf(xhp, "IO error while fetching %s: %s\n", + xbps_dbg_printf("IO error while fetching %s: %s\n", filename, fetchLastErrString); errno = EIO; rv = -1; goto fetch_file_out; } else if (url_st.size > 0 && ((bytes_dload + url->offset) != url_st.size)) { - xbps_dbg_printf(xhp, "file %s is truncated\n", filename); + xbps_dbg_printf("file %s is truncated\n", filename); errno = EIO; rv = -1; goto fetch_file_out; @@ -311,7 +310,7 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char rename_file: /* File downloaded successfully, rename to destfile */ if (rename(tempfile, filename) == -1) { - xbps_dbg_printf(xhp, "failed to rename %s to %s: %s", + xbps_dbg_printf("failed to rename %s to %s: %s", tempfile, filename, strerror(errno)); rv = -1; goto fetch_file_out; diff --git a/lib/external/fexec.c b/lib/external/fexec.c index b15af0cf..11c40120 100644 --- a/lib/external/fexec.c +++ b/lib/external/fexec.c @@ -58,12 +58,12 @@ pfcexec(struct xbps_handle *xhp, const char *file, const char **argv) if (strcmp(xhp->rootdir, "/")) { if ((geteuid() == 0) && (access("bin/sh", X_OK) == 0)) { if (chroot(xhp->rootdir) == -1) { - xbps_dbg_printf(xhp, "%s: chroot() " + xbps_dbg_printf("%s: chroot() " "failed: %s\n", *argv, strerror(errno)); _exit(errno); } if (chdir("/") == -1) { - xbps_dbg_printf(xhp, "%s: chdir() " + xbps_dbg_printf("%s: chdir() " "failed: %s\n", *argv, strerror(errno)); _exit(errno); } diff --git a/lib/initend.c b/lib/initend.c index 9a69ca3b..9ed9c03a 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -48,7 +48,10 @@ xbps_init(struct xbps_handle *xhp) assert(xhp != NULL); - xbps_dbg_printf(xhp, "%s\n", XBPS_RELVER); + if (xhp->flags & XBPS_FLAG_DEBUG) + xbps_debug_level = 1; + + xbps_dbg_printf("%s\n", XBPS_RELVER); /* Set rootdir */ if (xhp->rootdir[0] == '\0') { @@ -151,23 +154,23 @@ xbps_init(struct xbps_handle *xhp) if (xbps_path_clean(xhp->metadir) == -1) return ENOTSUP; - xbps_dbg_printf(xhp, "rootdir=%s\n", xhp->rootdir); - xbps_dbg_printf(xhp, "metadir=%s\n", xhp->metadir); - xbps_dbg_printf(xhp, "cachedir=%s\n", xhp->cachedir); - xbps_dbg_printf(xhp, "confdir=%s\n", xhp->confdir); - xbps_dbg_printf(xhp, "sysconfdir=%s\n", xhp->sysconfdir); - xbps_dbg_printf(xhp, "syslog=%s\n", xhp->flags & XBPS_FLAG_DISABLE_SYSLOG ? "false" : "true"); - xbps_dbg_printf(xhp, "bestmatching=%s\n", xhp->flags & XBPS_FLAG_BESTMATCH ? "true" : "false"); - xbps_dbg_printf(xhp, "keepconf=%s\n", xhp->flags & XBPS_FLAG_KEEP_CONFIG ? "true" : "false"); - xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->native_arch); - xbps_dbg_printf(xhp, "Target Architecture: %s\n", xhp->target_arch ? xhp->target_arch : "(null)"); + xbps_dbg_printf("rootdir=%s\n", xhp->rootdir); + xbps_dbg_printf("metadir=%s\n", xhp->metadir); + xbps_dbg_printf("cachedir=%s\n", xhp->cachedir); + xbps_dbg_printf("confdir=%s\n", xhp->confdir); + xbps_dbg_printf("sysconfdir=%s\n", xhp->sysconfdir); + xbps_dbg_printf("syslog=%s\n", xhp->flags & XBPS_FLAG_DISABLE_SYSLOG ? "false" : "true"); + xbps_dbg_printf("bestmatching=%s\n", xhp->flags & XBPS_FLAG_BESTMATCH ? "true" : "false"); + xbps_dbg_printf("keepconf=%s\n", xhp->flags & XBPS_FLAG_KEEP_CONFIG ? "true" : "false"); + xbps_dbg_printf("Architecture: %s\n", xhp->native_arch); + xbps_dbg_printf("Target Architecture: %s\n", xhp->target_arch ? xhp->target_arch : "(null)"); if (xhp->flags & XBPS_FLAG_DEBUG) { const char *repodir; for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) { if (!xbps_array_get_cstring_nocopy(xhp->repositories, i, &repodir)) return errno; - xbps_dbg_printf(xhp, "Repository[%u]=%s\n", i, repodir); + xbps_dbg_printf("Repository[%u]=%s\n", i, repodir); } } diff --git a/lib/log.c b/lib/log.c index efdabc44..30dde1b8 100644 --- a/lib/log.c +++ b/lib/log.c @@ -34,6 +34,8 @@ #pragma clang diagnostic ignored "-Wformat-nonliteral" #endif +int xbps_debug_level = 0; + /** * @file lib/log.c * @brief Logging functions @@ -52,14 +54,11 @@ common_printf(FILE *f, const char *msg, const char *fmt, va_list ap) } void -xbps_dbg_printf_append(struct xbps_handle *xhp, const char *fmt, ...) +xbps_dbg_printf_append(const char *fmt, ...) { va_list ap; - if (!xhp) - return; - - if ((xhp->flags & XBPS_FLAG_DEBUG) == 0) + if (xbps_debug_level == 0) return; va_start(ap, fmt); @@ -68,14 +67,11 @@ xbps_dbg_printf_append(struct xbps_handle *xhp, const char *fmt, ...) } void -xbps_dbg_printf(struct xbps_handle *xhp, const char *fmt, ...) +xbps_dbg_printf(const char *fmt, ...) { va_list ap; - if (!xhp) - return; - - if ((xhp->flags & XBPS_FLAG_DEBUG) == 0) + if (xbps_debug_level == 0) return; va_start(ap, fmt); diff --git a/lib/package_alternatives.c b/lib/package_alternatives.c index f23b440d..7d3cddb6 100644 --- a/lib/package_alternatives.c +++ b/lib/package_alternatives.c @@ -181,7 +181,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname) dir = xbps_xasprintf("%s/%s", xhp->rootdir, dir); if (strcmp(dir, ".") && xbps_mkpath(dir, 0755) && errno != EEXIST) { rv = errno; - xbps_dbg_printf(xhp, + xbps_dbg_printf( "failed to create target dir '%s' for group '%s': %s\n", dir, grname, strerror(errno)); free(dir); @@ -194,7 +194,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname) dir = dirname(p); if (strcmp(dir, ".") && xbps_mkpath(dir, 0755) && errno != EEXIST) { rv = errno; - xbps_dbg_printf(xhp, + xbps_dbg_printf( "failed to create symlink dir '%s' for group '%s': %s\n", dir, grname, strerror(errno)); free(p); @@ -214,7 +214,7 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname) unlink(linkpath); if ((rv = symlink(target, linkpath)) != 0) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "failed to create alt symlink '%s' for group '%s': %s\n", linkpath, grname, strerror(errno)); goto err; diff --git a/lib/package_config_files.c b/lib/package_config_files.c index 31db6ff0..bc7f7995 100644 --- a/lib/package_config_files.c +++ b/lib/package_config_files.c @@ -87,7 +87,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, * Get original hash for the file from current * installed package. */ - xbps_dbg_printf(xhp, "%s: processing conf_file %s\n", + xbps_dbg_printf("%s: processing conf_file %s\n", pkgver, entry_pname); if (pkg_filesd == NULL || mysymlink) { @@ -98,7 +98,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, */ version = xbps_pkg_version(pkgver); assert(version); - xbps_dbg_printf(xhp, "%s: conf_file %s not currently " + xbps_dbg_printf("%s: conf_file %s not currently " "installed, renaming to %s.new-%s\n", pkgver, entry_pname, entry_pname, version); snprintf(buf, sizeof(buf), "%s.new-%s", entry_pname, version); @@ -126,7 +126,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, * First case: original hash not found, install new file. */ if (sha256_orig == NULL) { - xbps_dbg_printf(xhp, "%s: conf_file %s not installed\n", + xbps_dbg_printf("%s: conf_file %s not installed\n", pkgver, entry_pname); rv = 1; goto out; @@ -146,7 +146,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, /* * File not installed, install new one. */ - xbps_dbg_printf(xhp, "%s: conf_file %s not " + xbps_dbg_printf("%s: conf_file %s not " "installed\n", pkgver, entry_pname); rv = 1; break; @@ -164,7 +164,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, if ((strcmp(sha256_orig, sha256_cur) == 0) && (strcmp(sha256_orig, sha256_new) == 0) && (strcmp(sha256_cur, sha256_new) == 0)) { - xbps_dbg_printf(xhp, "%s: conf_file %s orig = X, " + xbps_dbg_printf("%s: conf_file %s orig = X, " "cur = X, new = X\n", pkgver, entry_pname); rv = 0; break; @@ -209,7 +209,7 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp, } else if ((strcmp(sha256_cur, sha256_new) == 0) && (strcmp(sha256_orig, sha256_new)) && (strcmp(sha256_orig, sha256_cur))) { - xbps_dbg_printf(xhp, "%s: conf_file %s orig = X, " + xbps_dbg_printf("%s: conf_file %s orig = X, " "cur = Y, new = Y\n", pkgver, entry_pname); rv = 0; break; @@ -239,7 +239,7 @@ out: xbps_object_iterator_release(iter); - xbps_dbg_printf(xhp, "%s: conf_file %s returned %d\n", + xbps_dbg_printf("%s: conf_file %s returned %d\n", pkgver, entry_pname, rv); return rv; diff --git a/lib/package_configure.c b/lib/package_configure.c index 23ac9bc2..709ed128 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -66,14 +66,14 @@ xbps_configure_packages(struct xbps_handle *xhp, xbps_array_t ignpkgs) if (xbps_array_count(ignpkgs)) { if ((xbps_match_string_in_array(ignpkgs, pkgver)) || (xbps_match_pkgver_in_array(ignpkgs, pkgver))) { - xbps_dbg_printf(xhp, "%s: ignoring pkg %s\n", + xbps_dbg_printf("%s: ignoring pkg %s\n", __func__, pkgver); continue; } } rv = xbps_configure_pkg(xhp, pkgver, true, false); if (rv != 0) { - xbps_dbg_printf(xhp, "%s: failed to configure %s: %s\n", + xbps_dbg_printf("%s: failed to configure %s: %s\n", __func__, pkgver, strerror(rv)); break; } @@ -106,15 +106,15 @@ xbps_configure_pkg(struct xbps_handle *xhp, pkgd = xbps_pkgdb_get_pkg(xhp, p); if (pkgd == NULL) { - xbps_dbg_printf(xhp, "[configure] cannot find %s (%s) " + xbps_dbg_printf("[configure] cannot find %s (%s) " "in pkgdb\n", p, pkgver); return ENOENT; } rv = xbps_pkg_state_dictionary(pkgd, &state); - xbps_dbg_printf(xhp, "%s: state %d rv %d\n", pkgver, state, rv); + xbps_dbg_printf("%s: state %d rv %d\n", pkgver, state, rv); if (rv != 0) { - xbps_dbg_printf(xhp, "%s: [configure] failed to get " + xbps_dbg_printf("%s: [configure] failed to get " "pkg state: %s\n", pkgver, strerror(rv)); return EINVAL; } diff --git a/lib/package_fulldeptree.c b/lib/package_fulldeptree.c index bb8fac4c..869fbd16 100644 --- a/lib/package_fulldeptree.c +++ b/lib/package_fulldeptree.c @@ -183,7 +183,7 @@ ordered_depends(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool, } if (curpkgd == NULL) { /* package depends on missing dependencies */ - xbps_dbg_printf(xhp, "%s: missing dependency '%s'\n", pkgver, curdep); + xbps_dbg_printf("%s: missing dependency '%s'\n", pkgver, curdep); errno = ENODEV; return NULL; } @@ -193,7 +193,7 @@ ordered_depends(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool, } if (provides && xbps_match_pkgname_in_array(provides, curdepname)) { - xbps_dbg_printf(xhp, "%s: ignoring dependency %s " + xbps_dbg_printf("%s: ignoring dependency %s " "already in provides\n", pkgver, curdep); continue; } @@ -205,7 +205,7 @@ ordered_depends(struct xbps_handle *xhp, xbps_dictionary_t pkgd, bool rpool, xitem = ordered_depends(xhp, curpkgd, rpool, depth+1); if (xitem == NULL) { /* package depends on missing dependencies */ - xbps_dbg_printf(xhp, "%s: missing dependency '%s'\n", pkgver, curdep); + xbps_dbg_printf("%s: missing dependency '%s'\n", pkgver, curdep); errno = ENODEV; return NULL; } diff --git a/lib/package_orphans.c b/lib/package_orphans.c index a8f5502d..49632d5b 100644 --- a/lib/package_orphans.c +++ b/lib/package_orphans.c @@ -93,14 +93,14 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) /* _XBPS_ALTERNATIVES_ */ continue; } - xbps_dbg_printf(xhp, " %s checking %s\n", __func__, pkgver); + xbps_dbg_printf(" %s checking %s\n", __func__, pkgver); xbps_dictionary_get_bool(pkgd, "automatic-install", &automatic); if (!automatic) { - xbps_dbg_printf(xhp, " %s skipped (!automatic)\n", pkgver); + xbps_dbg_printf(" %s skipped (!automatic)\n", pkgver); continue; } if (xbps_find_pkg_in_array(array, pkgver, 0)) { - xbps_dbg_printf(xhp, " %s orphan (queued)\n", pkgver); + xbps_dbg_printf(" %s orphan (queued)\n", pkgver); continue; } revdeps = xbps_pkgdb_get_pkg_revdeps(xhp, pkgver); @@ -109,7 +109,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) if (revdepscnt == 0) { added = true; xbps_array_add(array, pkgd); - xbps_dbg_printf(xhp, " %s orphan (automatic and !revdeps)\n", pkgver); + xbps_dbg_printf(" %s orphan (automatic and !revdeps)\n", pkgver); continue; } /* verify all revdeps are seen */ @@ -123,11 +123,11 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) if (cnt == revdepscnt) { added = true; xbps_array_add(array, pkgd); - xbps_dbg_printf(xhp, " %s orphan (automatic and all revdeps)\n", pkgver); + xbps_dbg_printf(" %s orphan (automatic and all revdeps)\n", pkgver); } } - xbps_dbg_printf(xhp, "orphans pkgdb iter: added %s\n", added ? "true" : "false"); + xbps_dbg_printf("orphans pkgdb iter: added %s\n", added ? "true" : "false"); xbps_object_iterator_reset(iter); if (!added) break; @@ -164,7 +164,7 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) continue; } - xbps_dbg_printf(xhp, " processing rdeps for %s\n", pkgver); + xbps_dbg_printf(" processing rdeps for %s\n", pkgver); for (unsigned int x = 0; x < xbps_array_count(rdeps); x++) { xbps_array_t reqby; xbps_dictionary_t deppkgd; @@ -174,13 +174,13 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) cnt = 0; xbps_array_get_cstring_nocopy(rdeps, x, &deppkgver); if (xbps_find_pkg_in_array(array, deppkgver, 0)) { - xbps_dbg_printf(xhp, " rdep %s already queued\n", deppkgver); + xbps_dbg_printf(" rdep %s already queued\n", deppkgver); continue; } deppkgd = xbps_pkgdb_get_pkg(xhp, deppkgver); xbps_dictionary_get_bool(deppkgd, "automatic-install", &automatic); if (!automatic) { - xbps_dbg_printf(xhp, " rdep %s skipped (!automatic)\n", deppkgver); + xbps_dbg_printf(" rdep %s skipped (!automatic)\n", deppkgver); continue; } @@ -190,13 +190,13 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) const char *reqbydep = NULL; xbps_array_get_cstring_nocopy(reqby, j, &reqbydep); - xbps_dbg_printf(xhp, " %s processing revdep %s\n", pkgver, reqbydep); + xbps_dbg_printf(" %s processing revdep %s\n", pkgver, reqbydep); if (xbps_find_pkg_in_array(array, reqbydep, 0)) cnt++; } if (cnt == reqbycnt) { xbps_array_add(array, deppkgd); - xbps_dbg_printf(xhp, " added %s orphan\n", deppkgver); + xbps_dbg_printf(" added %s orphan\n", deppkgver); } } } diff --git a/lib/package_register.c b/lib/package_register.c index f2e0c874..805856e8 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -60,7 +60,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) * preserve its value. */ if (autoinst && !xbps_dictionary_set_bool(pkgd, "automatic-install", true)) { - xbps_dbg_printf(xhp, "%s: invalid autoinst for %s\n", __func__, pkgver); + xbps_dbg_printf("%s: invalid autoinst for %s\n", __func__, pkgver); rv = EINVAL; goto out; } @@ -77,19 +77,19 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) */ t = time(NULL); if ((tmp = localtime_r(&t, &tm)) == NULL) { - xbps_dbg_printf(xhp, "%s: localtime_r failed: %s\n", + xbps_dbg_printf("%s: localtime_r failed: %s\n", pkgver, strerror(errno)); rv = EINVAL; goto out; } if (strftime(outstr, sizeof(outstr)-1, "%F %R %Z", tmp) == 0) { - xbps_dbg_printf(xhp, "%s: strftime failed: %s\n", + xbps_dbg_printf("%s: strftime failed: %s\n", pkgver, strerror(errno)); rv = EINVAL; goto out; } if (!xbps_dictionary_set_cstring(pkgd, "install-date", outstr)) { - xbps_dbg_printf(xhp, "%s: install-date set failed!\n", pkgver); + xbps_dbg_printf("%s: install-date set failed!\n", pkgver); rv = EINVAL; goto out; } @@ -123,8 +123,7 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd) xbps_dictionary_remove(pkgd, "version"); if (!xbps_dictionary_set(xhp->pkgdb, pkgname, pkgd)) { - xbps_dbg_printf(xhp, - "%s: failed to set pkgd for %s\n", __func__, pkgver); + xbps_dbg_printf("%s: failed to set pkgd for %s\n", __func__, pkgver); } out: xbps_object_release(pkgd); diff --git a/lib/package_remove.c b/lib/package_remove.c index 276b2efe..686a844f 100644 --- a/lib/package_remove.c +++ b/lib/package_remove.c @@ -128,16 +128,16 @@ xbps_remove_pkg(struct xbps_handle *xhp, const char *pkgver, bool update) if ((pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) { rv = errno; - xbps_dbg_printf(xhp, "[remove] cannot find %s in pkgdb: %s\n", + xbps_dbg_printf("[remove] cannot find %s in pkgdb: %s\n", pkgver, strerror(rv)); goto out; } if ((rv = xbps_pkg_state_dictionary(pkgd, &state)) != 0) { - xbps_dbg_printf(xhp, "[remove] cannot find %s in pkgdb: %s\n", + xbps_dbg_printf("[remove] cannot find %s in pkgdb: %s\n", pkgver, strerror(rv)); goto out; } - xbps_dbg_printf(xhp, "attempting to remove %s state %d\n", pkgver, state); + xbps_dbg_printf("attempting to remove %s state %d\n", pkgver, state); if (!update) xbps_set_cb_state(xhp, XBPS_STATE_REMOVE, 0, pkgver, NULL); @@ -223,7 +223,7 @@ purge: /* * Unregister package from pkgdb. */ - xbps_dbg_printf(xhp, "[remove] unregister %s returned %d\n", pkgver, rv); + xbps_dbg_printf("[remove] unregister %s returned %d\n", pkgver, rv); xbps_set_cb_state(xhp, XBPS_STATE_REMOVE_DONE, 0, pkgver, NULL); xbps_dictionary_remove(xhp->pkgdb, pkgname); out: diff --git a/lib/package_script.c b/lib/package_script.c index 3082aadf..f34ba32f 100644 --- a/lib/package_script.c +++ b/lib/package_script.c @@ -57,7 +57,7 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp, assert(action); if (xhp->target_arch) { - xbps_dbg_printf(xhp, "%s: not executing %s " + xbps_dbg_printf("%s: not executing %s " "install/remove action.\n", pkgver, action); return 0; } @@ -81,7 +81,7 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp, /* Create temp file to run script */ if ((fd = mkstemp(fpath)) == -1) { rv = errno; - xbps_dbg_printf(xhp, "%s: mkstemp %s\n", + xbps_dbg_printf("%s: mkstemp %s\n", __func__, strerror(errno)); goto out; } @@ -89,7 +89,7 @@ xbps_pkg_exec_buffer(struct xbps_handle *xhp, ret = write(fd, blob, blobsiz); if (ret == -1) { rv = errno; - xbps_dbg_printf(xhp, "%s: write %s\n", + xbps_dbg_printf("%s: write %s\n", __func__, strerror(errno)); close(fd); goto out; diff --git a/lib/package_unpack.c b/lib/package_unpack.c index 83a633d9..1d446a8f 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -249,7 +249,7 @@ unpack_archive(struct xbps_handle *xhp, * Skip files that match noextract patterns from configuration file. */ if (xhp->noextract && xbps_patterns_match(xhp->noextract, entry_pname+1)) { - xbps_dbg_printf(xhp, "[unpack] %s skipped (matched by a pattern)\n", entry_pname+1); + xbps_dbg_printf("[unpack] %s skipped (matched by a pattern)\n", entry_pname+1); xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FILE_PRESERVED, 0, pkgver, "%s: file `%s' won't be extracted, " "it matches a noextract pattern.", pkgver, entry_pname); @@ -270,7 +270,7 @@ unpack_archive(struct xbps_handle *xhp, */ if (file_exists && match_preserved_file(xhp, entry_pname)) { archive_read_data_skip(ar); - xbps_dbg_printf(xhp, "[unpack] `%s' exists on disk " + xbps_dbg_printf("[unpack] `%s' exists on disk " "and must be preserved, skipping.\n", entry_pname); xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FILE_PRESERVED, 0, pkgver, "%s: file `%s' won't be extracted, " @@ -327,7 +327,7 @@ unpack_archive(struct xbps_handle *xhp, xhp, binpkg_filesd, "files", buf); if (rv == -1) { /* error */ - xbps_dbg_printf(xhp, + xbps_dbg_printf( "%s: failed to check" " hash for `%s': %s\n", pkgver, entry_pname, @@ -337,7 +337,7 @@ unpack_archive(struct xbps_handle *xhp, /* * hash match, skip extraction. */ - xbps_dbg_printf(xhp, + xbps_dbg_printf( "%s: file %s " "matches existing SHA256, " "skipping...\n", @@ -358,14 +358,14 @@ unpack_archive(struct xbps_handle *xhp, if (lchown(entry_pname, archive_entry_uid(entry), archive_entry_gid(entry)) != 0) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "%s: failed " "to set uid/gid to %"PRIu64":%"PRIu64" (%s)\n", pkgver, archive_entry_uid(entry), archive_entry_gid(entry), strerror(errno)); } else { - xbps_dbg_printf(xhp, "%s: entry %s changed " + xbps_dbg_printf("%s: entry %s changed " "uid/gid to %"PRIu64":%"PRIu64".\n", pkgver, entry_pname, archive_entry_uid(entry), archive_entry_gid(entry)); @@ -379,7 +379,7 @@ unpack_archive(struct xbps_handle *xhp, (archive_entry_mode(entry) != st.st_mode)) { if (chmod(entry_pname, archive_entry_mode(entry)) != 0) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "%s: failed " "to set perms %s to %s: %s\n", pkgver, archive_entry_strmode(entry), @@ -388,7 +388,7 @@ unpack_archive(struct xbps_handle *xhp, rv = EINVAL; goto out; } - xbps_dbg_printf(xhp, "%s: entry %s changed file " + xbps_dbg_printf("%s: entry %s changed file " "mode to %s.\n", pkgver, entry_pname, archive_entry_strmode(entry)); } diff --git a/lib/pkgdb.c b/lib/pkgdb.c index 145675c8..4595a4fc 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -82,7 +82,7 @@ xbps_pkgdb_lock(struct xbps_handle *xhp) } if (xbps_mkpath(xhp->metadir, 0755) == -1) { rv = errno; - xbps_dbg_printf(xhp, "[pkgdb] failed to create metadir " + xbps_dbg_printf("[pkgdb] failed to create metadir " "%s: %s\n", xhp->metadir, strerror(rv)); goto ret; } @@ -91,7 +91,7 @@ xbps_pkgdb_lock(struct xbps_handle *xhp) xhp->pkgdb = xbps_dictionary_create(); if (!xbps_dictionary_externalize_to_file(xhp->pkgdb, xhp->pkgdb_plist)) { rv = errno; - xbps_dbg_printf(xhp, "[pkgdb] failed to create pkgdb " + xbps_dbg_printf("[pkgdb] failed to create pkgdb " "%s: %s\n", xhp->pkgdb_plist, strerror(rv)); goto ret; } @@ -99,7 +99,7 @@ xbps_pkgdb_lock(struct xbps_handle *xhp) if ((pkgdb_fd = open(xhp->pkgdb_plist, O_CREAT|O_RDWR|O_CLOEXEC, 0664)) == -1) { rv = errno; - xbps_dbg_printf(xhp, "[pkgdb] cannot open pkgdb for locking " + xbps_dbg_printf("[pkgdb] cannot open pkgdb for locking " "%s: %s\n", xhp->pkgdb_plist, strerror(rv)); free(xhp->pkgdb_plist); goto ret; @@ -110,14 +110,14 @@ xbps_pkgdb_lock(struct xbps_handle *xhp) */ if (lockf(pkgdb_fd, F_TLOCK, 0) == -1) { rv = errno; - xbps_dbg_printf(xhp, "[pkgdb] cannot lock pkgdb: %s\n", strerror(rv)); + xbps_dbg_printf("[pkgdb] cannot lock pkgdb: %s\n", strerror(rv)); } /* * Check if rootdir is writable. */ if (access(xhp->rootdir, W_OK) == -1) { rv = errno; - xbps_dbg_printf(xhp, "[pkgdb] rootdir %s: %s\n", xhp->rootdir, strerror(rv)); + xbps_dbg_printf("[pkgdb] rootdir %s: %s\n", xhp->rootdir, strerror(rv)); } ret: @@ -126,13 +126,13 @@ ret: } void -xbps_pkgdb_unlock(struct xbps_handle *xhp) +xbps_pkgdb_unlock(struct xbps_handle *xhp UNUSED) { - xbps_dbg_printf(xhp, "%s: pkgdb_fd %d\n", __func__, pkgdb_fd); + xbps_dbg_printf("%s: pkgdb_fd %d\n", __func__, pkgdb_fd); if (pkgdb_fd != -1) { if (lockf(pkgdb_fd, F_ULOCK, 0) == -1) - xbps_dbg_printf(xhp, "[pkgdb] failed to unlock pkgdb: %s\n", strerror(errno)); + xbps_dbg_printf("[pkgdb] failed to unlock pkgdb: %s\n", strerror(errno)); (void)close(pkgdb_fd); pkgdb_fd = -1; @@ -182,12 +182,12 @@ pkgdb_map_vpkgs(struct xbps_handle *xhp) xbps_array_get_cstring_nocopy(provides, i, &vpkg); if (!xbps_dictionary_set_cstring(xhp->vpkgd, vpkg, pkgname)) { - xbps_dbg_printf(xhp, "%s: set_cstring vpkg " + xbps_dbg_printf("%s: set_cstring vpkg " "%s pkgname %s\n", __func__, vpkg, pkgname); rv = EINVAL; goto out; } - xbps_dbg_printf(xhp, "[pkgdb] added vpkg %s for %s\n", vpkg, pkgname); + xbps_dbg_printf("[pkgdb] added vpkg %s for %s\n", vpkg, pkgname); } } out: @@ -258,21 +258,21 @@ xbps_pkgdb_init(struct xbps_handle *xhp) if ((rv = xbps_pkgdb_update(xhp, false, true)) != 0) { if (rv != ENOENT) - xbps_dbg_printf(xhp, "[pkgdb] cannot internalize " + xbps_dbg_printf("[pkgdb] cannot internalize " "pkgdb dictionary: %s\n", strerror(rv)); return rv; } if ((rv = pkgdb_map_names(xhp)) != 0) { - xbps_dbg_printf(xhp, "[pkgdb] pkgdb_map_names %s\n", strerror(rv)); + xbps_dbg_printf("[pkgdb] pkgdb_map_names %s\n", strerror(rv)); return rv; } if ((rv = pkgdb_map_vpkgs(xhp)) != 0) { - xbps_dbg_printf(xhp, "[pkgdb] pkgdb_map_vpkgs %s\n", strerror(rv)); + xbps_dbg_printf("[pkgdb] pkgdb_map_vpkgs %s\n", strerror(rv)); return rv; } assert(xhp->pkgdb); - xbps_dbg_printf(xhp, "[pkgdb] initialized ok.\n"); + xbps_dbg_printf("[pkgdb] initialized ok.\n"); return 0; } @@ -335,7 +335,7 @@ xbps_pkgdb_release(struct xbps_handle *xhp) xbps_pkgdb_unlock(xhp); if (xhp->pkgdb) xbps_object_release(xhp->pkgdb); - xbps_dbg_printf(xhp, "[pkgdb] released ok.\n"); + xbps_dbg_printf("[pkgdb] released ok.\n"); } int diff --git a/lib/pkgdb_conversion.c b/lib/pkgdb_conversion.c index c698d3db..c9be47d6 100644 --- a/lib/pkgdb_conversion.c +++ b/lib/pkgdb_conversion.c @@ -84,7 +84,7 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist) * Copy old pkgdb objects to the new pkgdb. */ if (!xbps_dictionary_set(pkgdb, pkgname, pkgd)) { - xbps_dbg_printf(xhp, "%s: failed to copy %s pkgd " + xbps_dbg_printf("%s: failed to copy %s pkgd " "for pkgdb conversion\n", __func__, pkgname); rv = EINVAL; goto out; @@ -96,7 +96,7 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist) pkgmetad = xbps_plist_dictionary_from_file(xhp, pkgmeta); if (pkgmetad == NULL) { rv = EINVAL; - xbps_dbg_printf(xhp, "%s: cannot open %s: %s\n", + xbps_dbg_printf("%s: cannot open %s: %s\n", __func__, pkgmeta, strerror(errno)); goto out; } @@ -129,7 +129,7 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist) continue; } if (!xbps_dictionary_set(pkgd, key, curobj)) { - xbps_dbg_printf(xhp, "%s: failed to copy %s " + xbps_dbg_printf("%s: failed to copy %s " "pkgd for pkgdb conversion\n", pkgname, key); xbps_object_iterator_release(iter2); xbps_object_release(pkgmetad); @@ -147,12 +147,12 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist) pkgfiles = xbps_xasprintf("%s/.%s-files.plist", xhp->metadir, pkgname); if (!xbps_dictionary_externalize_to_file(pkgfilesd, pkgfiles)) { - xbps_dbg_printf(xhp, "%s: failed to " + xbps_dbg_printf("%s: failed to " "externalize %s: %s\n", __func__, pkgfiles, strerror(errno)); rv = EINVAL; goto out; } - xbps_dbg_printf(xhp, "%s: externalized %s successfully\n", __func__, pkgfiles); + xbps_dbg_printf("%s: externalized %s successfully\n", __func__, pkgfiles); /* * Update SHA56 hash for the pkg files plist. */ @@ -173,7 +173,7 @@ pkgdb038(struct xbps_handle *xhp, const char *opkgdb_plist) * Externalize the new pkgdb plist. */ if (!xbps_dictionary_externalize_to_file(pkgdb, xhp->pkgdb_plist)) { - xbps_dbg_printf(xhp, "%s: failed to externalize %s: " + xbps_dbg_printf("%s: failed to externalize %s: " "%s!\n", __func__, xhp->pkgdb_plist, strerror(errno)); rv = EINVAL; goto out; diff --git a/lib/plist_find.c b/lib/plist_find.c index 36c54a77..4d51d1c0 100644 --- a/lib/plist_find.c +++ b/lib/plist_find.c @@ -262,7 +262,7 @@ vpkg_user_conf(struct xbps_handle *xhp, const char *vpkg, bool only_conf) continue; } } - xbps_dbg_printf(xhp, "%s: vpkg_conf %s pkg %s vpkgname %s\n", __func__, vpkg_conf, pkg, vpkgname); + xbps_dbg_printf("%s: vpkg_conf %s pkg %s vpkgname %s\n", __func__, vpkg_conf, pkg, vpkgname); free(vpkgname); found = true; break; diff --git a/lib/proplib_wrapper.c b/lib/proplib_wrapper.c index 9c6900bd..09a279ce 100644 --- a/lib/proplib_wrapper.c +++ b/lib/proplib_wrapper.c @@ -940,7 +940,7 @@ xbps_plist_array_from_file(struct xbps_handle *xhp, const char *f) a = xbps_array_internalize_from_zfile(f); if (xbps_object_type(a) != XBPS_TYPE_ARRAY) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "xbps: failed to internalize array from %s\n", f); } return a; @@ -953,7 +953,7 @@ xbps_plist_dictionary_from_file(struct xbps_handle *xhp, const char *f) d = xbps_dictionary_internalize_from_zfile(f); if (xbps_object_type(d) != XBPS_TYPE_DICTIONARY) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "xbps: failed to internalize dict from %s\n", f); } return d; diff --git a/lib/pubkey2fp.c b/lib/pubkey2fp.c index 2efe83cf..2ef6f092 100644 --- a/lib/pubkey2fp.c +++ b/lib/pubkey2fp.c @@ -88,20 +88,20 @@ xbps_pubkey2fp(struct xbps_handle *xhp, xbps_data_t pubkey) pPubKey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL); if (!pPubKey) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "unable to decode public key from the given file: %s\n", ERR_error_string(ERR_get_error(), NULL)); goto out; } if (EVP_PKEY_base_id(pPubKey) != EVP_PKEY_RSA) { - xbps_dbg_printf(xhp, "only RSA public keys are currently supported\n"); + xbps_dbg_printf("only RSA public keys are currently supported\n"); goto out; } pRsa = EVP_PKEY_get1_RSA(pPubKey); if (!pRsa) { - xbps_dbg_printf(xhp, "failed to get RSA public key : %s\n", + xbps_dbg_printf("failed to get RSA public key : %s\n", ERR_error_string(ERR_get_error(), NULL)); goto out; } diff --git a/lib/repo.c b/lib/repo.c index ea79fb90..0c37b118 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -72,8 +72,7 @@ repo_get_dict(struct xbps_repo *repo) rv = archive_read_next_header(repo->ar, &entry); if (rv != ARCHIVE_OK) { - xbps_dbg_printf(repo->xhp, - "%s: read_next_header %s\n", repo->uri, + xbps_dbg_printf("%s: read_next_header %s\n", repo->uri, archive_error_string(repo->ar)); return NULL; } @@ -103,12 +102,12 @@ xbps_repo_lock(struct xbps_handle *xhp, const char *repodir, if (fd != -1) break; if (rv != EEXIST) { - xbps_dbg_printf(xhp, "[repo] `%s' failed to " + xbps_dbg_printf("[repo] `%s' failed to " "create lock file %s\n", lockfile, strerror(rv)); free(lockfile); return false; } else { - xbps_dbg_printf(xhp, "[repo] `%s' lock file exists," + xbps_dbg_printf("[repo] `%s' lock file exists," "waiting for 1s...\n", lockfile); sleep(1); } @@ -136,7 +135,7 @@ repo_open_local(struct xbps_repo *repo, const char *repofile) struct stat st; if (fstat(repo->fd, &st) == -1) { - xbps_dbg_printf(repo->xhp, "[repo] `%s' fstat repodata %s\n", + xbps_dbg_printf("[repo] `%s' fstat repodata %s\n", repofile, strerror(errno)); return false; } @@ -151,13 +150,12 @@ repo_open_local(struct xbps_repo *repo, const char *repofile) archive_read_support_format_tar(repo->ar); if (archive_read_open_fd(repo->ar, repo->fd, st.st_blksize) == ARCHIVE_FATAL) { - xbps_dbg_printf(repo->xhp, - "[repo] `%s' failed to open repodata archive %s\n", + xbps_dbg_printf("[repo] `%s' failed to open repodata archive %s\n", repofile, archive_error_string(repo->ar)); return false; } if ((repo->idx = repo_get_dict(repo)) == NULL) { - xbps_dbg_printf(repo->xhp, "[repo] `%s' failed to internalize " + xbps_dbg_printf("[repo] `%s' failed to internalize " " index on archive, removing file.\n", repofile); /* broken archive, remove it */ (void)unlink(repofile); @@ -188,7 +186,7 @@ repo_open_remote(struct xbps_repo *repo) rv = xbps_repo_fetch_remote(repo, rpath); free(rpath); if (rv) { - xbps_dbg_printf(repo->xhp, "[repo] `%s' used remotely (kept in memory).\n", repo->uri); + xbps_dbg_printf("[repo] `%s' used remotely (kept in memory).\n", repo->uri); if (repo->xhp->state_cb && xbps_repo_key_import(repo) != 0) rv = false; } @@ -246,7 +244,7 @@ repo_open_with_type(struct xbps_handle *xhp, const char *url, const char *name) repo->fd = open(repofile, O_RDONLY|O_CLOEXEC); if (repo->fd == -1) { int rv = errno; - xbps_dbg_printf(xhp, "[repo] `%s' open %s %s\n", + xbps_dbg_printf("[repo] `%s' open %s %s\n", repofile, name, strerror(rv)); goto out; } @@ -279,17 +277,17 @@ xbps_repo_store(struct xbps_handle *xhp, const char *repo) if (!xbps_repository_is_remote(repo)) { if (repo[0] != '/' && repo[0] != '\0') { if ((url = realpath(repo, NULL)) == NULL) - xbps_dbg_printf(xhp, "[repo] %s: realpath %s\n", __func__, repo); + xbps_dbg_printf("[repo] %s: realpath %s\n", __func__, repo); } } if (xbps_match_string_in_array(xhp->repositories, url ? url : repo)) { - xbps_dbg_printf(xhp, "[repo] `%s' already stored\n", url ? url : repo); + xbps_dbg_printf("[repo] `%s' already stored\n", url ? url : repo); if (url) free(url); return false; } if (xbps_array_add_cstring(xhp->repositories, url ? url : repo)) { - xbps_dbg_printf(xhp, "[repo] `%s' stored successfully\n", url ? url : repo); + xbps_dbg_printf("[repo] `%s' stored successfully\n", url ? url : repo); if (url) free(url); return true; @@ -315,7 +313,7 @@ xbps_repo_remove(struct xbps_handle *xhp, const char *repo) url = strdup(repo); if (xbps_remove_string_from_array(xhp->repositories, repo)) { if (url) - xbps_dbg_printf(xhp, "[repo] `%s' removed\n", url); + xbps_dbg_printf("[repo] `%s' removed\n", url); rv = true; } free(url); @@ -430,7 +428,7 @@ xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg) if (!xbps_dictionary_set_cstring(pkgd, "pkgname", pkgname)) { return NULL; } - xbps_dbg_printf(repo->xhp, "%s: found %s\n", __func__, pkgver); + xbps_dbg_printf("%s: found %s\n", __func__, pkgver); return pkgd; } @@ -470,7 +468,7 @@ add: if (!xbps_dictionary_set_cstring(pkgd, "pkgname", pkgname)) { return NULL; } - xbps_dbg_printf(repo->xhp, "%s: found %s\n", __func__, pkgver); + xbps_dbg_printf("%s: found %s\n", __func__, pkgver); return pkgd; } @@ -637,8 +635,7 @@ xbps_repo_key_import(struct xbps_repo *repo) * If repository does not have required metadata plist, ignore it. */ if (!xbps_dictionary_count(repo->idxmeta)) { - xbps_dbg_printf(repo->xhp, - "[repo] `%s' unsigned repository!\n", repo->uri); + xbps_dbg_printf("[repo] `%s' unsigned repository!\n", repo->uri); return 0; } /* @@ -653,8 +650,7 @@ xbps_repo_key_import(struct xbps_repo *repo) if (signedby == NULL || pubkey_size == 0 || xbps_object_type(pubkey) != XBPS_TYPE_DATA) { - xbps_dbg_printf(repo->xhp, - "[repo] `%s': incomplete signed repository " + xbps_dbg_printf("[repo] `%s': incomplete signed repository " "(missing objs)\n", repo->uri); rv = EINVAL; goto out; @@ -666,8 +662,7 @@ xbps_repo_key_import(struct xbps_repo *repo) rkeyfile = xbps_xasprintf("%s/keys/%s.plist", repo->xhp->metadir, hexfp); repokeyd = xbps_plist_dictionary_from_file(repo->xhp, rkeyfile); if (xbps_object_type(repokeyd) == XBPS_TYPE_DICTIONARY) { - xbps_dbg_printf(repo->xhp, - "[repo] `%s' public key already stored.\n", repo->uri); + xbps_dbg_printf("[repo] `%s' public key already stored.\n", repo->uri); goto out; } /* @@ -692,8 +687,7 @@ xbps_repo_key_import(struct xbps_repo *repo) rv = xbps_mkpath(dbkeyd, 0755); if (rv != 0) { rv = errno; - xbps_dbg_printf(repo->xhp, - "[repo] `%s' cannot create %s: %s\n", + xbps_dbg_printf("[repo] `%s' cannot create %s: %s\n", repo->uri, dbkeyd, strerror(errno)); free(p); goto out; @@ -708,8 +702,7 @@ xbps_repo_key_import(struct xbps_repo *repo) if (!xbps_dictionary_externalize_to_file(repokeyd, rkeyfile)) { rv = errno; - xbps_dbg_printf(repo->xhp, - "[repo] `%s' failed to externalize %s: %s\n", + xbps_dbg_printf("[repo] `%s' failed to externalize %s: %s\n", repo->uri, rkeyfile, strerror(rv)); } diff --git a/lib/rpool.c b/lib/rpool.c index 65df5ad8..d9936575 100644 --- a/lib/rpool.c +++ b/lib/rpool.c @@ -70,7 +70,7 @@ xbps_rpool_sync(struct xbps_handle *xhp, const char *uri) continue; if (xbps_repo_sync(xhp, repouri) == -1) { - xbps_dbg_printf(xhp, + xbps_dbg_printf( "[rpool] `%s' failed to fetch repository data: %s\n", repouri, fetchLastErrCode == 0 ? strerror(errno) : xbps_fetch_error_string()); @@ -98,7 +98,7 @@ xbps_regget_repo(struct xbps_handle *xhp, const char *url) return NULL; SIMPLEQ_INSERT_TAIL(&rpool_queue, repo, entries); - xbps_dbg_printf(xhp, "[rpool] `%s' registered.\n", repouri); + xbps_dbg_printf("[rpool] `%s' registered.\n", repouri); } } SIMPLEQ_FOREACH(repo, &rpool_queue, entries) @@ -151,7 +151,7 @@ xbps_rpool_foreach(struct xbps_handle *xhp, again: for (unsigned int i = n; i < xbps_array_count(xhp->repositories); i++, n++) { xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri); - xbps_dbg_printf(xhp, "[rpool] checking `%s' at index %u\n", repouri, n); + xbps_dbg_printf("[rpool] checking `%s' at index %u\n", repouri, n); if ((repo = xbps_rpool_get_repo(repouri)) == NULL) { repo = xbps_repo_open(xhp, repouri); if (!repo) { @@ -159,7 +159,7 @@ again: goto again; } SIMPLEQ_INSERT_TAIL(&rpool_queue, repo, entries); - xbps_dbg_printf(xhp, "[rpool] `%s' registered.\n", repouri); + xbps_dbg_printf("[rpool] `%s' registered.\n", repouri); } foundrepo = true; rv = (*fn)(repo, arg, &done); @@ -235,16 +235,14 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done UNUSED) if (errno && errno != ENOENT) return errno; - xbps_dbg_printf(repo->xhp, - "[rpool] Package '%s' not found in repository " - "'%s'.\n", rpf->pattern, repo->uri); + xbps_dbg_printf("[rpool] Package '%s' not found in repository" + " '%s'.\n", rpf->pattern, repo->uri); return 0; } xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &repopkgver); if (rpf->bestpkgver == NULL) { - xbps_dbg_printf(repo->xhp, - "[rpool] Found match '%s' (%s).\n", + xbps_dbg_printf("[rpool] Found match '%s' (%s).\n", repopkgver, repo->uri); rpf->pkgd = pkgd; rpf->bestpkgver = repopkgver; @@ -255,8 +253,7 @@ find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done UNUSED) * version from current package in repository. */ if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) { - xbps_dbg_printf(repo->xhp, - "[rpool] Found best match '%s' (%s).\n", + xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n", repopkgver, repo->uri); rpf->pkgd = pkgd; rpf->bestpkgver = repopkgver; diff --git a/lib/transaction_check_conflicts.c b/lib/transaction_check_conflicts.c index 165feb5d..c83d0ae5 100644 --- a/lib/transaction_check_conflicts.c +++ b/lib/transaction_check_conflicts.c @@ -105,7 +105,7 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, continue; } } - xbps_dbg_printf(xhp, "found conflicting installed " + xbps_dbg_printf("found conflicting installed " "pkg %s with pkg in transaction %s " "(matched by %s [trans])\n", pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " @@ -137,7 +137,7 @@ pkg_conflicts_trans(struct xbps_handle *xhp, xbps_array_t array, if (!xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver)) { break; } - xbps_dbg_printf(xhp, "found conflicting pkgs in " + xbps_dbg_printf("found conflicting pkgs in " "transaction %s <-> %s (matched by %s [trans])\n", pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " @@ -209,7 +209,7 @@ pkgdb_conflicts_cb(struct xbps_handle *xhp, xbps_object_t obj, rv = EINVAL; break; } - xbps_dbg_printf(xhp, "found conflicting pkgs in " + xbps_dbg_printf("found conflicting pkgs in " "transaction %s <-> %s (matched by %s [pkgdb])\n", pkgver, repopkgver, cfpkg); buf = xbps_xasprintf("CONFLICT: %s with " diff --git a/lib/transaction_check_replaces.c b/lib/transaction_check_replaces.c index cd468a51..b691666f 100644 --- a/lib/transaction_check_replaces.c +++ b/lib/transaction_check_replaces.c @@ -140,7 +140,7 @@ xbps_transaction_check_replaces(struct xbps_handle *xhp, xbps_array_t pkgs) xbps_object_iterator_release(iter); return false; } - xbps_dbg_printf(xhp, + xbps_dbg_printf( "Package `%s' in transaction will be " "replaced by `%s', matched with `%s'\n", curpkgver, pkgver, pattern); @@ -172,7 +172,7 @@ xbps_transaction_check_replaces(struct xbps_handle *xhp, xbps_array_t pkgs) xbps_object_iterator_release(iter); return false; } - xbps_dbg_printf(xhp, + xbps_dbg_printf( "Package `%s' will be replaced by `%s', " "matched with `%s'\n", curpkgver, pkgver, pattern); } diff --git a/lib/transaction_check_shlibs.c b/lib/transaction_check_shlibs.c index bbe3de1c..d13655f4 100644 --- a/lib/transaction_check_shlibs.c +++ b/lib/transaction_check_shlibs.c @@ -121,7 +121,7 @@ collect_shlibs(struct xbps_handle *xhp, xbps_array_t pkgs, bool req) const char *shlib = NULL; xbps_array_get_cstring_nocopy(shobjs, i, &shlib); - xbps_dbg_printf(xhp, "%s: registering %s for %s\n", + xbps_dbg_printf("%s: registering %s for %s\n", pkgver, shlib, req ? "shlib-requires" : "shlib-provides"); if (req) shlib_register(d, shlib, pkgver); @@ -155,13 +155,13 @@ xbps_transaction_check_shlibs(struct xbps_handle *xhp, xbps_array_t pkgs) while ((obj = xbps_object_iterator_next(iter))) { shlib = xbps_dictionary_keysym_cstring_nocopy(obj); - xbps_dbg_printf(xhp, "%s: checking for `%s': ", __func__, shlib); + xbps_dbg_printf("%s: checking for `%s': ", __func__, shlib); if ((obj2 = xbps_dictionary_get(shprovides, shlib))) { - xbps_dbg_printf_append(xhp, "provided by `%s'\n", + xbps_dbg_printf_append("provided by `%s'\n", xbps_string_cstring_nocopy(obj2)); continue; } - xbps_dbg_printf_append(xhp, "not found\n"); + xbps_dbg_printf_append("not found\n"); broken = true; array = xbps_dictionary_get_keysym(shrequires, obj); diff --git a/lib/transaction_commit.c b/lib/transaction_commit.c index 3daadf26..2a0dbd85 100644 --- a/lib/transaction_commit.c +++ b/lib/transaction_commit.c @@ -153,7 +153,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) * Download and verify binary packages. */ if ((rv = xbps_transaction_fetch(xhp, iter)) != 0) { - xbps_dbg_printf(xhp, "[trans] failed to fetch and verify binpkgs: " + xbps_dbg_printf("[trans] failed to fetch and verify binpkgs: " "%s\n", strerror(rv)); goto out; } @@ -171,7 +171,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) * Internalize metadata of downloaded binary packages. */ if ((rv = xbps_transaction_internalize(xhp, iter)) < 0) { - xbps_dbg_printf(xhp, "[trans] failed to internalize transaction binpkgs: " + xbps_dbg_printf("[trans] failed to internalize transaction binpkgs: " "%s\n", strerror(-rv)); goto out; } @@ -182,7 +182,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) */ xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FILES, 0, NULL, NULL); if ((rv = xbps_transaction_files(xhp, iter)) != 0) { - xbps_dbg_printf(xhp, "[trans] failed to verify transaction files: " + xbps_dbg_printf("[trans] failed to verify transaction files: " "%s\n", strerror(rv)); goto out; } @@ -229,14 +229,14 @@ xbps_transaction_commit(struct xbps_handle *xhp) ttype = xbps_transaction_pkg_type(obj); if (ttype == XBPS_TRANS_INSTALL || ttype == XBPS_TRANS_HOLD || ttype == XBPS_TRANS_CONFIGURE) { - xbps_dbg_printf(xhp, "%s: skipping pre-remove script for " + xbps_dbg_printf("%s: skipping pre-remove script for " "%s: %d\n", __func__, pkgver, ttype); continue; } if ((pkgdb_pkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) { rv = ENOENT; - xbps_dbg_printf(xhp, "[trans] cannot find %s in pkgdb: %s\n", + xbps_dbg_printf("[trans] cannot find %s in pkgdb: %s\n", pkgname, strerror(rv)); goto out; } @@ -289,7 +289,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); ttype = xbps_transaction_pkg_type(obj); if (ttype == XBPS_TRANS_REMOVE || ttype == XBPS_TRANS_HOLD) { - xbps_dbg_printf(xhp, "%s: skipping pre-install script for " + xbps_dbg_printf("%s: skipping pre-install script for " "%s: %d\n", __func__, pkgver, ttype); continue; } @@ -316,7 +316,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) xbps_dictionary_get_bool(obj, "remove-and-update", &update); rv = xbps_remove_pkg(xhp, pkgver, update); if (rv != 0) { - xbps_dbg_printf(xhp, "[trans] failed to " + xbps_dbg_printf("[trans] failed to " "remove %s: %s\n", pkgver, strerror(rv)); goto out; } @@ -352,7 +352,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) * Unpack binary package. */ if ((rv = xbps_unpack_binary_pkg(xhp, obj)) != 0) { - xbps_dbg_printf(xhp, "[trans] failed to unpack " + xbps_dbg_printf("[trans] failed to unpack " "%s: %s\n", pkgver, strerror(rv)); goto out; } @@ -360,7 +360,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) * Register package. */ if ((rv = xbps_register_pkg(xhp, obj)) != 0) { - xbps_dbg_printf(xhp, "[trans] failed to register " + xbps_dbg_printf("[trans] failed to register " "%s: %s\n", pkgver, strerror(rv)); goto out; } @@ -401,7 +401,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); ttype = xbps_transaction_pkg_type(obj); if (ttype == XBPS_TRANS_REMOVE || ttype == XBPS_TRANS_HOLD) { - xbps_dbg_printf(xhp, "%s: skipping configuration for " + xbps_dbg_printf("%s: skipping configuration for " "%s: %d\n", __func__, pkgver, ttype); continue; } @@ -411,7 +411,7 @@ xbps_transaction_commit(struct xbps_handle *xhp) rv = xbps_configure_pkg(xhp, pkgver, false, update); if (rv != 0) { - xbps_dbg_printf(xhp, "%s: configure failed for " + xbps_dbg_printf("%s: configure failed for " "%s: %s\n", __func__, pkgver, strerror(rv)); goto out; } diff --git a/lib/transaction_fetch.c b/lib/transaction_fetch.c index 72ce0747..74c0c1a8 100644 --- a/lib/transaction_fetch.c +++ b/lib/transaction_fetch.c @@ -54,7 +54,7 @@ verify_binpkg(struct xbps_handle *xhp, xbps_dictionary_t pkgd) */ if ((repo = xbps_rpool_get_repo(repoloc)) == NULL) { rv = errno; - xbps_dbg_printf(xhp, "%s: failed to get repository " + xbps_dbg_printf("%s: failed to get repository " "%s: %s\n", pkgver, repoloc, strerror(errno)); goto out; } @@ -150,7 +150,7 @@ download_binpkg(struct xbps_handle *xhp, xbps_dictionary_t repo_pkgd) if ((repo = xbps_rpool_get_repo(repoloc)) == NULL) { rv = errno; - xbps_dbg_printf(xhp, "%s: failed to get repository " + xbps_dbg_printf("%s: failed to get repository " "%s: %s\n", pkgver, repoloc, strerror(errno)); return rv; } @@ -242,11 +242,11 @@ xbps_transaction_fetch(struct xbps_handle *xhp, xbps_object_iterator_t iter) n = xbps_array_count(fetch); if (n) { xbps_set_cb_state(xhp, XBPS_STATE_TRANS_DOWNLOAD, 0, NULL, NULL); - xbps_dbg_printf(xhp, "[trans] downloading %d packages.\n", n); + xbps_dbg_printf("[trans] downloading %d packages.\n", n); } for (i = 0; i < n; i++) { if ((rv = download_binpkg(xhp, xbps_array_get(fetch, i))) != 0) { - xbps_dbg_printf(xhp, "[trans] failed to download binpkgs: " + xbps_dbg_printf("[trans] failed to download binpkgs: " "%s\n", strerror(rv)); goto out; } @@ -258,11 +258,11 @@ xbps_transaction_fetch(struct xbps_handle *xhp, xbps_object_iterator_t iter) n = xbps_array_count(verify); if (n) { xbps_set_cb_state(xhp, XBPS_STATE_TRANS_VERIFY, 0, NULL, NULL); - xbps_dbg_printf(xhp, "[trans] verifying %d packages.\n", n); + xbps_dbg_printf("[trans] verifying %d packages.\n", n); } for (i = 0; i < n; i++) { if ((rv = verify_binpkg(xhp, xbps_array_get(verify, i))) != 0) { - xbps_dbg_printf(xhp, "[trans] failed to check binpkgs: " + xbps_dbg_printf("[trans] failed to check binpkgs: " "%s\n", strerror(rv)); goto out; } diff --git a/lib/transaction_files.c b/lib/transaction_files.c index 1ef4fe1e..9cb30e17 100644 --- a/lib/transaction_files.c +++ b/lib/transaction_files.c @@ -139,7 +139,7 @@ match_preserved_file(struct xbps_handle *xhp, const char *file) } static bool -can_delete_directory(struct xbps_handle *xhp, const char *file, size_t len, size_t max) +can_delete_directory(const char *file, size_t len, size_t max) { struct item *item; size_t rmcount = 0, fcount = 0; @@ -150,7 +150,7 @@ can_delete_directory(struct xbps_handle *xhp, const char *file, size_t len, size if (errno == ENOENT) { return true; } else { - xbps_dbg_printf(xhp, "[files] %s: %s: %s\n", + xbps_dbg_printf("[files] %s: %s: %s\n", __func__, file, strerror(errno)); return false; } @@ -183,7 +183,7 @@ can_delete_directory(struct xbps_handle *xhp, const char *file, size_t len, size fcount -= 2; if (fcount <= rmcount) { - xbps_dbg_printf(xhp, "[files] only removed %zu out of %zu files: %s\n", + xbps_dbg_printf("[files] only removed %zu out of %zu files: %s\n", rmcount, fcount, file); } closedir(dp); @@ -233,7 +233,7 @@ collect_obsoletes(struct xbps_handle *xhp) item = items[i]; if (match_preserved_file(xhp, item->file)) { - xbps_dbg_printf(xhp, "[obsoletes] %s: file exists on disk" + xbps_dbg_printf("[obsoletes] %s: file exists on disk" " and must be preserved: %s\n", item->old.pkgver, item->file); continue; } @@ -245,7 +245,7 @@ collect_obsoletes(struct xbps_handle *xhp) * Probably obsolete. */ if (item->old.preserve && item->old.update) { - xbps_dbg_printf(xhp, "[files] %s: skipping `preserve` %s: %s\n", + xbps_dbg_printf("[files] %s: skipping `preserve` %s: %s\n", item->old.pkgver, typestr(item->old.type), item->file); continue; } @@ -276,9 +276,9 @@ collect_obsoletes(struct xbps_handle *xhp) * Directory replaced by a file or symlink. * We MUST be able to delete the directory. */ - xbps_dbg_printf(xhp, "[files] %s: directory changed to %s: %s\n", + xbps_dbg_printf("[files] %s: directory changed to %s: %s\n", item->new.pkgver, typestr(item->new.type), item->file); - if (!can_delete_directory(xhp, item->file, item->len, i)) { + if (!can_delete_directory(item->file, item->len, i)) { xbps_set_cb_state(xhp, XBPS_STATE_FILES_FAIL, ENOTEMPTY, item->old.pkgver, "%s: directory `%s' can not be deleted.", @@ -329,13 +329,13 @@ collect_obsoletes(struct xbps_handle *xhp) */ if (item->old.removepkg && !item->new.pkgname && (xhp->flags & XBPS_FLAG_FORCE_REMOVE_FILES) != 0) { - xbps_dbg_printf(xhp, "[obsoletes] %s: SHA256 mismatch," + xbps_dbg_printf("[obsoletes] %s: SHA256 mismatch," " force remove %s: %s\n", item->old.pkgname, typestr(item->old.type), item->file+1); break; } - xbps_dbg_printf(xhp, "[obsoletes] %s: SHA256 mismatch," + xbps_dbg_printf("[obsoletes] %s: SHA256 mismatch," " skipping remove %s: %s\n", item->old.pkgname, typestr(item->old.type), item->file+1); @@ -360,12 +360,12 @@ collect_obsoletes(struct xbps_handle *xhp) } lnk = xbps_symlink_target(xhp, file, item->old.target); if (lnk == NULL) { - xbps_dbg_printf(xhp, "[obsoletes] %s " + xbps_dbg_printf("[obsoletes] %s " "symlink_target: %s\n", item->file+1, strerror(errno)); continue; } if (strcmp(lnk, item->old.target) != 0) { - xbps_dbg_printf(xhp, "[obsoletes] %s: skipping modified" + xbps_dbg_printf("[obsoletes] %s: skipping modified" " symlink (stored `%s' current `%s'): %s\n", item->old.pkgname, item->old.target, lnk, item->file+1); free(lnk); @@ -390,7 +390,7 @@ collect_obsoletes(struct xbps_handle *xhp) } assert(pkgname); - xbps_dbg_printf(xhp, "[obsoletes] %s: removes %s: %s\n", + xbps_dbg_printf("[obsoletes] %s: removes %s: %s\n", pkgname, typestr(item->old.type), item->file+1); /* @@ -462,7 +462,7 @@ collect_file(struct xbps_handle *xhp, const char *file, size_t size, * Multiple packages removing the same file. * Shouldn't happen, but its not fatal. */ - xbps_dbg_printf(xhp, "[files] %s: file already removed" + xbps_dbg_printf("[files] %s: file already removed" " by package `%s': %s\n", pkgver, item->old.pkgver, file); /* @@ -546,11 +546,11 @@ add: */ if (strcmp(item->new.pkgname, item->old.pkgname) != 0) { if (removefile) { - xbps_dbg_printf(xhp, "[files] %s: %s moved to" + xbps_dbg_printf("[files] %s: %s moved to" " package `%s': %s\n", pkgver, typestr(item->old.type), item->new.pkgver, file); } else { - xbps_dbg_printf(xhp, "[files] %s: %s moved from" + xbps_dbg_printf("[files] %s: %s moved from" " package `%s': %s\n", pkgver, typestr(item->new.type), item->old.pkgver, file); } diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index 24fc1f1c..1f123901 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -130,7 +130,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force) !xbps_pkg_reverts(pkg_repod, instpkgver)) { xbps_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc); - xbps_dbg_printf(xhp, "[rpool] Skipping `%s' " + xbps_dbg_printf("[rpool] Skipping `%s' " "(installed: %s) from repository `%s'\n", repopkgver, instpkgver, repoloc); return EEXIST; @@ -171,7 +171,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force) */ if (ttype == XBPS_TRANS_UPDATE) { if (xbps_find_pkg_in_array(pkgs, repopkgver, 0)) { - xbps_dbg_printf(xhp, "[update] `%s' already queued in " + xbps_dbg_printf("[update] `%s' already queued in " "transaction.\n", repopkgver); return EEXIST; } @@ -243,7 +243,7 @@ xbps_autoupdate(struct xbps_handle *xhp) rv = trans_find_pkg(xhp, pkgname, false); - xbps_dbg_printf(xhp, "%s: trans_find_pkg xbps: %d\n", __func__, rv); + xbps_dbg_printf("%s: trans_find_pkg xbps: %d\n", __func__, rv); if (rv == 0) { if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) { @@ -256,13 +256,13 @@ xbps_autoupdate(struct xbps_handle *xhp) char curpkgn[XBPS_NAME_SIZE] = {0}; xbps_array_get_cstring_nocopy(rdeps, i, &curpkgver); - xbps_dbg_printf(xhp, "%s: processing revdep %s\n", __func__, curpkgver); + xbps_dbg_printf("%s: processing revdep %s\n", __func__, curpkgver); if (!xbps_pkg_name(curpkgn, sizeof(curpkgn), curpkgver)) { abort(); } rv = trans_find_pkg(xhp, curpkgn, false); - xbps_dbg_printf(xhp, "%s: trans_find_pkg revdep %s: %d\n", __func__, curpkgver, rv); + xbps_dbg_printf("%s: trans_find_pkg revdep %s: %d\n", __func__, curpkgver, rv); if (rv && rv != ENOENT && rv != EEXIST && rv != ENODEV) return -1; } @@ -326,7 +326,7 @@ xbps_transaction_update_packages(struct xbps_handle *xhp) break; } rv = trans_find_pkg(xhp, pkgname, false); - xbps_dbg_printf(xhp, "%s: trans_find_pkg %s: %d\n", __func__, pkgver, rv); + xbps_dbg_printf("%s: trans_find_pkg %s: %d\n", __func__, pkgver, rv); if (rv == 0) { newpkg_found = true; } else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) { @@ -349,7 +349,7 @@ xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg, bool force int rv; rv = xbps_autoupdate(xhp); - xbps_dbg_printf(xhp, "%s: xbps_autoupdate %d\n", __func__, rv); + xbps_dbg_printf("%s: xbps_autoupdate %d\n", __func__, rv); switch (rv) { case 1: /* xbps needs to be updated, only allow xbps to be updated */ @@ -382,14 +382,14 @@ xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkg, bool force break; } rv = trans_find_pkg(xhp, pkgname, false); - xbps_dbg_printf(xhp, "%s: trans_find_pkg %s: %d\n", __func__, pkgver, rv); + xbps_dbg_printf("%s: trans_find_pkg %s: %d\n", __func__, pkgver, rv); if (rv && rv != ENOENT && rv != EEXIST && rv != ENODEV) { return rv; } } /* add pkg repod */ rv = trans_find_pkg(xhp, pkg, force); - xbps_dbg_printf(xhp, "%s: trans_find_pkg %s: %d\n", __func__, pkg, rv); + xbps_dbg_printf("%s: trans_find_pkg %s: %d\n", __func__, pkg, rv); return rv; } @@ -432,13 +432,13 @@ xbps_transaction_install_pkg(struct xbps_handle *xhp, const char *pkg, bool forc break; } rv = trans_find_pkg(xhp, pkgname, false); - xbps_dbg_printf(xhp, "%s: trans_find_pkg %s: %d\n", __func__, pkgver, rv); + xbps_dbg_printf("%s: trans_find_pkg %s: %d\n", __func__, pkgver, rv); if (rv && rv != ENOENT && rv != EEXIST && rv != ENODEV) { return rv; } } rv = trans_find_pkg(xhp, pkg, force); - xbps_dbg_printf(xhp, "%s: trans_find_pkg %s: %d\n", __func__, pkg, rv); + xbps_dbg_printf("%s: trans_find_pkg %s: %d\n", __func__, pkg, rv); return rv; } diff --git a/lib/transaction_pkg_deps.c b/lib/transaction_pkg_deps.c index e23966ed..002350e1 100644 --- a/lib/transaction_pkg_deps.c +++ b/lib/transaction_pkg_deps.c @@ -76,7 +76,7 @@ add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg) * if new dependency version is greater than current * one, store it. */ - xbps_dbg_printf(xhp, "Missing pkgdep name matched, curver: %s newver: %s\n", curver, pkgver); + xbps_dbg_printf("Missing pkgdep name matched, curver: %s newver: %s\n", curver, pkgver); if (xbps_cmpver(curver, pkgver) <= 0) { add_pkgdep = false; rv = EEXIST; @@ -151,15 +151,15 @@ repo_deps(struct xbps_handle *xhp, reqpkg = xbps_string_cstring_nocopy(obj); if (xhp->flags & XBPS_FLAG_DEBUG) { - xbps_dbg_printf(xhp, "%s", ""); + xbps_dbg_printf("%s", ""); for (unsigned short x = 0; x < *depth; x++) { - xbps_dbg_printf_append(xhp, " "); + xbps_dbg_printf_append(" "); } - xbps_dbg_printf_append(xhp, "%s: requires dependency '%s': ", curpkg ? curpkg : " ", reqpkg); + xbps_dbg_printf_append("%s: requires dependency '%s': ", curpkg ? curpkg : " ", reqpkg); } if ((!xbps_pkgpattern_name(pkgname, sizeof(pkgname), reqpkg)) && (!xbps_pkg_name(pkgname, sizeof(pkgname), reqpkg))) { - xbps_dbg_printf(xhp, "%s: can't guess pkgname for dependency: %s\n", curpkg, reqpkg); + xbps_dbg_printf("%s: can't guess pkgname for dependency: %s\n", curpkg, reqpkg); xbps_set_cb_state(xhp, XBPS_STATE_INVALID_DEP, ENXIO, NULL, "%s: can't guess pkgname for dependency '%s'", curpkg, reqpkg); rv = ENXIO; @@ -169,7 +169,7 @@ repo_deps(struct xbps_handle *xhp, * Pass 0: check if required dependency is ignored. */ if (xbps_pkg_is_ignored(xhp, pkgname)) { - xbps_dbg_printf_append(xhp, "%s ignored.\n", pkgname); + xbps_dbg_printf_append("%s ignored.\n", pkgname); continue; } /* @@ -177,7 +177,7 @@ repo_deps(struct xbps_handle *xhp, * package via "provides", if true ignore dependency. */ if (pkg_provides && xbps_match_virtual_pkg_in_array(pkg_provides, reqpkg)) { - xbps_dbg_printf_append(xhp, "%s is a vpkg provided by %s, ignored.\n", pkgname, curpkg); + xbps_dbg_printf_append("%s is a vpkg provided by %s, ignored.\n", pkgname, curpkg); continue; } /* @@ -189,7 +189,7 @@ repo_deps(struct xbps_handle *xhp, xbps_trans_type_t ttype_q = xbps_transaction_pkg_type(curpkgd); xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q); if (ttype_q != XBPS_TRANS_REMOVE && ttype_q != XBPS_TRANS_HOLD) { - xbps_dbg_printf_append(xhp, " (%s queued %d)\n", pkgver_q, ttype_q); + xbps_dbg_printf_append(" (%s queued %d)\n", pkgver_q, ttype_q); continue; } } @@ -216,11 +216,11 @@ repo_deps(struct xbps_handle *xhp, if (errno && errno != ENOENT) { /* error */ rv = errno; - xbps_dbg_printf(xhp, "failed to find installed pkg for `%s': %s\n", reqpkg, strerror(rv)); + xbps_dbg_printf("failed to find installed pkg for `%s': %s\n", reqpkg, strerror(rv)); break; } /* Required dependency not installed */ - xbps_dbg_printf_append(xhp, "not installed.\n"); + xbps_dbg_printf_append("not installed.\n"); ttype = XBPS_TRANS_INSTALL; state = XBPS_PKG_STATE_NOT_INSTALLED; } else { @@ -240,7 +240,7 @@ repo_deps(struct xbps_handle *xhp, * Check if required dependency is a virtual package and is satisfied * by an installed package. */ - xbps_dbg_printf_append(xhp, "[virtual] satisfied by `%s'.\n", pkgver_q); + xbps_dbg_printf_append("[virtual] satisfied by `%s'.\n", pkgver_q); continue; } rv = xbps_pkgpattern_match(pkgver_q, reqpkg); @@ -254,23 +254,23 @@ repo_deps(struct xbps_handle *xhp, } if (strcmp(pkgname, curpkgname)) { - xbps_dbg_printf_append(xhp, "not installed `%s (vpkg)'", pkgver_q); + xbps_dbg_printf_append("not installed `%s (vpkg)'", pkgver_q); if (xbps_dictionary_get(curpkgd, "hold")) { ttype = XBPS_TRANS_HOLD; - xbps_dbg_printf_append(xhp, " on hold state! ignoring package.\n"); + xbps_dbg_printf_append(" on hold state! ignoring package.\n"); rv = ENODEV; } else { - xbps_dbg_printf_append(xhp, "\n"); + xbps_dbg_printf_append("\n"); ttype = XBPS_TRANS_INSTALL; } } else { - xbps_dbg_printf_append(xhp, "installed `%s', must be updated", pkgver_q); + xbps_dbg_printf_append("installed `%s', must be updated", pkgver_q); if (xbps_dictionary_get(curpkgd, "hold")) { - xbps_dbg_printf_append(xhp, " on hold state! ignoring package.\n"); + xbps_dbg_printf_append(" on hold state! ignoring package.\n"); ttype = XBPS_TRANS_HOLD; rv = ENODEV; } else { - xbps_dbg_printf_append(xhp, "\n"); + xbps_dbg_printf_append("\n"); ttype = XBPS_TRANS_UPDATE; } } @@ -280,14 +280,14 @@ repo_deps(struct xbps_handle *xhp, if (rv == ENODEV) { rv = add_missing_reqdep(xhp, reqpkg); if (rv != 0 && rv != EEXIST) { - xbps_dbg_printf(xhp, "`%s': add_missing_reqdep failed\n", reqpkg); + xbps_dbg_printf("`%s': add_missing_reqdep failed\n", reqpkg); break; } else if (rv == EEXIST) { - xbps_dbg_printf(xhp, "`%s' missing dep already added.\n", reqpkg); + xbps_dbg_printf("`%s' missing dep already added.\n", reqpkg); rv = 0; continue; } else { - xbps_dbg_printf(xhp, "`%s' added into the missing deps array.\n", reqpkg); + xbps_dbg_printf("`%s' added into the missing deps array.\n", reqpkg); continue; } } @@ -301,19 +301,19 @@ repo_deps(struct xbps_handle *xhp, * Package matches the dependency pattern but was only unpacked, * configure pkg. */ - xbps_dbg_printf_append(xhp, "installed `%s', must be configured.\n", pkgver_q); + xbps_dbg_printf_append("installed `%s', must be configured.\n", pkgver_q); ttype = XBPS_TRANS_CONFIGURE; } else if (state == XBPS_PKG_STATE_INSTALLED) { /* * Package matches the dependency pattern and is fully installed, * skip to next one. */ - xbps_dbg_printf_append(xhp, "installed `%s'.\n", pkgver_q); + xbps_dbg_printf_append("installed `%s'.\n", pkgver_q); continue; } } else { /* error matching pkgpattern */ - xbps_dbg_printf(xhp, "failed to match pattern %s with %s\n", reqpkg, pkgver_q); + xbps_dbg_printf("failed to match pattern %s with %s\n", reqpkg, pkgver_q); break; } } @@ -325,7 +325,7 @@ repo_deps(struct xbps_handle *xhp, if (xbps_dictionary_get(curpkgd, "repolock")) { const char *repourl = NULL; struct xbps_repo *repo = NULL; - xbps_dbg_printf(xhp, "`%s' is repolocked, looking at single repository.\n", reqpkg); + xbps_dbg_printf("`%s' is repolocked, looking at single repository.\n", reqpkg); xbps_dictionary_get_cstring_nocopy(curpkgd, "repository", &repourl); if (repourl && (repo = xbps_regget_repo(xhp, repourl))) { curpkgd = xbps_repo_get_pkg(repo, reqpkg); @@ -341,20 +341,20 @@ repo_deps(struct xbps_handle *xhp, if (curpkgd == NULL) { /* pkg not found, there was some error */ if (errno && errno != ENOENT) { - xbps_dbg_printf(xhp, "failed to find pkg for `%s' in rpool: %s\n", reqpkg, strerror(errno)); + xbps_dbg_printf("failed to find pkg for `%s' in rpool: %s\n", reqpkg, strerror(errno)); rv = errno; break; } rv = add_missing_reqdep(xhp, reqpkg); if (rv != 0 && rv != EEXIST) { - xbps_dbg_printf(xhp, "`%s': add_missing_reqdep failed\n", reqpkg); + xbps_dbg_printf("`%s': add_missing_reqdep failed\n", reqpkg); break; } else if (rv == EEXIST) { - xbps_dbg_printf(xhp, "`%s' missing dep already added.\n", reqpkg); + xbps_dbg_printf("`%s' missing dep already added.\n", reqpkg); rv = 0; continue; } else { - xbps_dbg_printf(xhp, "`%s' added into the missing deps array.\n", reqpkg); + xbps_dbg_printf("`%s' added into the missing deps array.\n", reqpkg); continue; } } @@ -373,7 +373,7 @@ repo_deps(struct xbps_handle *xhp, break; } if (strcmp(pkgname, reqpkgname) == 0) { - xbps_dbg_printf_append(xhp, "[ignoring wrong dependency %s (depends on itself)]\n", reqpkg); + xbps_dbg_printf_append("[ignoring wrong dependency %s (depends on itself)]\n", reqpkg); xbps_remove_string_from_array(pkg_rdeps, reqpkg); continue; } @@ -414,16 +414,16 @@ repo_deps(struct xbps_handle *xhp, * Process rundeps for current pkg found in rpool. */ if (xhp->flags & XBPS_FLAG_DEBUG) { - xbps_dbg_printf(xhp, "%s", ""); + xbps_dbg_printf("%s", ""); for (unsigned short x = 0; x < *depth; x++) { - xbps_dbg_printf_append(xhp, " "); + xbps_dbg_printf_append(" "); } - xbps_dbg_printf_append(xhp, "%s: finding dependencies:\n", pkgver_q); + xbps_dbg_printf_append("%s: finding dependencies:\n", pkgver_q); } (*depth)++; rv = repo_deps(xhp, pkgs, curpkgd, depth); if (rv != 0) { - xbps_dbg_printf(xhp, "Error checking %s for rundeps: %s\n", reqpkg, strerror(rv)); + xbps_dbg_printf("Error checking %s for rundeps: %s\n", reqpkg, strerror(rv)); break; } } @@ -437,12 +437,12 @@ repo_deps(struct xbps_handle *xhp, */ if (!xbps_transaction_pkg_type_set(curpkgd, ttype)) { rv = EINVAL; - xbps_dbg_printf(xhp, "xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv)); + xbps_dbg_printf("xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv)); break; } if (!xbps_transaction_store(xhp, pkgs, curpkgd, true)) { rv = EINVAL; - xbps_dbg_printf(xhp, "xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv)); + xbps_dbg_printf("xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv)); break; } } @@ -466,7 +466,7 @@ xbps_transaction_pkg_deps(struct xbps_handle *xhp, assert(pkg_repod); xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver); - xbps_dbg_printf(xhp, "Finding required dependencies for '%s':\n", pkgver); + xbps_dbg_printf("Finding required dependencies for '%s':\n", pkgver); /* * This will find direct and indirect deps, if any of them is not * there it will be added into the missing_deps array. diff --git a/lib/transaction_prepare.c b/lib/transaction_prepare.c index f50f831f..76db67e8 100644 --- a/lib/transaction_prepare.c +++ b/lib/transaction_prepare.c @@ -172,7 +172,7 @@ compute_transaction_stats(struct xbps_handle *xhp) /* Get free space from target rootdir: return ENOSPC if there's not enough space */ if (statvfs(xhp->rootdir, &svfs) == -1) { - xbps_dbg_printf(xhp, "%s: statvfs failed: %s\n", __func__, strerror(errno)); + xbps_dbg_printf("%s: statvfs failed: %s\n", __func__, strerror(errno)); return 0; } /* compute free space on disk */ @@ -297,7 +297,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) if ((edges = xbps_array_create()) == NULL) return ENOMEM; - xbps_dbg_printf(xhp, "%s: processing deps\n", __func__); + xbps_dbg_printf("%s: processing deps\n", __func__); /* * The edges are also appended after its dependencies have been * collected; the edges at the original array are removed later. @@ -350,7 +350,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) * If all pkgs in transaction are on hold, no need to check * for anything else. */ - xbps_dbg_printf(xhp, "%s: checking on hold pkgs\n", __func__); + xbps_dbg_printf("%s: checking on hold pkgs\n", __func__); for (i = 0; i < cnt; i++) { tpkgd = xbps_array_get(pkgs, i); if (xbps_transaction_pkg_type(tpkgd) != XBPS_TRANS_HOLD) { @@ -364,7 +364,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) /* * Check for packages to be replaced. */ - xbps_dbg_printf(xhp, "%s: checking replaces\n", __func__); + xbps_dbg_printf("%s: checking replaces\n", __func__); if (!xbps_transaction_check_replaces(xhp, pkgs)) { xbps_object_release(xhp->transd); xhp->transd = NULL; @@ -373,7 +373,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) /* * Check if there are missing revdeps. */ - xbps_dbg_printf(xhp, "%s: checking revdeps\n", __func__); + xbps_dbg_printf("%s: checking revdeps\n", __func__); if (!xbps_transaction_check_revdeps(xhp, pkgs)) { xbps_object_release(xhp->transd); xhp->transd = NULL; @@ -381,7 +381,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) } if (xbps_dictionary_get(xhp->transd, "missing_deps")) { if (xhp->flags & XBPS_FLAG_FORCE_REMOVE_REVDEPS) { - xbps_dbg_printf(xhp, "[trans] continuing with broken reverse dependencies!"); + xbps_dbg_printf("[trans] continuing with broken reverse dependencies!"); } else { return ENODEV; } @@ -389,7 +389,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) /* * Check for package conflicts. */ - xbps_dbg_printf(xhp, "%s: checking conflicts\n", __func__); + xbps_dbg_printf("%s: checking conflicts\n", __func__); if (!xbps_transaction_check_conflicts(xhp, pkgs)) { xbps_object_release(xhp->transd); xhp->transd = NULL; @@ -401,7 +401,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) /* * Check for unresolved shared libraries. */ - xbps_dbg_printf(xhp, "%s: checking shlibs\n", __func__); + xbps_dbg_printf("%s: checking shlibs\n", __func__); if (!xbps_transaction_check_shlibs(xhp, pkgs)) { xbps_object_release(xhp->transd); xhp->transd = NULL; @@ -409,7 +409,7 @@ xbps_transaction_prepare(struct xbps_handle *xhp) } if (xbps_dictionary_get(xhp->transd, "missing_shlibs")) { if (xhp->flags & XBPS_FLAG_FORCE_REMOVE_REVDEPS) { - xbps_dbg_printf(xhp, "[trans] continuing with unresolved shared libraries!"); + xbps_dbg_printf("[trans] continuing with unresolved shared libraries!"); } else { return ENOEXEC; } @@ -420,7 +420,7 @@ out: * number of packages to be installed, updated, configured * and removed to the transaction dictionary. */ - xbps_dbg_printf(xhp, "%s: computing stats\n", __func__); + xbps_dbg_printf("%s: computing stats\n", __func__); if ((rv = compute_transaction_stats(xhp)) != 0) { return rv; } diff --git a/lib/transaction_store.c b/lib/transaction_store.c index bb4e4699..13e0c24e 100644 --- a/lib/transaction_store.c +++ b/lib/transaction_store.c @@ -68,7 +68,7 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs, if (!xbps_remove_pkg_from_array_by_pkgver(pkgs, curpkgver)) { return false; } - xbps_dbg_printf(xhp, "[trans] replaced %s with %s\n", curpkgver, pkgver); + xbps_dbg_printf("[trans] replaced %s with %s\n", curpkgver, pkgver); } } @@ -105,7 +105,7 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs, xbps_set_cb_state(xhp, XBPS_STATE_TRANS_ADDPKG, 0, pkgver, "Found %s in repository %s", pkgver, repo); - xbps_dbg_printf(xhp, "[trans] `%s' stored (%s)\n", pkgver, repo); + xbps_dbg_printf("[trans] `%s' stored (%s)\n", pkgver, repo); xbps_object_release(pkgd); return true; diff --git a/lib/verifysig.c b/lib/verifysig.c index 1cfe8991..5679d250 100644 --- a/lib/verifysig.c +++ b/lib/verifysig.c @@ -58,7 +58,7 @@ rsa_verify_hash(struct xbps_repo *repo, xbps_data_t pubkey, rsa = PEM_read_bio_RSA_PUBKEY(bio, NULL, NULL, NULL); if (rsa == NULL) { - xbps_dbg_printf(repo->xhp, "`%s' error reading public key: %s\n", + xbps_dbg_printf("`%s' error reading public key: %s\n", repo->uri, ERR_error_string(ERR_get_error(), NULL)); return false; } @@ -84,13 +84,13 @@ xbps_verify_signature(struct xbps_repo *repo, const char *sigfile, bool val = false; if (!xbps_dictionary_count(repo->idxmeta)) { - xbps_dbg_printf(repo->xhp, "%s: unsigned repository\n", repo->uri); + xbps_dbg_printf("%s: unsigned repository\n", repo->uri); return false; } hexfp = xbps_pubkey2fp(repo->xhp, xbps_dictionary_get(repo->idxmeta, "public-key")); if (hexfp == NULL) { - xbps_dbg_printf(repo->xhp, "%s: incomplete signed repo, missing hexfp obj\n", repo->uri); + xbps_dbg_printf("%s: incomplete signed repo, missing hexfp obj\n", repo->uri); return false; } @@ -100,7 +100,7 @@ xbps_verify_signature(struct xbps_repo *repo, const char *sigfile, rkeyfile = xbps_xasprintf("%s/keys/%s.plist", repo->xhp->metadir, hexfp); repokeyd = xbps_plist_dictionary_from_file(repo->xhp, rkeyfile); if (xbps_object_type(repokeyd) != XBPS_TYPE_DICTIONARY) { - xbps_dbg_printf(repo->xhp, "cannot read rkey data at %s: %s\n", + xbps_dbg_printf("cannot read rkey data at %s: %s\n", rkeyfile, strerror(errno)); goto out; } @@ -110,7 +110,7 @@ xbps_verify_signature(struct xbps_repo *repo, const char *sigfile, goto out; if (!xbps_mmap_file(sigfile, (void *)&sig_buf, &sigbuflen, &sigfilelen)) { - xbps_dbg_printf(repo->xhp, "can't open signature file %s: %s\n", + xbps_dbg_printf("can't open signature file %s: %s\n", sigfile, strerror(errno)); goto out; } @@ -141,7 +141,7 @@ xbps_verify_file_signature(struct xbps_repo *repo, const char *fname) bool val = false; if (!xbps_file_sha256_raw(digest, sizeof digest, fname)) { - xbps_dbg_printf(repo->xhp, "can't open file %s: %s\n", fname, strerror(errno)); + xbps_dbg_printf("can't open file %s: %s\n", fname, strerror(errno)); return false; }