From 4be94bbfd9b43bce259df0c0068847fb8b082e16 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 13 Aug 2024 11:48:33 +0200 Subject: [PATCH] QT6: check for old platforms Signed-off-by: tobiasKaminsky --- src/Response.php | 79 +++++++- tests/unit/ResponseTest.php | 378 +++++++++++++++++++++++++++++++++--- 2 files changed, 427 insertions(+), 30 deletions(-) diff --git a/src/Response.php b/src/Response.php index b1fbfb2..0743dfe 100644 --- a/src/Response.php +++ b/src/Response.php @@ -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; @@ -41,6 +47,9 @@ class Response { public function __construct(string $oem, string $platform, string $version, + string $osRelease, + string $osVersion, + string $kernelVersion, string $channel, bool $isSparkle, bool $isFileProvider, @@ -48,6 +57,9 @@ public function __construct(string $oem, $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; @@ -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; } @@ -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 diff --git a/tests/unit/ResponseTest.php b/tests/unit/ResponseTest.php index 715bd0b..1f532d2 100644 --- a/tests/unit/ResponseTest.php +++ b/tests/unit/ResponseTest.php @@ -29,6 +29,28 @@ public function updateDataProvider(): array { $config = [ 'nextcloud' => [ + 'stable-qt5' => [ + 'release' => '2019-01-01 01:01', + 'linux' => [ + 'version' => '2.0.0', + 'versionstring' => 'Nextcloud Client 2.0.0', + 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0-x64.AppImage', + 'web' => 'https://nextcloud.com/install/#install-clients', + ], + 'win32' => [ + 'version' => '2.0.0.0000', + 'versionstring' => 'Nextcloud Client 2.0.0 (build 0000)', + 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000-setup.exe', + ], + 'macos' => [ + 'version' => '2.0.0.0000', + 'versionstring' => 'Nextcloud Client 2.0.0 (build 0000)', + 'downloadurl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000.pkg', + 'sparkleDownloadUrl' => 'https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000.pkg.tbz', + 'signature' => 'MC0CFQDmXR6biDmNVW7TvMh0bfPPTzCvtwIUCzASgpzYdi4lltOnwbFCeQwgDjY=', + 'length' => 62738920, + ] + ], 'stable' => [ 'release' => '2019-02-24 17:05', 'linux' => [ @@ -106,6 +128,9 @@ public function updateDataProvider(): array 'nextcloud', 'win32', '1.9.0', + '', + "11", + "10.0.26080", 'stable', false, false, @@ -114,11 +139,14 @@ public function updateDataProvider(): array 2.2.2.6192Nextcloud Client 2.2.2 (build 6192)https://download.nextcloud.com/desktop/stable/ownCloud-2.2.2.6192-setup.exe ' ], - // #2 Updates for client available + // #1 Updates for client available [ 'nextcloud', 'win32', '1.9.0', + '', + "11", + "10.0.26080", 'stable', false, false, @@ -127,11 +155,14 @@ public function updateDataProvider(): array 2.2.2.6192Nextcloud Client 2.2.2 (build 6192)https://download.nextcloud.com/desktop/stable/ownCloud-2.2.2.6192-setup.exe ' ], - // #3 + // #2 [ 'nextcloud', 'win32', '1.9.0', + '', + "11", + "10.0.26080", 'stable', true, false, @@ -140,11 +171,14 @@ public function updateDataProvider(): array 2.2.2.6192Nextcloud Client 2.2.2 (build 6192)https://download.nextcloud.com/desktop/stable/ownCloud-2.2.2.6192-setup.exe ' ], - // #4 + // #3 [ 'nextcloud', 'linux', '1.9.0', + '', + 'rhel', + '9.3', 'stable', false, false, @@ -153,11 +187,14 @@ public function updateDataProvider(): array 2.2.2Nextcloud Client 2.2.2https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.2-x64.AppImagehttps://nextcloud.com/install/#install-clients ' ], - // #5 + // #4 [ 'nextcloud', 'macos', '1.9.0', + '', + '12.4', + '21.04.00', 'stable', false, false, @@ -166,11 +203,14 @@ public function updateDataProvider(): array 2.2.2.3472Nextcloud Client 2.2.2 (build 3472)https://download.owncloud.com/desktop/stable/ownCloud-2.2.2.3472.pkghttps://download.owncloud.com/desktop/stable/ownCloud-2.2.2.3472.pkg.tbzMC0CFQDmXR6biDmNVW7TvMh0bfPPTzCvtwIUCzASgpzYdi4lltOnwbFCeQwgDjY=62738920 ' ], - // #6 + // #5 [ 'nextcloud', 'macos', '1.9.0', + '', + "12", + "21.0.1", 'stable', true, false, @@ -190,11 +230,14 @@ public function updateDataProvider(): array ' ], - // #7 stable -> beta version + // #6 stable -> beta version [ 'nextcloud', 'win32', '1.9.0', + '', + "11", + "10.0.26080", 'beta', false, false, @@ -203,11 +246,14 @@ public function updateDataProvider(): array 2.2.3-rc3Nextcloud Client 2.2.3-rc3https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.3-rc3-x86.msihttps://nextcloud.com/install/#install-clients ' ], - // #8 older beta -> newer beta version + // #7 older beta -> newer beta version [ 'nextcloud', 'win32', '2.2.3-rc1', + '', + "11", + "10.0.26080", 'beta', false, false, @@ -216,11 +262,14 @@ public function updateDataProvider(): array 2.2.3-rc3Nextcloud Client 2.2.3-rc3https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.3-rc3-x86.msihttps://nextcloud.com/install/#install-clients ' ], - // #9 older beta, but newer stable -> update + // #8 older beta, but newer stable -> update [ 'nextcloud', 'linux', '2.2.2-rc1', + '', + 'rhel', + '9.3', 'beta', false, false, @@ -229,11 +278,14 @@ public function updateDataProvider(): array 2.2.2Nextcloud Client 2.2.2https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.2-x64.AppImagehttps://nextcloud.com/install/#install-clients ' ], - // #10 Updates for not existing entries + // #9 Updates for not existing entries [ 'randomOem', 'macos', '1.9.0', + '', + "12", + "21.0.1", 'stable', false, false, @@ -242,11 +294,14 @@ public function updateDataProvider(): array ' ], - // #11 + // #10 [ 'nextcloud', 'randomOs', '1.9.0', + '', + 'unknown', + '???', 'stable', false, false, @@ -255,11 +310,14 @@ public function updateDataProvider(): array ' ], - // #12 No updates if the version is the same + // #11 No updates if the version is the same [ 'nextcloud', 'win32', '2.2.2.6192', + '', + "11", + "10.0.26080", 'stable', false, false, @@ -268,11 +326,14 @@ public function updateDataProvider(): array ' ], - // #13 + // #12 [ 'nextcloud', 'win32', '2.2.6192', + '', + "11", + "10.0.26080", 'stable', true, false, @@ -281,11 +342,14 @@ public function updateDataProvider(): array ' ], - // #14 + // #13 [ 'nextcloud', 'linux', '2.2.2', + '', + 'rhel', + '9.3', 'stable', false, false, @@ -294,11 +358,14 @@ public function updateDataProvider(): array ' ], - // #15 + // #14 [ 'nextcloud', 'macos', '2.2.2.3472', + '', + '12.4', + '21.04.00', 'stable', false, false, @@ -307,11 +374,14 @@ public function updateDataProvider(): array ' ], - // #16 Except for Sparkle, which always needs to know what the latest version is + // #15 Except for Sparkle, which always needs to know what the latest version is [ 'nextcloud', 'macos', '2.2.2.3472', + '', + '12.4', + '21.04.00', 'stable', true, false, @@ -331,11 +401,14 @@ public function updateDataProvider(): array ' ], - // #17 No updates if the version is higher + // #16 No updates if the version is higher [ 'nextcloud', 'win32', '2.3', + '', + "11", + "10.0.26080", 'stable', false, false, @@ -344,11 +417,14 @@ public function updateDataProvider(): array ' ], - // #18 + // #17 [ 'nextcloud', 'win32', '2.3', + '', + "11", + "10.0.26080", 'stable', true, false, @@ -357,11 +433,14 @@ public function updateDataProvider(): array ' ], - // #19 + // #18 [ 'nextcloud', 'linux', '2.3', + '', + 'rhel', + '9.3', 'stable', false, false, @@ -370,11 +449,14 @@ public function updateDataProvider(): array ' ], - // #20 + // #19 [ 'nextcloud', 'macos', '2.3', + '', + '12.4', + '21.04.00', 'stable', false, false, @@ -383,11 +465,14 @@ public function updateDataProvider(): array ' ], - // #21 Again, Sparkle needs to know about the latest version + // #20 Again, Sparkle needs to know about the latest version [ 'nextcloud', 'macos', '2.3', + '', + '11.0', + '21.04.00', 'stable', true, false, @@ -407,11 +492,14 @@ public function updateDataProvider(): array ' ], - // #22 Sparkle on, always needs to know what the latest version is + // #21 Sparkle on, always needs to know what the latest version is [ 'nextcloud', 'macos', '2.2.2-rc2', + '', + '12.4', + '21.04.00', 'beta', true, false, @@ -431,11 +519,14 @@ public function updateDataProvider(): array ' ], - // #23 Sparkle on, always needs to know what the latest version is + // #22 Sparkle on, always needs to know what the latest version is [ 'nextcloud', 'macos', '2.2.2', + '', + '12.4', + '21.04.00', 'beta', true, false, @@ -455,17 +546,239 @@ public function updateDataProvider(): array ' ], - // #24 daily + // #23 daily [ 'nextcloud', 'linux', '20240601', + '', + 'debian', + '20', 'daily', false, false, $config, ' 20240604Nextcloud Daily 20240604https://download.nextcloud.com/desktop/daily/linux/linux-20240604.AppImagehttps://nextcloud.com/install/#install-clients +' + ], + // #24 Win7 -> QT5 + [ + 'nextcloud', + 'win32', + '1.9.0', + '', + "7", + "06.01.00", + 'stable', + true, + false, + $config, + ' +2.0.0.0000Nextcloud Client 2.0.0 (build 0000)https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000-setup.exe +' + ], + // #25 Win10 -> QT5 + [ + 'nextcloud', + 'win32', + '1.9.0', + '', + "10", + "10.0.1800", + 'stable', + true, + false, + $config, + ' +2.0.0.0000Nextcloud Client 2.0.0 (build 0000)https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000-setup.exe +' + ], + // #26 Win10 -> QT6 + [ + 'nextcloud', + 'win32', + '1.9.0', + '', + "10", + "10.0.26080", + 'stable', + true, + false, + $config, + ' +2.2.2.6192Nextcloud Client 2.2.2 (build 6192)https://download.nextcloud.com/desktop/stable/ownCloud-2.2.2.6192-setup.exe +' + ], + // #27 Win11 -> QT6 + [ + 'nextcloud', + 'win32', + '1.9.0', + '', + "11", + "10.0.22622", + 'stable', + true, + false, + $config, + ' +2.2.2.6192Nextcloud Client 2.2.2 (build 6192)https://download.nextcloud.com/desktop/stable/ownCloud-2.2.2.6192-setup.exe +' + ], + // #28 stable-qt5 -> old beta -> latest qt5 stable + [ + 'nextcloud', + 'win32', + '1.9.0', + '', + "10", + '10.0.1500', + 'beta', + false, + false, + $config, + ' +2.0.0.0000Nextcloud Client 2.0.0 (build 0000)https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000-setup.exe +' + ], + // #29 MAC QT5 + [ + 'nextcloud', + 'macos', + '1.9.0', + '', + "10.16", + "21.0.1.00", + 'stable', + true, + false, + $config, + ' + + + Download Channel + Most recent changes with links to updates. + en + + Nextcloud Client 2.0.0 (build 0000) + Wed, 13 July 16 21:07:31 +0200 + + 11.0 + + +' + ], + // #30 old Win11 -> QT5 + [ + 'nextcloud', + 'win32', + '1.9.0', + '', + "11", + "10.0.17700", + 'stable', + true, + false, + $config, + ' +2.0.0.0000Nextcloud Client 2.0.0 (build 0000)https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0.0000-setup.exe +' + ], + // #31 old Ubuntu + [ + 'nextcloud', + 'linux', + '1.9.0', + 'ubuntu', + '22.00', + '5.5.0', + 'stable', + false, + false, + $config, + ' +2.0.0Nextcloud Client 2.0.0https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0-x64.AppImagehttps://nextcloud.com/install/#install-clients +' + ], + // #32 new Ubuntu + [ + 'nextcloud', + 'linux', + '1.9.0', + 'ubuntu', + '24.04', + '6.6.0', + 'stable', + false, + false, + $config, + ' +2.2.2Nextcloud Client 2.2.2https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.2-x64.AppImagehttps://nextcloud.com/install/#install-clients +' + ], + // #33 old RHEL + [ + 'nextcloud', + 'linux', + '1.9.0', + 'rhel', + '8.0', + '5.5.0', + 'stable', + false, + false, + $config, + ' +2.0.0Nextcloud Client 2.0.0https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0-x64.AppImagehttps://nextcloud.com/install/#install-clients +' + ], + // #34 new RHEL + [ + 'nextcloud', + 'linux', + '1.9.0', + 'rhel', + '9.4', + '6.6.0', + 'stable', + false, + false, + $config, + ' +2.2.2Nextcloud Client 2.2.2https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.2-x64.AppImagehttps://nextcloud.com/install/#install-clients +' + ], + // #35 old openSuse + [ + 'nextcloud', + 'linux', + '1.9.0', + 'opensuse-leap', + '15.1', + '5.5.0', + 'stable', + false, + false, + $config, + ' +2.0.0Nextcloud Client 2.0.0https://download.nextcloud.com/desktop/stable/Nextcloud-2.0.0-x64.AppImagehttps://nextcloud.com/install/#install-clients +' + ], + // #36 new openSuse + [ + 'nextcloud', + 'linux', + '1.9.0', + 'opensuse-leap', + '15.6', + '6.6.0', + 'stable', + false, + false, + $config, + ' +2.2.2Nextcloud Client 2.2.2https://download.nextcloud.com/desktop/stable/Nextcloud-2.2.2-x64.AppImagehttps://nextcloud.com/install/#install-clients ' ], ]; @@ -477,22 +790,37 @@ public function updateDataProvider(): array * @param string $oem * @param string $platform * @param string $version + * @param string $osVersion + * @param string $kernelVersion * @param string $channel * @param bool $isSparkle - * @param bool $isFileProvider + * @param bool $isFileProvider * @param array $config * @param string $expected */ public function testBuildResponse(string $oem, string $platform, string $version, + string $osRelease, + string $osVersion, + string $kernelVersion, string $channel, bool $isSparkle, bool $isFileProvider, array $config, string $expected) { $response = $this->getMockBuilder('\ClientUpdateServer\Response') - ->setConstructorArgs([$oem, $platform, $version, $channel, $isSparkle, $isFileProvider, $config]) + ->setConstructorArgs([ + $oem, + $platform, + $version, + $osRelease, + $osVersion, + $kernelVersion, + $channel, + $isSparkle, + $isFileProvider, + $config]) ->setMethods(['getCurrentTimeStamp']) ->getMock(); $response