diff options
author | Remi Collet <fedora@famillecollet.com> | 2013-01-31 10:21:34 +0100 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2013-01-31 10:21:34 +0100 |
commit | 38aca08fb0ff231aa49679756282152056c5d4ce (patch) | |
tree | 6af4ee973098c988edd2ec7fdcdcfd6c37fede2e /checkrpmdate |
add script to check date in rpm changelog
Diffstat (limited to 'checkrpmdate')
-rwxr-xr-x | checkrpmdate | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/checkrpmdate b/checkrpmdate new file mode 100755 index 0000000..f4bfa82 --- /dev/null +++ b/checkrpmdate @@ -0,0 +1,42 @@ +#!/usr/bin/php +<?php +if (!isset($_SERVER['argv'][1])) { + die("usage checkrpmdate <specfile>\n"); +} +if (!file_exists($_SERVER['argv'][1])) { + die("File not found\n"); +} +$text = file_get_contents($_SERVER['argv'][1]); +$lines = explode("\n", $text); + +$key = array_search("%changelog", $lines); +if (!$key) { + die("%changelog not found\n"); +} +$lines = array_slice($lines, $key); +$nbok = $nbko = 0; +foreach ($lines as $line) { + if (preg_match('/^\* (([[:alpha:]]{3}) ([[:alpha:]]{3}) *([[:digit:]]{1,2}) ([[:digit:]]{4}))/', $line, $reg)) { + $d0 = $reg[4].' '.$reg[3].' '.$reg[5]; + $t = strtotime($d0); + $d1 = date("D M d Y", $t); + $d2 = date("D M j Y", $t); + if ($d1 == $reg[1] || $d2 == $reg[1]) { + $nbok++; + } else { + echo $reg[1].": should be $d1\n"; + $nbko++; + } + } else if (substr($line,0,1)=='*') { + echo "$line: should start with a date\n"; + $nbko++; + } +} +if (!$nbko) { + if ($nbok) { + echo "$nbok dates found are ok\n"; + } else { + echo "No date found\n"; + } +} + |