[zi-cvs] packages/com.zzoss.package.lib Dependency.php,1.3,1.4 Package.php,1.4,1.5

[email protected] Fri, 05 Mar 2004 06:25:56 -0800
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-serv8129/com.zzoss.package.lib

Modified Files:
	Dependency.php Package.php 
Log Message:
new plugin architecture in installer

Index: Dependency.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.package.lib/Dependency.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Dependency.php	12 Feb 2004 10:36:40 -0000	1.3
--- Dependency.php	5 Mar 2004 14:25:23 -0000	1.4
***************
*** 243,246 ****
--- 243,247 ----
                  // Check if the needed package is defined in application.xml
                  if(!isset($this->packages_versions[$this->dep["#"]])){
+                     //echo $this->dep["#"].'<- '.$this->package_name.'<br>';
                      $pkg_undef_name = $this->dep["#"];
                      if(strlen($this->dep["@"]["version"])){
***************
*** 250,254 ****
                      $this->undefined[$pkg_undef_name]['name'] = $this->dep["#"];
                      $this->undefined[$pkg_undef_name]['needed_by'][] = array($this->package_name => $this->dep["@"]["rel"]);
!                     $this->undefined[$pkg_undef_name]['needed_by'] = array_unique($this->undefined[$pkg_undef_name]['needed_by']);
                      $this->error = 'Some packages not defined by application';
                  } else {
--- 251,257 ----
                      $this->undefined[$pkg_undef_name]['name'] = $this->dep["#"];
                      $this->undefined[$pkg_undef_name]['needed_by'][] = array($this->package_name => $this->dep["@"]["rel"]);
!                     //print_r($this->undefined[$pkg_undef_name]['needed_by']);
!                     //$this->undefined[$pkg_undef_name]['needed_by'] = array_unique($this->undefined[$pkg_undef_name]['needed_by']);
!                     //print_r($this->undefined[$pkg_undef_name]['needed_by']);
                      $this->error = 'Some packages not defined by application';
                  } else {
***************
*** 263,267 ****
                          if(!$this->_isResolved($this->dep['@']['rel'], $this->dep["#"], $v_available, $this->dep["@"]["version"])){
                              $pending[$this->dep["#"].'-'.$v_available]['needed_by'][] = array($this->package_name => $this->dep["@"]["rel"]);
!                             $pending[$this->dep["#"].'-'.$v_available]['needed_by'] = array_unique($pending[$this->dep["#"].'-'.$v_available]['needed_by']);
                          } else {
                              $dep_result = true;
--- 266,270 ----
                          if(!$this->_isResolved($this->dep['@']['rel'], $this->dep["#"], $v_available, $this->dep["@"]["version"])){
                              $pending[$this->dep["#"].'-'.$v_available]['needed_by'][] = array($this->package_name => $this->dep["@"]["rel"]);
!                             //$pending[$this->dep["#"].'-'.$v_available]['needed_by'] = array_unique($pending[$this->dep["#"].'-'.$v_available]['needed_by']);
                          } else {
                              $dep_result = true;

Index: Package.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.package.lib/Package.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Package.php	9 Feb 2004 18:16:10 -0000	1.4
--- Package.php	5 Mar 2004 14:25:23 -0000	1.5
***************
*** 106,109 ****
--- 106,112 ----
              
              if(!is_null($backup_dest)){
+                 if(!is_dir($backup_dest)){
+                     System::mkdir(array('-p', $backup_dest));
+                 }
                  copy($file, $backup_dest.basename($file));
              }
***************
*** 209,220 ****
          $application = $application_config->query('/application');
          $application_dir = $dest.'applications'.DIRECTORY_SEPARATOR.$application["name"].'-'.$application["release"]["version"].DIRECTORY_SEPARATOR;
!         System::mkdir(array('-p',$application_dir));
          @copy($application_xml_src, $application_dir.'application.xml');
-         System::mkdir(array('-p',$application_dir.'installer'));
-         System::mkdir(array('-p',$application_dir.'downloads'));
-         System::mkdir(array('-p',$application_dir.'packages'));
-         System::mkdir(array('-p',$application_dir.'packages_installed'));
-         System::mkdir(array('-p',$application_dir.'cache'));
-         System::mkdir(array('-p',$application_dir.'plugins'));
          
          if(file_exists($packages_xml_src)){
--- 212,217 ----
          $application = $application_config->query('/application');
          $application_dir = $dest.'applications'.DIRECTORY_SEPARATOR.$application["name"].'-'.$application["release"]["version"].DIRECTORY_SEPARATOR;
!         ZZOSS_InstallerRegistry::mkDirsApplication($application_dir);
          @copy($application_xml_src, $application_dir.'application.xml');
          
          if(file_exists($packages_xml_src)){
***************
*** 256,260 ****
      }
      
!     function extractPackages($src, $dest)
      {
          if(ZZOSS_PACKAGE_DEBUG){
--- 253,257 ----
      }
      
!     function extractPackages($src, $dest, $pkgs_allowed = array())
      {
          if(ZZOSS_PACKAGE_DEBUG){
***************
*** 265,298 ****
              while (false !== ($file = readdir($dp))) { 
                  $parts = pathinfo($file);
!                 if($parts["extension"]=='tgz' || $parts["extension"]=='gz') {
                      $pkgsrc = $src.$file;
!                     if(ZZOSS_PACKAGE_DEBUG){
!                         ZZOSS_Debug::log('ZZOSS_Package', 'Attempting to extract '.$pkgsrc.' to '.$dest, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                     }
!                     $tar = new Archive_Tar($pkgsrc);
!                     if (!$tar->extract($dest)) {
!                         return PEAR::raiseError("unable to unpack $pgksrc");
!                         if(ZZOSS_PACKAGE_DEBUG){
!                             ZZOSS_Debug::log('ZZOSS_Package', 'Unable to extract '.$pkgsrc.' to '.$dest, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
                          }
                      }
!                     @unlink($pkgsrc);
!                     $package_xml_src = $dest.'package.xml';
!                     if(ZZOSS_PACKAGE_DEBUG){
!                         ZZOSS_Debug::log('ZZOSS_Package', 'Detect '.$package_xml_src.' of '.$pkgsrc, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                     }
!                     if(file_exists($package_xml_src)) {
                          if(ZZOSS_PACKAGE_DEBUG){
!                             ZZOSS_Debug::log('ZZOSS_Package', 'Read '.$package_xml_src.' of '.$pkgsrc, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
                          }
!                         $package_config = new ZZOSS_Config(array('numeric' => array('dep','file', 'build', 'maintainer')));
!                         $package_config->setFile($package_xml_src);
!                         $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){
!                             ZZOSS_Debug::log('ZZOSS_Package', 'Copied '.$package_xml_src.' to '.$package_xml_dest, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
                          }
-                         unlink($package_xml_src);
                      }
                  }
--- 262,307 ----
              while (false !== ($file = readdir($dp))) { 
                  $parts = pathinfo($file);
!                 if($parts["extension"] == 'tgz' || $parts["extension"] == 'gz') {
                      $pkgsrc = $src.$file;
!                     
!                     $do_extract = true;
!                     // did we specify the packages we allow to be extracted
!                     if(count($pkgs_allowed)){
!                         $pkg_name = str_replace('.'.$parts['extension'], '', $parts['basename']);
!                         if(!isset($pkgs_allowed[$pkg_name])){
!                             $do_extract = false;
                          }
                      }
!                     
!                     if($do_extract){
                          if(ZZOSS_PACKAGE_DEBUG){
!                             ZZOSS_Debug::log('ZZOSS_Package', 'Attempting to extract '.$pkgsrc.' to '.$dest, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
                          }
!                         $tar = new Archive_Tar($pkgsrc);
!                         if (!$tar->extract($dest)) {
!                             return PEAR::raiseError("unable to unpack $pgksrc");
!                             if(ZZOSS_PACKAGE_DEBUG){
!                                 ZZOSS_Debug::log('ZZOSS_Package', 'Unable to extract '.$pkgsrc.' to '.$dest, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                             }
!                         }
!                         //@unlink($pkgsrc);
!                         $package_xml_src = $dest.'package.xml';
                          if(ZZOSS_PACKAGE_DEBUG){
!                             ZZOSS_Debug::log('ZZOSS_Package', 'Detect '.$package_xml_src.' of '.$pkgsrc, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                         }
!                         if(file_exists($package_xml_src)) {
!                             if(ZZOSS_PACKAGE_DEBUG){
!                                 ZZOSS_Debug::log('ZZOSS_Package', 'Read '.$package_xml_src.' of '.$pkgsrc, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                             }
!                             $package_config = new ZZOSS_Config(array('numeric' => array('dep','file', 'build', 'maintainer')));
!                             $package_config->setFile($package_xml_src);
!                             $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){
!                                 ZZOSS_Debug::log('ZZOSS_Package', 'Copied '.$package_xml_src.' to '.$package_xml_dest, __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                             }
!                             unlink($package_xml_src);
                          }
                      }
                  }
***************
*** 304,316 ****
      function packageSources($bundle_dir, $packages, $app_settings)
      {
          foreach($packages as $pos => $package){
              
              $package_unique = $package['@']['name'].'-'.$package['@']['version'];
              
              for($i = 1; $i <= 5; $i++){
                  if(strlen($app_settings['source_'.$i])){
                      if(isset($packages[$pos])){
                          $log[$package_unique] .= '* Scanning '.$app_settings['source_'.$i]."\n";
!                         $package_src = $app_settings['source_'.$i].$package['@']['name'].DIRECTORY_SEPARATOR;
                          $package_dest = $bundle_dir;
                          $package_tgz = $package_unique.'.tgz';
--- 313,335 ----
      function packageSources($bundle_dir, $packages, $app_settings)
      {
+         $has_pkg_source = false;
+         $log = array();
+         if(!is_dir($bundle_dir)){
+             System::mkdir(array('-p', $bundle_dir));
+         }
+         
          foreach($packages as $pos => $package){
              
              $package_unique = $package['@']['name'].'-'.$package['@']['version'];
+             $log[$package_unique] = '';
              
              for($i = 1; $i <= 5; $i++){
                  if(strlen($app_settings['source_'.$i])){
                      if(isset($packages[$pos])){
+                         
+                         $has_pkg_source = true;
+                         
                          $log[$package_unique] .= '* Scanning '.$app_settings['source_'.$i]."\n";
!                         $package_src = ZZOSS_InstallerUtils::fixPath($app_settings['source_'.$i].DIRECTORY_SEPARATOR.$package['@']['name'].DIRECTORY_SEPARATOR);
                          $package_dest = $bundle_dir;
                          $package_tgz = $package_unique.'.tgz';
***************
*** 318,325 ****
                          
                          if(!file_exists($package_xml)){
                              // Maybe, a .tgz is already there...
!                             if(file_exists($app_settings['source_'.$i].$package_tgz)){
                                  $log[$package_unique] .= '  Found '.$package_tgz.'.'."\n";
!                                 copy($app_settings['source_'.$i].$package_tgz, $package_dest.$package_tgz);
                                  // remove this package from stack
                                  unset($packages[$pos]);
--- 337,345 ----
                          
                          if(!file_exists($package_xml)){
+                             $package_tgz_path = ZZOSS_InstallerUtils::fixPath($app_settings['source_'.$i].DIRECTORY_SEPARATOR.$package_tgz);
                              // Maybe, a .tgz is already there...
!                             if(file_exists($package_tgz_path)){
                                  $log[$package_unique] .= '  Found '.$package_tgz.'.'."\n";
!                                 copy($package_tgz_path, $package_dest.$package_tgz);
                                  // remove this package from stack
                                  unset($packages[$pos]);
***************
*** 345,350 ****
                              // Create the temporary directory where we place it.
                              // But only if the directory does not already exist.
!                             if(!strlen($pgk_tmpdir)){
!                                 if (!($pkg_tmpdir = System::mktemp(array('-d')))) {
                                      return PEAR::raiseError("Cannot create temporary directory.");
                                  }
--- 365,370 ----
                              // 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.");
                                  }
***************
*** 364,370 ****
                                  
                                  // Iterate files.
!                                 $files = $xml['release']['filelist']['file'];
!                                 if(!is_array($files)){
                                      $files = array();
                                  }
                                  if(count($files)){
--- 384,394 ----
                                  
                                  // 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)){
***************
*** 376,383 ****
                                  $plugin_files = array();
                                  // Process plugin files.
!                                 if(is_array($xml['release']['plugin']['filelist']['file'])){
                                      $plugin_files = $xml['release']['plugin']['filelist']['file'];
                                  }
!                                 if(is_array($xml['release']['plugin']['file'])){
                                      $plugin_files = $xml['release']['plugin']['file'];
                                  }
--- 400,411 ----
                                  $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'];
                                  }
***************
*** 423,433 ****
          }
          
          $this->pkgs_unprocessed = $packages;
          
          // If a temporary directory has been created for temporary package.xml files,
          // then remove it now.
!         if(strlen($pgk_tmpdir)){
!             System::rm(array('-rf', $pgk_tmpdir));
!         }
          
          // General info
--- 451,468 ----
          }
          
+         if(!$has_pkg_source){
+             return false;
+         }
+         
          $this->pkgs_unprocessed = $packages;
          
          // If a temporary directory has been created for temporary package.xml files,
          // then remove it now.
!         
!         // is handled by a shutdown function of PEAR::System
!         /*if(isset($pkg_tmpdir) && is_dir($pkg_tmpdir)){
!             echo "<p>$pkg_tmpdir</p>";
!             //System::rm(array('-rf', $pkg_tmpdir));
!         }*/
          
          // General info
***************
*** 440,443 ****
--- 475,480 ----
              $this->log .= "\n";
          }
+         
+         return true;
      }
      



-------------------------------------------------------
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