[zi-cvs] packages/com.zzoss.package.lib Package.php,1.12,1.13
Sandro Zic <[email protected]> Wed, 14 Apr 2004 11:13:50 +0000
| Newsgroups | gmane.comp.php.zzoss.installer.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/zzossinstaller/packages/com.zzoss.package.lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8372/com.zzoss.package.lib
Modified Files:
Package.php
Log Message:
GUI to create package .tgz
Index: Package.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.package.lib/Package.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Package.php 5 Apr 2004 09:58:16 -0000 1.12
--- Package.php 14 Apr 2004 11:13:48 -0000 1.13
***************
*** 445,454 ****
}
- // take care of *nix and Win directory separators
- if(DIRECTORY_SEPARATOR == '/'){
- $wrong_dir_separator = '\\';
- } else {
- $wrong_dir_separator = '/';
- }
foreach($packages as $pos => $package){
--- 445,448 ----
***************
*** 502,599 ****
}
! // Get package.xml and parse it to fill placeholder with content.
!
! $replace_values['{zi_release_date}'] = date('Y-m-d');
! $replace_values['{zi_copyright_year}'] = date('Y');
!
! include_once 'ZZOSS_File/Replace.php';
! $replace = new ZZOSS_FileReplace;
! $replace->file($package_xml);
! $replace->replace($replace_values);
!
! // Create a temporary package.xml
!
! // Create the temporary directory where we place it.
! // But only if the directory does not already exist.
! if(!isset($pkg_tmpdir) || !strlen($pkg_tmpdir)){
! if (!($pkg_tmpdir = System::mktemp('-d'))) {
! return PEAR::raiseError("Cannot create temporary directory.");
! }
! }
!
! $package_xml_new = $pkg_tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
! $replace->writeout($package_xml_new);
!
! // Get package.xml parameters.
! include_once 'ZZOSS_Config/Config.php';
! $config = new ZZOSS_Config(array('cache' => true, 'numeric' => array('file')));
! $config->setFile($package_xml_new);
! $xml = $config->query('/package');
! if($package_unique == $xml['name'].'-'.$xml['release']['version']){
! $tar_list = array();
!
! // Iterate files.
! if(
! !isset($xml['release']['filelist']['file']) ||
! !is_array($xml['release']['filelist']['file'])
! ){
! $files = array();
! } else {
! $files = $xml['release']['filelist']['file'];
! }
! if(count($files)){
! foreach($files as $file){
! $tar_list[] = str_replace($wrong_dir_separator,DIRECTORY_SEPARATOR,$file['@']['name']);
! }
! }
!
! $plugin_files = array();
! // Process plugin files.
! if(
! isset($xml['release']['plugin']['filelist']['file']) &&
! is_array($xml['release']['plugin']['filelist']['file'])){
! $plugin_files = $xml['release']['plugin']['filelist']['file'];
! }
! if(
! isset($xml['release']['plugin']['file']) &&
! is_array($xml['release']['plugin']['file'])){
! $plugin_files = $xml['release']['plugin']['file'];
! }
!
! if(count($plugin_files)){
! // We remember if a plugin file has been defined
! // various times, because we need to process it only once.
! $plugin_files_processed = array();
! foreach($plugin_files as $plugin_file){
! if(!in_array($plugin_file['@']['name'], $plugin_files_processed)){
! array_push($plugin_files_processed, $plugin_file['@']['name']);
! $tar_list[] = $plugin_file['@']['name'];
! }
! }
! }
!
! $cwd = getcwd();
! chdir($package_src);
! $tar = new Archive_Tar($package_dest.$package_tgz);
! //$tar->setErrorHandling(PEAR_ERROR_PRINT);
! $tar->createModify($package_xml_new, '', $pkg_tmpdir);
! //$tar->create('package.xml');
! $tar->addModify($tar_list, $package_unique);
! $log[$package_unique] .= ' Created package '.$package_tgz.'.'."\n";
! chdir($cwd);
!
! // delete the temporary package.xml
! unlink($package_xml_new);
!
! //copy($package_tgz, $package_dest.$package_tgz);
! //@unlink($package_tgz);
! //chdir($cwd);
!
! //$log[$package_unique] .= ' Moved '.$package_tgz.' to '.$bundle_dir.' directory.'."\n";
!
! // remove this package from stack
! unset($packages[$pos]);
! }
}
}
--- 496,504 ----
}
! $pkg_tgz_path = ZZOSS_Package::createPkgArchive($package_src, $package_dest);
! $log[$package_unique] .= ' Created package '.$pkg_tgz_path.'.'."\n";
! // remove this package from stack
! unset($packages[$pos]);
}
}
***************
*** 630,633 ****
--- 535,643 ----
}
+ function createPkgArchive($pkg_src_dir, $pkg_dest_dir = null)
+ {
+ static $pkg_tmpdir = '';
+
+ // take care of *nix and Win directory separators
+ if(DIRECTORY_SEPARATOR == '/'){
+ $wrong_dir_separator = '\\';
+ } else {
+ $wrong_dir_separator = '/';
+ }
+
+ if(is_null($pkg_dest_dir)){
+ $pkg_dest_dir = $pkg_src_dir;
+ }
+
+ $package_xml = $pkg_src_dir.DIRECTORY_SEPARATOR.'package.xml';
+
+ // Get package.xml and parse it to fill placeholder with content.
+
+ $replace_values['{zi_release_date}'] = date('Y-m-d');
+ $replace_values['{zi_copyright_year}'] = date('Y');
+
+ include_once 'ZZOSS_File/Replace.php';
+ $replace = new ZZOSS_FileReplace;
+ $replace->file($package_xml);
+ $replace->replace($replace_values);
+
+ // Create a temporary package.xml
+
+ // Create the temporary directory where we place it.
+ // But only if the directory does not already exist.
+ if(!isset($pkg_tmpdir) || !strlen($pkg_tmpdir)){
+ if (!($pkg_tmpdir = System::mktemp('-d'))) {
+ return PEAR::raiseError("Cannot create temporary directory.");
+ }
+ }
+
+ $package_xml_new = $pkg_tmpdir.DIRECTORY_SEPARATOR.'package.xml';
+ $replace->writeout($package_xml_new);
+
+ // Get package.xml parameters.
+ include_once 'ZZOSS_Config/Config.php';
+ $config = new ZZOSS_Config(array('cache' => true, 'numeric' => array('file')));
+ $config->setFile($package_xml_new);
+ $xml = $config->query('/package');
+
+ $pkg_unique = $xml['name'].'-'.$xml['release']['version'];
+ $pkg_tgz = $pkg_dest_dir.DIRECTORY_SEPARATOR.$pkg_unique.'.tgz';
+ $tar_list = array();
+
+ // Iterate files.
+ if(
+ !isset($xml['release']['filelist']['file']) ||
+ !is_array($xml['release']['filelist']['file'])
+ ){
+ $files = array();
+ } else {
+ $files = $xml['release']['filelist']['file'];
+ }
+ if(count($files)){
+ foreach($files as $file){
+ $tar_list[] = str_replace($wrong_dir_separator,DIRECTORY_SEPARATOR,$file['@']['name']);
+ }
+ }
+
+ $plugin_files = array();
+ // Process plugin files.
+ if(
+ isset($xml['release']['plugin']['filelist']['file']) &&
+ is_array($xml['release']['plugin']['filelist']['file'])){
+ $plugin_files = $xml['release']['plugin']['filelist']['file'];
+ }
+ if(
+ isset($xml['release']['plugin']['file']) &&
+ is_array($xml['release']['plugin']['file'])){
+ $plugin_files = $xml['release']['plugin']['file'];
+ }
+
+ if(count($plugin_files)){
+ // We remember if a plugin file has been defined
+ // various times, because we need to process it only once.
+ $plugin_files_processed = array();
+ foreach($plugin_files as $plugin_file){
+ if(!in_array($plugin_file['@']['name'], $plugin_files_processed)){
+ array_push($plugin_files_processed, $plugin_file['@']['name']);
+ $tar_list[] = $plugin_file['@']['name'];
+ }
+ }
+ }
+
+ $cwd = getcwd();
+ chdir($pkg_src_dir);
+ $tar = new Archive_Tar($pkg_tgz);
+ //$tar->setErrorHandling(PEAR_ERROR_PRINT);
+ $tar->createModify($package_xml_new, '', $pkg_tmpdir);
+ //$tar->create('package.xml');
+ $tar->addModify($tar_list, $pkg_unique);
+ chdir($cwd);
+
+ // delete the temporary package.xml
+ unlink($package_xml_new);
+
+ return $pkg_tgz;
+ }
+
function getLog()
{
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click