[zi-cvs] packages/com.zzoss.plugin.lib Plugin.php,1.6,1.7

Sandro Zic <[email protected]> Thu, 18 Mar 2004 09:41:40 +0000
Newsgroups gmane.comp.php.zzoss.installer.cvs
Message-ID <[email protected]>
Update of /cvsroot/zzossinstaller/packages/com.zzoss.plugin.lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15653/com.zzoss.plugin.lib

Modified Files:
	Plugin.php 
Log Message:
quick install of dev apps

Index: Plugin.php
===================================================================
RCS file: /cvsroot/zzossinstaller/packages/com.zzoss.plugin.lib/Plugin.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Plugin.php	5 Mar 2004 14:25:24 -0000	1.6
--- Plugin.php	18 Mar 2004 09:41:38 -0000	1.7
***************
*** 57,60 ****
--- 57,65 ----
      
      /**
+     * Available package descriptions.
+     */
+     var $packages = array();
+     
+     /**
      * Relating file name to its baseinstalldir.
      */
***************
*** 95,98 ****
--- 100,121 ----
      {
          $this->registry = &$registry;
+         $this->initPlugins();
+         $this->initPackages();
+         $this->initApplicationPackages();
+     }
+     
+     /**
+     * Using this function, one can execute a plugin on
+     * a certain package.
+     */
+     function loadPackage($package_xml, $action, $step = 0)
+     {
+         if(!$xml = $this->registry->getPackageDescr($package_xml)){
+             return PEAR::raiseError('Cannot read \''.$package_xml.'\'');
+         }
+         
+         $pkg_name = $xml["name"].'-'.$xml['release']['version'];
+         $this->queue = array($step => array($pkg_name => $action));
+         $this->packages[$pkg_name] = $xml;
      }
      
***************
*** 103,162 ****
          $this->mode = $mode;
          $this->log .= "## Plugin mode '".$mode."'\n";
!         $this->log .= "\n# Step ".($step+1)."\n";
!         
!         $this->initPlugins();
!         $this->initPackages();
          
          $queue = $this->queue[$step];
- 
-         $this->initApplicationPackages();
          
          // Now we deal with the packages
!         foreach($queue as $key => $val) {
!             // Pre-processing
!             switch($val) {
!                 case 'I':
!                     $this->action = 'install';
!                     $this->plugin_action = 'add';
!                     break;
!                 case 'U':
!                     $this->action = 'update';
!                     $this->plugin_action = 'add';
!                     break;
!                 case 'R':
!                     $this->action = 'remove';
!                     $this->plugin_action = 'remove';
!                     break;
!             }
!             
!             $this->package = $this->packages[$key];
!             $this->log .= "\n[$key]\n\n";
!             $this->log .= "Action: ".$this->action."\n";
!             
!             // compose absolute baseinstalldir
!             $this->pkg_root = '';
!             if(isset($this->packages_application[$key]["@"]["baseinstalldir"])){
!                 $this->pkg_root = ZZOSS_InstallerUtils::fixPath($this->packages_application[$key]["@"]["baseinstalldir"]);
!             }
!             $this->pkg_root .= DIRECTORY_SEPARATOR;
!             
!             // execute plugins
!             switch($this->role){
!                 case 'role':
!                     $this->execRole();
!                     $this->registerPlugins();
!                     $this->registry->setPlugins($this->plugins);
!                     break;
!                 case 'build':
!                     $this->execBuild();
!                     break;
!             }
          }
          
!         // register plugins
!         //if(isset($this->plugins_params['add']) && isset($this->plugins_params['remove'])){
!             //$this->registry->setPlugins($this->plugins);
!             //$this->initPlugins();
!         //}
      }
      
--- 126,179 ----
          $this->mode = $mode;
          $this->log .= "## Plugin mode '".$mode."'\n";
!         $this->log .= "\n# Step ".($step)."\n";
          
          $queue = $this->queue[$step];
          
          // Now we deal with the packages
!         foreach($queue as $pkg_name => $action) {
!             $this->execPackage($action, $pkg_name);
!         }
!     }
!     
!     function execPackage($action, $pkg_name)
!     {
!         // Pre-processing
!         switch($action) {
!             case 'I':
!                 $this->action = 'install';
!                 $this->plugin_action = 'add';
!                 break;
!             case 'U':
!                 $this->action = 'update';
!                 $this->plugin_action = 'add';
!                 break;
!             case 'R':
!                 $this->action = 'remove';
!                 $this->plugin_action = 'remove';
!                 break;
          }
          
!         $this->package = $this->packages[$pkg_name];
!         $this->log .= "\n[$pkg_name]\n\n";
!         $this->log .= "Action: ".$this->action."\n";
!         
!         // compose absolute baseinstalldir
!         $this->pkg_root = '';
!         if(isset($this->packages_application[$pkg_name]["@"]["baseinstalldir"])){
!             $this->pkg_root = ZZOSS_InstallerUtils::fixPath($this->packages_application[$pkg_name]["@"]["baseinstalldir"]);
!         }
!         $this->pkg_root .= DIRECTORY_SEPARATOR;
!         
!         // execute plugins
!         switch($this->role){
!             case 'role':
!                 $this->execRole();
!                 $this->registerPlugins();
!                 $this->registry->setPlugins($this->plugins);
!                 break;
!             case 'build':
!                 $this->execBuild();
!                 break;
!         }
      }
      
