Overview

Namespaces

  • GAubry
    • ErrorHandler
    • Helpers
    • Logger
    • Shell
  • Himedia
    • Padocc
      • DB
      • Minifier
      • Numbering
      • Properties
      • Task
        • Base
        • Extended
  • None
  • Psr
    • Log

Classes

  • B2CSwitchSymlink
  • BuildLanguage
  • CVSExport
  • GitExport
  • Minifier
  • SwitchSymlink
  • TwengaServers
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: namespace Himedia\Padocc\Task\Extended;
  4: 
  5: use Himedia\Padocc\AttributeProperties;
  6: use Himedia\Padocc\Task;
  7: 
  8: /**
  9:  * Exporte tout ou partie du contenu d'un dépôt CVS vers une ou plusieurs destinations.
 10:  * À inclure dans une tâche env ou target.
 11:  *
 12:  * Exploite le script '/src/inc/cvsexport.sh'.
 13:  * Réalise la synchronisation à l'aide d'une tâche ''sync''.
 14:  *
 15:  * Attributs :
 16:  * - 'repository'
 17:  * - 'module' : sous-répertoire du dépôt qui nous intéresse
 18:  * - 'src' : lieu temporaire d'extraction du contenu qui nous intéresse du dépôt avant de l'envoyer
 19:  *   vers la destination => laisser à vide de manière générale,
 20:  *   l'outil utilisera alors le répertoire $aConfig['dir']['repositories']
 21:  * - 'dest'
 22:  *
 23:  * Exemple :
 24:  * <cvsexport repository=":extssh:gaubry@fs1.twenga.com:/home/cvsroot"
 25:  *     module="twengaweb/common" destdir="${SERVERS}:${COMMONDIR}" />
 26:  *
 27:  * @author Geoffroy AUBRY <gaubry@hi-media.com>
 28:  */
 29: class CVSExport extends Task
 30: {
 31:     /**
 32:      * Tâche de synchronisation sous-jacente.
 33:      * @var Task\Base\Sync
 34:      */
 35:     private $oSyncTask;
 36: 
 37:     /**
 38:      * {@inheritdoc}
 39:      */
 40:     protected function init()
 41:     {
 42:         parent::init();
 43: 
 44:         $this->aAttrProperties = array(
 45:             'repository' => AttributeProperties::FILE | AttributeProperties::REQUIRED,
 46:             'module' => AttributeProperties::DIR | AttributeProperties::REQUIRED,
 47:             'srcdir' => AttributeProperties::DIR,
 48:             'destdir' => AttributeProperties::DIR | AttributeProperties::REQUIRED
 49:                 | AttributeProperties::ALLOW_PARAMETER
 50:         );
 51: 
 52:         if (empty($this->aAttValues['srcdir'])) {
 53:             $this->aAttValues['srcdir'] =
 54:                 $this->aConfig['dir']['repositories'] . '/cvs/'
 55:                 . $this->oProperties->getProperty('project_name') . '_'
 56:                 . $this->oProperties->getProperty('environment_name') . '_'
 57:                 . $this->sCounter;
 58:         } else {
 59:             $this->aAttValues['srcdir'] =
 60:                 preg_replace('#/$#', '', $this->aAttValues['srcdir']);
 61:         }
 62: 
 63:         // Création de la tâche de synchronisation sous-jacente :
 64:         $this->oNumbering->addCounterDivision();
 65:         $this->oSyncTask = Task\Base\Sync::getNewInstance(
 66:             array(
 67:                 'src' => $this->aAttValues['srcdir'] . '/' . $this->aAttValues['module'] . '/',
 68:                 'destdir' => $this->aAttValues['destdir']
 69:             ),
 70:             $this->oProject,
 71:             $this->oDIContainer
 72:         );
 73:         $this->oNumbering->removeCounterDivision();
 74:     }
 75: 
 76:     /**
 77:      * {@inheritdoc}
 78:      * @codeCoverageIgnore
 79:      */
 80:     public static function getTagName ()
 81:     {
 82:         return 'cvsexport';
 83:     }
 84: 
 85:     /**
 86:      * Prépare la tâche avant exécution : vérifications basiques, analyse des serveurs concernés...
 87:      */
 88:     public function setUp ()
 89:     {
 90:         parent::setUp();
 91:         $this->getLogger()->info('+++');
 92:         try {
 93:             $this->oSyncTask->setUp();
 94:         } catch (\UnexpectedValueException $oException) {
 95:             if ($oException->getMessage() !== "File or directory '" . $this->aAttValues['srcdir']
 96:                                             . '/' . $this->aAttValues['module'] . '/' . "' not found!") {
 97:                 throw $oException;
 98:             }
 99:         }
100: 
101:         $this->getLogger()->info('---');
102:     }
103: 
104:     /**
105:      * Phase de traitements centraux de l'exécution de la tâche.
106:      * Elle devrait systématiquement commencer par "parent::centralExecute();".
107:      * Appelé par execute().
108:      * @see execute()
109:      */
110:     protected function centralExecute ()
111:     {
112:         parent::centralExecute();
113:         $this->getLogger()->info('+++');
114: 
115:         $this->getLogger()->info("Export from '" . $this->aAttValues['repository'] . "' CVS repository+++");
116:         $aResult = $this->oShell->exec(
117:             $this->aConfig['bash_path'] . ' ' . $this->aConfig['dir']['inc'] . '/cvsexport.sh'
118:             . ' "' . $this->aAttValues['repository'] . '"'
119:             . ' "' . $this->aAttValues['module'] . '"'
120:             . ' "' . $this->aAttValues['srcdir'] . '"'
121:         );
122:         $this->getLogger()->info(implode("\n", $aResult) . '---');
123: 
124:         $this->oSyncTask->execute();
125:         $this->getLogger()->info('---');
126:     }
127: }
128: 
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0