/**
  * @see	Action::execute()
  */
 public function execute()
 {
     parent::execute();
     $this->sourceFileEditor->delete();
     $this->executed();
     exit;
 }
 /**
  * Builds a package
  *
  * @param	integer		$source			id or instance of a source
  * @param	PackageReader	$package		required and optional packages
  * @param	string		$directory		source directory
  * @param	string		$filename		the filename
  * @param	mixed		$excludeFiles		files to exclude while packing archive
  * @param	boolean		$ignoreDotFiles		should files beginning with a dot be ignored
  * @param	boolean		$removeAfter		should temporary files be removed afterwards
  */
 public function __construct($source, PackageReader $package, $directory, $filename, $excludeFiles = array(), $ignoreDotFiles = true, $removeAfter = false, $allowedDotFiles = array())
 {
     // read source
     $this->source = $source instanceof Source ? $source : new Source($source);
     // read package
     $this->package = $package->getPackageData();
     if (!isset($this->package['name'])) {
         throw new SystemException('Missing package name in "' . $directory . '", package.xml is not valid');
     }
     $this->ignoreDotFiles = $ignoreDotFiles;
     // add additional files whitch should be allowed
     if (!empty($allowedDotFiles)) {
         if (!is_array($allowedDotFiles)) {
             $allowedDotFiles = array($allowedDotFiles);
         }
         $this->allowedDotFiles = array_merge($this->allowedDotFiles, $allowedDotFiles);
     }
     // add additional files whitch should be excluded
     if (!empty($excludeFiles)) {
         if (!is_array($excludeFiles)) {
             $excludeFiles = array($excludeFiles);
         }
         $this->excludeFiles = array_merge($this->excludeFiles, $excludeFiles);
     }
     // get data for filename
     $data = array('pn' => $this->package['name'], 'pv' => $this->package['version'], 'pr' => 'r' . $this->source->revision, 't' => DateUtil::formatTime('%Y-%m-%d %H:%M:%S', TIME_NOW, false));
     // set archive name
     $this->filename = PackageHelper::getArchiveName($filename, $data);
     // mark package as built
     $buildDirectory = FileUtil::addTrailingSlash($this->source->buildDirectory);
     $location = $buildDirectory . $this->filename;
     PackageHelper::addPackageData($this->package['name'], $location);
     // check requirements
     $this->verifyPackages('requiredpackage', $directory);
     $this->verifyPackages('optionalpackage', $directory);
     // intialize archive
     $location = $this->createArchive($directory, $this->filename, $removeAfter);
     // do not move files created on-the-fly
     if (PackageHelper::isTemporaryFile($location)) {
         $this->location = $location;
         return;
     }
     // register file
     require_once PB_DIR . 'lib/data/source/file/SourceFileEditor.class.php';
     $sourceFile = SourceFileEditor::create($this->source->sourceID, $location, 'package');
     $this->location = $sourceFile->getPath();
 }
 /**
  * Builds a WCFSetup.
  * 
  * @param	array	$packages
  * @param	string	$outputDirectory
  */
 public function createWcfSetup(array $packages, $outputDirectory = '')
 {
     // ensure output directory is set and exists
     if (empty($outputDirectory)) {
         $outputDirectory = $this->source->buildDirectory;
     } else {
         if (!is_dir($outputDirectory)) {
             FileUtil::makePath($outputDirectory);
         }
     }
     $outputDirectory = FileUtil::addTrailingSlash($outputDirectory);
     // create temporarily directory
     $hash = StringUtil::getRandomID();
     $buildDirectory = $outputDirectory . $hash . '/';
     // populate install directory
     $this->cloneDirectory($buildDirectory, 'install/files');
     $this->cloneDirectory($buildDirectory, 'install/lang');
     $this->cloneDirectory($buildDirectory, 'install/packages');
     // populate setup directory
     $this->cloneDirectory($buildDirectory, 'setup/db');
     $this->cloneDirectory($buildDirectory, 'setup/lang');
     $this->cloneDirectory($buildDirectory, 'setup/license');
     $this->cloneDirectory($buildDirectory, 'setup/template');
     // copy packages
     foreach ($packages as $package) {
         if (!file_exists($package)) {
             throw new SystemException("Required package '" . $package . "' not found.");
         }
         copy($package, $buildDirectory . 'install/packages/' . basename($package));
     }
     // create wcf setup
     $wcfSetup = new TarWriter($outputDirectory . 'WCFSetup.tar.gz', true);
     $wcfSetup->add(array($buildDirectory . 'install', $buildDirectory . 'setup'), '', $buildDirectory);
     $wcfSetup->create();
     // remove temoprarily directory
     $this->deleteDirectory($buildDirectory);
     @rmdir($buildDirectory);
     // set path
     $path = $outputDirectory . 'WCFSetup.tar.gz';
     require_once PB_DIR . 'lib/data/source/file/SourceFileEditor.class.php';
     $sourceFile = SourceFileEditor::create($this->source->sourceID, $path, 'wcfsetup', $this->profileName);
     $this->path = $sourceFile->getPath();
 }