From 05897c3e010e193ccb772dab511e16c63c8f5075 Mon Sep 17 00:00:00 2001 From: "Andreas Burchert (scarya)" Date: Wed, 20 Oct 2010 19:47:31 +0000 Subject: [PATCH] - fix in FroxlorPkgCreator::pack() (better file name, path fix) - added FroxlorDeployfileCreator --- .../class.FroxlorDeployfileCreator.php | 89 +++++++++++++++++++ .../sshtransport/class.FroxlorPkgCreator.php | 2 +- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 lib/classes/sshtransport/class.FroxlorDeployfileCreator.php diff --git a/lib/classes/sshtransport/class.FroxlorDeployfileCreator.php b/lib/classes/sshtransport/class.FroxlorDeployfileCreator.php new file mode 100644 index 00000000..b66e6e3b --- /dev/null +++ b/lib/classes/sshtransport/class.FroxlorDeployfileCreator.php @@ -0,0 +1,89 @@ + + * @copyright 2010 the authors + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @version SVN: $Id: class.FroxlorPkgCreator.php 1376 2010-10-20 19:07:51Z scarya $ + * @link http://www.froxlor.org/ + */ + +/** + * Class FroxlorDeployfileCreator + * + * This class creates the deploy file. + * + * @category FroxlorCore + * @package Classes + * @subpackage System + * @author Froxlor Team + * @copyright 2010 the authors + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @link http://www.froxlor.org/ + */ +class FroxlorDeployfileCreator +{ + public static $_list = null; + + /** + * This function iterates through the $dir and generates the deploy list. + * + * @param string $dir dir to deploy + * + * @return array file listing + */ + public static function createList($dir) + { + $list = array(); + + if (is_dir($dir)) { + $its = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir) + ); + + foreach ($its as $fullFileName => $it ) { + if (!preg_match("/userdata.inc.php$/i", $it->getFilename())) { + $list[] = strstr($fullFileName, "lib/"); + } + } + + } + + self::$_list = $list; + + return $list; + } + + /** + * This function saves the deploy list to a file. + * + * @param string $toPath file path + * @param array $list array list with all needed files + * + * @return boolean + */ + public static function saveListTo($toPath, $list = null) + { + if (is_null($list)) { + $list = self::$_list; + } + + return file_put_contents($toPath, implode("\n", $list)); + } +} \ No newline at end of file diff --git a/lib/classes/sshtransport/class.FroxlorPkgCreator.php b/lib/classes/sshtransport/class.FroxlorPkgCreator.php index 0bcf7135..1f36430e 100644 --- a/lib/classes/sshtransport/class.FroxlorPkgCreator.php +++ b/lib/classes/sshtransport/class.FroxlorPkgCreator.php @@ -132,7 +132,7 @@ class FroxlorPkgCreator if ($zip->open($toPath, ZIPARCHIVE::OVERWRITE)) { // write data foreach ($this->_config as $var) { - $zip->addFile($var); + $zip->addFile($var, strstr($var, "lib/")); } // close it