[zi-cvs] packages/com.zzoss.installer.lib Registry.php,1.29,1.30 Setup.php,1.6,1.7 Utils.php,1.7,1.8

Sandro Zic <[email protected]> Tue, 06 Apr 2004 14:45:19 +0000
Newsgroups gmane.comp.php.zzoss.installer.cvs
Message-ID <[email protected]>
Update of /cvsroot/zzossinstaller/packages/com.zzoss.installer.lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32569/com.zzoss.installer.lib

Modified Files:
	Registry.php Setup.php Utils.php 
Log Message:
make plugins sandbox work

Index: Utils.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.installer.lib/Utils.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Utils.php	3 Apr 2004 16:15:47 -0000	1.7
--- Utils.php	6 Apr 2004 14:45:16 -0000	1.8
***************
*** 81,85 ****
  		
  		// split data path in directories 
! 		$dataDirs = explode( '/', $path ); 
  		for( $a=0; $a<count($dataDirs); $a++) { 
  			$currPath .= $dataDirs[$a].'/'; 
--- 81,86 ----
  		
  		// split data path in directories 
! 		$dataDirs = explode( '/', $path );
!         $currPath = '';
  		for( $a=0; $a<count($dataDirs); $a++) { 
  			$currPath .= $dataDirs[$a].'/'; 

Index: Setup.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.installer.lib/Setup.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Setup.php	19 Mar 2004 12:18:15 -0000	1.6
--- Setup.php	6 Apr 2004 14:45:16 -0000	1.7
***************
*** 25,29 ****
  
  require_once 'Utils.php';
! require_once 'System.php';
  
  class ZZOSS_InstallerSetup {
--- 25,32 ----
  
  require_once 'Utils.php';
! 
! if(ZI_INIT_MODE != 'RE'){
!     require_once 'System.php';
! }
  
  class ZZOSS_InstallerSetup {

Index: Registry.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.installer.lib/Registry.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** Registry.php	5 Apr 2004 08:23:12 -0000	1.29
--- Registry.php	6 Apr 2004 14:45:16 -0000	1.30
***************
*** 24,38 ****
      */
      
-     require_once 'PEAR.php';
-     
-     // Include package handling.
-     require_once 'ZZOSS_Package/Package.php';
-     
      // Include utility functions
      require_once 'ZZOSS_Installer/Utils.php';
      
!     require_once 'ZZOSS_Config/Config.php';
!     
!     require_once 'ZZOSS_Debug/Debug.php';
      
  class ZZOSS_InstallerRegistry
--- 24,39 ----
      */
      
      // Include utility functions
      require_once 'ZZOSS_Installer/Utils.php';
      
!     // the following classes are only included
!     // if we are not in the plugins runtime environment
!     if(ZI_INIT_MODE != 'RE'){
!         require_once 'PEAR.php';
!         // Include package handling.
!         require_once 'ZZOSS_Package/Package.php';
!         require_once 'ZZOSS_Config/Config.php';
!         require_once 'ZZOSS_Debug/Debug.php';
!     }
      
  class ZZOSS_InstallerRegistry
***************
*** 62,72 ****
      function ZZOSS_InstallerRegistry($dir = NULL)
      {
!         if(!strlen($dir)){
!             include_once 'System.php';
!             $this->dir = System::tmpdir().DIRECTORY_SEPARATOR.'zzoss_installer';
!         } else {
!             $this->dir = $dir;
!         }
!         
          $this->dir_installer                = $this->dir.'installer'.DIRECTORY_SEPARATOR;
          $this->dir_distributions_rel        = 'distributions'.DIRECTORY_SEPARATOR;
--- 63,67 ----
      function ZZOSS_InstallerRegistry($dir = NULL)
      {
!         $this->dir = $dir;
          $this->dir_installer                = $this->dir.'installer'.DIRECTORY_SEPARATOR;
          $this->dir_distributions_rel        = 'distributions'.DIRECTORY_SEPARATOR;
***************
*** 474,477 ****
--- 469,473 ----
          */
          
+         $isModified = false;
          $applications = array();
          $applications_resolve = array();
***************
*** 490,536 ****
              $application = $this->application;
              
              while (false !== ($entry = readdir($dp))) {
                  $dir = $this->distribution_path.'applications'.DIRECTORY_SEPARATOR.$entry;
                  $file = $dir.DIRECTORY_SEPARATOR.'application.xml';
                  if(is_dir($dir)&&($entry != '.')&&($entry != '..')&&(file_exists($file))) {
!                     $config = new ZZOSS_Config(array('numeric' => array('maintainer', 'plugin', 'package', 'holder', 'license')));
!                     $config->setFile($file);
!                     $xml = $config->query('/application');
!                     $xml["install"]["path"] = $this->distribution_path.'applications'.DIRECTORY_SEPARATOR.$entry.DIRECTORY_SEPARATOR;
!                     $xml["id"] = $count;
!                     // is this application installed ?
!                     if($config_installed = $this->isInstalledApplication($entry)){
!                         $xml["installed"] = $config_installed["release"]["version"];
                      }
-                     // is this application hidden ?
-                     $xml["hidden"] = $this->isHiddenApplication($entry);
                      
!                     $key = $xml["name"].'-'.$xml['release']['version'];
!                     $applications[$key] = $xml;
!                     $applications_resolve[$count] = $key;
!                     $count++;
!                     // check if all necessary directories exist
!                     $data_dir = $xml["install"]["path"].'installer';
!                     if(!is_dir($data_dir)) {
!                         @mkdir($data_dir);
                      }
                  }
              }
              closedir($dp);
              
!             // sort array
!             if(is_array($applications)) {
!                 ksort($applications);
!                 reset($applications);
!             }
!             // dump arrays to file
!             $this->setApplications($applications);
!             $this->setApplicationsResolve( $applications_resolve );
!             // remove possible flag
!             $this->unlockApplications();
!             
!             // Set back application
!             if(strlen($application)){
!                 $this->setApplication($application);
              }
          }
--- 486,573 ----
              $application = $this->application;
              
+             $apps_reg = $this->distribution_path.'installer'.DIRECTORY_SEPARATOR.'applications.reg';
+             
+             if(file_exists($apps_reg)){
+                 $reg = $this->distribution_path.'installer'.DIRECTORY_SEPARATOR.'applications.reg';
+                 $applications = ZZOSS_InstallerUtils::unserializeFromFile($reg);
+                 $apps_mtime = filemtime($apps_reg);
+             } else {
+                 $apps_mtime = 0;
+             }
+             
              while (false !== ($entry = readdir($dp))) {
                  $dir = $this->distribution_path.'applications'.DIRECTORY_SEPARATOR.$entry;
                  $file = $dir.DIRECTORY_SEPARATOR.'application.xml';
                  if(is_dir($dir)&&($entry != '.')&&($entry != '..')&&(file_exists($file))) {
!                     
!                     $this->setApplication($entry);
!                     
!                     $app_installed_reg = $this->application_path.'installer'.DIRECTORY_SEPARATOR.'application_installed.reg';
!                     $app_hidden_reg = $this->application_path.'installer'.DIRECTORY_SEPARATOR.'application_hidden.reg';
!                     
!                     if(file_exists($app_installed_reg)){
!                         $installed_mtime = filemtime($app_installed_reg);
!                     } else {
!                         $installed_mtime = 0;
                      }
                      
!                     if(file_exists($app_hidden_reg)){
!                         $hidden_mtime = filemtime($app_hidden_reg);
!                     } else {
!                         $hidden_mtime = 0;
                      }
+                     
+                     // only update, if applications.reg is older
+                     if(
+                         filemtime($file) > $apps_mtime ||
+                         $installed_mtime > $apps_mtime ||
+                         $hidden_mtime > $apps_mtime){
+                         
+                         $isModified = true;
+                         
+                         $config = new ZZOSS_Config(array('numeric' => array('maintainer', 'plugin', 'package', 'holder', 'license')));
+                         $config->setFile($file);
+                         $xml = $config->query('/application');
+                         $xml["install"]["path"] = $this->distribution_path.'applications'.DIRECTORY_SEPARATOR.$entry.DIRECTORY_SEPARATOR;
+                         //$xml["id"] = $count;
+                         // is this application installed ?
+                         if($config_installed = $this->isInstalledApplication($entry)){
+                             $xml["installed"] = $config_installed["release"]["version"];
+                         }
+                         // is this application hidden ?
+                         $xml["hidden"] = $this->isHiddenApplication($entry);
+                         
+                         $key = $xml["name"].'-'.$xml['release']['version'];
+                         $applications[$key] = $xml;
+                         //$applications_resolve[$count] = $key;
+                         
+                         // check if all necessary directories exist
+                         $data_dir = $xml["install"]["path"].'installer';
+                         if(!is_dir($data_dir)) {
+                             @mkdir($data_dir);
+                         }
+                     }
+                     
+                     //$count++;
                  }
              }
              closedir($dp);
              
!             if($isModified){
!                 // sort array
!                 if(is_array($applications)) {
!                     ksort($applications);
!                     reset($applications);
!                 }
!                 // dump arrays to file
!                 $this->setApplications($applications);
!                 //$this->setApplicationsResolve( $applications_resolve );
!                 // remove possible flag
!                 $this->unlockApplications();
!                 
!                 // Set back application
!                 if(strlen($application)){
!                     $this->setApplication($application);
!                 }
              }
          }
***************
*** 814,817 ****
--- 851,866 ----
      }
      
+     function unsetApplications($distribution = NULL)
+     {
+         if(!is_null($distribution)){
+             $this->setDistribution($distribution);
+         }
+         
+         $apps_reg = $this->distribution_path.'installer'.DIRECTORY_SEPARATOR.'applications.reg';
+         if(file_exists($apps_reg)){
+             unlink($apps_reg);
+         }
+     }
+     
      /**
      * @see refreshApplications()
***************
*** 893,899 ****
          }
          
!         if(is_dir($this->application_path) && System::rm(array('-rf', $this->application_path))){
!             // set rebuild applications flag
!             return $this->lockApplications();
          }
      }
--- 942,948 ----
          }
          
!         if(is_dir($this->application_path)){
!             System::rm(array('-rf', $this->application_path));
!             $this->unsetApplications();
          }
      }
***************
*** 1233,1241 ****
          }
          if(is_dir($pkg_installed)){
!             System::rm(array('-rf', $pkg_installed));
              $this->log .= '* Removed '.$pkg_installed."\n";
          }
          // Post-processing
!         System::mkDir(array('-p', $pkg_installed));
          $this->log .= '* Created '.$pkg_installed."\n";
          copy(
--- 1282,1290 ----
          }
          if(is_dir($pkg_installed)){
!             ZZOSS_InstallerUtils::rmdir($pkg_installed);
              $this->log .= '* Removed '.$pkg_installed."\n";
          }
          // Post-processing
!         ZZOSS_InstallerUtils::mkdir($pkg_installed);
          $this->log .= '* Created '.$pkg_installed."\n";
          copy(



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