/*!
\pure
Installs the package item
487214
function install( $package, $installType, $parameters,
                      $name, $os, $filename, $subdirectory,
                      $content, &$installParameters,
                      &$installData )
    {
    }
120616
function install(items, callback) {

    var item = items[next],
        command = item.command,
        args = item.args,
        admin = item.admin,
        spawnopt = (item.spawnopt || {}),
        print;


    // set the spawn object according to the passed admin argument
    admin = setSpawnObject(admin);

    // run the command
    if (isLinux) {
        if (admin) {
            // use sudo
            args.unshift(command);
            print = args.join(" ");
            logger.console.log("[package-script] Running Installer command: " + print);

            sudoopt.spawnOptions = {};
            jsutils.Object.copy(spawnopt, sudoopt.spawnOptions);
            cprocess = spawn(args, sudoopt);
        } else {
            //use child_process
            print = args.join(" ");
            logger.console.log("[package-script] Running Installer command: " + command + " " + print);
            cprocess = spawn(command, args, spawnopt);
        }
    } else {
        args.unshift(command);
        args.unshift("/c");
        command = "cmd";
        print = [command, args.join(" ")].join(" ");
        logger.console.log("[package-script] Running Installer command: " + print);
        cprocess = spawn(command, args, spawnopt);

    }

    // -- Spawn Listeners
    cprocess.stdout.on('data', function (data) {
        var log = 'CAT Installer: ' + data;
        logger.logall(log);
    });

    cprocess.stderr.on('data', function (data) {
        if (data && (new String(data)).indexOf("npm ERR") != -1) {
            logger.logall('Package Script : ' + data);
        } else {
            logger.log2file('Package Script : ' + data);
        }
    });

    cprocess.on('close', function (code) {
        logger.log2file('Package Script Complete ' + code);
        next++;
        if (next < size) {
            install(items, callback);

        } else {
            // callback
            if (callback && _.isFunction(callback)) {
                callback.call(this, code);

            }
        }
    });
}
985459
function initializePackageInformation( $package, $http, $step, &$persistentData, $tpl )
    {
        $persistentData['name'] = false;
        $persistentData['summary'] = false;
        $persistentData['description'] = false;
        $persistentData['licence'] = 'GPL';
        $persistentData['version'] = '1.0';
        if ( isset( $_SERVER['HOSTNAME'] ) )
            $host = $_SERVER['HOSTNAME'];
        else
            $host = $_SERVER['HTTP_HOST'];
        $persistentData['host'] = $host;
        $user = eZUser::currentUser();
        $userObject = $user->attribute( 'contentobject' );
        $packager = false;
        if ( $userObject )
            $packager = $userObject->attribute( 'name' );
        $persistentData['packager'] = $packager;
        $this->generatePackageInformation( $persistentData, $package, $http, $step, $persistentData );

        // Make sure the package name contains only valid characters
        $trans = eZCharTransform::instance();
        $persistentData['name'] = $trans->transformByGroup( $persistentData['name'], 'identifier' );
    }
453310
public function install($tab = null)
    {
        if (get('search')) {
            return Response::make($this->onSearchProducts());
        }

        try {
            $this->bodyClass = 'compact-container breadcrumb-flush';
            $this->pageTitle = 'system::lang.plugins.install_products';

            $this->addJs('/modules/system/assets/js/updates/install.js', 'core');
            $this->addCss('/modules/system/assets/css/updates/install.css', 'core');

            $this->vars['activeTab'] = $tab ?: 'plugins';
            $this->vars['installedPlugins'] = $this->getInstalledPlugins();
            $this->vars['installedThemes'] = $this->getInstalledThemes();
        }
        catch (Exception $ex) {
            $this->handleError($ex);
        }
    }
1367692
function install($dir = null, &$result)
    {
        // Get a database connector object
        $db = Factory::getDBO();
        $result['status'] = false;
        $result['name'] = null;
        if (!$dir && !is_dir(Path::clean($dir))) {
            $this->installer->abort(Text::_('INSTALL_INVALID_PATH'));
	        throw new RuntimeException(Text::_('INSTALL_INVALID_PATH'));
        } else {
            $this->installer->setPath('source', $dir);

            // Get the extension manifest object
            $manifest = $this->getManifest($dir);
            if (is_null($manifest)) {
                $this->installer->abort(Text::_('INSTALL_NOT_VALID_PLUGIN'));
	            throw new RuntimeException(Text::_('INSTALL_NOT_VALID_PLUGIN'));
            } else {
                $this->manifest = $manifest;

	            $framework = JFusionFramework::getComposerInfo();

	            $version = $this->getAttribute($this->manifest, 'version');

	            /**
	             * ---------------------------------------------------------------------------------------------
	             * Manifest Document Setup Section
	             * ---------------------------------------------------------------------------------------------
	             */
	            // Set the extensions name
	            /**
	             * Check that the plugin is an actual JFusion plugin
	             */
	            $name = $this->manifest->name;
	            $name = $this->filterInput->clean($name, 'string');

	            if (!$framework || !$version || version_compare($framework->version, $version) >= 0 || $framework->version == 'dev-master') {
		            $result['name'] = $name;
		            $this->name = $name;

		            // installation path
		            $this->installer->setPath('extension_root', JFusionFramework::getPluginPath($name));
		            // get files to copy

		            /**
		             * ---------------------------------------------------------------------------------------------
		             * Filesystem Processing Section
		             * ---------------------------------------------------------------------------------------------
		             */

		            // If the plugin directory does not exist, lets create it
		            $created = false;
		            if (!file_exists($this->installer->getPath('extension_root'))) {
			            if (!$created = Folder::create($this->installer->getPath('extension_root'))) {
				            $msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('INSTALL_FAILED_DIRECTORY') . ': "' . $this->installer->getPath('extension_root') . '"';
				            $this->installer->abort($msg);
				            throw new RuntimeException($name . ': ' . $msg);
			            }
		            }
		            /**
		             * If we created the plugin directory and will want to remove it if we
		             * have to roll back the installation, lets add it to the installation
		             * step stack
		             */
		            if ($created) {
			            $this->installer->pushStep(array('type' => 'folder', 'path' => $this->installer->getPath('extension_root')));
		            }
		            // Copy all necessary files
		            if ($this->installer->parseFiles($this->manifest->files[0], -1) === false) {
			            // Install failed, roll back changes
			            $this->installer->abort();
			            throw new RuntimeException($name . ': ' . Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('FAILED'));
		            } else {
			            $vendor = $dir . '/vendor';
			            if (is_dir(Path::clean($vendor))) {
				            Folder::copy($vendor, $this->installer->getPath('extension_root') . '/vendor', '', true);
			            }
			            $language = $dir . '/language';
			            if (is_dir(Path::clean($language))) {
				            Folder::copy($language, $this->installer->getPath('extension_root') . '/language', '', true);
			            }
			            /**
			             * ---------------------------------------------------------------------------------------------
			             * Database Processing Section
			             * ---------------------------------------------------------------------------------------------
			             */
			            //let's check to see if a plugin with the same name is already installed
			            $query = $db->getQuery(true)
				            ->select('id')
				            ->from('#__jfusion')
				            ->where('name = ' . $db->quote($name));

			            $db->setQuery($query);

			            $plugin = $db->loadObject();
			            if (!empty($plugin)) {
				            if (!$this->installer->isOverwrite()) {
					            // Install failed, roll back changes
					            $msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ': ' . Text::_('PLUGIN') . ' "' . $name . '" ' . Text::_('ALREADY_EXISTS');
					            $this->installer->abort($msg);
					            throw new RuntimeException($name . ': ' . $msg);
				            } else {
					            //set the overwrite tag
					            $result['overwrite'] = 1;
				            }
			            } else {
				            //prepare the variables
				            $result['overwrite'] = 0;
				            $plugin_entry = new stdClass;
				            $plugin_entry->id = null;
				            $plugin_entry->name = $name;
				            $plugin_entry->dual_login = 0;
				            //now append the new plugin data
				            try {
					            $db->insertObject('#__jfusion', $plugin_entry, 'id');
				            } catch (Exception $e) {
					            // Install failed, roll back changes
					            $msg = Text::_('PLUGIN') . ' ' . Text::_('INSTALL') . ' ' . Text::_('ERROR') . ': ' . $e->getMessage();
					            $this->installer->abort($msg);
					            throw new RuntimeException($name . ': ' . $msg);
				            }
				            $this->installer->pushStep(array('type' => 'plugin', 'id' => $plugin_entry->id));
			            }
			            /**
			             * ---------------------------------------------------------------------------------------------
			             * Finalization and Cleanup Section
			             * ---------------------------------------------------------------------------------------------
			             */

			            //check to see if this is updating a plugin that has been copied
			            $query = $db->getQuery(true)
				            ->select('name')
				            ->from('#__jfusion')
				            ->where('original_name = ' . $db->quote($name));

			            $db->setQuery($query);
			            $copiedPlugins = $db->loadObjectList();
			            foreach ($copiedPlugins as $plugin) {
				            //update the copied version with the new files
//				            $this->copy($name, $plugin->name, true);
			            }

			            if ($result['overwrite'] == 1) {
				            $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('UPDATE') . ': ' . Text::_('SUCCESS');
			            } else {
				            $msg = Text::_('PLUGIN') . ' ' . $name . ' ' . Text::_('INSTALL') . ': ' . Text::_('SUCCESS');
			            }
			            $result['message'] = $name . ': ' . $msg;
			            $result['status'] = true;
		            }
	            } else {
		            $msg = Text::_('PLUGIN') . ' ' . $name . ': ' . Text::_('FAILED') . ' ' . Text::_('NEED_JFUSION_VERSION') . ' "' . $version . '" ' . Text::_('OR_HIGHER');
		            $this->installer->abort($msg);
		            throw new RuntimeException($name . ': ' . $msg);
	            }
            }
        }
        return $result;
    }
