public static function update($version, $backupBase) { if (!is_dir($backupBase)) { throw new \Exception("Backup directory {$backupBase} is not found"); } set_include_path($backupBase . PATH_SEPARATOR . $backupBase . '/core/lib' . PATH_SEPARATOR . $backupBase . '/core/config' . PATH_SEPARATOR . $backupBase . '/3rdparty' . PATH_SEPARATOR . $backupBase . '/apps' . PATH_SEPARATOR . get_include_path()); $tempDir = self::getTempDir(); Helper::mkdir($tempDir, true); $installed = Helper::getDirectories(); $sources = Helper::getSources($version); try { $thirdPartyUpdater = new Location_3rdparty($installed[Helper::THIRDPARTY_DIRNAME], $sources[Helper::THIRDPARTY_DIRNAME]); $thirdPartyUpdater->update($tempDir . '/' . Helper::THIRDPARTY_DIRNAME); self::$processed[] = $thirdPartyUpdater; $coreUpdater = new Location_Core($installed[Helper::CORE_DIRNAME], $sources[Helper::CORE_DIRNAME]); $coreUpdater->update($tempDir . '/' . Helper::CORE_DIRNAME); self::$processed[] = $coreUpdater; $appsUpdater = new Location_Apps('', $sources[Helper::APP_DIRNAME]); $appsUpdater->update($tempDir . '/' . Helper::APP_DIRNAME); self::$processed[] = $appsUpdater; } catch (\Exception $e) { self::rollBack(); self::cleanUp(); throw $e; } // zip backup $zip = new \ZipArchive(); if ($zip->open($backupBase . ".zip", \ZIPARCHIVE::CREATE) === true) { Helper::addDirectoryToZip($zip, $backupBase, $backupBase); $zip->close(); \OCP\Files::rmdirr($backupBase); } return true; }
*/ namespace OCA\Updater; \OCP\JSON::checkAdminUser(); \OCP\JSON::callCheck(); set_time_limit(0); $updateEventSource = new \OC_EventSource(); $watcher = new UpdateWatcher($updateEventSource); \OCP\Util::connectHook('update', 'success', $watcher, 'success'); \OCP\Util::connectHook('update', 'failure', $watcher, 'failure'); $watcher->success((string) App::$l10n->t('Checking your installation...')); // Check if we have enough permissions $installed = Helper::getDirectories(); $thirdPartyUpdater = new Location_3rdparty($installed[Helper::THIRDPARTY_DIRNAME], ''); $coreUpdater = new Location_Core($installed[Helper::CORE_DIRNAME], ''); $appsUpdater = new Location_Apps('', ''); $errors = array_merge($thirdPartyUpdater->check(), $coreUpdater->check(), $appsUpdater->check()); if (count($errors)) { $message = App::$l10n->t('Upgrade is not possible. Make sure that your webserver has write access to the following files and directories:'); $message .= '<br /><br />' . implode('<br />', $errors); $watcher->failure($message); } // Download package // Url to download package e.g. http://download.owncloud.org/releases/owncloud-4.0.5.tar.bz2 $packageUrl = ''; //Package version e.g. 4.0.4 $packageVersion = ''; $updateData = \OC_Updater::check(); if (isset($updateData['version'])) { $packageVersion = $updateData['version']; }