[zi-cvs] packages/com.zzoss.package.lib Dependency.php,1.4,1.5 Package.php,1.8,1.9
Sandro Zic <[email protected]> Thu, 01 Apr 2004 18:59:13 +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-serv15800/com.zzoss.package.lib
Modified Files:
Dependency.php Package.php
Log Message:
better and wrapped bundle routines
Index: Package.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.package.lib/Package.php,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Package.php 27 Mar 2004 14:16:15 -0000 1.8
--- Package.php 1 Apr 2004 18:59:05 -0000 1.9
***************
*** 24,27 ****
--- 24,28 ----
*/
+ require_once 'PEAR.php';
require_once 'Archive/Tar.php';
require_once 'System.php';
***************
*** 39,43 ****
*/
! class ZZOSS_Package {
/**
--- 40,44 ----
*/
! class ZZOSS_Package extends PEAR {
/**
***************
*** 51,54 ****
--- 52,72 ----
var $pkgs_unprocessed = array();
+ /**
+ * The path to the bundle tgz.
+ */
+ var $_bundle_tgz = '';
+
+ /*
+ * Destructor
+ */
+ function _ZZOSS_Package()
+ {
+ // clean up temporary bundle tgz
+ if ($this->_bundle_tgz != ''){
+ @unlink($this->_bundle_tgz);
+ }
+ $this->_PEAR();
+ }
+
function extractBundles($src, $dest, $backup_dest = NULL)
{
***************
*** 75,78 ****
--- 93,180 ----
}
+ function mkBundle($dir_src, $distri_xml = null, $app_xml = null)
+ {
+ // reset previous bundle tgz
+ $this->_bundle_tgz = '';
+
+ // if distri or app XML are not provided, we
+ // asumme they are within the src dir
+ if(is_null($distri_xml)){
+ $distri_xml = $dir_src.DIRECTORY_SEPARATOR.'distribution.xml';
+ }
+ if(is_null($app_xml)){
+ $app_xml = $dir_src.DIRECTORY_SEPARATOR.'application.xml';
+ }
+
+ // destination directory is the temp dir of the system
+ $dir_dest = System::tmpdir().DIRECTORY_SEPARATOR;
+
+ // check whether distribution and app XML exist
+ if(!file_exists($distri_xml)){
+ return PEAR::raiseError("Distribution XML does not exist at '$distri_xml'");
+ }
+ if(!file_exists($app_xml)){
+ return PEAR::raiseError("Distribution XML does not exist at '$app_xml'");
+ }
+
+ $config = new ZZOSS_Config;
+ $config->setFile($distri_xml);
+ $xml = $config->query('/distribution');
+ $distri_name = $xml['name'];
+
+ $config = new ZZOSS_Config;
+ $config->setFile($app_xml);
+ $xml = $config->query('/application');
+ $app_name = $xml['name'];
+ $app_version = $xml['release']['version'];
+
+ // clean up memory
+ unset($config);
+ unset($xml);
+
+ //System::mkdir(array('-p', $dir_dest));
+
+ // copy the distribution XML descriptor to the bundle directory
+ //copy($distri_xml, $dir_src.'distribution.xml');
+ // copy the application XML descriptor to the bundle directory
+ //copy($app_xml, $dir_src.'application.xml');
+
+ // Create the bundle.tgz
+ $instant_tgz = $app_name.'-'.$app_version.'.tgz';
+ $bundle_tgz = $distri_name.'.'.$app_name.'.bundle-'.$app_version.'.tgz';
+
+ if($dp = @opendir($dir_src)) {
+ while (false !== ($entry = readdir($dp))) {
+ // make sure that we do not include the bundle or the instant bundle
+ if($entry != '.' && $entry != '..') {
+ $tar_list[] = $entry;
+ }
+ }
+ closedir($dp);
+ }
+
+ $cwd = getcwd();
+ chdir($dir_src);
+ $tar = new Archive_Tar($dir_dest.$bundle_tgz);
+ $tar->create($tar_list);
+ chdir($cwd);
+ // add distribution and app XML to the tgz
+ $tar->addModify($distri_xml, '', dirname($distri_xml));
+ $tar->addModify($app_xml, '', dirname($app_xml));
+
+ // copy bundle to bundles/ directory of installer
+ //copy($dir_src.$bundle_tgz, $dir_dest.$bundle_tgz);
+ //@unlink($dir_src.$bundle_tgz);
+
+ // We use PEAR to clean up the temporary bundle upon shutdown
+ // with the destructor.
+ // Notice that ZZOSS_Package extends PEAR!
+ $this->PEAR();
+
+ $this->_bundle_tgz = $dir_dest.$bundle_tgz;
+
+ return $this->_bundle_tgz;
+ }
+
function extractBundle($file, $dest, $backup_dest = NULL)
{
***************
*** 315,319 ****
$package = $package_config->query('/package');
$package_xml_dest = $dest.$package["name"].'-'.$package["release"]["version"].DIRECTORY_SEPARATOR.'package.xml';
!
copy($package_xml_src, $package_xml_dest);
if(ZZOSS_PACKAGE_DEBUG){
--- 417,424 ----
$package = $package_config->query('/package');
$package_xml_dest = $dest.$package["name"].'-'.$package["release"]["version"].DIRECTORY_SEPARATOR.'package.xml';
! // create the pckage directory if it does not exist yet
! if(!is_dir($package_xml_src)){
! System::mkdir(array('-p', dirname($package_xml_src)));
! }
copy($package_xml_src, $package_xml_dest);
if(ZZOSS_PACKAGE_DEBUG){
Index: Dependency.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.package.lib/Dependency.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Dependency.php 5 Mar 2004 14:25:23 -0000 1.4
--- Dependency.php 1 Apr 2004 18:59:04 -0000 1.5
***************
*** 245,249 ****
//echo $this->dep["#"].'<- '.$this->package_name.'<br>';
$pkg_undef_name = $this->dep["#"];
! if(strlen($this->dep["@"]["version"])){
$pkg_undef_name .= '-'.$this->dep["@"]["version"];
$this->undefined[$pkg_undef_name]['version'] = $this->dep["@"]["version"];
--- 245,249 ----
//echo $this->dep["#"].'<- '.$this->package_name.'<br>';
$pkg_undef_name = $this->dep["#"];
! if(isset($this->dep["@"]["version"]) && strlen($this->dep["@"]["version"])){
$pkg_undef_name .= '-'.$this->dep["@"]["version"];
$this->undefined[$pkg_undef_name]['version'] = $this->dep["@"]["version"];
-------------------------------------------------------
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