1185998
function install( $package, $installType, $parameters,
                      $name, $os, $filename, $subdirectory,
                      $content, &$installParameters,
                      &$installData )
    {
        $path = $package->path();
        $databaseType = false;
        if ( isset( $parameters['database-type'] ) )
        {
            $databaseType = $parameters['database-type'];
        }
        $path .= '/' . eZDBPackageHandler::sqlDirectory();
        if ( $databaseType )
        {
            $path .= '/' . $databaseType;
        }

        if ( file_exists( $path ) )
        {
            $db = eZDB::instance();
            $canInsert = true;
            if ( $databaseType and
                 $databaseType != $db->databaseName() )
            {
                $canInsert = false;
            }

            if ( $canInsert )
            {
                eZDebug::writeDebug( "Installing SQL file $path/$filename" );
                $db->insertFile( $path, $filename, false );
                return true;
            }
            else
            {
                eZDebug::writeDebug( "Skipping SQL file $path/$filename" );
            }
        }
        else
        {
            eZDebug::writeError( "Could not find SQL file $path/$filename" );
        }
        return false;
    }
894415
protected function installPackage()
    {
        if ($this->confirm('Do you want publish the pingpong/admin\'s migrations ?')) {
            $this->call('admin:migration');
        }

        if ($this->confirm('Do you want publish the pingpong/trusty\'s migrations ?')) {
            $this->call('vendor:publish', [
                '--provider' => 'Pingpong\Trusty\TrustyServiceProvider',
            ]);
        }

        if ($this->confirm('Do you want run all migrations now ?')) {
            $this->call('migrate');
        }

        if ($this->confirm('Do you want run the pingpong/admin\'s seeders now ?')) {
            $this->call('admin:seed');
        }

        if ($this->confirm('Do you want publish configuration files from pingpong/admin package ?')) {
            $this->call('vendor:publish', [
                '--provider' => 'Pingpong\Admin\AdminServiceProvider',
                ['--tag' => ['config']],
            ]);
        }

        if ($this->confirm('Do you want publish assets from pingpong/admin package ?')) {
            $this->call('vendor:publish', [
                '--provider' => 'Pingpong\Admin\AdminServiceProvider',
                ['--tag' => ['assets']],
            ]);
        }

        if ($this->confirm('Do you want create the app/menus.php file ?')) {
            $this->installMenus();
        }

        $this->call('optimize');
    }
