From e705d0fe8cf295cee563d28e516c0b9921048340 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Mon, 4 Jun 2012 11:03:35 +0200 Subject: [PATCH] Added scripts --- src/wdm/debian/Packager.php | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/wdm/debian/Packager.php b/src/wdm/debian/Packager.php index 3f882ad..8a5024f 100644 --- a/src/wdm/debian/Packager.php +++ b/src/wdm/debian/Packager.php @@ -38,12 +38,65 @@ class Packager private $_mountPoints = array(); private $_outputPath; + private $_preInst; + private $_postInst; + private $_preRM; + private $_postRM; + + /** + * Set the control file + * + * This file contains the base package information + * + * @param StandardFile $control + * @return \wdm\debian\Packager + */ public function setControl(StandardFile $control) { $this->_control = $control; return $this; } + /** + * Pre install script + * + * @param string $path The absolute path of your pre-install script + */ + public function setPreInstallScript($path) + { + $this->_preInst = $path; + } + + /** + * Post install script + * + * @param string $path The absolute path of your post-install script + */ + public function setPostInstallScript($path) + { + $this->_postInst = $path; + } + + /** + * Pre remove script + * + * @param string $path The absolute path of your pre-remove script + */ + public function setPreRemoveScript($path) + { + $this->_preRM = $path; + } + + /** + * Post remove script + * + * @param string $path The absolute path of your post-remove script + */ + public function setPostRemoveScript($path) + { + $this->_postRM = $path; + } + public function mount($sourcePath, $destinationPath) { $this->_mountPoints[$sourcePath] = $destinationPath; @@ -73,8 +126,33 @@ class Packager } mkdir($this->_outputPath . "/DEBIAN", 0777); + file_put_contents($this->_outputPath . "/DEBIAN/control", (string)$this->_control); + if ($this->_preInst) { + $dest = $this->_outputPath . "/DEBIAN/preinst"; + $this->_copy($this->_preInst, $dest); + chmod($dest, 0755); + } + + if ($this->_postInst) { + $dest = $this->_outputPath . "/DEBIAN/postinst"; + $this->_copy($this->_postInst, $dest); + chmod($dest, 0755); + } + + if ($this->_preRM) { + $dest = $this->_outputPath . "/DEBIAN/prerm"; + $this->_copy($this->_preRM, $dest); + chmod($dest, 0755); + } + + if ($this->_postRM) { + $dest = $this->_outputPath . "/DEBIAN/postrm"; + $this->_copy($this->_postRM, $dest); + chmod($dest, 0755); + } + return $this; }