Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QT6: check for old platforms #154

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 74 additions & 5 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class Response {
/** @var string */
private $version;
/** @var string */
private $osRelease;
/** @var string */
private $osVersion;
/** @var string */
private $kernelVersion;
/** @var string */
private $channel;
/** @var bool */
private $isSparkle;
Expand All @@ -41,13 +47,19 @@ class Response {
public function __construct(string $oem,
string $platform,
string $version,
string $osRelease,
string $osVersion,
string $kernelVersion,
string $channel,
bool $isSparkle,
bool $isFileProvider,
array $config) {
$this->oem = $oem;
$this->platform = $platform;
$this->version = $version;
$this->osRelease = $osRelease;
$this->osVersion = $osVersion;
$this->kernelVersion = $kernelVersion;
$this->channel = $channel;
$this->isSparkle = $isSparkle;
$this->isFileProvider = $isFileProvider;
Expand Down Expand Up @@ -86,15 +98,23 @@ private function getUpdateVersion() : array {
return [];
}

$stable = $this->config[$this->oem]['stable'][$this->platform];
$beta = $this->config[$this->oem]['beta'][$this->platform];
$daily = $this->config[$this->oem]['daily'][$this->platform];
// if outdated platform, hand out latest stable-qt5, no daily/beta possible
if ($this->checkOldPlatform()) {
$stable = $this->config[$this->oem]['stable-qt5'][$this->platform];
$beta = null;
$daily = null;
} else {
$stable = $this->config[$this->oem]['stable'][$this->platform];
$beta = $this->config[$this->oem]['beta'][$this->platform];
$daily = $this->config[$this->oem]['daily'][$this->platform];
}

if ($this->channel == 'daily' && (version_compare($this->version, $daily['version']) == -1)) {
if (isset($daily) && $this->channel == 'daily' && (version_compare($this->version, $daily['version']) == -1)) {
return $daily;
}

if ($this->channel == 'beta' && (version_compare($stable['version'], $beta['version']) == -1 || ($this->platform === 'macos' && $this->isSparkle === true))) {
if (isset($beta) && $this->channel == 'beta' && (version_compare($stable['version'], $beta['version']) == -1 ||
($this->platform === 'macos' && $this->isSparkle === true))) {
return $beta;
}

Expand All @@ -105,6 +125,55 @@ private function getUpdateVersion() : array {
return [];
}

private function checkOldPlatform(): bool {
// Outdated platforms:
// - macOS < 11
// - Win < 10
// - Win 10 (build number < 1809)
// - Win 11 (build number < 17764)
// - Ubuntu <22.04
// - openSuse <15.5
// - RHEL <9.2

// Mac < 11
if ($this->platform === "macos" && version_compare($this->osVersion, "11") == -1) {
return true;
}

// Windows <10
if ($this->platform === "win32" && version_compare($this->osVersion, "10") == -1) {
return true;
}

// Windows 10 (build number < 1809)
if ($this->platform === "win32" && version_compare($this->osVersion, "10") == 0 && version_compare($this->kernelVersion, '10.0.1809') == -1) {
return true;
}

// - Win 11 (build number < 17764)
if ($this->platform === "win32" && version_compare($this->osVersion, "11") == 0 && version_compare($this->kernelVersion, '10.0.17764') == -1) {
return true;
}

// - Ubuntu <22.04
if ($this->platform === "linux" && $this->osRelease == "ubuntu" && version_compare($this->osVersion, '22.04') == -1) {
return true;
}

// - RHEL <9.2
if ($this->platform === "linux" && $this->osRelease == "rhel" && version_compare($this->osVersion, '9.2') == -1) {
return true;
}


// - openSuse <15.5
if ($this->platform === "linux" && $this->osRelease == "opensuse-leap" && version_compare($this->osVersion, '15.5') == -1) {
return true;
}

return false;
}

/**
* Returns the current time stamp
* @return string
Expand Down
Loading
Loading