From c97400f8819306b1901839798ab418a25a5245eb Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 5 Mar 2010 15:28:06 +0000 Subject: [PATCH] allow to replace archives in obs checkout --- doc/rpm-build/checkout-build-archives.php | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/doc/rpm-build/checkout-build-archives.php b/doc/rpm-build/checkout-build-archives.php index 4fc6690810..b383fb4669 100644 --- a/doc/rpm-build/checkout-build-archives.php +++ b/doc/rpm-build/checkout-build-archives.php @@ -35,6 +35,7 @@ $config = array( 'freshclam' => '/usr/bin/freshclam', 'gpg' => '/usr/bin/gpg', 'packager' => 'build@stylite.de', + 'obs' => false, 'skip' => array(), 'run' => array('checkout','copy','virusscan','create','sign') ); @@ -76,6 +77,13 @@ while(($arg = array_shift($argv))) } break; + case 'obs': + if (!is_dir($value)) + { + usage("Path '$value' not found!"); + } + if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; + // fall through default: $config[$name] = $value; break; @@ -99,6 +107,34 @@ foreach(array_diff($config['run'],$config['skip']) as $func) $func(); } +/** + * Copy archive files to obs checkout and commit them + * + */ +function do_obs() +{ + global $config,$verbose; + + $n = 0; + foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) + { + if (basename(dirname($path)) != '.osc' && + preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-[0-9.-]+(\.tar\.(gz|bz2))$/',$path,$matches) && + file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) + { + if (basename($path) != basename($new_name)) + { + unlink($path); + if ($verbose) echo "rm $path\n"; + } + copy($new_name,dirname($path).'/'.basename($new_name)); + if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; + ++$n; + } + } + if ($n) echo "$n files replaced in $config[obs] --> commit them now: osc addremove; osc commit\n"; +} + /** * Sign sha1sum file */