Creates the a PHAR archive from the sources.

@return void
545911
public function createPhar()
    {

        // run the build process
        $this->build();

        // prepare the PHAR archive name
        $archiveName = sprintf(
            '%s/%s.phar',
            $this->properties['target.dir'],
            $this->properties['webapp.name']
        );

        // prepare the target directory
        $targetDir = $this->properties['target.dir'] . DIRECTORY_SEPARATOR . $this->properties['webapp.version'];

        // copy the composer.json file
        $this->taskFilesystemStack()
             ->copy(
                  __DIR__ . DIRECTORY_SEPARATOR . 'composer.json',
                  $targetDir. DIRECTORY_SEPARATOR. 'composer.json'
             )->run();

          // copy the .semver file
          $this->taskFilesystemStack()
               ->copy(
                   __DIR__ . DIRECTORY_SEPARATOR . '.semver',
                   $targetDir. DIRECTORY_SEPARATOR. '.semver'
               )->run();

          // copy the bootstrap.php file
          $this->taskFilesystemStack()
               ->copy(
                  __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php',
                  $targetDir. DIRECTORY_SEPARATOR. 'bootstrap.php'
               )->run();

        // copy the src/etc directory
        $this->taskCopyDir(
                  array(
                      $this->properties['src.dir'] => $targetDir . DIRECTORY_SEPARATOR . 'src'
                  )
               )->run();

        // copy the syfmony directory
        $this->taskCopyDir(
                   array(
                       $this->properties['symfony.dir'] => $targetDir . DIRECTORY_SEPARATOR . 'symfony'
                   )
               )->run();

        // install the composer dependencies
        $this->taskComposerInstall()
            ->dir($targetDir)
            ->noDev()
            ->optimizeAutoloader()
            ->run();

        // prepare the task
        $pharTask = $this->taskPackPhar($archiveName)
            ->compress()
            ->stub('stub.php');

        // load a list with all the source files from the vendor directory
        $finder = Finder::create()->files()
            ->name('*.php')
            ->name('.semver')
            ->name('services.xml')
            ->name('services-1.0.xsd')
            ->name('techdivision-import.json')
            ->in($targetDir)
            ->ignoreDotFiles(false);

        // iterate over the source files of the vendor directory and add them to the PHAR archive
        foreach ($finder as $file) {
            $pharTask->addFile($file->getRelativePathname(), $file->getRealPath());
        }

        // create the PHAR archive
        $pharTask->run();

        // verify PHAR archive is packed correctly
        $this->_exec(sprintf('php %s', $archiveName));

        // prepare the PHAR archive distribution name
        $distArchiveName = sprintf('%s/%s.phar', $this->properties['dist.dir'], $this->properties['webapp.name']);

        // clean up the dist directory
        $this->taskCleanDir($this->properties['dist.dir'])->run();

        // copy the latest PHAR archive to the dist directory
        $this->taskFilesystemStack()->copy($archiveName, $distArchiveName)->run();
    }
1295656
public function createArchive($options = array(), $nameArchive = null, $mode = 'create')
    {
        $options = array_merge($options, ['target_public_id' => $nameArchive, 'mode' => $mode]);
        return $this->getUploader()->create_archive($options);
    }
1263735
private function addAutoload($phar)
    {
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/autoload.php'));
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/autoload_classmap.php'));
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/autoload_files.php'));
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/autoload_namespaces.php'));
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/autoload_psr4.php'));
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/autoload_real.php'));
        if (file_exists($this->path . '/vendor/composer/include_paths.php')) {
            $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/include_paths.php'));
        }
        $this->addFile($phar, new \SplFileInfo($this->path . '/vendor/composer/ClassLoader.php'));

        /* add react/promise */
        $react = new Finder();
        $react->files()->ignoreVCS(true)->ignoreDotFiles(true)->name('*.php')->in($this->path . '/vendor/react/promise/src');
        foreach ($react as $file) {
            $this->addFile($phar, $file);
        }
    }
