Skip to content

Commit

Permalink
Add runtime library version information to verbose pkg -vv
Browse files Browse the repository at this point in the history
With pkg using external library dependencies, exact runtime information of these libraries is needed for efficient support.

Add pkg_libversion to libpkg to report its own version.
Report libpkg, libcurl, libarchive, sqlite and openssl runtime versions in verbose show_version_info.
  • Loading branch information
Keve authored and bapt committed Nov 14, 2024
1 parent f600043 commit d3f3903
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions libpkg/pkg.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ void pkg_event_register(pkg_event_cb cb, void *data);
bool pkg_compiled_for_same_os_major(void);
int pkg_ini(const char *, const char *, pkg_init_flags);
int pkg_init(const char *, const char *);
const char *pkg_libversion(void);
int pkg_initialized(void);
void pkg_shutdown(void);

Expand Down
6 changes: 6 additions & 0 deletions libpkg/pkg_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ connect_evpipe(const char *evpipe) {

}

const char *
pkg_libversion(void)
{
return PKGVERSION;
}

int
pkg_initialized(void)
{
Expand Down
11 changes: 11 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
#include <pkg.h>
#include <tllist.h>
#include <xmalloc.h>
#include <curl/curl.h>

#include <archive.h>
#include <sqlite3.h>
#include <openssl/crypto.h>

#include "pkgcli.h"

Expand Down Expand Up @@ -374,6 +379,12 @@ show_version_info(int version)
if (version == 1)
exit(EXIT_SUCCESS);

printf("%-24s: %s\n", "libpkg", pkg_libversion());
printf("%-24s: %s\n", "libcurl", curl_version());
printf("%-24s: %s\n", "libarchive", archive_version_string());
printf("%-24s: %s\n", "sqlite", sqlite3_libversion());
printf("%-24s: %s\n", "openssl", OpenSSL_version(OPENSSL_VERSION));

config = pkg_config_dump();
printf("%s\n", config);
free(config);
Expand Down

0 comments on commit d3f3903

Please sign in to comment.