[ Index ] |
|
Code source de PHP PEAR 1.4.5 |
1 <?php 2 /** 3 * PEAR_Packager for generating releases 4 * 5 * PHP versions 4 and 5 6 * 7 * LICENSE: This source file is subject to version 3.0 of the PHP license 8 * that is available through the world-wide-web at the following URI: 9 * http://www.php.net/license/3_0.txt. If you did not receive a copy of 10 * the PHP License and are unable to obtain it through the web, please 11 * send a note to license@php.net so we can mail you a copy immediately. 12 * 13 * @category pear 14 * @package PEAR 15 * @author Stig Bakken <ssb@php.net> 16 * @author Tomas V. V. Cox <cox@idecnet.com> 17 * @author Greg Beaver <cellog@php.net> 18 * @copyright 1997-2006 The PHP Group 19 * @license http://www.php.net/license/3_0.txt PHP License 3.0 20 * @version CVS: $Id: Packager.php,v 1.70 2006/09/25 05:12:21 cellog Exp $ 21 * @link http://pear.php.net/package/PEAR 22 * @since File available since Release 0.1 23 */ 24 25 /** 26 * base class 27 */ 28 require_once 'PEAR/Common.php'; 29 require_once 'PEAR/PackageFile.php'; 30 require_once 'System.php'; 31 32 /** 33 * Administration class used to make a PEAR release tarball. 34 * 35 * @category pear 36 * @package PEAR 37 * @author Greg Beaver <cellog@php.net> 38 * @copyright 1997-2006 The PHP Group 39 * @license http://www.php.net/license/3_0.txt PHP License 3.0 40 * @version Release: 1.5.0 41 * @link http://pear.php.net/package/PEAR 42 * @since Class available since Release 0.1 43 */ 44 class PEAR_Packager extends PEAR_Common 45 { 46 /** 47 * @var PEAR_Registry 48 */ 49 var $_registry; 50 // {{{ package() 51 52 function package($pkgfile = null, $compress = true, $pkg2 = null) 53 { 54 // {{{ validate supplied package.xml file 55 if (empty($pkgfile)) { 56 $pkgfile = 'package.xml'; 57 } 58 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 59 $pkg = &new PEAR_PackageFile($this->config, $this->debug); 60 $pf = &$pkg->fromPackageFile($pkgfile, PEAR_VALIDATE_NORMAL); 61 $main = &$pf; 62 PEAR::staticPopErrorHandling(); 63 if (PEAR::isError($pf)) { 64 if (is_array($pf->getUserInfo())) { 65 foreach ($pf->getUserInfo() as $error) { 66 $this->log(0, 'Error: ' . $error['message']); 67 } 68 } 69 $this->log(0, $pf->getMessage()); 70 return $this->raiseError("Cannot package, errors in package file"); 71 } else { 72 foreach ($pf->getValidationWarnings() as $warning) { 73 $this->log(1, 'Warning: ' . $warning['message']); 74 } 75 } 76 77 // }}} 78 if ($pkg2) { 79 $this->log(0, 'Attempting to process the second package file'); 80 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 81 $pf2 = &$pkg->fromPackageFile($pkg2, PEAR_VALIDATE_NORMAL); 82 PEAR::staticPopErrorHandling(); 83 if (PEAR::isError($pf2)) { 84 if (is_array($pf2->getUserInfo())) { 85 foreach ($pf2->getUserInfo() as $error) { 86 $this->log(0, 'Error: ' . $error['message']); 87 } 88 } 89 $this->log(0, $pf2->getMessage()); 90 return $this->raiseError("Cannot package, errors in second package file"); 91 } else { 92 foreach ($pf2->getValidationWarnings() as $warning) { 93 $this->log(1, 'Warning: ' . $warning['message']); 94 } 95 } 96 if ($pf2->getPackagexmlVersion() == '2.0' || 97 $pf2->getPackagexmlVersion() == '2.1') { 98 $main = &$pf2; 99 $other = &$pf; 100 } else { 101 $main = &$pf; 102 $other = &$pf2; 103 } 104 if ($main->getPackagexmlVersion() != '2.0' && 105 $main->getPackagexmlVersion() != '2.1') { 106 return PEAR::raiseError('Error: cannot package two package.xml version 1.0, can ' . 107 'only package together a package.xml 1.0 and package.xml 2.0'); 108 } 109 if ($other->getPackagexmlVersion() != '1.0') { 110 return PEAR::raiseError('Error: cannot package two package.xml version 2.0, can ' . 111 'only package together a package.xml 1.0 and package.xml 2.0'); 112 } 113 } 114 $main->setLogger($this); 115 if (!$main->validate(PEAR_VALIDATE_PACKAGING)) { 116 foreach ($main->getValidationWarnings() as $warning) { 117 $this->log(0, 'Error: ' . $warning['message']); 118 } 119 return $this->raiseError("Cannot package, errors in package"); 120 } else { 121 foreach ($main->getValidationWarnings() as $warning) { 122 $this->log(1, 'Warning: ' . $warning['message']); 123 } 124 } 125 if ($pkg2) { 126 $other->setLogger($this); 127 $a = false; 128 if (!$other->validate(PEAR_VALIDATE_NORMAL) || $a = !$main->isEquivalent($other)) { 129 foreach ($other->getValidationWarnings() as $warning) { 130 $this->log(0, 'Error: ' . $warning['message']); 131 } 132 foreach ($main->getValidationWarnings() as $warning) { 133 $this->log(0, 'Error: ' . $warning['message']); 134 } 135 if ($a) { 136 return $this->raiseError('The two package.xml files are not equivalent!'); 137 } 138 return $this->raiseError("Cannot package, errors in package"); 139 } else { 140 foreach ($other->getValidationWarnings() as $warning) { 141 $this->log(1, 'Warning: ' . $warning['message']); 142 } 143 } 144 $gen = &$main->getDefaultGenerator(); 145 $tgzfile = $gen->toTgz2($this, $other, $compress); 146 if (PEAR::isError($tgzfile)) { 147 return $tgzfile; 148 } 149 $dest_package = basename($tgzfile); 150 $pkgdir = dirname($pkgfile); 151 152 // TAR the Package ------------------------------------------- 153 $this->log(1, "Package $dest_package done"); 154 if (file_exists("$pkgdir/CVS/Root")) { 155 $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pf->getVersion()); 156 $cvstag = "RELEASE_$cvsversion"; 157 $this->log(1, 'Tag the released code with "pear cvstag ' . 158 $main->getPackageFile() . '"'); 159 $this->log(1, "(or set the CVS tag $cvstag by hand)"); 160 } 161 } else { // this branch is executed for single packagefile packaging 162 $gen = &$pf->getDefaultGenerator(); 163 $tgzfile = $gen->toTgz($this, $compress); 164 if (PEAR::isError($tgzfile)) { 165 $this->log(0, $tgzfile->getMessage()); 166 return $this->raiseError("Cannot package, errors in package"); 167 } 168 $dest_package = basename($tgzfile); 169 $pkgdir = dirname($pkgfile); 170 171 // TAR the Package ------------------------------------------- 172 $this->log(1, "Package $dest_package done"); 173 if (file_exists("$pkgdir/CVS/Root")) { 174 $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pf->getVersion()); 175 $cvstag = "RELEASE_$cvsversion"; 176 $this->log(1, "Tag the released code with `pear cvstag $pkgfile'"); 177 $this->log(1, "(or set the CVS tag $cvstag by hand)"); 178 } 179 } 180 return $dest_package; 181 } 182 183 // }}} 184 } 185 186 // {{{ md5_file() utility function 187 if (!function_exists('md5_file')) { 188 function md5_file($file) { 189 if (!$fd = @fopen($file, 'r')) { 190 return false; 191 } 192 fclose($fd); 193 $md5 = md5(file_get_contents($file)); 194 return $md5; 195 } 196 } 197 // }}} 198 199 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 14:08:00 2007 | par Balluche grâce à PHPXref 0.7 |