768488
private function create()
    {
        try {
            callback_event('rah_backup.backup');
        } catch (Rah_Backup_Exception $e) {
            $this->browser(array($e->getMessage(), E_ERROR));
            return;
        } catch (Exception $e) {
            $this->browser(array(txpspecialchars($e->getMessage()), E_ERROR));
            return;
        }

        $this->browser(gTxt('rah_backup_done'));
    }
1215486
def create_archive(
            self,
            archive_name,
            authority_name,
            archive_path,
            versioned,
            raise_on_err=True,
            metadata=None,
            user_config=None,
            tags=None,
            helper=False):
        '''
        

        '''

        archive_metadata = self._create_archive_metadata(
            archive_name=archive_name,
            authority_name=authority_name,
            archive_path=archive_path,
            versioned=versioned,
            raise_on_err=raise_on_err,
            metadata=metadata,
            user_config=user_config,
            tags=tags,
            helper=helper)

        if raise_on_err:
            self._create_archive(
                archive_name,
                archive_metadata)
        else:
            self._create_if_not_exists(
                archive_name,
                archive_metadata)

        return self.get_archive(archive_name)
182762
public function createComponentZip()
	{
		$comZip = new \ZipArchive(JPATH_BASE . "/dist", \ZipArchive::CREATE);

		$tmp_path = '/dist/tmp/cbuild';

		if (file_exists(JPATH_BASE . $tmp_path))
		{
			$this->_deleteDir(JPATH_BASE . $tmp_path);
		}

		// Improve, should been a whitelist instead of a hardcoded copy
		$this->_mkdir(JPATH_BASE . $tmp_path);

		$this->_copyDir($this->current . '/administrator', JPATH_BASE . $tmp_path . '/administrator');
		$this->_remove(JPATH_BASE . $tmp_path . '/administrator/manifests');
		$this->_copyDir($this->current . '/language', JPATH_BASE . $tmp_path . '/language');
		$this->_copyDir($this->current . '/components', JPATH_BASE . $tmp_path . '/components');

		if (file_exists($this->current . '/media'))
		{
			$this->_copyDir($this->current . '/media', JPATH_BASE . $tmp_path . '/media');
		}

		$comZip->open(JPATH_BASE . '/dist/zips/com_' . $this->getExtensionName() . '.zip', \ZipArchive::CREATE);

		// Process the files to zip
		$this->addFiles($comZip, JPATH_BASE . $tmp_path);

		$comZip->addFile($this->current . "/" . $this->getExtensionName() . ".xml", $this->getExtensionName() . ".xml");
		$comZip->addFile($this->current . "/administrator/components/com_" . $this->getExtensionName() . "/script.php", "script.php");

		// Close the zip archive
		$comZip->close();
	}
1275352
public function build()
    {
        if (! $view = $this->getRSSView()) {
            return;
        }

        $pageContent = $this->viewFactory->make($view, $this->viewsData)->render();

        $this->filesystem->put(
            sprintf('%s/%s', KATANA_PUBLIC_DIR, 'feed.rss'),
            $pageContent
        );
    }
1213552
public function createModuleZips()
	{
		$path = $this->current . "/modules";

		// Get every module
		$hdl = opendir($path);

		while ($entry = readdir($hdl))
		{
			// Only folders
			$p = $path . "/" . $entry;

			if (substr($entry, 0, 1) == '.')
			{
				continue;
			}

			if (!is_file($p))
			{
				$this->say("Packaging Module " . $entry);

				// Package file
				$zip = new \ZipArchive(JPATH_BASE . "/dist", \ZipArchive::CREATE);

				$zip->open(JPATH_BASE . '/dist/zips/' . $entry . '.zip', \ZipArchive::CREATE);

				$this->say("Module " . $p);

				// Process the files to zip
				$this->addFiles($zip, $p);

				// Close the zip archive
				$zip->close();
			}
		}

		closedir($hdl);
	}
