Update of /cvsroot/fink/pdb
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv16006

Modified Files:
        create-finkdb.pl 
Log Message:
change of tack, using solr instead -- really fast, and easy to add/remove index 
stuff

Index: create-finkdb.pl
===================================================================
RCS file: /cvsroot/fink/pdb/create-finkdb.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- create-finkdb.pl    27 Nov 2007 21:58:39 -0000      1.5
+++ create-finkdb.pl    28 Nov 2007 03:25:40 -0000      1.6
@@ -143,7 +143,7 @@
        next unless ($releases->{$release}->{'isactive'});
 
        print "- checking out $release\n";
-       check_out_release($releases->{$release});
+       #check_out_release($releases->{$release});
 
        print "- indexing $release\n";
        index_release_to_xml($releases->{$release});
@@ -332,9 +332,9 @@
                mkpath($xmlpath);
 
                my $outputfile = $xmlpath . '/' . package_id($package_info) . 
'.xml';
-               my $output = IO::File->new('>' . $outputfile);
+               my $xml;
 
-               my $writer = XML::Writer->new(OUTPUT => $output);
+               my $writer = XML::Writer->new(OUTPUT => \$xml);
 
                # alternate schema, solr
                $writer->startTag("add");
@@ -361,6 +361,13 @@
                $writer->endTag("doc");
                $writer->endTag("add");
 
+               #$xml .= "\n<commit />\n";
+
+               my $output = IO::File->new('>' . $outputfile);
+               print $output $xml;
+               $output->close();
+               post_to_solr($outputfile);
+
                # old schema, hand-made
 #              $writer->startTag("infofile", "version" => $fink_version);
 #              $writer->startTag("id");
@@ -375,6 +382,8 @@
 #              $writer->endTag("infofile");
 
                $writer->end();
+
+
        }
 }
 
@@ -393,6 +402,7 @@
                                print "file = $file\n" if ($trace);
                                my $xml = XMLin($file);
                                $xml = $xml->{'doc'}->{'field'};
+                               return unless ($xml->{'doc_id'}->{'content'});
 
                                my $package_info = {};
 
@@ -402,16 +412,7 @@
                                        print "- package 
$xml->{'name'}->{'content'} is still valid ($infofile)\n" if ($trace);
                                } else {
                                        print "- removing obsolete package 
$xml->{'name'}->{'content'}\n" if ($debug);
-                                       system(
-                                               'curl', 
'http://localhost:8983/solr/update', '--data-binary',
-                                               '<delete><query>doc_id:' . 
$xml->{'doc_id'}->{'content'} . '</query></delete>',
-                                               '-H', 'Content-type:text/xml; 
charset=utf-8',
-                                       ) == 0 or die "failed to delete 
$xml->{'doc_id'}->{'content'}: $!";
-
-                                       system(
-                                               'curl', 
'http://localhost:8983/solr/update', '--data-binary', '<commit />',
-                                               '-H', 'Content-type:text/xml; 
charset=utf-8',
-                                       ) == 0 or die "failed to commit 
$xml->{'doc_id'}->{'content'}: $!";
+                                       post_to_solr('<delete><query>doc_id:' . 
$xml->{'doc_id'}->{'content'} . '</query></delete>');
                                        unlink($file);
                                }
                        },
@@ -555,7 +556,24 @@
 EOMSG
 }
 
-exit 0;
 
+sub post_to_solr {
+       my $contents = shift;
+
+       my @curl = ( 'curl', 'http://localhost:8983/solr/update', '-s', '-o', 
'/dev/null', '-H', 'Content-type:text/xml; charset=utf-8', '--data-binary' );
+       my @command;
+
+       if (-f $contents) {
+               @command = (@curl, '@' . $contents);
+       } else {
+               @command = (@curl, $contents);
+       }
+
+       print "    - posting $contents\n" if ($debug);
+       system(@command) == 0 or die ("unable to post update ($contents) to 
solr: $!");
+
+       print "    - committing\n" if ($debug);
+       system(@curl, '<commit />') == 0 or die ("unable to commit update 
($contents): $!");
+}
 
 # vim: ts=4 sw=4 noet


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Fink-commits mailing list
[email protected]
http://news.gmane.org/gmane.os.apple.fink.cvs

Reply via email to