2021-08-29 09:54:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2023-02-28 15:39:41 +00:00
|
|
|
#include <AK/String.h>
|
2021-08-29 09:54:59 +00:00
|
|
|
#include <LibCore/Version.h>
|
|
|
|
|
2023-09-16 18:30:04 +00:00
|
|
|
#ifdef AK_OS_SERENITY
|
|
|
|
# include <sys/utsname.h>
|
|
|
|
#endif
|
|
|
|
|
2021-08-29 09:54:59 +00:00
|
|
|
namespace Core::Version {
|
|
|
|
|
2023-02-28 15:39:41 +00:00
|
|
|
ErrorOr<String> read_long_version_string()
|
2021-08-29 09:54:59 +00:00
|
|
|
{
|
2023-08-19 22:31:07 +00:00
|
|
|
#ifdef AK_OS_SERENITY
|
2023-09-16 18:30:04 +00:00
|
|
|
struct utsname uts;
|
|
|
|
int rc = uname(&uts);
|
|
|
|
if ((rc) < 0) {
|
|
|
|
return Error::from_syscall("uname"sv, rc);
|
|
|
|
}
|
|
|
|
auto const* version = uts.release;
|
|
|
|
auto const* git_hash = uts.version;
|
2022-08-30 10:47:44 +00:00
|
|
|
|
2023-02-28 15:39:41 +00:00
|
|
|
return String::formatted("Version {} revision {}", version, git_hash);
|
2023-08-19 22:31:07 +00:00
|
|
|
#else
|
2024-02-07 17:53:38 +00:00
|
|
|
return "Version 1.0"_string;
|
2023-08-19 22:31:07 +00:00
|
|
|
#endif
|
2021-08-29 09:54:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|