Use getters for the output path

This commit is contained in:
Walter Dal Mut 2015-04-12 13:12:26 +02:00
parent c52fb1b0ae
commit 5251337b38
2 changed files with 30 additions and 12 deletions

5
CHANGELOG-0.0.10.md Normal file
View file

@ -0,0 +1,5 @@
# BC Breaks
# Deprecations
* Method `mount` will be replaced by method `addMount` in the future

View file

@ -78,7 +78,15 @@ class Packager
$this->_postRM = $path;
}
/**
* @deprecated See addMount instead
*/
public function mount($sourcePath, $destinationPath)
{
return $this->addMount($sourcePath, $destinationPath);
}
public function addMount($sourcePath, $destinationPath)
{
$this->_mountPoints[$sourcePath] = $destinationPath;
return $this;
@ -90,10 +98,15 @@ class Packager
return $this;
}
public function getOutputPath()
{
return $this->_outputPath;
}
public function run()
{
if (file_exists($this->_outputPath)) {
$iterator = new \DirectoryIterator($this->_outputPath);
if (file_exists($this->getOutputPath())) {
$iterator = new \DirectoryIterator($this->getOutputPath());
foreach ($iterator as $path) {
if ($path != '.' || $path != '..') {
echo "OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!" . PHP_EOL;
@ -102,36 +115,36 @@ class Packager
}
}
mkdir($this->_outputPath, 0777);
mkdir($this->getOutputPath(), 0777);
foreach ($this->_mountPoints as $path => $dest) {
$this->_pathToPath($path, $this->_outputPath . DIRECTORY_SEPARATOR . $dest);
$this->_pathToPath($path, $this->getOutputPath() . DIRECTORY_SEPARATOR . $dest);
}
mkdir($this->_outputPath . "/DEBIAN", 0777);
mkdir($this->getOutputPath() . "/DEBIAN", 0777);
file_put_contents($this->_outputPath . "/DEBIAN/control", (string)$this->_control);
file_put_contents($this->getOutputPath() . "/DEBIAN/control", (string)$this->_control);
if ($this->_preInst) {
$dest = $this->_outputPath . "/DEBIAN/preinst";
$dest = $this->getOutputPath() . "/DEBIAN/preinst";
$this->_copy($this->_preInst, $dest);
chmod($dest, 0755);
}
if ($this->_postInst) {
$dest = $this->_outputPath . "/DEBIAN/postinst";
$dest = $this->getOutputPath() . "/DEBIAN/postinst";
$this->_copy($this->_postInst, $dest);
chmod($dest, 0755);
}
if ($this->_preRM) {
$dest = $this->_outputPath . "/DEBIAN/prerm";
$dest = $this->getOutputPath() . "/DEBIAN/prerm";
$this->_copy($this->_preRM, $dest);
chmod($dest, 0755);
}
if ($this->_postRM) {
$dest = $this->_outputPath . "/DEBIAN/postrm";
$dest = $this->getOutputPath() . "/DEBIAN/postrm";
$this->_copy($this->_postRM, $dest);
chmod($dest, 0755);
}
@ -170,10 +183,10 @@ class Packager
public function build($debPackageName = false)
{
if (!$debPackageName) {
$debPackageName = basename($this->_outputPath . ".deb");
$debPackageName = basename($this->getOutputPath() . ".deb");
}
$command = "dpkg -b {$this->_outputPath} {$debPackageName}";
$command = "dpkg -b {$this->getOutputPath()} {$debPackageName}";
return $command;
}