automatic updating version number in .dsc and .spec files

This commit is contained in:
Ralf Becker 2010-03-18 19:39:53 +00:00
parent 16707ee82e
commit 09177e4018

View File

@ -124,8 +124,10 @@ function do_obs()
$n = 0; $n = 0;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path)
{ {
if (basename(dirname($path)) != '.osc' && if (basename(dirname($path)) == '.osc') continue;
preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9]+(\.tar\.(gz|bz2))$/',$path,$matches) && if (!preg_match('/\/'.preg_quote($config['packagename']).'[a-z-]*-'.preg_quote($config['version']).'/',$path)) continue;
if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9]+(\.tar\.(gz|bz2))$/',$path,$matches) &&
file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2]))
{ {
if (basename($path) != basename($new_name)) if (basename($path) != basename($new_name))
@ -137,6 +139,25 @@ function do_obs()
if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; if ($verbose) echo "cp $new_name ".dirname($path)."/\n";
++$n; ++$n;
} }
// updating dsc and spec files
if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec')
{
$content = $content_was = file_get_contents($path);
$content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9]+/m','Version: '.$config['version'].'.'.$config['packaging'],$content);
if (substr($path,-4) == '.dsc')
{
$content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'.
preg_quote($config['version']).'\.[0-9]+(\.tar\.(gz|bz2))$/m',
'\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content);
}
if ($content != $content_was)
{
file_put_contents($path,$content);
if ($verbose) echo "Updated $path\n";
++$n;
}
}
} }
if ($n) if ($n)
{ {