763848
protected static function createArchiveForPhar(array $files, $archiveFileName)
    {
        if (preg_match('~^(.+)\.(tar\.(gz|bz2))$~i', $archiveFileName, $match)) {
            $ext = $match[2];
            $basename = $match[1];
        } else {
            $ext = pathinfo($archiveFileName, PATHINFO_EXTENSION);
            $basename = dirname($archiveFileName).'/'.basename($archiveFileName, '.'.$ext);
        }
        $tar = new PharData($basename.'.tar', 0, null, Phar::TAR);

        try {
            foreach ($files as $localName => $filename) {
                if (is_null($filename)) {
                    if (!in_array($localName, ['/', ''], true)) {
                        if ($tar->addEmptyDir($localName) === false) {
                            return false;
                        }
                    }
                } else {
                    if ($tar->addFile($filename, $localName) === false) {
                        return false;
                    }
                }
            }
        } catch (Exception $e) {
            return false;
        }

        switch (strtolower(pathinfo($archiveFileName, PATHINFO_EXTENSION))) {
            case 'gz':
            case 'tgz':
                $tar->compress(Phar::GZ, $ext);
                break;
            case 'bz2':
            case 'tbz2':
                $tar->compress(Phar::BZ2, $ext);
                break;
        }
        $tar = null;

        return count($files);
    }
234891
protected function addStub(Phar $phar)
    {
        $this->fireEvent('STUB');

        // Add warning once the phar is older than 30 days
        $defineTime = '';
        if (array_key_exists('package_version', $this->params)) {
            $warningTime = time() + 30 * 86400;
            $defineTime = "define('PHAR_DEV_WARNING_TIME', $warningTime);\n";
        }

        $content = $this->files->get(__DIR__ . '/../stubs/compile.stub');
        $content = str_replace('DubbyAlias', $this->alias, $content);
        $content = str_replace('DubbyDefineDateTime', $defineTime, $content);

        $phar->setStub($content);
    }
1167603
public function createPermissionsView()
    {
        $schemasPath = __DIR__ . DIRECTORY_SEPARATOR . 'schemas';
        if (is_dir($schemasPath)) {
            $fileSystem = app('files');
            $files      = $fileSystem->allFiles($schemasPath);
            foreach ($files as $file) {
                DB::unprepared($file->getContents());
            }
        }
    }
738280
public function doArchive()
    {
        $owner = $this->owner;
        $owner->invokeWithExtensions('onBeforeArchive', $this);
        $owner->deleteFromChangeSets();
        // Unpublish without creating deleted version
        $this->suppressDeletedVersion(function () use ($owner) {
            $owner->doUnpublish();
            $owner->deleteFromStage(static::DRAFT);
        });
        // Create deleted version in both stages
        $this->createDeletedVersion([
            static::LIVE,
            static::DRAFT,
        ]);
        $owner->invokeWithExtensions('onAfterArchive', $this);
        return true;
    }
106754
protected function archive()
    {
        if( $archiveDatabaseList = $this->getArchiveDatabaseList() )
        {
            foreach( $archiveDatabaseList as $database )
            {
                if( ! empty($tables = $this->getArchiveDatabaseTableList($database)) )
                {
                    $dbForge = $this->getDBForgeDifferentConnectionByDatabaseName($database);
    
                    foreach( $tables as $table )
                    {
                        $dbForge->dropTable($this->getTableNameWithoutExtension($table));
                    }
                }
    
                $tool = $this->getDBToolDifferentConnectionByDatabaseName($database);
    
                if( empty($tool->listTables()) )
                {
                    $this->forge->dropDatabase($database);
                }
            }

            return true;
        }
        
        return false;
    }