127093
protected function addScriptsToNpmPackage()
    {
        $package = json_decode(file_get_contents(base_path('package.json')), true);

        $package['scripts']['build-'.$this->assetName()] = 'cd '.$this->relativeAssetPath().' && npm run dev';
        $package['scripts']['build-'.$this->assetName().'-prod'] = 'cd '.$this->relativeAssetPath().' && npm run prod';

        file_put_contents(
            base_path('package.json'),
            json_encode($package, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
        );
    }
306589
function install_ (pkg, reg, seen, mustHave, pkglist, bundles, cb) {
  log.verbose(pkg, "install_")
  if (seen[pkg]) return cb() // repeat, skip it
  seen[pkg] = true

  // it's a local thing or a url if it has a / in it.
  if (pkg.indexOf("/") !== -1 || pkg === ".") {
    log.silly(pkg, "install local")
    return cache.add(pkg, finisher(pkg, reg, pkglist, bundles, cb))
  }

  // now we know it's not a URL or file,
  // so handle it like a tag, version, or range.
  pkg = pkg.split("@")
  var name = pkg[0]
    , defTag = npm.config.get("tag")
    , ver = pkg.slice(1).join("@").trim() || defTag
    , range = semver.validRange(ver)
    , exact = semver.valid(ver)
    , tag = !exact && !range && range !== "" && ver
  log.verbose([pkg, mustHave], "must install?")
  pkg = pkg.join("@")
  seen[name+"@"+ver] = true

  // if there is a satisfying version already, then simply move on.
  if (!tag && findSatisfying(pkg, name, range, mustHave, reg)) {
    return cb()
  }

  // at this point, assume that it has to be installed.
  if (exact) {
    log.verbose("exact", pkg)
    // just pull the data out of the cache to ensure it's there
    return cache.read(name, exact, finisher(pkg, reg, pkglist, bundles, cb))
  }

  getData(name, function (er, data) {
    if (er) return cb(er)
    log.silly(data, pkg)
    if (tag) {
      log.verbose(tag, pkg+" tag")
      var tags = data["dist-tags"]
      if (!tags[tag]) cb(new Error(
        "Tag not found: "+data.name+"@"+tag
        +"\nValid install targets for "+data.name+": "
        +installTargets(data)))
      install_(data.name+"@"+tags[tag], reg, seen, mustHave
              , pkglist, bundles, cb)
    } else {
      log(pkg, "range")
      // prefer the default tag version.
      var defTag = npm.config.get("tag")
        , satis
      defTag = defTag && data["dist-tags"] && data["dist-tags"][defTag]
      if (semver.satisfies(defTag, range)) satis = defTag
      else satis = semver.maxSatisfying(Object.keys(data.versions), range)

      if (!satis) return cb(new Error(
        "No satisfying version found for '"+data.name+"'@'"+range+"'"
        +"\nValid install targets for "+data.name+": "
        +installTargets(data)))
      install_(data.name+"@"+satis, reg, seen, mustHave
              , pkglist, bundles, cb)
    }
  })
}
25115
function install( $package, $installType, $parameters,
                      $name, $os, $filename, $subdirectory,
                      $content, &$installParameters,
                      &$installData )
    {
        //$this->Package =& $package;

        $trans = eZCharTransform::instance();
        $name = $content->getAttribute( 'name' );
        $extensionName = $trans->transformByGroup( $name, 'urlalias' );
        if ( strcmp( $name, $extensionName ) !== 0 )
        {
            $description = ezpI18n::tr( 'kernel/package', 'Package contains an invalid extension name: %extensionname', false, array( '%extensionname' => $name ) );
            $installParameters['error'] = array( 'error_code' => false,
                                                 'element_id' => $name,
                                                 'description' => $description );
            return false;
        }

        $siteINI = eZINI::instance();
        $extensionRootDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' );
        $extensionDir = $extensionRootDir . '/' . $extensionName;
        $packageExtensionDir = $package->path() . '/' . $parameters['sub-directory'] . '/' . $extensionName;

        // Error: extension already exists.
        if ( file_exists( $extensionDir ) )
        {
            $description = ezpI18n::tr( 'kernel/package', "Extension '%extensionname' already exists.",
                                   false, array( '%extensionname' => $extensionName ) );
            $choosenAction = $this->errorChoosenAction( self::ERROR_EXISTS,
                                                        $installParameters, $description, $this->HandlerType );
            switch( $choosenAction )
            {
            case self::ACTION_SKIP:
                return true;

            case eZPackage::NON_INTERACTIVE:
            case self::ACTION_REPLACE:
                eZDir::recursiveDelete( $extensionDir );
                break;

            default:
                $installParameters['error'] = array( 'error_code' => self::ERROR_EXISTS,
                                                     'element_id' => $extensionName,
                                                     'description' => $description,
                                                     'actions' => array( self::ACTION_REPLACE => ezpI18n::tr( 'kernel/package', "Replace extension" ),
                                                                         self::ACTION_SKIP => ezpI18n::tr( 'kernel/package', 'Skip' ) ) );
                return false;
            }
        }

        eZDir::mkdir( $extensionDir, false, true );
        eZDir::copy( $packageExtensionDir, $extensionRootDir );

        // Regenerate autoloads for extensions to pick up the newly created extension
        ezpAutoloader::updateExtensionAutoloadArray();

        // Activate extension
        $siteINI = eZINI::instance( 'site.ini', 'settings/override', null, null, false, true );

        if ( $siteINI->hasVariable( 'ExtensionSettings', "ActiveExtensions" ) )
        {
            $selectedExtensions = $siteINI->variable( 'ExtensionSettings', "ActiveExtensions" );
        }
        else
        {
            $selectedExtensions = array();
        }

        if ( !in_array( $extensionName, $selectedExtensions ) )
        {
            $selectedExtensions[] = $extensionName;
            $siteINI->setVariable( "ExtensionSettings", "ActiveExtensions", $selectedExtensions );
            $siteINI->save( 'site.ini.append', '.php', false, false );
        }
        return true;
    }
80625
public function install()
    {
        $this->updatePackages();
        $this->updateBootstrapping();

        $this->filesystem->deleteDirectory(resource_path('assets/js/components'));
        $this->filesystem->delete(resource_path('assets/sass/_variables.scss'));
        $this->filesystem->deleteDirectory(base_path('node_modules'));
        $this->filesystem->deleteDirectory(public_path('css'));
        $this->filesystem->deleteDirectory(public_path('js'));
    }
315149
static function package($package) {
        if(!isset(self::$packages[$package])) {
            self::$packages[$package] = new Package($package);
        }
        
        return self::$packages[$package];
    }
529481
public function installPackage($package)
    {
        // We read its composer file
        $jsonData = $this->getPackageJsonFile($package);
        // We get the package assets dirs
        $packagesAssetsDir = $this->getPackageAssetsDirs($jsonData);
        if (!is_null($packagesAssetsDir)) {
            $this->log($package->getTarget(), self::LOG_INFO, self::CODE_INSTALLING_PACKAGE);
            $this->packagesStatuses[$package->getTarget()]['extra'] = 1;
            foreach ($packagesAssetsDir as $namespace => $packageAssetsDir) {
                if (!isset($this->packagesStatuses[$package->getTarget()]['dirs'])) {
                    $this->packagesStatuses[$package->getTarget()]['dirs'] = array();
                }
                $this->packagesStatuses[$package->getTarget()]['dirs'][$namespace] = null;
                // We install each package directory
                $this->installPackageDir($package, $namespace, $packageAssetsDir);
            }
        } else {
            $this->log($package->getTarget(), self::LOG_INFO, self::CODE_NO_INSTALL);
            $this->packagesStatuses[$package->getTarget()]['extra'] = 0;
        }
    }
69259
protected function install()
    {
        $this->setupCore();
        $this->setupBackend();
        $this->initializeDatabase();
        $this->runCommand('cache:clear', array('--no-warmup' => true));
    }
489201
public function install()
    {
        if ($this->request->data()) {
            $task = false;
            $uploadError = false;

            if (isset($this->request->data['download'])) {
                $task = (bool)WebShellDispatcher::run("Installer.plugins install -s \"{$this->request->data['url']}\" --theme -a");
            } elseif (isset($this->request->data['file_system'])) {
                $task = (bool)WebShellDispatcher::run("Installer.plugins install -s \"{$this->request->data['path']}\" --theme -a");
            } else {
                $uploader = new PackageUploader($this->request->data['file']);
                if ($uploader->upload()) {
                    $task = (bool)WebShellDispatcher::run('Installer.plugins install -s "' . $uploader->dst() . '" --theme -a');
                } else {
                    $uploadError = true;
                    $this->Flash->set(__d('system', 'Plugins installed but some errors occur'), [
                        'element' => 'System.installer_errors',
                        'params' => ['errors' => $uploader->errors(), 'type' => 'warning'],
                    ]);
                }
            }

            if ($task) {
                $this->Flash->success(__d('system', 'Theme successfully installed!'));
                $this->redirect($this->referer());
            } elseif (!$task && !$uploadError) {
                $this->Flash->set(__d('system', 'Theme could not be installed'), [
                    'element' => 'System.installer_errors',
                    'params' => ['errors' => WebShellDispatcher::output()],
                ]);
            }
        }

        $this->title(__d('system', 'Install Theme'));
        $this->Breadcrumb
            ->push('/admin/system/themes')
            ->push(__d('system', 'Install new theme'), '#');
    }
1257370
public function install()
    {
        $this->ensureComponentDirectoryExists();
        $this->updatePackages();
        $this->updateWebpackConfiguration();
        $this->updateBootstrapping();
        $this->updateComponent();
        $this->removeNodeModules();
    }
1087166
function initializePackageChangelog( $package, $http, $step, &$persistentData, $tpl )
    {
        $user = eZUser::currentUser();
        $userObject = $user->attribute( 'contentobject' );
        if ( $userObject )
            $changelogPerson = $userObject->attribute( 'name' );
        $changelogEmail = $user->attribute( 'email' );
        $changelogText = '';

        $persistentData['changelog_person'] = $changelogPerson;
        $persistentData['changelog_email'] = $changelogEmail;
        if ( !( $package instanceof eZPackage ) )
        {
            $changelogText = $this->initialChangelogEntry( $package, $http, $step, $persistentData, $tpl );
        }
        $persistentData['changelog_text'] = $changelogText;
        $persistentData['changelog_entries'] = array();
    }