Skip to content
Snippets Groups Projects
Commit 04bdbc37 authored by Robin Appelman's avatar Robin Appelman
Browse files

fix migration script


Signed-off-by: default avatarRobin Appelman <robin@icewind.nl>
parent aa75969d
No related branches found
No related tags found
No related merge requests found
<?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";
}
}
...@@ -23,15 +23,15 @@ declare(strict_types=1); ...@@ -23,15 +23,15 @@ declare(strict_types=1);
namespace OCA\NotifyPush\Migration; namespace OCA\NotifyPush\Migration;
use OCA\NotifyPush\SetupWizard; use OCA\NotifyPush\BinaryFinder;
use OCP\Migration\IOutput; use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep; use OCP\Migration\IRepairStep;
class Install implements IRepairStep { class Install implements IRepairStep {
private $setupWizard; private $binaryFinder;
public function __construct(SetupWizard $setupWizard) { public function __construct(BinaryFinder $setupWizard) {
$this->setupWizard = $setupWizard; $this->binaryFinder = $setupWizard;
} }
public function getName() { public function getName() {
...@@ -42,6 +42,7 @@ class Install implements IRepairStep { ...@@ -42,6 +42,7 @@ class Install implements IRepairStep {
* @return void * @return void
*/ */
public function run(IOutput $output) { public function run(IOutput $output) {
$this->setupWizard->testBinary(); $path = $this->binaryFinder->getBinaryPath();
@chmod($path, 0755);
} }
} }
...@@ -31,42 +31,33 @@ use OCP\IConfig; ...@@ -31,42 +31,33 @@ use OCP\IConfig;
use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Output\BufferedOutput;
class SetupWizard { class SetupWizard {
private $appManager;
private $queue; private $queue;
private $test; private $test;
private $client; private $client;
private $config; private $config;
private $httpsCache = []; private $httpsCache = [];
private $binaryFinder;
public function __construct( public function __construct(
IAppManager $appManager,
IQueue $queue, IQueue $queue,
SelfTest $test, SelfTest $test,
IClientService $clientService, IClientService $clientService,
IConfig $config IConfig $config,
BinaryFinder $binaryFinder
) { ) {
$this->appManager = $appManager;
$this->queue = $queue; $this->queue = $queue;
$this->test = $test; $this->test = $test;
$this->client = $clientService->newClient(); $this->client = $clientService->newClient();
$this->config = $config; $this->config = $config;
$this->binaryFinder = $binaryFinder;
} }
public function getArch(): string { public function getArch(): string {
$arch = php_uname('m'); return $this->binaryFinder->getArch();
if (strpos($arch, 'armv7') === 0) {
return 'armv7';
}
if (strpos($arch, 'aarch64') === 0) {
return 'aarch64';
}
return $arch;
} }
private function getBinaryPath(): string { private function getBinaryPath(): string {
$basePath = realpath(__DIR__ . '/../bin/'); return $this->binaryFinder->getBinaryPath();
$arch = $this->getArch();
return "$basePath/$arch/notify_push";
} }
public function hasBundledBinaries(): bool { public function hasBundledBinaries(): bool {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment