64 require_once(
"FIXMETOBERELATIVE/pathinclude.php");
65 require_once(
"$LIBDIR/lib_projxml.h.php");
68 Usage: diffm [-h] -f <file1> <file2> [-o <dir-path>]
69 Where <file1> path to an uncompressed top1000 Freshmeat rdf XML file
70 <file2> path to an uncompressed top1000 Freshmeat rdf XML file
72 For the differences to be found as expected file1 should be the newer
73 file. E.g. f1.2008-1-14 f2.2008-1-13.
75 <dir-path> fully qualified path where output files will be placed.
76 If no -o option given, the cwd is used
for the output files.
78 Output files are: FM-projects2update and Update.fm.rdf
80 See
mktop1k to create a top1000 Freshmeat file from the master rdf file.
84 for ($i = 1; $i < $argc; $i++) {
89 if ((isset($argv[$i])) and (isset($argv[$i+1]))){
90 $in_file1 = $argv[$i];
92 $in_file2 = $argv[$i];
96 echo(
"ERROR: Must specify 2 uncompressed filenames after -f");
102 if(eregi(
'^-+', $in_file2)) {
103 echo(
"ERROR: Must specify 2 uncompressed filenames after -f");
110 if (isset($argv[$i])) {
111 $dir_path = $argv[$i];
114 die(
"ERROR: Must specify fully qualified directory path after -o");
122 die(
"ERROR: Unknown argument: $argv[$i]\n$usage");
129 echo
"ERROR: -f is a required parameter\n";
134 if (
false == file_exists($in_file1)) {
135 echo
"Error: $in_file1 does not exist\n";
139 if (
false == file_exists($in_file2)) {
140 echo
"Error: $in_file2 does not exist\n";
145 if (0 == $size = filesize($in_file1)){
146 echo
"Error, file $in_file1 is empty\n";
149 if (0 == $size = filesize($in_file2)){
150 echo
"Error, file $in_file2 is empty\n";
155 $F1 = fopen($in_file1,
'r') or die("Can't open: $in_file1 $php_errormsg\n");
156 $F2 = fopen($in_file2, 'r') or die("Can't open: $in_file2 $php_errormsg\n");
158 echo "Comparing the following files:\n$in_file1\n$in_file2\n\n";
162 $dstamp = date('Y-m-d');
163 $projs2update = $dir_path . 'FM-projects2update.' . $dstamp;
164 $xml_changes = $dir_path . 'Update.fm.rdf.' . $dstamp;
166 $P2up = fopen($projs2update, 'w') or die("Can't open: $php_errormsg\n");
167 $Cxml = fopen($xml_changes, 'w') or die("Can't open: $php_errormsg\n");
177 $list1 = mklists($in_file1);
178 $list2 = mklists($in_file2);
183 $adiffs = array_diff_assoc($list1, $list2);
187 $diffs_found = count($adiffs);
188 if ($diffs_found == 0){
189 echo
"NOTE: No differences were found. \n";
190 $junk = exec(
"rm -f $projs2update $xml_changes", $dummy, $rtn);
192 echo
"cound not remove files $projs2update\nand\n$xml_changes\n";
193 echo
"Please remove them manually";
200 while(
false != ($f1_line = fgets($F1, 1024))) {
203 if (preg_match(
'/<project>/', $f1_line)) {
205 $proj1 = get_entry($F1, $m1);
213 $proj_name = xtract($proj1[4]);
214 foreach($adiffs as $name => $version){
215 if ($proj_name == $name){
217 $Yupdate =
"$name " .
"has a new version:" .
" $version\n";
218 save_Yupdated($P2up, $Yupdate);
220 write_pxml($Cxml, $proj1);
230 if($diffs_found > 0){
232 "$diffs_found differences were found. Please consult the following files:\n";
233 echo
"$projs2update and $xml_changes\n";
247 function mklists($xml_file){
250 $pdoc1= simplexml_load_file(
"$xml_file");
252 $projects = $pdoc1->xpath(
'/project-listing/project');
254 foreach($projects as $proj){
255 list($pname_short) = $proj->xpath(
'projectname_short');
257 list($lrv) = $proj->xpath(
'latest_release/latest_release_version');
258 $p[
"$pname_short"] =
"$lrv";
if(!preg_match("/\s$projectGroup\s/", $groups)&&(posix_getgid()!=$gInfo['gid']))
get monk license list of one specified uploadtree_id
Usage()
Print Usage statement.
list_t type structure used to keep various lists. (e.g. there are multiple lists).