0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd: Apply uniform info::versions for all dependency version identification.

This commit is contained in:
Jason Volk 2019-05-31 16:06:55 -07:00
parent 7d4de7ec82
commit eb73595c50
17 changed files with 247 additions and 218 deletions

View file

@ -28,13 +28,8 @@ namespace ircd::db
// db subsystem has its own logging facility
extern struct log::log log;
// Version information from rocksdb headers (when building ircd).
extern const uint version[3];
extern const string_view version_str;
// Version of the RocksDB shared library (when running ircd).
extern const uint abi_version[3];
extern const string_view abi_version_str;
// Version information from rocksdb headers and library
extern const info::versions version_api, version_abi;
// Supported compressions (detected when running ircd)
extern std::array<std::string, 16> compressions;

View file

@ -52,17 +52,17 @@ namespace ircd::info
extern const size_t rlimit_nofile;
extern const size_t rlimit_rttime;
// Host information
// Host & third-party information
#ifdef HAVE_SYS_UTSNAME_H
extern const ::utsname utsname;
#endif
extern const string_view kname;
extern const string_view kversion_str;
extern const int kversion[3];
// Third-party information
extern const int glibc_version[3];
extern const string_view glibc_version_str;
extern const string_view kernel_name;
extern const string_view kernel_release;
extern const versions kernel_version;
extern const versions glibc_version_api;
extern const versions glibc_version_abi;
// Primary information
extern const string_view name;

View file

@ -29,8 +29,7 @@ namespace ircd
{
namespace asio = boost::asio; ///< Alias so that asio:: can be used.
extern const uint boost_version[3];
extern const string_view boost_version_str;
extern const info::versions boost_version_api, boost_version_abi;
}
namespace ircd::ios

View file

@ -22,7 +22,7 @@ namespace ircd::magick
struct thumbnail;
struct thumbcrop;
std::tuple<ulong, string_view> version();
extern const info::versions version_api, version_abi;
}
/// Composite thumbnailer to resize close to the requested dimension but

View file

@ -24,7 +24,7 @@ namespace ircd::magic
string_view extensions(const mutable_buffer &out, const const_buffer &);
string_view description(const mutable_buffer &out, const const_buffer &);
int version();
extern const info::versions version_api, version_abi;
}
struct ircd::magic::init

View file

@ -18,7 +18,7 @@ namespace ircd::nacl
struct init;
string_view version();
extern const info::versions version_api, version_abi;
}
struct ircd::nacl::init

View file

@ -55,9 +55,6 @@ namespace ircd::openssl
using EC_KEY = ::ec_key_st;
using DH = ::dh_st;
// Header version; library version
std::pair<string_view, string_view> version();
// Observers
string_view error_string(const mutable_buffer &buf, const ulong &);
ulong peek_error();
@ -141,6 +138,9 @@ namespace ircd::openssl
// SNI suite
string_view server_name(const SSL &); // provided by client
void server_name(SSL &, const string_view &); // set by client
// Header version; library version
extern const info::versions version_api, version_abi;
}
/// OpenSSL BIO convenience utils and wraps; also secure file IO closures

View file

@ -92,47 +92,30 @@ namespace ircd::db
static void init_directory();
}
decltype(ircd::db::version)
ircd::db::version
decltype(ircd::db::version_api)
ircd::db::version_api
{
ROCKSDB_MAJOR,
ROCKSDB_MINOR,
ROCKSDB_PATCH
"RocksDB", info::versions::API, 0,
{
ROCKSDB_MAJOR, ROCKSDB_MINOR, ROCKSDB_PATCH,
},
// version string generator
[](auto &version, const auto &buf)
{
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
version[0],
version[1],
version[2]);
}
};
char ircd_db_version_str_buf[64];
decltype(ircd::db::version_str)
ircd::db::version_str
(
ircd_db_version_str_buf,
::snprintf(ircd_db_version_str_buf, sizeof(ircd_db_version_str_buf),
"%u.%u.%u",
version[0],
version[1],
version[2])
);
decltype(ircd::db::abi_version)
ircd::db::abi_version
decltype(ircd::db::version_abi)
ircd::db::version_abi
{
//TODO: Get lib version.
0,
0,
0,
"RocksDB", info::versions::ABI, 0, {0}, "<unknown>" //TODO: get this
};
char ircd_db_abi_version_str_buf[64];
decltype(ircd::db::abi_version_str)
ircd::db::abi_version_str
(
ircd_db_abi_version_str_buf,
::snprintf(ircd_db_abi_version_str_buf, sizeof(ircd_db_abi_version_str_buf),
"%u.%u.%u",
abi_version[0],
abi_version[1],
abi_version[2])
);
//
// init::init
//

