[zi-cvs] packages/com.zzoss.package.lib Package.php,1.6,1.7

Sandro Zic <[email protected]> Fri, 26 Mar 2004 10:16:33 +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-serv21805

Modified Files:
	Package.php 
Log Message:
process packages/plugins only if they have been changed in sources

Index: Package.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.package.lib/Package.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Package.php	19 Mar 2004 12:18:15 -0000	1.6
--- Package.php	26 Mar 2004 10:16:31 -0000	1.7
***************
*** 263,308 ****
                  $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);
                          }
                      }
                  }
--- 263,324 ----
                  $parts = pathinfo($file);
                  if($parts["extension"] == 'tgz' || $parts["extension"] == 'gz') {
+                     $pkg_name = str_replace('.'.$parts['extension'], '', $parts['basename']);
                      $pkgsrc = $src.$file;
+                     $pkg_dest_dir = $dest.$pkg_name.DIRECTORY_SEPARATOR;
                      
                      // did we specify the packages we allow to be extracted
                      if(count($pkgs_allowed)){
                          if(!isset($pkgs_allowed[$pkg_name])){
!                             continue;
                          }
                      }
                      
!                     // check if the tgz has changed since we last extracted it
!                     if(ZZOSS_PACKAGE_DEBUG){
!                         ZZOSS_Debug::log('ZZOSS_Package', 'Check if \''.$pkg_dest_dir.'\' is older then \''.$pkgsrc.'\'.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
!                     }
!                     if(is_dir($pkg_dest_dir)){
!                         if(filemtime($pkgsrc) < filemtime($pkg_dest_dir.'.')){
!                             // the tgz we registered is up-to-date, so continue the loop
                              if(ZZOSS_PACKAGE_DEBUG){
!                                 ZZOSS_Debug::log('ZZOSS_Package', 'Package \''.$file.'\' is up-to-date.', __FILE__, __LINE__, __FUNCTION__, __CLASS__);
                              }
+                             continue;
+                         } else {
+                             // remove directory of previously extracted tgz
+                             System::rm(array('-rf', $pkg_dest_dir));
                          }
!                     }
!                     
!                     
!                     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);
                      }
                  }
***************
*** 342,345 ****
--- 358,370 ----
                              if(file_exists($package_tgz_path)){
                                  $log[$package_unique] .= '  Found '.$package_tgz.'.'."\n";
+                                 // check if the tgz has changed since we last registered it
+                                 if( file_exists($package_dest.$package_tgz) &&
+                                     filemtime($package_tgz_path) < filemtime($package_dest.$package_tgz)){
+                                     // the tgz we registered is up-to-date, so continue the loop
+                                     $log[$package_unique] .= '  Registered package is up-to-date.'."\n";
+                                     // remove this package from stack
+                                     unset($packages[$pos]);
+                                     continue;
+                                 }
                                  copy($package_tgz_path, $package_dest.$package_tgz);
                                  // remove this package from stack
***************
*** 352,355 ****
--- 377,390 ----
                              $log[$package_unique] .= '  Found package.xml'."\n";
                              
+                             // check if the tgz has changed since we last registered it
+                             if( file_exists($package_dest.$package_tgz) &&
+                                 filemtime($package_src.'.') < filemtime($package_dest.$package_tgz)){
+                                 // the tgz we registered is up-to-date, so continue the loop
+                                 $log[$package_unique] .= '  Registered package is up-to-date.'."\n";
+                                 // remove this package from stack
+                                 unset($packages[$pos]);
+                                 continue;
+                             }
+                             
                              // Get package.xml and parse it to fill placeholder with content.
                              



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