本文整理汇总了PHP中pake_sh函数的典型用法代码示例。如果您正苦于以下问题:PHP pake_sh函数的具体用法?PHP pake_sh怎么用?PHP pake_sh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pake_sh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: package_pear_package
public static function package_pear_package($package_xml_path, $target_dir)
{
if (!file_exists($package_xml_path)) {
throw new pakeException('"' . $package_xml_path . '" file does not exist');
}
pake_mkdirs($target_dir);
$current = getcwd();
chdir($target_dir);
if (!class_exists('PEAR_Packager')) {
@(include 'PEAR/Packager.php');
if (!class_exists('PEAR_Packager')) {
// falling back to cli-call
$results = pake_sh('pear package ' . escapeshellarg($package_xml_path));
if ($task->is_verbose()) {
echo $results;
}
chdir($current);
return;
}
}
$packager = new PEAR_Packager();
$packager->debug = 0;
// silence output
$archive = $packager->package($package_xml_path, true);
pake_echo_action('file+', $target_dir . '/' . $archive);
chdir($current);
}
示例2: run_pear
public static function run_pear($task, $args)
{
$results = pake_sh('pear package');
if ($task->is_verbose()) {
echo $results;
}
}
示例3: dropDatabase
public function dropDatabase($name)
{
if ($this->mode == 'cli') {
pake_sh($this->cliCommandPrefix() . ' drop ' . escapeshellarg($name));
} else {
$sql = 'DROP DATABASE IF EXISTS ' . $name;
$this->sqlExec($sql);
}
}
示例4: export
public static function export($src_url, $target_path)
{
if (count(pakeFinder::type('any')->in($target_path)) > 0) {
throw new pakeException('"' . $target_path . '" directory is not empty. Can not export there');
}
pake_echo_action('svn export', $target_path);
if (extension_loaded('svn')) {
$result = svn_export($src_url, $target_path, false);
if (false === $result) {
throw new pakeException('Couldn\'t export "' . $src_url . '" repository');
}
} else {
pake_sh(escapeshellarg(pake_which('svn')) . ' export ' . escapeshellarg($src_url) . ' ' . escapeshellarg($target_path));
}
}
示例5: run_phpunit
function run_phpunit()
{
$cc_token = getenv('CODECLIMATE_REPO_TOKEN');
$cc = !empty($cc_token);
$clover = $cc ? ' --coverage-clover build/logs/clover.xml' : '';
$circle_test_reports = getenv('CIRCLE_TEST_REPORTS');
if (!empty($circle_test_reports)) {
pake_mkdirs($circle_test_reports);
$junit = " --log-junit {$circle_test_reports}/phpunit/junit.xml";
} else {
$junit = '';
}
print pake_sh('vendor/bin/phpunit' . $clover . $junit);
if ($cc && file_exists('build/logs/clover.xml')) {
print pake_sh('vendor/bin/test-reporter');
}
}
示例6: run_sync
function run_sync($task, $args)
{
if (!count($args)) {
throw new Exception('You must provide an environment to synchronize.');
}
$env = $args[0];
$dryrun = isset($args[1]) ? $args[1] : false;
if (!file_exists('config/rsync_exclude.txt')) {
throw new Exception('You must create a rsync_exclude file for your project.');
}
$host = $task->get_property('host', $env);
$dir = $task->get_property('dir', $env);
try {
$user = $task->get_property('user', $env) . '@';
} catch (pakeException $e) {
$user = '';
}
if (substr($dir, -1) != '/') {
$dir .= '/';
}
$ssh = 'ssh';
try {
$port = $task->get_property('port', $env);
$ssh = '"ssh -p' . $port . '"';
} catch (pakeException $e) {
}
try {
$parameters = $task->get_property('parameters', $env);
} catch (pakeException $e) {
$parameters = '-azC --force --delete';
if (file_exists('config/rsync_exclude.txt')) {
$parameters .= ' --exclude-from=config/rsync_exclude.txt';
}
if (file_exists('config/rsync_include.txt')) {
$parameters .= ' --include-from=config/rsync_include.txt';
}
if (file_exists('config/rsync.txt')) {
$parameters .= ' --files-from=config/rsync.txt';
}
}
$dry_run = $dryrun == 'go' || $dryrun == 'ok' ? '' : '--dry-run';
$cmd = "rsync --progress {$dry_run} {$parameters} -e {$ssh} ./ {$user}{$host}:{$dir}";
echo pake_sh($cmd);
}
示例7: clone_repository
public static function clone_repository($src_url, $target_path = null)
{
if (null === $target_path) {
// trying to "guess" path
$target_path = basename($src_url);
// removing suffix
if (substr($target_path, -3) === '.hg') {
$target_path = substr($target_path, 0, -3);
}
}
if (self::isRepository($target_path)) {
throw new pakeException('"' . $target_path . '" directory is a Mercurial repository already');
}
if (file_exists($target_path)) {
throw new pakeException('"' . $target_path . '" directory already exists. Can not clone Mercurial-repository there');
}
pake_mkdirs($target_path);
pake_sh('hg clone -q ' . escapeshellarg($src_url) . ' ' . escapeshellarg($target_path));
return new pakeMercurial($target_path);
}
示例8: sync_from_server
public static function sync_from_server($local_path, $server_host, $remote_paths, $rsync_login = '', $transport = 'ssh')
{
if (strlen($rsync_login) > 0) {
$rsync_login .= '@';
}
pake_mkdirs($local_path);
if (is_string($remote_paths)) {
// sync contents of dir, so adding trailing slash
if ($remote_paths[strlen($remote_paths) - 1] != '/') {
$remote_paths .= '/';
}
$remote_paths = array($remote_paths);
} elseif (is_array($remote_paths)) {
// syncing multiple objects, so removing trailing slashes
$remote_paths = array_map(create_function('$path', 'return rtrim($path, "/");'), $remote_paths);
}
foreach ($remote_paths as &$remote_path) {
$remote_path = $rsync_login . $server_host . ':' . $remote_path;
}
pake_sh('rsync -az -e ' . escapeshellarg($transport) . ' ' . implode(' ', array_map('escapeshellarg', $remote_paths)) . ' ' . escapeshellarg($local_path));
}
示例9: run_demo
function run_demo()
{
pake_sh('aip app ' . realpath(__DIR__ . '/examples/new/config.yaml'), true);
}
示例10: clone_repository
public static function clone_repository($src_url, $target_path = null)
{
if (null === $target_path) {
// trying to "guess" path
$target_path = basename($src_url);
// removing suffix
if (substr($target_path, -4) === '.git') {
$target_path = substr($target_path, 0, -4);
}
}
if (self::isRepository($target_path)) {
throw new pakeException('"' . $target_path . '" directory is a Git repository already');
}
if (file_exists($target_path)) {
throw new pakeException('"' . $target_path . '" directory already exists. Can not clone git-repository there');
}
pake_sh(escapeshellarg(pake_which('git')) . ' clone -q ' . escapeshellarg($src_url) . ' ' . escapeshellarg($target_path));
return new pakeGit($target_path);
}
示例11: pake_shdir
function pake_shdir($cmd, $dir, $interactive = false)
{
$current_dir = realpath(getcwd());
$dir = realpath($dir);
pake_echo_comment("Jump into {$dir}");
chdir($dir);
try {
$result = pake_sh($cmd, $interactive);
} catch (Exception $e) {
pake_echo_comment("Cd back into {$current_dir}");
chdir($current_dir);
throw $e;
}
pake_echo_comment("Jump back into {$current_dir}");
chdir($current_dir);
return $result;
}
示例12: run_dist
/**
* Creates the tarballs for a release
*/
function run_dist($task = null, $args = array(), $cliOpts = array())
{
// copy workspace dir into dist dir, without git
pake_mkdirs(Builder::distDir());
$finder = pakeFinder::type('any')->ignore_version_control();
pake_mirror($finder, realpath(Builder::workspaceDir()), realpath(Builder::distDir()));
// remove unwanted files from dist dir
// also: do we still need to run dos2unix?
// create tarballs
$cwd = getcwd();
chdir(dirname(Builder::distDir()));
foreach (Builder::distFiles() as $distFile) {
// php can not really create good zip files via phar: they are not compressed!
if (substr($distFile, -4) == '.zip') {
$cmd = Builder::tool('zip');
$extra = '-9 -r';
pake_sh("{$cmd} {$distFile} {$extra} " . basename(Builder::distDir()));
} else {
$finder = pakeFinder::type('any')->pattern(basename(Builder::distDir()) . '/**');
// see https://bugs.php.net/bug.php?id=58852
$pharFile = str_replace(Builder::libVersion(), '_LIBVERSION_', $distFile);
pakeArchive::createArchive($finder, '.', $pharFile);
rename($pharFile, $distFile);
}
}
chdir($cwd);
}
示例13: extractChangelogEntriesFromRepo
/**
* Classifies all entries in git changelog as 4 types.
* Each entry is returned starting with "- "
* @return array the 1st-level elements are themselves matrixes, except for 'unmatchedEntries' which is a plain array
*/
public static function extractChangelogEntriesFromRepo($rootpath, $previousrev)
{
if ($previousrev != '') {
/// @todo check if given revision exists in git repo? We'll get an empty changelog if it does not...
/// @todo replace with pakegit::log
$git = escapeshellarg(pake_which('git'));
$changelogArray = preg_split('/(\\r\\n|\\n\\r|\\r|\\n)/', pake_sh(self::getCdCmd($rootpath) . " && {$git} log --pretty=%s " . escapeshellarg($previousrev) . "..HEAD"));
$changelogArray = array_map('trim', $changelogArray);
foreach ($changelogArray as $i => $line) {
if ($line == '') {
unset($changelogArray[$i]);
}
}
$changelogText = implode("\n", $changelogArray);
if ($changelogText == '') {
pake_echo("Git log returns an empty string - generating an empty changelog file. Please check if there is any problem with {$rootpath}");
}
// Was: "extract and categorize issues using known patterns"
// This proved not to be reliable!
// We categorize all issues by looking at their type in the bug tracker instead
/*preg_match_all( "/^[- ]?Fix(?:ed|ing)?(?: bug|issue|for ticket)? (EZP-[0-9]+):? (.*)$/mi", $changelogText, $bugfixesMatches, PREG_PATTERN_ORDER );
preg_match_all( "/^[- ]?Implement(?:ed)?(?: enhancement|issue)? (EZP-[0-9]+):? (.*)$/mi", $changelogText, $enhancementsMatches, PREG_PATTERN_ORDER );*/
preg_match_all("!^Merge pull request #0?([0-9]+):? ([^/]*)(?:/.*)?\$!mi", $changelogText, $pullreqsMatches, PREG_PATTERN_ORDER);
// remove merge commits to get "unmatched" items
$unmatchedEntries = array_diff($changelogArray, $pullreqsMatches[0]);
/// if we identify an issue number, look up its type in jira to determine its type
$issueTypes = array();
foreach ($unmatchedEntries as $i => $entry) {
if (preg_match('/(EZP-[0-9]+):? (.*)$/i', $entry, $matches)) {
if (isset($issueTypes[$matches[1]])) {
$type = $issueTypes[$matches[1]];
} else {
$type = self::findIssueType($matches[1]);
$issueTypes[$matches[1]] = $type;
}
switch ($type) {
case 'enhancement':
$enhancementsMatches[0][] = $matches[0];
$enhancementsMatches[1][] = $matches[1];
$enhancementsMatches[2][] = $matches[2];
unset($unmatchedEntries[$i]);
break;
case 'bugfix':
$bugfixesMatches[0][] = $matches[0];
$bugfixesMatches[1][] = $matches[1];
$bugfixesMatches[2][] = $matches[2];
unset($unmatchedEntries[$i]);
break;
}
}
}
$unmatchedEntries = array_values(array_map(function ($item) {
return substr($item, 0, 2) != "- " ? "- {$item}" : $item;
}, $unmatchedEntries));
} else {
pake_echo('Can not determine the git tag of last version. Generating an empty changelog file');
$bugfixesMatches = array(array());
$enhancementsMatches = array(array());
$pullreqsMatches = array(array());
$unmatchedEntries = array();
}
return array('bugfixesMatches' => $bugfixesMatches, 'enhancementsMatches' => $enhancementsMatches, 'pullreqsMatches' => $pullreqsMatches, 'unmatchedEntries' => $unmatchedEntries);
}
示例14: Exception
// unit tests
$h->register_glob($h->base_dir . '/unit/*/*Test.php');
// functional tests
$h->register_glob($h->base_dir . '/functional/*Test.php');
$h->register_glob($h->base_dir . '/functional/*/*Test.php');
$ret = $h->run();
if (!$ret) {
throw new Exception('Some tests failed. Release process aborted!');
}
if (is_file('package.xml')) {
pake_remove('package.xml', getcwd());
}
pake_copy(getcwd() . '/package.xml.tmpl', getcwd() . '/package.xml');
// add class files
$finder = pakeFinder::type('file')->ignore_version_control()->relative();
$xml_classes = '';
$dirs = array('lib' => 'php', 'data' => 'data');
foreach ($dirs as $dir => $role) {
$class_files = $finder->in($dir);
foreach ($class_files as $file) {
$xml_classes .= '<file role="' . $role . '" baseinstalldir="symfony" install-as="' . $file . '" name="' . $dir . '/' . $file . '" />' . "\n";
}
}
// replace tokens
pake_replace_tokens('package.xml', getcwd(), '##', '##', array('SYMFONY_VERSION' => $version, 'CURRENT_DATE' => date('Y-m-d'), 'CLASS_FILES' => $xml_classes, 'STABILITY' => $stability));
$results = pake_sh('pear package');
echo $results;
pake_remove('package.xml', getcwd());
// copy .tgz as symfony-latest.tgz
pake_copy(getcwd() . '/symfony-' . $version . '.tgz', getcwd() . '/symfony-latest.tgz');
exit(0);
示例15: run_dist_init
/**
* Downloads the build tarballs from Jenkins for further repackaging; options: --build=<buildnr>
*/
public static function run_dist_init($task = null, $args = array(), $cliopts = array())
{
$opts = self::getOpts($args, $cliopts);
$buildnr = @$cliopts['build'];
if ($buildnr == '') {
pake_echo('Fetching latest available build');
$buildnr = 'lastBuild';
}
// get list of files from the build
$out = self::jenkinsCall('job/' . $opts['jenkins']['jobs']['community'] . '/' . $buildnr . '/api/json', $opts);
if (!is_array($out) || !is_array(@$out['artifacts'])) {
pake_echo('Error in retrieving build description from Jenkins or no artifacts in build');
return;
} else {
if ($buildnr == 'lastBuild') {
pake_echo('Found build ' . $out['number']);
}
}
// find the correct variant
//$buildurl = self::jenkinsUrl( 'job/' . $opts['jenkins']['jobs']['community'] . '/' . $buildnr, $opts );
$fileurl = '';
foreach ($out['artifacts'] as $artifact) {
if (substr($artifact['fileName'], -4) == '.bz2') {
$fileurl = 'job/' . $opts['jenkins']['jobs']['community'] . '/' . $buildnr . '/artifact/' . $artifact['relativePath'];
break;
}
}
if ($fileurl == '') {
pake_echo("No artifacts available for build {$buildnr}");
return;
}
// clean up the 'release' dir
$rootpath = $opts['build']['dir'] . '/release';
/// @todo this method is a bit slow, should find a faster one
pake_remove_dir($rootpath);
// download and unzip the file
pake_mkdirs($rootpath);
$filename = $rootpath . '/' . $artifact['fileName'];
pake_write_file($filename, self::jenkinsCall($fileurl, $opts, 'GET', null, false), 'cpb');
// and unzip eZ into it - in a folder with a specific name
$tar = self::getTool('tar', $opts);
pake_sh(self::getCdCmd($rootpath) . " && {$tar} -xjf " . escapeshellarg($artifact['fileName']));
$currdir = pakeFinder::type('directory')->in($rootpath);
$currdir = $currdir[0];
$finaldir = $rootpath . '/' . self::getProjName();
pake_rename($currdir, $finaldir);
pake_echo("dir+ " . $finaldir);
}