View file

@ -37,8 +37,8 @@ decltype(ircd::fs::support_pwritev2)
ircd::fs::support_pwritev2
{
#if defined(HAVE_PWRITEV2)
info::kversion[0] >= 4 &&
info::kversion[1] >= 6
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 6
#else
false
#endif
@ -48,8 +48,8 @@ decltype(ircd::fs::support_sync)
ircd::fs::support_sync
{
#if defined(HAVE_PWRITEV2) && defined(RWF_SYNC)
info::kversion[0] >= 4 &&
info::kversion[1] >= 7
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 7
#else
false
#endif
@ -59,8 +59,8 @@ decltype(ircd::fs::support_dsync)
ircd::fs::support_dsync
{
#if defined(HAVE_PWRITEV2) && defined(RWF_DSYNC)
info::kversion[0] >= 4 &&
info::kversion[1] >= 7
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 7
#else
false
#endif
@ -70,8 +70,8 @@ decltype(ircd::fs::support_hipri)
ircd::fs::support_hipri
{
#if defined(HAVE_PWRITEV2) && defined(RWF_HIPRI)
info::kversion[0] >= 4 &&
info::kversion[1] >= 6
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 6
#else
false
#endif
@ -81,8 +81,8 @@ decltype(ircd::fs::support_nowait)
ircd::fs::support_nowait
{
#if defined(HAVE_PWRITEV2) && defined(RWF_NOWAIT)
info::kversion[0] >= 4 &&
info::kversion[1] >= 14
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 14
#else
false
#endif
@ -92,8 +92,8 @@ decltype(ircd::fs::support_append)
ircd::fs::support_append
{
#if defined(HAVE_PWRITEV2) && defined(RWF_APPEND)
info::kversion[0] >= 4 &&
info::kversion[1] >= 16
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 16
#else
false
#endif
@ -103,8 +103,8 @@ decltype(ircd::fs::support_rwh_write_life)
ircd::fs::support_rwh_write_life
{
#if defined(HAVE_FCNTL_H) && defined(F_SET_FILE_RW_HINT)
info::kversion[0] >= 4 &&
info::kversion[1] >= 13
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 13
#else
false
#endif
@ -1024,9 +1024,9 @@ ircd::fs::ircd_fs_append__resolve()
{
log, support_append? log::DEBUG : log::DWARNING,
"This host '%s %s' %s the RWF_APPEND flag to pwritev2(2).",
info::kname,
info::kversion_str,
support_append? "SUPPORTS"_sv : "DOES NOT SUPPORT"_sv
info::kernel_name,
string_view{info::kernel_version},
support_append? "SUPPORTS"_sv : "DOES NOT SUPPORT"_sv,
};
return support_append? _append__rwf : _append__no_rwf;
@ -1202,8 +1202,8 @@ ircd::fs::ircd_fs_write_pwritev__resolve()
{
log, support_pwritev2? log::DEBUG : log::DWARNING,
"This host '%s %s' %s the pwritev2(2) system call.",
info::kname,
info::kversion_str,
info::kernel_name,
string_view{info::kernel_version},
support_pwritev2? "SUPPORTS"_sv : "DOES NOT SUPPORT"_sv
};
@ -1432,16 +1432,16 @@ decltype(ircd::fs::aio::support_fsync)
extern __attribute__((weak))
ircd::fs::aio::support_fsync
{
info::kversion[0] >= 4 &&
info::kversion[1] >= 18
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 18
};
decltype(ircd::fs::aio::support_fdsync)
extern __attribute__((weak))
ircd::fs::aio::support_fdsync
{
info::kversion[0] >= 4 &&
info::kversion[1] >= 18
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 18
};
decltype(ircd::fs::aio::MAX_EVENTS)

View file

@ -33,8 +33,8 @@ ircd::fs::aio::support
decltype(ircd::fs::aio::support_fsync)
ircd::fs::aio::support_fsync
{
info::kversion[0] >= 4 &&
info::kversion[1] >= 18
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 18
};
/// True if IOCB_CMD_FDSYNC is supported by AIO. If this is false then
@ -42,8 +42,8 @@ ircd::fs::aio::support_fsync
decltype(ircd::fs::aio::support_fdsync)
ircd::fs::aio::support_fdsync
{
info::kversion[0] >= 4 &&
info::kversion[1] >= 18
info::kernel_version[0] >= 4 &&
info::kernel_version[1] >= 18
};
decltype(ircd::fs::aio::MAX_EVENTS)

View file

@ -45,19 +45,28 @@ ircd::info::dump()
RB_DEBUG_LEVEL? "(DEBUG MODE)" : ""
};
// This message flashes information about our dependencies which are being
// assumed for this execution.
// This message flashes information about our API dependencies from compile time.
log::info
{
"%s. glibc %s. boost %s. RocksDB %s. SpiderMonkey %s. sodium %s. %s. libmagic %d.",
PACKAGE_STRING,
glibc_version_str,
boost_version_str,
db::version_str,
js::version(js::ver::IMPLEMENTATION),
nacl::version(),
openssl::version().second,
magic::version()
"API: glibc %s. boost %s. RocksDB %s. sodium %s. %s. magic %ld.",
string_view{glibc_version_api},
string_view{boost_version_api},
string_view{db::version_api},
string_view{nacl::version_api},
string_view{openssl::version_api},
long(magic::version_api),
};
// This message flashes information about our ABI dependencies on this system.
log::debug
{
"ABI: glibc %s. boost %s. RocksDB %s. sodium %s. %s. magic %ld.",
string_view{glibc_version_abi},
string_view{boost_version_abi},
string_view{db::version_abi},
string_view{nacl::version_abi},
string_view{openssl::version_abi},
long(magic::version_abi),
};
// This message flashes posix information about the system and platform IRCd
@ -226,26 +235,6 @@ ircd_name
// Third party dependency information
//
decltype(ircd::info::glibc_version)
ircd::info::glibc_version
{
__GNU_LIBRARY__,
__GLIBC__,
__GLIBC_MINOR__,
};
char ircd_info_glibc_version_str_buf[32];
decltype(ircd::info::glibc_version_str)
ircd::info::glibc_version_str
(
ircd_info_glibc_version_str_buf,
::snprintf(ircd_info_glibc_version_str_buf, sizeof(ircd_info_glibc_version_str_buf),
"%d.%d.%d",
glibc_version[0],
glibc_version[1],
glibc_version[2])
);
//
// Host information
//
@ -260,44 +249,77 @@ ircd::info::utsname{[]
}()};
#endif
decltype(ircd::info::kname)
ircd::info::kname
// kernel
decltype(ircd::info::kernel_name)
ircd::info::kernel_name
{
#ifdef HAVE_SYS_UTSNAME_H
utsname.sysname
#endif
};
decltype(ircd::info::kversion_str)
ircd::info::kversion_str
decltype(ircd::info::kernel_release)
ircd::info::kernel_release
{
#ifdef HAVE_SYS_UTSNAME_H
utsname.release
#endif
};
decltype(ircd::info::kversion)
ircd::info::kversion
decltype(ircd::info::kernel_version)
ircd::info::kernel_version
{
[] // major
"kernel", versions::ABI, 0,
{
const auto str(split(kversion_str, '.').first);
return try_lex_cast<int>(str)?
lex_cast<int>(str):
0;
}(),
[] // major
{
const auto str(split(kernel_release, '.').first);
return try_lex_cast<int>(str)?
lex_cast<int>(str):
0;
}(),
[] // minor
[] // minor
{
auto str(split(kernel_release, '.').second);
str = split(str, '.').first;
return try_lex_cast<int>(str)?
lex_cast<int>(str):
0;
}(),
0 // patch
},
utsname.release
};
// libc
decltype(ircd::info::glibc_version_api)
ircd::info::glibc_version_api
{
"glibc", versions::API, 0,
{
auto str(split(kversion_str, '.').second);
str = split(str, '.').first;
return try_lex_cast<int>(str)?
lex_cast<int>(str):
0;
}(),
__GNU_LIBRARY__,
__GLIBC__,
__GLIBC_MINOR__,
},
// patch
0
[](auto &that, const auto &buf)
{
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
that.semantic[0],
that.semantic[1],
that.semantic[2]);
}
};
decltype(ircd::info::glibc_version_abi)
ircd::info::glibc_version_abi
{
"glibc", versions::ABI, 0, {0}, "<unknown>" //TODO: get this.
};
//

View file

@ -10,27 +10,6 @@
#include <ircd/asio.h>
/// Boost version indicator for compiled header files.
decltype(ircd::boost_version)
ircd::boost_version
{
BOOST_VERSION / 100000,
BOOST_VERSION / 100 % 1000,
BOOST_VERSION % 100,
};
char ircd_boost_version_str_buf[32];
decltype(ircd::boost_version_str)
ircd::boost_version_str
(
ircd_boost_version_str_buf,
::snprintf(ircd_boost_version_str_buf, sizeof(ircd_boost_version_str_buf),
"%u.%u.%u",
boost_version[0],
boost_version[1],
boost_version[2])
);
/// Record of the ID of the thread static initialization took place on.
decltype(ircd::ios::static_thread_id)
ircd::ios::static_thread_id
@ -45,6 +24,36 @@ ircd::ios::main_thread_id;
decltype(ircd::ios::user)
ircd::ios::user;
decltype(ircd::boost_version_api)
ircd::boost_version_api
{
"boost", info::versions::API, BOOST_VERSION,
{
BOOST_VERSION / 100000,
BOOST_VERSION / 100 % 1000,
BOOST_VERSION % 100,
},
// Version string generator since boost doesn't provide any strings.
[](auto &version, const auto &buf)
{
::snprintf(data(buf), size(buf), "%ld.%ld.%ld",
version[0],
version[1],
version[2]);
}
};
decltype(ircd::boost_version_abi)
ircd::boost_version_abi
{
"boost", info::versions::ABI, 0, {0}, "<unknown>" //TODO: get this
};
//
// init
//
void
ircd::ios::init(asio::io_context &user)
{

View file

@ -26,6 +26,18 @@ namespace ircd::magic
static void version_check();
}
decltype(ircd::magic::version_api)
ircd::magic::version_api
{
"magic", info::versions::API, MAGIC_VERSION
};
decltype(ircd::magic::version_abi)
ircd::magic::version_abi
{
"magic", info::versions::ABI, ::magic_version()
};
ircd::magic::init::init()
{
version_check();
@ -158,22 +170,16 @@ ircd::magic::throw_on_error(const magic_t &cookie)
assert(magic_errno(cookie) == 0);
}
int
ircd::magic::version()
{
return ::magic_version();
}
void
ircd::magic::version_check()
{
if(likely(MAGIC_VERSION == version()))
if(likely(MAGIC_VERSION == ::magic_version()))
return;
log::warning
{
"Linked libmagic version %d is not the compiled magic.h version %d.\n",
version(),
::magic_version(),
MAGIC_VERSION
};
}

View file

@ -48,6 +48,18 @@ namespace ircd::openssl
// openssl.h
//
decltype(ircd::openssl::version_api)
ircd::openssl::version_api
{
"OpenSSL", info::versions::API, OPENSSL_VERSION_NUMBER, {0}, OPENSSL_VERSION_TEXT
};
decltype(ircd::openssl::version_abi)
ircd::openssl::version_abi
{
"OpenSSL", info::versions::ABI, long(::SSLeay()), {0}, ::SSLeay_version(SSLEAY_VERSION)
};
//
// SNI
//
@ -1245,15 +1257,6 @@ ircd::openssl::error_string(const mutable_buffer &buf,
return { data(buf), strnlen(data(buf), size(buf)) };
}
std::pair<ircd::string_view, ircd::string_view>
ircd::openssl::version()
{
return
{
OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)
};
}
//
// bio
//
@ -1601,13 +1604,12 @@ const
ircd::openssl::init::init()
{
const auto v(version());
if(v.first != v.second)
if(long(version_api) != long(version_abi))
log::warning
{
"Linked OpenSSL version '%s' is not the compiled OpenSSL version '%s'",
v.first,
v.second
string_view{version_api},
string_view{version_abi},
};
OPENSSL_init();

View file

@ -29,11 +29,33 @@ struct throw_on_error
// ircd/nacl.h
//
ircd::string_view
ircd::nacl::version()
decltype(ircd::nacl::version_api)
ircd::nacl::version_api
{
return ::sodium_version_string();
}
"sodium", info::versions::API, 0,
{
SODIUM_LIBRARY_VERSION_MAJOR,
SODIUM_LIBRARY_VERSION_MINOR,
0
},
SODIUM_VERSION_STRING,
};
decltype(ircd::nacl::version_abi)
ircd::nacl::version_abi
{
"sodium", info::versions::ABI, 0,
{
::sodium_library_version_major(),
::sodium_library_version_minor(),
0
},
::sodium_version_string(),
};
//
// init
//
ircd::nacl::init::init()
{

View file

@ -643,16 +643,6 @@ console_cmd__version(opt &out, const string_view &line)
out << "info::server_agent " << info::server_agent << std::endl;
out << std::endl;
out << "info::kname " << info::kname << std::endl;
out << "info::kversion_str " << info::kversion_str << std::endl;
out << "info::glibc_version_str " << info::glibc_version_str << std::endl;
out << "ircd::boost_version_str " << ircd::boost_version_str << std::endl;
out << "db::version_str " << db::version_str << std::endl;
out << "nacl::version " << nacl::version() << std::endl;
out << "openssl::version " << openssl::version().second << std::endl;
out << "magic::version " << magic::version() << std::endl;
out << std::endl;
out << "VERSION " << VERSION << std::endl;
out << std::endl;

View file

@ -80,6 +80,24 @@ ircd::magick::yield_interval
{ "default", 768L },
};
decltype(ircd::magick::version_api)
ircd::magick::version_api
{
"magick", info::versions::API, MagickLibVersion, {0}, MagickLibVersionText
};
decltype(ircd::magick::version_abi)
ircd::magick::version_abi
{
"magick", info::versions::ABI, 0, {0}, []
(auto &version, const auto &buf)
{
ulong monotonic(0);
strlcpy(buf, ::GetMagickVersion(&monotonic));
version.monotonic = monotonic;
}
};
//
// init
//
@ -87,26 +105,21 @@ ircd::magick::yield_interval
void
ircd::magick::init()
{
const auto version
log::info
{
magick::version()
log, "Initializing Magick Library version API:%lu [%s] ABI:%lu [%s]",
long(version_api),
string_view{version_api},
long(version_abi),
string_view{version_abi},
};
log::debug
{
log, "Initializing Magick Library version inc:%lu [%s] lib:%lu [%s]",
ulong(MagickLibVersion),
MagickLibVersionText,
std::get<0>(version),
std::get<1>(version),
};
if(std::get<0>(version) != ulong(MagickLibVersion))
if(long(version_api) != long(version_abi))
log::warning
{
log, "Magick Library version mismatch headers:%lu library:%lu",
ulong(MagickLibVersion),
std::get<0>(version),
long(version_api),
long(version_abi),
};
::MagickAllocFunctions(handle_free, handle_malloc, handle_realloc);
@ -144,18 +157,6 @@ ircd::magick::fini()
::DestroyMagick();
}
std::tuple<ulong, ircd::string_view>
ircd::magick::version()
{
ulong number(0);
const char *const string
{
::GetMagickVersion(&number)
};
return { number, string };
}
//
// thumbcrop
//