[ Index ] |
|
Code source de GeekLog 1.4.1 |
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.68 2006/01/06 04:47:36 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.4.11 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 $main = &$pf2; 98 $other = &$pf; 99 } else { 100 $main = &$pf; 101 $other = &$pf2; 102 } 103 if ($main->getPackagexmlVersion() != '2.0') { 104 return PEAR::raiseError('Error: cannot package two package.xml version 1.0, can ' . 105 'only package together a package.xml 1.0 and package.xml 2.0'); 106 } 107 if ($other->getPackagexmlVersion() != '1.0') { 108 return PEAR::raiseError('Error: cannot package two package.xml version 2.0, can ' . 109 'only package together a package.xml 1.0 and package.xml 2.0'); 110 } 111 } 112 $main->setLogger($this); 113 if (!$main->validate(PEAR_VALIDATE_PACKAGING)) { 114 foreach ($main->getValidationWarnings() as $warning) { 115 $this->log(0, 'Error: ' . $warning['message']); 116 } 117 return $this->raiseError("Cannot package, errors in package"); 118 } else { 119 foreach ($main->getValidationWarnings() as $warning) { 120 $this->log(1, 'Warning: ' . $warning['message']); 121 } 122 } 123 if ($pkg2) { 124 $other->setLogger($this); 125 $a = false; 126 if (!$other->validate(PEAR_VALIDATE_NORMAL) || $a = !$main->isEquivalent($other)) { 127 foreach ($other->getValidationWarnings() as $warning) { 128 $this->log(0, 'Error: ' . $warning['message']); 129 } 130 foreach ($main->getValidationWarnings() as $warning) { 131 $this->log(0, 'Error: ' . $warning['message']); 132 } 133 if ($a) { 134 return $this->raiseError('The two package.xml files are not equivalent!'); 135 } 136 return $this->raiseError("Cannot package, errors in package"); 137 } else { 138 foreach ($other->getValidationWarnings() as $warning) { 139 $this->log(1, 'Warning: ' . $warning['message']); 140 } 141 } 142 $gen = &$main->getDefaultGenerator(); 143 $tgzfile = $gen->toTgz2($this, $other, $compress); 144 if (PEAR::isError($tgzfile)) { 145 return $tgzfile; 146 } 147 $dest_package = basename($tgzfile); 148 $pkgdir = dirname($pkgfile); 149 150 // TAR the Package ------------------------------------------- 151 $this->log(1, "Package $dest_package done"); 152 if (file_exists("$pkgdir/CVS/Root")) { 153 $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pf->getVersion()); 154 $cvstag = "RELEASE_$cvsversion"; 155 $this->log(1, 'Tag the released code with "pear cvstag ' . 156 $main->getPackageFile() . '"'); 157 $this->log(1, "(or set the CVS tag $cvstag by hand)"); 158 } 159 } else { // this branch is executed for single packagefile packaging 160 $gen = &$pf->getDefaultGenerator(); 161 $tgzfile = $gen->toTgz($this, $compress); 162 if (PEAR::isError($tgzfile)) { 163 $this->log(0, $tgzfile->getMessage()); 164 return $this->raiseError("Cannot package, errors in package"); 165 } 166 $dest_package = basename($tgzfile); 167 $pkgdir = dirname($pkgfile); 168 169 // TAR the Package ------------------------------------------- 170 $this->log(1, "Package $dest_package done"); 171 if (file_exists("$pkgdir/CVS/Root")) { 172 $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pf->getVersion()); 173 $cvstag = "RELEASE_$cvsversion"; 174 $this->log(1, "Tag the released code with `pear cvstag $pkgfile'"); 175 $this->log(1, "(or set the CVS tag $cvstag by hand)"); 176 } 177 } 178 return $dest_package; 179 } 180 181 // }}} 182 } 183 184 // {{{ md5_file() utility function 185 if (!function_exists('md5_file')) { 186 function md5_file($file) { 187 if (!$fd = @fopen($file, 'r')) { 188 return false; 189 } 190 if (function_exists('file_get_contents')) { 191 fclose($fd); 192 $md5 = md5(file_get_contents($file)); 193 } else { 194 $md5 = md5(fread($fd, filesize($file))); 195 fclose($fd); 196 } 197 return $md5; 198 } 199 } 200 // }}} 201 202 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 12:27:40 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |