From 04bdbc3743a1a421e2df225c32d095b8c79deb95 Mon Sep 17 00:00:00 2001 From: Robin Appelman <robin@icewind.nl> Date: Mon, 13 Sep 2021 17:46:02 +0200 Subject: [PATCH] fix migration script Signed-off-by: Robin Appelman <robin@icewind.nl> --- lib/BinaryFinder.php | 43 +++++++++++++++++++++++++++++++++++++++ lib/Migration/Install.php | 11 +++++----- lib/SetupWizard.php | 21 ++++++------------- 3 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 lib/BinaryFinder.php diff --git a/lib/BinaryFinder.php b/lib/BinaryFinder.php new file mode 100644 index 0000000..0c35637 --- /dev/null +++ b/lib/BinaryFinder.php @@ -0,0 +1,43 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\NotifyPush; + +class BinaryFinder { + public function getArch(): string { + $arch = php_uname('m'); + if (strpos($arch, 'armv7') === 0) { + return 'armv7'; + } + if (strpos($arch, 'aarch64') === 0) { + return 'aarch64'; + } + return $arch; + } + + public function getBinaryPath(): string { + $basePath = realpath(__DIR__ . '/../bin/'); + $arch = $this->getArch(); + return "$basePath/$arch/notify_push"; + } +} diff --git a/lib/Migration/Install.php b/lib/Migration/Install.php index 44e9bd1..e49b730 100644 --- a/lib/Migration/Install.php +++ b/lib/Migration/Install.php @@ -23,15 +23,15 @@ declare(strict_types=1); namespace OCA\NotifyPush\Migration; -use OCA\NotifyPush\SetupWizard; +use OCA\NotifyPush\BinaryFinder; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; class Install implements IRepairStep { - private $setupWizard; + private $binaryFinder; - public function __construct(SetupWizard $setupWizard) { - $this->setupWizard = $setupWizard; + public function __construct(BinaryFinder $setupWizard) { + $this->binaryFinder = $setupWizard; } public function getName() { @@ -42,6 +42,7 @@ class Install implements IRepairStep { * @return void */ public function run(IOutput $output) { - $this->setupWizard->testBinary(); + $path = $this->binaryFinder->getBinaryPath(); + @chmod($path, 0755); } } diff --git a/lib/SetupWizard.php b/lib/SetupWizard.php index 7c834b4..ddfac35 100644 --- a/lib/SetupWizard.php +++ b/lib/SetupWizard.php @@ -31,42 +31,33 @@ use OCP\IConfig; use Symfony\Component\Console\Output\BufferedOutput; class SetupWizard { - private $appManager; private $queue; private $test; private $client; private $config; private $httpsCache = []; + private $binaryFinder; public function __construct( - IAppManager $appManager, IQueue $queue, SelfTest $test, IClientService $clientService, - IConfig $config + IConfig $config, + BinaryFinder $binaryFinder ) { - $this->appManager = $appManager; $this->queue = $queue; $this->test = $test; $this->client = $clientService->newClient(); $this->config = $config; + $this->binaryFinder = $binaryFinder; } public function getArch(): string { - $arch = php_uname('m'); - if (strpos($arch, 'armv7') === 0) { - return 'armv7'; - } - if (strpos($arch, 'aarch64') === 0) { - return 'aarch64'; - } - return $arch; + return $this->binaryFinder->getArch(); } private function getBinaryPath(): string { - $basePath = realpath(__DIR__ . '/../bin/'); - $arch = $this->getArch(); - return "$basePath/$arch/notify_push"; + return $this->binaryFinder->getBinaryPath(); } public function hasBundledBinaries(): bool { -- GitLab