/** * @see Installer::createTargetDir() */ protected function createTargetDir() { if (!@is_dir($this->targetDir)) { if (!FileUtil::makePath($this->targetDir, IS_APACHE_MODULE ? 0777 : 0755)) { throw new SystemException("Could not create dir '" . $this->targetDir . "'", 11011); } } if (IS_APACHE_MODULE || !is_writeable($this->targetDir)) { $this->makeWriteable($this->targetDir); } }
/** * Clones a directory. * * @param string $buildDirectory * @param string $path */ protected function cloneDirectory($buildDirectory, $path) { $path = FileUtil::addTrailingSlash($path); // ensure source directory exists if (!is_dir($this->resourceDirectory . $path)) { throw new SystemException("Required path '" . $path . "' within resource directory is not available."); } // create path if (!is_dir($buildDirectory . $path)) { FileUtil::makePath($buildDirectory . $path); } // copy files recursively $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->resourceDirectory . $path)); while ($it->valid()) { if (!$it->isDot()) { // ignore .svn directories $tmp = explode('/', FileUtil::unifyDirSeperator($it->getSubPath())); if (in_array('.svn', $tmp)) { $it->next(); continue; } $subPath = FileUtil::addTrailingSlash($it->getSubPath()); if (!is_dir($buildDirectory . $path . $subPath)) { FileUtil::makePath($buildDirectory . $path . $subPath); } copy($it->key(), $buildDirectory . $path . $it->getSubPathName()); } $it->next(); } }
/** * 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.'); } }