', str_repeat(" ", $tab), $dir); } function format_close_dir($tab) { return sprintf("%s", str_repeat(" ", $tab)); } function format_file($filename, $tab) { return sprintf('%s', str_repeat(" ", $tab+1), get_role($filename), $filename); } function make_tree($files) { $retval = array(); $lastdir = "."; $tab = 2; $retval[] = format_open_dir("/", $tab); foreach($files as $file) { $dir = dirname($file); $filename = basename($file); if ($dir != $lastdir) { $currdir = explode("/", $dir); $prevdir = explode("/", $lastdir); foreach($currdir as $n => $d) { if (isset($prevdir[$n]) && $prevdir[$n] == $d) { /* In case we are shorter then previous */ $n++; continue; } break; } if ($lastdir != ".") { foreach(array_reverse(array_slice($prevdir, $n)) as $close) { $retval[] = format_close_dir($tab--); } } foreach(array_slice($currdir, $n) as $open) { $retval[] = format_open_dir($open, ++$tab); } } $retval[] = format_file($filename, $tab); $lastdir = $dir; } foreach(array_reverse(explode("/", $lastdir)) as $close) { $retval[] = format_close_dir($tab--); } $retval[] = format_close_dir($tab); return $retval; } function usage() { global $argv; echo "Usage:\n\t"; echo $argv[0], " <-stability>\n"; exit(1); } if ($argc != 2) { usage(); } if (strpos($argv[1], "-")) { list($VERSION, $STABILITY) = explode("-", $argv[1], 2); } else { $VERSION = $argv[1]; /* 0.x.y. are developmental releases and cannot be stable */ if ((int)$VERSION < 1) { $STABILITY = "devel"; } /* A release candidate is a "beta" stability in terms of PECL */ $rc = substr($VERSION, -3, 2); if (strcasecmp($rc, "rc") == 0) { $STABILITY = "beta"; } else { $STABILITY = "stable"; } } verify_stability($STABILITY); verify_version($VERSION, $STABILITY); $changelog = __DIR__ . "/../RELEASE-".$VERSION; verify_changelog($changelog); $currtime = $_SERVER["REQUEST_TIME"]; $DATE = date("Y-m-d", $currtime); $TIME = date("H:i:s", $currtime); $fullnotes = file($changelog, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $NOTES = array(); foreach($fullnotes as $note) { $note = " " . str_replace("&", "&", trim($note)); /* PHP PHPC JIRA Project */ if (strstr($note, "PHPC-") !== false) { $NOTES[] = $note; continue; } /* Coverity ID */ if (strstr($note, "CID-") !== false) { $NOTES[] = $note; continue; } } $TREE = make_tree(get_files()); $contents = file_get_contents(__DIR__ . "/package.xml.in"); $REPLACE = array( "%RELEASE_DATE%" => $DATE, "%RELEASE_TIME%" => $TIME, "%RELEASE_VERSION%" => $VERSION, "%RELEASE_STABILITY%" => $STABILITY, "%RELEASE_NOTES%" => join("\n", $NOTES), "%RELEASE_FILES%" => join("\n", $TREE), ); $contents = str_replace(array_keys($REPLACE), array_values($REPLACE), $contents); file_put_contents(__DIR__ . "/../package.xml", $contents); echo "Wrote package.xml\n";