/**
  * Verifies if all neccessary packages are present
  *
  * @param	string	$packageType
  * @param	string	$directory
  */
 public function verifyPackages($packageType, $directory)
 {
     $directory = $this->source->sourceDirectory . $directory;
     // break if package type is unknown
     if (!isset($this->package[$packageType])) {
         return;
     }
     foreach ($this->package[$packageType] as $packageName => $package) {
         // we do not care about referenced packages with an empty file attribute
         if (empty($package['file'])) {
             continue;
         }
         // check for file in optionals/requiredments folder
         if (file_exists($directory . $package['file'])) {
             continue;
         }
         // look for previously built packages
         $location = PackageHelper::searchPackage($packageName);
         if (!is_null($location)) {
             if (!@copy($location, $directory . $package['file'])) {
                 throw new SystemException('Unable to copy archive (' . $package['file'] . '), check permissions for directory ' . $directory);
             }
             // register temporary file
             PackageHelper::registerTemporaryFile($directory . $package['file']);
             continue;
         }
         // set minimum required version or null if version does not matter
         $minVersion = isset($package['minversion']) ? $package['minversion'] : null;
         // search within cached packages
         $location = PackageHelper::searchCachedPackage($this->source->sourceID, $packageName, $minVersion);
         if (!is_null($location)) {
             $packageData = new PackageReader($this->source, $location);
             $pb = new PackageBuilder($this->source, $packageData, $location, 'pn', array(), true, true);
             // add directory if it does not exist
             FileUtil::makePath(dirname($directory . $package['file']), 0777);
             // copy archive
             if (!@copy($pb->getArchiveLocation(), $directory . $package['file'])) {
                 throw new SystemException('Unable to copy archive (' . $package['file'] . '), check permissions for directory ' . $directory);
             }
             // register temporary file
             PackageHelper::registerTemporaryFile($directory . $package['file']);
             continue;
         }
         // we were unable to locate or build package, thus we have no chance to build this package
         throw new SystemException('Can not build package, ' . $package['file'] . ' not found.');
     }
 }