ability to create svn tag or branch for the package

This commit is contained in:
Ralf Becker 2010-05-25 20:19:36 +00:00
parent 51f619e54b
commit 72d07f94e8

View File

@ -13,6 +13,7 @@ if (isset($_SERVER['HTTP_HOST'])) // security precaution: forbit calling setup-c
{
die('<h1>checkout-build-tgz.php must NOT be called as web-page --> exiting !!!</h1>');
}
date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings
$verbose = 0;
$config = array(
@ -36,10 +37,11 @@ $config = array(
'gpg' => '/usr/bin/gpg',
'packager' => 'build@stylite.de',
'obs' => false,
'changelog' => false, // eg. ' * 1. Zeile\n * 2. Zeile' for debian.changes
'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes
'changelog_packager' => 'Ralf Becker <rb@stylite.de>',
'svntag' => 'Stylite-EPL-$version.$packaging', // eg. '$version.$packaging'
'skip' => array(),
'run' => array('checkout','copy','virusscan','create','sign')
'run' => array('svntag','checkout','copy','virusscan','create','sign')
);
// process config from command line
@ -79,6 +81,11 @@ while(($arg = array_shift($argv)))
}
break;
case 'svntag':
$config[$name] = $value;
array_unshift($config['run'],'svntag');
break;
case 'obs':
if (!is_dir($value))
{
@ -354,6 +361,39 @@ function do_checkout()
throw new Exception("svn checkout directory '{$config['svndir']} exists and is NO directory or NOT writable!");
}
chdir($config['svndir']);
// do we use a just created tag --> list of taged modules
if ($config['svntag'] && isset($config['modules']))
{
if (file_exists($config['aliasdir']))
{
system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags
clearstatcache();
}
foreach($config['modules'] as $repo => $modules)
{
$cmd = $svn.' co ';
foreach($modules as $path => $url)
{
if ($path == $config['aliasdir'])
{
$cmd = $svn.' co '.$repo.'/'.$config['svntag'].'/'.$path;
run_cmd($cmd);
chdir($path);
$cmd = $svn.' co ';
continue;
}
if(file_exists($config['aliasdir']))
{
die('"egroupware" applications must be first one in externals!');
}
$cmd .= ' '.$repo.'/'.$config['svntag'].'/'.basename($path);
}
run_cmd($cmd);
}
return;
}
// regular branch update, without tag
$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
if (file_exists($config['aliasdir']))
{
@ -395,6 +435,59 @@ function do_checkout()
}
}
/**
* Create svn tag or branch
*/
function do_svntag()
{
global $config,$svn,$verbose;
$translate = array();
foreach($config as $name => $value) $translate['$'.$name] = $value;
if (strpos($config['svntag'],'$') !== false) // allow to use config vars like $version in tag
{
$config['svntag'] = strtr($config['svntag'],$translate);
}
echo "Creating SVN tag $config[svntag]\n";
// process alias/externals
$svnbranch = $config['svnbase'].'/'.$config['svnbranch'];
$url = $svnbranch.'/'.$config['svnalias'];
$cmd = $svn.' propget svn:externals --strict '.$url;
if ($verbose) echo $cmd."\n";
exec($cmd,$output,$ret);
$config['modules'] = array();
foreach($output as $line)
{
list($path,$url) = preg_split('/[ \t\r\n]+/',trim($line));
if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die('Invalid SVN URL!');
$repo = $matches[1];
$config['modules'][$repo][$path] = $url;
}
// process extra modules
foreach($config['extra'] as $module)
{
if (strpos($module,'$') !== false) // allow to use config vars like $svnbranch in module
{
$module = strtr($module,$translate);
}
$url = strpos($module,'://') === false ? $svnbranch.'/' : '';
$url .= $module;
if (strpos($module,'://') !== false) $module = basename($module);
if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die('Invalid SVN URL!');
$repo = $matches[1];
$config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url;
}
// create tags (per repo)
foreach($config['modules'] as $repo => $modules)
{
if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://svn@dev.egroupware.org/egroupware';
$cmd = $svn.' cp '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/';
run_cmd($cmd);
}
}
/**
* Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose)
*