[zi-cvs] packages/com.zzoss.installer.lib Registry.php,1.20,1.21

Sandro Zic <[email protected]> Thu, 25 Mar 2004 12:26:28 +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-serv19792

Modified Files:
	Registry.php 
Log Message:
resolved problem with package reg refresh and "not specified in application"

Index: Registry.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.installer.lib/Registry.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Registry.php	25 Mar 2004 00:35:40 -0000	1.20
--- Registry.php	25 Mar 2004 12:26:26 -0000	1.21
***************
*** 940,965 ****
          
          $src_pkgs = $this->application_path.$src.DIRECTORY_SEPARATOR;
-         $installed_pkgs = $this->application_path.$this->package_type.'s_installed'.DIRECTORY_SEPARATOR;
          
! 		/*
! 		Somehow following code snippet makes installer broken on my system.
! 		Commenting it seems to help. (czonsius, 25-03-2004)
! 		
! 		TODO: Look for real reason of strange processing
! 
! 		
!         // Refresh package registry only if something changed in source since
!         // we last registerd the packages
!         if($this->isRegPackages()){
!             $mtime_pkgs = $this->getPackagesMtime();
!             if(!
!                 (filemtime($src_pkgs.'.') > $mtime_pkgs) &&
!                 (is_dir($installed_pkgs) && filemtime($installed_pkgs) < $mtime_pkgs)
!                 ){
!                 return true;
!                 }
          }
! 		*/
!                 
          if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
              ZZOSS_Debug::log('ZZOSS_Registry', 'Start registering packages.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
--- 940,952 ----
          
          $src_pkgs = $this->application_path.$src.DIRECTORY_SEPARATOR;
          
!         // Refresh package registry only if something changed
!         if(!$this->isOldPkgsReg($src_pkgs)){
!             return true;
          }
!         
!         $packages_specified = $this->getApplicationPackages();
!         $this->setPackagesSpecified($packages_specified);
!         
          if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
              ZZOSS_Debug::log('ZZOSS_Registry', 'Start registering packages.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
***************
*** 986,989 ****
--- 973,1026 ----
          $this->refreshPackages();
         // $this->refreshPlugins();
+        return true;
+     }
+     
+     /**
+     * Check if the package registry is old.
+     */
+     function isOldPkgsReg($pkgs_src_dir)
+     {
+         /*
+ 		Somehow following code snippet makes installer broken on my system.
+ 		Commenting it seems to help. (czonsius, 25-03-2004)
+ 		
+ 		TODO: Look for real reason of strange processing
+         */
+         if(!$this->isRegPackages()){
+             if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
+                 ZZOSS_Debug::log('ZZOSS_Registry', 'Package registry is old, because there is no registry at all.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
+             }
+             return true;
+         }
+         
+         // make sure that file stats are fresh
+         clearstatcache();
+         
+         // get the modified time of the package registry file
+         $pkgs_reg_mtime = $this->getPkgsRegMtime();
+         
+         // have things changed in the source directory where all the package archives reside?
+ 
+         if(filemtime($pkgs_src_dir.'.') > $pkgs_reg_mtime){
+             if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
+                 ZZOSS_Debug::log('ZZOSS_Registry', 'Package registry is old; checked filemtime: '.filemtime($pkgs_src_dir.'.').'('.$pkgs_src_dir.') > '.$pkgs_reg_mtime.'?', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
+             }
+             return true;
+         }
+         
+         // has something changed in the directory where we store installed packages?
+         $pkgs_installed_dir = $this->application_path.$this->package_type.'s_installed'.DIRECTORY_SEPARATOR;
+         if(is_dir($pkgs_installed_dir) && filemtime($pkgs_installed_dir) > $pkgs_reg_mtime){
+             if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
+                 ZZOSS_Debug::log('ZZOSS_Registry', 'Package registry is old; checked filemtime: '.filemtime($pkgs_installed_dir.'.').'('.$pkgs_installed_dir.') > '.$pkgs_reg_mtime.'?', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
+             }
+             return true;
+         }
+         
+         // The package registry is not old, it's up-to-date.
+         if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
+             ZZOSS_Debug::log('ZZOSS_Registry', 'Packages registry is up-to-date.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
+         }
+         return false;
      }
      
***************
*** 1089,1093 ****
      }
      
!     function getPackagesMtime($application = NULL, $distribution = NULL)
      {
          if(!is_null($distribution)){
--- 1126,1130 ----
      }
      
!     function getPkgsRegMtime($application = NULL, $distribution = NULL)
      {
          if(!is_null($distribution)){
***************
*** 1608,1611 ****
--- 1645,1651 ----
      function getApplicationPackages()
      {
+         if(ZZOSS_INSTALLER_REGISTRY_DEBUG){
+             ZZOSS_Debug::log('ZZOSS_Registry', 'Compose application '.$this->package_type.'s.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
+         }
          $packages_application = array();
          $application = $this->getApplication();
***************
*** 1867,1871 ****
          $procedures_reg = $this->application_path.'installer'.DIRECTORY_SEPARATOR.'procedures.reg';
          $procedures = ZZOSS_InstallerUtils::unserializeFromFile($procedures_reg);
!         return (isset($procedures[$type]) && $procedures[$type] == 'on');
      }
  
--- 1907,1911 ----
          $procedures_reg = $this->application_path.'installer'.DIRECTORY_SEPARATOR.'procedures.reg';
          $procedures = ZZOSS_InstallerUtils::unserializeFromFile($procedures_reg);
!         return (isset($procedures[$type]));
      }
  



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