Skip to content

Commit

Permalink
Deprecate Linux versions with glibc version < 2.23.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 2, 2020
1 parent 57d7fa7 commit 2f9ae12
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/platform/base_platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ class QDate;

namespace Platform {

enum class OutdateReason {
IsOld,
Is32Bit,
};

[[nodiscard]] QString DeviceModelPretty();
[[nodiscard]] QString SystemVersionPretty();
[[nodiscard]] QString SystemCountry();
[[nodiscard]] QString SystemLanguage();
[[nodiscard]] QDate WhenSystemBecomesOutdated();
[[nodiscard]] OutdateReason WhySystemBecomesOutdated();
[[nodiscard]] int AutoUpdateVersion();
[[nodiscard]] QString AutoUpdateKey();

Expand Down Expand Up @@ -45,6 +51,7 @@ namespace Platform {
[[nodiscard]] constexpr bool IsLinux();
[[nodiscard]] constexpr bool IsLinux32Bit();
[[nodiscard]] constexpr bool IsLinux64Bit();
[[nodiscard]] QString GetGlibCVersion();

void Start(QJsonObject settings);
void Finish();
Expand Down
26 changes: 26 additions & 0 deletions base/platform/linux/base_info_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QtCore/QProcess>
#include <QtCore/QVersionNumber>
#include <QtCore/QDate>
#include <gnu/libc-version.h>

This comment has been minimized.

Copy link
@maxice8

maxice8 Jun 3, 2020

This breaks musl


namespace Platform {
namespace {
Expand Down Expand Up @@ -51,6 +52,15 @@ void FallbackFontConfig(
}
}

const std::optional<QVersionNumber> &GetLibCVersion() {
static const auto result = [&] {
const auto version = gnu_get_libc_version(); // #TODO log
const auto parsed = QVersionNumber::fromString(version);
return parsed.isNull() ? std::nullopt : std::make_optional(parsed);
}();
return result;
}

} // namespace

QString DeviceModelPretty() {
Expand Down Expand Up @@ -83,10 +93,18 @@ QString SystemLanguage() {
QDate WhenSystemBecomesOutdated() {
if (IsLinux32Bit()) {
return QDate(2020, 9, 1);
} else if (const auto version = GetGlibCVersion(); !version.isEmpty()) {
if (QVersionNumber::fromString(version) < QVersionNumber(2, 23)) {
return QDate(2020, 9, 1); // Older than Ubuntu 16.04.
}
}
return QDate();
}

OutdateReason WhySystemBecomesOutdated() {
return IsLinux32Bit() ? OutdateReason::Is32Bit : OutdateReason::IsOld;
}

int AutoUpdateVersion() {
return 2;
}
Expand All @@ -101,6 +119,14 @@ QString AutoUpdateKey() {
}
}

QString GetGlibCVersion() {
static const auto result = [&] {
const auto version = QString::fromLatin1(gnu_get_libc_version());
return QVersionNumber::fromString(version).isNull() ? QString() : version;
}();
return result;
}

void Start(QJsonObject options) {
const auto from = options.value("custom_font_config_src").toString();
const auto to = options.value("custom_font_config_dst").toString();
Expand Down
5 changes: 5 additions & 0 deletions base/platform/mac/base_info_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

namespace Platform {

inline OutdateReason WhySystemBecomesOutdated() {
return OutdateReason::IsOld;
}

inline constexpr bool IsMac() {
return true;
}
Expand Down Expand Up @@ -41,5 +45,6 @@ inline bool IsWindows10OrGreater() { return false; }
inline constexpr bool IsLinux() { return false; }
inline constexpr bool IsLinux32Bit() { return false; }
inline constexpr bool IsLinux64Bit() { return false; }
inline QString GetGlibCVersion() { return QString(); }

} // namespace Platform
5 changes: 5 additions & 0 deletions base/platform/win/base_info_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

namespace Platform {

inline OutdateReason WhySystemBecomesOutdated() {
return OutdateReason::IsOld;
}

inline constexpr bool IsWindows() {
return true;
}
Expand Down Expand Up @@ -37,5 +41,6 @@ inline bool IsMac10_14OrGreater() { return false; }
inline constexpr bool IsLinux() { return false; }
inline constexpr bool IsLinux32Bit() { return false; }
inline constexpr bool IsLinux64Bit() { return false; }
inline QString GetGlibCVersion() { return QString(); }

} // namespace Platform

0 comments on commit 2f9ae12

Please sign in to comment.