1<?php 2 3$headerFilename = __DIR__."/../php_imagick.h"; 4 5$phpImagickLines = file($headerFilename); 6 7if ($phpImagickLines === false) { 8 echo "Failed to read $headerFilename\n"; 9 exit(-1); 10} 11 12$versionPackage = false; 13$extNumPackage = false; 14 15foreach ($phpImagickLines as $phpImagickLine) { 16 if (strpos($phpImagickLine, "#define PHP_IMAGICK_VERSION") === 0) { 17 $versionPackage = trim(substr($phpImagickLine, strlen("#define PHP_IMAGICK_VERSION"))); 18 } 19 20 if (strpos($phpImagickLine, "#define PHP_IMAGICK_EXTNUM") === 0) { 21 $extNumPackage = trim(substr($phpImagickLine, strlen("#define PHP_IMAGICK_EXTNUM"))); 22 } 23} 24 25 26$sxe = simplexml_load_file (__DIR__ . "/../package.xml"); 27 28$versionRelease = (string) $sxe->version->release; 29$versionApi = (string) $sxe->version->api; 30$stabilityRelease = (string) $sxe->stability->release; 31$stabilityApi = (string) $sxe->stability->api; 32 33$versionReleaseNumber = preg_replace('/[^\d\.]/', '', $versionApi); 34 35$parts = explode('.', $versionReleaseNumber); 36 37if (count($parts) != 3) { 38 echo "Version number doesn't have 3 parts."; 39 exit(-1); 40} 41 42list($major, $minor, $bug) = $parts; 43 44$extNum = sprintf("%d%02d%02d", $major, $minor, $bug); 45 46if (strcasecmp($extNumPackage, $extNum) !== 0) { 47 echo "Error: package.xml and php_imagick.h EXTNUM mismatch: $extNumPackage, $extNum\n"; 48 exit (-1); 49} 50 51if (strcasecmp($stabilityRelease, "beta") === 0) { 52 if (strpos($versionRelease, 'b') === false && strpos($versionRelease, 'RC') === false) { 53 echo "Error: release is marked 'beta' but version [$versionRelease] doesn't include b or RC\n"; 54 exit(-1); 55 } 56} 57else if (strcasecmp($stabilityRelease, "stable") === 0) { 58 if (strpos($versionRelease, 'b') !== false) { 59 echo "Error: release is marked 'stable' but version [$versionRelease] includes b\n"; 60 exit(-1); 61 } 62 if (strpos($versionRelease, 'RC') !== false) { 63 echo "Error: release is marked 'stable' but version [$versionRelease] includes RC \n"; 64 exit(-1); 65 } 66} 67else { 68 echo "unknown stability $stabilityRelease\n"; 69 exit(-1); 70} 71 72if (strcmp($stabilityRelease, $stabilityApi) !== 0) { 73 echo "Warning: API and release stability differ\n"; 74 exit(-1); 75} 76