private static function read_server($http, $server, $uri, $tgz, $package_path) { if ($http->do_get($server . "__repository__.php" . "/state/" . $uri)->status() === 200) { if (Tag::setof($tag, $http->body(), "rest") && $tag->f("status.value()") == "success") { $http->do_download($server . "__repository__.php" . "/download/" . $uri, $tgz); File::untgz($tgz, getcwd()); File::rm($tgz); return true; } } return false; }
/** * repository serverからダウンロードして展開する * @param string $repository_name リポジトリ名 * @param string $package パッケージ名 * @param string $download_path 展開先のパス */ public static function download($repository_name, $package, $download_path) { $path_list = explode(".", $package); $domain = null; if (sizeof($path_list) > 1) { $domain = $path_list[1] . "." . $path_list[0]; unset($path_list[1], $path_list[0]); } if (strpos($domain, '.') !== false || ctype_upper($domain[0])) { while (true) { try { $server = self::server_address($domain); $http = new Http(); $uri = str_replace(".", "/", $package); if ($http->do_get($server . "/__repository__.php/" . $repository_name . "/state/" . $uri)->status() === 200) { File::untgz($server . "/__repository__.php/" . $repository_name . "/download/" . $uri, $download_path); return; } } catch (InvalidArgumentException $e) { } if (empty($path_list)) { break; } $domain = array_shift($path_list) . "." . $domain; } } throw new InvalidArgumentException("package `" . $package . "` not found"); }
/** * vendorsをすべて更新する * -cでcoreも更新する * * -up [-c] */ public static function __setup_up__(Request $req, $value) { if ($req->is_vars("c") && defined("_JUMP_PATH_")) { if (empty($value) && defined("_CORE_URL_")) { $value = constant("_CORE_URL_"); } if (Http::request_status($value) === 404) { throw new InvalidArgumentException($value . " not found"); } File::rm(constant("_JUMP_PATH_"), false); File::untgz($value, constant("_JUMP_PATH_")); self::info_print('core updated'); } Lib::vendors_update(); self::info_print('vendors updated'); }
private static function read_server($http, $server, $uri, $tgz, $package_path, $expand_path) { if ($http->do_get($server . "__package__.php" . "/state/" . $uri)->status() === 200) { if (Tag::setof($tag, $http->body(), "rest") && $tag->f("status.value()") == "success") { $http->do_download($server . "__package__.php" . "/download/" . $uri, $tgz); File::untgz($tgz, self::$PATH); File::rm($tgz); return self::import_include($expand_path, $package_path); } } }