|
11 | 11 | use Symfony\Component\Console\Output\OutputInterface;
|
12 | 12 | use Symfony\Component\Process\Exception\ProcessFailedException;
|
13 | 13 | use Symfony\Component\Process\Process;
|
| 14 | +use function process; |
14 | 15 |
|
15 | 16 | class Install extends Command
|
16 | 17 | {
|
@@ -51,29 +52,13 @@ protected function checkOs()
|
51 | 52 | {
|
52 | 53 | if (file_exists('/usr/bin/yum')) {
|
53 | 54 | $pm = 'yum';
|
54 |
| - $process = new Process('command -v lsb_release >/dev/null 2>&1 || { yum -y install redhat-lsb-core; }');//todo 给予当前用户 |
55 |
| - try { |
56 |
| - $process->mustRun(); |
57 |
| - } catch (\Exception $e) { |
58 |
| - throw new RuntimeException($process->getErrorOutput()); |
59 |
| - } |
| 55 | + process('command -v lsb_release >/dev/null 2>&1 || { yum -y install redhat-lsb-core; }'); |
60 | 56 | } else if (file_exists('/usr/bin/apt-get')) {
|
61 | 57 | $pm = 'apt-get';
|
62 |
| - $process = new Process('command -v lsb_release >/dev/null 2>&1 || { yum -y install redhat-lsb-core; }');//todo 给予当前用户 |
63 |
| - try { |
64 |
| - $process->mustRun(); |
65 |
| - } catch (\Exception $e) { |
66 |
| - throw new RuntimeException($process->getErrorOutput()); |
67 |
| - } |
| 58 | + process('command -v lsb_release >/dev/null 2>&1 || { yum -y install redhat-lsb-core; }'); |
68 | 59 | }
|
| 60 | + process('command -v lsb_release >/dev/null 2>&1 || { echo >&2 "Fail to use lsb_release!"; exit 1; }'); |
69 | 61 | //
|
70 |
| - $process = new Process('command -v lsb_release >/dev/null 2>&1 || { echo >&2 "Fail to use lsb_release!"; exit 1; }'); |
71 |
| - try { |
72 |
| - $process->mustRun(); |
73 |
| - } catch (\Exception $e) { |
74 |
| - throw new RuntimeException($process->getErrorOutput()); |
75 |
| - } |
76 |
| - |
77 | 62 |
|
78 | 63 | // if (file_exists('/etc/redhat-release')) {
|
79 | 64 | // //RedHat,Centos
|
@@ -101,8 +86,7 @@ protected function checkCmakeOrInstall(OutputInterface $output)
|
101 | 86 | //检测系统
|
102 | 87 | //如果是ubuntu,直接apt-get
|
103 | 88 | //如果是centos则安装编译安装cmake
|
104 |
| - $process = new Process('sudo apt-get install -y cmake'); |
105 |
| - $process->mustRun(); |
| 89 | + process('sudo apt-get install -y cmake'); |
106 | 90 | }
|
107 | 91 |
|
108 | 92 | }
|
|
0 commit comments