예제 #1
0
//
// 'url' option
//
$packageURL = $scriptOptions['url'];
if (!$packageURL) {
    $packageINI = eZINI::instance('package.ini');
    $packageURL = $packageINI->variable('RepositorySettings', 'RemotePackagesIndexURL');
}
//
// 'auto-mode' option
//
global $autoMode;
$autoMode = $scriptOptions['auto-mode'];
if ($autoMode != 'off') {
    $autoMode = 'on';
    $importDir = eZPackage::repositoryPath() . "/{$packageRepository}";
    showWarning("Processing in auto-mode: \n" . "- packages will be downloaded to '{$packageDir}';\n" . "- packages will be imported to '{$importDir}';\n" . "- installing of existing classes will be skipped;\n" . "- all files(extesion, design, downloaded and imported packages) will be overwritten;");
    $action = getUserInput("Continue? [y/n]: ");
    if (strpos($action, 'y') !== 0) {
        $script->shutdown(0, 'Done');
    }
}
/**************************************************************
* do the work                                                 *
***************************************************************/
if (downloadPackages($packageList, $packageURL, $packageDir, $packageRepository)) {
    // install
    installPackages($packageList);
}
if (file_exists(installScriptDir($packageRepository, 'ezwebin_site'))) {
    include_once installScriptDir($packageRepository, 'ezwebin_site') . "/settings/ezwebininstaller.php";
예제 #2
0
function downloadPackages($packageList, $packageURL, $packageDir, $packageRepository)
{
    global $cli;
    showMessage2("Configuring...");
    if (!is_array($packageList) || count($packageList) == 0) {
        showError("Package list is empty. Aborting...");
    }
    // 1. check if packages specified in $packageList exist in $packageRepository(means already downloaded and imported).
    //    if yes - ask user to do download or not. If not - go out
    foreach (array_keys($packageList) as $k) {
        $packageName = $packageList[$k];
        $package = eZPackage::fetch($packageName);
        if (is_object($package)) {
            global $autoMode;
            if ($autoMode == 'on') {
                $action = 'y';
            } else {
                $action = getUserInput("Package '{$packageName}' already imported. Import it anyway? [y/n]: ");
            }
            if (strpos($action, 'n') === 0) {
                unset($packageList[$k]);
            } else {
                eZDir::recursiveDelete(eZPackage::repositoryPath() . "/{$packageRepository}/{$packageName}");
            }
        }
    }
    if (count($packageList) == 0) {
        // all packages are imported.
        return true;
    }
    // 2. check $packgesList exists in $packageDir(means packages downloaded but not imported)
    //    if yes - ask user to import or not. If not - go out
    if (!checkDir($packageDir)) {
        return false;
    }
    $downloadPackageList = array();
    foreach ($packageList as $packageName) {
        if (file_exists("{$packageDir}/{$packageName}.ezpkg")) {
            global $autoMode;
            if ($autoMode == 'on') {
                $action = 'y';
            } else {
                $action = getUserInput("Package '{$packageName}' already downloaded. Download it anyway? [y/n]: ");
            }
            if (strpos($action, 'n') === 0) {
                continue;
            }
        }
        $downloadPackageList[] = $packageName;
    }
    //
    // download
    //
    showMessage2("Downloading...");
    if (count($downloadPackageList) > 0) {
        // TODO: using 'eZStepSiteTypes' is hack.
        //       need to exclude 'downloadFile' from that class.
        $tpl = false;
        $http = false;
        $ini = false;
        $persistenceList = false;
        $downloader = new eZStepSiteTypes($tpl, $http, $ini, $persistenceList);
        foreach ($downloadPackageList as $packageName) {
            showMessage("{$packageName}");
            $archiveName = $downloader->downloadFile("{$packageURL}/{$packageName}.ezpkg", $packageDir);
            if ($archiveName === false) {
                showError("download error - " . $downloader->ErrorMsg);
            }
        }
    }
    //
    // import
    //
    showMessage2("Importing...");
    foreach ($packageList as $packageName) {
        showMessage("{$packageName}");
        $package = eZPackage::import("{$packageDir}/{$packageName}.ezpkg", $packageName, false, $packageRepository);
        if (!is_object($package)) {
            showError("Faild to import '{$packageName}' package: err = {$package}");
        }
    }
    return true;
}
예제 #3
0
 static function packageRepositories($parameters = array())
 {
     if (isset($parameters['path']) and $parameters['path']) {
         $path = $parameters['path'];
         $packageRepositories = array(array('path' => $path, 'id' => 'local', 'name' => ezpI18n::tr('kernel/package', 'Local'), 'type' => 'local'));
     } else {
         $repositoryPath = eZPackage::repositoryPath();
         $packageRepositories = array(array('path' => $repositoryPath . '/local', 'id' => 'local', 'name' => ezpI18n::tr('kernel/package', 'Local'), 'type' => 'local'));
         $subdirs = eZDir::findSubitems($repositoryPath, 'd');
         foreach ($subdirs as $dir) {
             if ($dir == 'local') {
                 continue;
             }
             $packageRepositories[] = array('path' => $repositoryPath . '/' . $dir, 'id' => $dir, 'name' => $dir, 'type' => 'global');
         }
     }
     return $packageRepositories;
 }