Generate the package file, saving to the given location
abstract public generatePackage ( string $sha, string $baseDir, $outputFilename, DeploynautLogFile $log ) : boolean | ||
$sha | string | |
$baseDir | string | string The base directory of the project, checked out from git. |
$outputFilename | string The filename to write to. | |
$log | DeploynautLogFile | |
return | boolean | True on success |
/** * Return the filename of the generated package, retrieving from cache or generating as necessary * * @param PackageGenerator $generator The generator to use to create cache entries. * @param string $identifier A unique identifier for the generator; used to partition the cache * @param string $sha The SHA of the commit to be deployed * @param string $repositoryDir The directory where the repository resides * @param DeploynautLogFile $log The log to write status output to, including package-generation commands */ public function getPackageFilename(PackageGenerator $generator, $identifier, $sha, $repositoryDir, DeploynautLogFile $log) { if (!$this->baseDir) { throw new \LogicException("Can't use PackageCache without setting BaseDir"); } $buildPath = $this->baseDir . '/' . $this->sanitiseDirName($identifier); $filename = "{$buildPath}/{$sha}.tar.gz"; if (!file_exists($this->baseDir)) { if (!mkdir($this->baseDir)) { throw new \LogicException("Can't create base dir {$this->baseDir}"); } } if (!file_exists($buildPath)) { if (!mkdir($buildPath)) { throw new \LogicException("Can't create build path {$buildPath}"); } } if (file_exists($filename)) { $log->write("Using previously generated package {$filename}"); // This will ensure that our cache garbage collection will remove least-recently-accessed, // rather than oldest. touch($filename); return $filename; } else { if ($this->cacheSize) { $this->reduceDirSizeTo($buildPath, $this->cacheSize - 1, $log); } if ($generator->generatePackage($sha, $repositoryDir, $filename, $log)) { return $filename; } } }