***************
*** 288,320 ****
                      PEAR::raiseError('No plugin directory defined.');
                  } else {*/
!                     $GLOBALS['ZI']['plugin_log'] = '';/*
!                     foreach($this->sources as $source){
!                         $this->log .= "* Checking source directory '".$source."'\n";*/
!                         $include = ZZOSS_InstallerUtils::fixPath(/*$source.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.*/$params['file']);
!                         $this->log .= "* Trying to include '".$include."'\n";
!                         if(/*!*/file_exists($include)){
!                             /*
!                             // Check for development plugin (has no version in its unique name).
!                             $include = ZZOSS_InstallerUtils::fixPath($source.DIRECTORY_SEPARATOR.$params['name'].DIRECTORY_SEPARATOR.$params['file']);
!                             $this->log .= "* Trying to include '".$include."'\n";
!                             if(file_exists($include)){
!                                 $this->initGlobalVariables();
!                                 $status = ZZOSS_PLUGIN_STATUS_INCLUDED;
!                                 include($include);
!                                 break;
!                             }
!                         } else {*/
!                             $this->initGlobalVariables();
!                             include($include);
!                             $status = ZZOSS_PLUGIN_STATUS_INCLUDED;
!                             //break;
!                         }
!                     //}
!                     if($status == ZZOSS_PLUGIN_STATUS_UNDEFINED){
!                         $this->log .= "* Plugin '$name': Could not find '".$params['file']./*"' nor '".$params['name'].DIRECTORY_SEPARATOR.$params['file'].*/"' in specified sources.\n";
!                     } elseif($status == ZZOSS_PLUGIN_STATUS_INCLUDED) {
!                         $this->log .= "* Including $include\n";
!                         $this->showPluginMessage();
!                     }
                  /*}
              */}/*
--- 305,309 ----
                      PEAR::raiseError('No plugin directory defined.');
                  } else {*/
!                     $status = $this->includePlugin($name, $params['file']);
                  /*}
              */}/*
***************
*** 327,330 ****
--- 316,354 ----
      }
      
+     function includePlugin($name, $include)
+     {
+         $GLOBALS['ZI']['plugin_log'] = '';/*
+         foreach($this->sources as $source){
+             $this->log .= "* Checking source directory '".$source."'\n";*/
+             $include = ZZOSS_InstallerUtils::fixPath(/*$source.DIRECTORY_SEPARATOR.$name.DIRECTORY_SEPARATOR.*/$include);
+             $this->log .= "* Trying to include '".$include."'\n";
+             if(/*!*/file_exists($include)){
+                 /*
+                 // Check for development plugin (has no version in its unique name).
+                 $include = ZZOSS_InstallerUtils::fixPath($source.DIRECTORY_SEPARATOR.$params['name'].DIRECTORY_SEPARATOR.$include);
+                 $this->log .= "* Trying to include '".$include."'\n";
+                 if(file_exists($include)){
+                     $this->initGlobalVariables();
+                     $status = ZZOSS_PLUGIN_STATUS_INCLUDED;
+                     include($include);
+                     break;
+                 }
+             } else {*/
+                 $this->initGlobalVariables();
+                 include($include);
+                 $status = ZZOSS_PLUGIN_STATUS_INCLUDED;
+                 //break;
+             }
+         //}
+         if($status == ZZOSS_PLUGIN_STATUS_UNDEFINED){
+             $this->log .= "* Plugin '$name': Could not find '".$include./*"' nor '".$params['name'].DIRECTORY_SEPARATOR.$include.*/"' in specified sources.\n";
+         } elseif($status == ZZOSS_PLUGIN_STATUS_INCLUDED) {
+             $this->log .= "* Including $include\n";
+             $this->showPluginMessage();
+         }
+         
+         return $status;
+     }
+     
      function showPluginMessage()
      {
***************
*** 467,471 ****
          
          $GLOBALS['ZI']['package_src'] =
!             ZZOSS_InstallerUtils::fixPath($this->package["install"]["path"]);
          
          $GLOBALS['ZI']['package_build_dir'] = $GLOBALS['ZI']['package_src'].$this->build['@']['dir'];
--- 491,495 ----
          
          $GLOBALS['ZI']['package_src'] =
!             ZZOSS_InstallerUtils::fixPath($this->package["install"]["path"].DIRECTORY_SEPARATOR);
          
          $GLOBALS['ZI']['package_build_dir'] = $GLOBALS['ZI']['package_src'].$this->build['@']['dir'];



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