示例#1
0
 /**
  * Retorna todas las migraciones disponibles desde la actual hasta la versión parametro
  *
  * @param toba_version $hasta
  * @param string $path_migraciones Path opcional de donde se ubican las migraciones (solo para tests)
  */
 function get_secuencia_migraciones($hasta, $path_migraciones = null)
 {
     if (!isset($path_migraciones)) {
         $dir = $this->path_migraciones();
     } else {
         $dir = $path_migraciones;
     }
     $exp = "/migracion_(.+)\\.php/";
     $archivos = toba_manejador_archivos::get_archivos_directorio($dir, $exp, false);
     $versiones = array();
     foreach ($archivos as $archivo) {
         $partes = array();
         preg_match($exp, $archivo, $partes);
         $numero = str_replace('_', '.', $partes[1]);
         $version = new toba_version($numero);
         if ($this->es_menor($version) && $hasta->es_mayor_igual($version)) {
             $versiones[] = $version;
         }
     }
     usort($versiones, array('toba_version', 'comparar_versiones'));
     return $versiones;
 }
示例#2
0
 function get_version_actual()
 {
     $sql = 'SELECT version FROM apex_instancia';
     $rs = $this->get_db()->consultar($sql);
     if (empty($rs)) {
         return toba_version::inicial();
         //Es la version anterior al cambio de la migracion
     } else {
         return new toba_version($rs[0]['version']);
     }
 }
示例#3
0
 /**
  * Arma los .tar.gz y .zip de todas las versiones lanzadas
  */
 function opcion__comprimir_versiones()
 {
     $error = null;
     $salida = null;
     $url_svn = 'http://localhost/svn/toba';
     $dir_temp = '/tmp';
     $destino = '/var/www/downloads/toba';
     $rama_branch = 'trunk_versiones';
     $rama_versiones = 'versiones';
     //-- Averiguo cual es el siguiente numero
     $versiones = explode("\n", trim(`svn ls {$url_svn}/{$rama_versiones}`));
     foreach ($versiones as $numero) {
         $siguiente = new toba_version(str_replace('/', '', $numero));
         $this->consola->mensaje("Comprimiendo version " . $siguiente->__toString(), false);
         //-- Hago el export a una carpeta
         $this->consola->mensaje("Export a carpeta temporal.", false);
         $export_dir = $dir_temp . "/toba_{$siguiente}";
         if (file_exists($export_dir)) {
             toba_manejador_archivos::eliminar_directorio($export_dir);
         }
         $cmd = "svn export {$url_svn}/{$rama_versiones}/{$siguiente} {$export_dir}";
         exec($cmd, $salida, $error);
         if ($error) {
             toba_manejador_archivos::eliminar_directorio($export_dir);
             throw new toba_error("No fue posible hacer el export. Comando:\n{$cmd}");
         }
         $this->consola->progreso_fin();
         //-- Armo el .zip
         $this->consola->mensaje("Creando ZIP.", false);
         if (file_exists("{$destino}/toba_{$siguiente}.zip")) {
             unlink("{$destino}/toba_{$siguiente}.zip");
         }
         $cmd = "cd {$dir_temp}; zip -r {$destino}/toba_{$siguiente}.zip toba_{$siguiente}";
         exec($cmd, $salida, $error);
         if ($error) {
             toba_manejador_archivos::eliminar_directorio($export_dir);
             throw new toba_error("Error armando el .zip. Comando:\n{$cmd}");
         }
         $this->consola->progreso_fin();
         //-- Armo el .tar.gz
         $this->consola->mensaje("Creando TAR.GZ.", false);
         if (file_exists("{$destino}/toba_{$siguiente}.tar.gz")) {
             unlink("{$destino}/toba_{$siguiente}.tar.gz");
         }
         $cmd = "cd {$dir_temp}; tar -czvf {$destino}/toba_{$siguiente}.tar.gz toba_{$siguiente}";
         exec($cmd, $salida, $error);
         if ($error) {
             toba_manejador_archivos::eliminar_directorio($export_dir);
             throw new toba_error("Error armando el .tar.gz. Comando:\n{$cmd}");
         }
         $this->consola->progreso_fin();
         //-- Borro temporales
         $this->consola->mensaje("Borrando archivos temporales.", false);
         toba_manejador_archivos::eliminar_directorio($export_dir);
         $this->consola->progreso_fin();
     }
 }
示例#4
0
 /**
  * Retorna la versión de TOBA con la cual fue cargado el proyecto en la instancia
  * @return toba_version
  */
 function get_version_actual()
 {
     $proyecto = $this->db->quote($this->identificador);
     $sql = "SELECT version_toba FROM apex_proyecto WHERE proyecto= {$proyecto}";
     $rs = $this->db->consultar($sql);
     if (!empty($rs)) {
         if (!isset($rs[0]['version_toba'])) {
             return toba_version::inicial();
         }
         return new toba_version($rs[0]['version_toba']);
     }
     return toba_version::inicial();
 }
示例#5
0
 function get_version_anterior()
 {
     if (file_exists($this->dir_base() . "/VERSION")) {
         return new toba_version(file_get_contents($this->dir_base() . "/VERSION"));
     } else {
         return toba_version::inicial();
     }
 }
示例#6
0
 function test_rango_builds_inverso()
 {
     $desde = new toba_version("0.1.4 (2005)");
     $hasta = new toba_version("0.2.5 (2012)");
     $intermedios = array('2012', '2011', '2010', '2009', '2008', '2007', '2006');
     $this->assertEqualArray($hasta->get_builds_intermedios($desde), $intermedios);
 }