Example #1
0
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $force = (bool) $input->getOption('force');
     $updateService = new SelfUpdateService($this->getApplication(), $output);
     if ($input->getOption('beta')) {
         $updateService->enablePreVersions();
     }
     if ($input->getOption('fallback')) {
         $updateService->enableUpdateFallback();
     }
     // Check if we need root rights
     if (!$this->getApplication()->isRunningAsRoot() && $updateService->isElevationNeeded()) {
         $this->elevateProcess($input, $output);
     }
     $updateService->update($force);
 }
Example #2
0
 /**
  * Run system update
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 protected function systemUpdate(InputInterface $input, OutputInterface $output)
 {
     $errorMsgList = array();
     // ##################
     // System update
     // ##################
     try {
         $this->outputBlock($output, 'Running system package update');
         $command = new CommandBuilder('apt-get', 'clean --quiet');
         $command->executeInteractive();
         $command = new CommandBuilder('apt-get', 'update --quiet');
         $command->executeInteractive();
         $command = new CommandBuilder('apt-get', 'dist-upgrade --fix-broken --assume-yes --quiet');
         $command->executeInteractive();
         $command = new CommandBuilder('apt-get', 'autoclean --quiet');
         $command->executeInteractive();
     } catch (\RuntimeException $e) {
         $msg = 'Running system package update... FAILED';
         $output->writeln('<error>' . $msg . '</error>');
         $errorMsgList[] = $msg;
     }
     // ##################
     // clitools update
     // ##################
     try {
         $this->outputBlock($output, 'Running clitools update');
         $updateService = new SelfUpdateService($this->getApplication(), $output);
         $updateService->update();
     } catch (\RuntimeException $e) {
         $msg = 'Running clitools update... FAILED';
         $output->writeln('<error>' . $msg . '</error>');
         $errorMsgList[] = $msg;
     }
     // ##################
     // Composer update
     // ##################
     try {
         $this->outputBlock($output, 'Running composer update');
         $command = new CommandBuilder('composer', 'self-update');
         $command->executeInteractive();
     } catch (\RuntimeException $e) {
         $msg = 'Running composer update... FAILED';
         $output->writeln('<error>' . $msg . '</error>');
         $errorMsgList[] = $msg;
     }
     // ##################
     // Box.phar update
     // ##################
     try {
         $this->outputBlock($output, 'Running box.phar update');
         $command = new CommandBuilder('box.phar', 'update');
         $command->executeInteractive();
     } catch (\RuntimeException $e) {
         $msg = 'Running box.phar update... FAILED';
         $output->writeln('<error>' . $msg . '</error>');
         $errorMsgList[] = $msg;
     }
     // ##################
     // Misc
     // ##################
     // TODO
     // ##################
     // Summary
     // ##################
     if (!empty($errorMsgList)) {
         $output->writeln('');
         $output->writeln('');
         $output->writeln('<error>[WARNING] Some update tasks have failed!</error>');
         foreach ($errorMsgList as $errorMsg) {
             $output->writeln('  * ' . $errorMsg);
         }
     } else {
         $output->writeln('<info>Update successfully finished</info>');
     }
     return 0;
 }