886174
protected function generateTar()
	{
		$this->content		= "";																	// Clear any data currently in $this->content	
		if( $this->numFolders > 0 )
		{																							// Generate Records for each folder, if we have directories
			foreach( $this->folders as $key => $information )
			{
				unset( $header );
				// Generate tar header for this folder
				// Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
				$header	= '';
				$header .= str_pad($information['name'],100,chr(0));
				$header .= str_pad(decoct($information['mode']),7,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['user_id']),7,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['group_id']),7,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct(0),11,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['time']),11,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_repeat(' ',8);
				$header .= '5';
				$header .= str_repeat(chr(0),100);
				$header .= str_pad('ustar',6,chr(32));
				$header .= chr(32) . chr(0);
				$header .= str_pad('',32,chr(0));
				$header .= str_pad('',32,chr(0));
				$header .= str_repeat(chr(0),8);
				$header .= str_repeat(chr(0),8);
				$header .= str_repeat(chr(0),155);
				$header .= str_repeat(chr(0),12);
				$checksum = str_pad(decoct($this->computeUnsignedChecksum($header)),6,'0',STR_PAD_LEFT);	// Compute header checksum
				for($i=0; $i<6; $i++)
					$header[(148 + $i)] = substr($checksum,$i,1);
				$header[154] = chr(0);
				$header[155] = chr(32);
				$this->content .= $header;																	// Add new tar formatted data to tar file contents
			}
		}
		if( $this->numFiles > 0 )																				// Generate Records for each file, if we have files( We should...)
		{
			foreach( $this->files as $key => $information )
			{
				unset($header);
				// Generate the TAR header for this file
				// Filename, Permissions, UID, GID, size, Time, checksum, typeflag, linkname, magic, version, user name, group name, devmajor, devminor, prefix, end
				$header	= '';
				$header .= str_pad($information['name'],100,chr(0));
				$header .= str_pad(decoct($information['mode']),7,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['user_id']),7,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['group_id']),7,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['size']),11,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_pad(decoct($information['time']),11,'0',STR_PAD_LEFT) . chr(0);
				$header .= str_repeat(' ',8);
				$header .= '0';
				$header .= str_repeat(chr(0),100);
				$header .= str_pad('ustar',6,chr(32));
				$header .= chr(32) . chr(0);
				$header .= str_pad($information['user_name'],32,chr(0));									// How do I get a file's user name from PHP?
				$header .= str_pad($information['group_name'],32,chr(0));									// How do I get a file's group name from PHP?
				$header .= str_repeat(chr(0),8);
				$header .= str_repeat(chr(0),8);
				$header .= str_repeat(chr(0),155);
				$header .= str_repeat(chr(0),12);
				$checksum = str_pad(decoct($this->computeUnsignedChecksum($header)),6,'0',STR_PAD_LEFT);	// Compute header checksum
				for($i=0; $i<6; $i++)
					$header[(148 + $i)] = substr($checksum,$i,1);
				$header[154] = chr(0);
				$header[155] = chr(32);
				$filecontents = str_pad($information['file'],(ceil($information['size'] / 512) * 512),chr(0));			// Pad file contents to byte count divisible by 512
				$this->content .= $header . $filecontents;													// Add new tar formatted data to tar file contents
			}
		}
		$this->content .= str_repeat(chr(0),512);															// Add 512 bytes of NULLs to designate EOF
		return true;
	}
682791
private function InitArticles()
    {
        $this->archive = Archive::Schema()->ByPage($this->CurrentPage());
        if ($this->archive) 
        {
            $this->InitArchiveArticles();
            return;
        }
        $this->category = Category::Schema()->ByPage($this->CurrentPage());
        if ($this->category)
        {
            $this->archive = $this->category->GetArchive();
            $this->InitCategoryArticles();
        }
    }
921439
private function loadSource(){
		if ($this->args["source"]) {
			$source = $this->localize($this->args["source"]);

			if ($this->args["pecl"]) {
				$this->source = new SourceDir\Pecl($source);
			} elseif ($this->args["git"]) {
				$this->source = new SourceDir\Git($source);
			} elseif (is_file("$source/pharext_package.php")) {
				$this->source = include "$source/pharext_package.php";
			} else {
				$this->source = new SourceDir\Basic($source);
			}

			if (!$this->source instanceof SourceDir) {
				throw new Exception("Unknown source dir $source");
			}

			foreach ($this->source->getPackageInfo() as $key => $val) {
				/* do not override command line arguments */
				if (!isset($this->args->$key)) {
					$this->args->$key = $val;
				}
			}
		}
	}
939056
public function addFiles(Phar $phar)
    {
        $finder = new Finder();
        $finder->files()
            ->ignoreVCS(true)
            ->name('*.php')
            ->name('*.stub')
            ->exclude('Tests')
            ->exclude('tests')
            ->exclude('/storage')
            ->exclude('/config')
            ->exclude('/build')
            ->in($this->pathBase);
        foreach ($finder as $file) {
            $this->addFile($phar, $file);
        }
    }