OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /e/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-re Date: 25-Nov-2002 16:57:28
Branch: HEAD Handle: 2002112515572800
Modified files:
openpkg-re openpkg-index
Log:
cache result of rpm2spec
Summary:
Revision Changes Path
1.20 +27 -8 openpkg-re/openpkg-index
____________________________________________________________________________
Index: openpkg-re/openpkg-index
============================================================
$ cvs diff -u -r1.19 -r1.20 openpkg-index
--- openpkg-re/openpkg-index 25 Nov 2002 15:54:15 -0000 1.19
+++ openpkg-re/openpkg-index 25 Nov 2002 15:57:28 -0000 1.20
@@ -30,8 +30,8 @@
use strict;
use Getopt::Std;
-getopts('r:p:o:ci');
-use vars qw/$opt_r $opt_p $opt_o $opt_c $opt_i/;
+getopts('r:p:C:o:ci');
+use vars qw/$opt_r $opt_p $opt_C $opt_o $opt_c $opt_i/;
use FileHandle;
use DirHandle;
@@ -762,9 +762,10 @@
#####################################################################
-sub write_index ($$$$$) {
- my($fh,$prefix,$resource,$platform,$list) = @_;
+sub write_index ($$$$$$) {
+ my($fh,$prefix,$resource,$platform,$list,$cache) = @_;
my($a,$h,$r,$spec);
+ my($mtime);
foreach (@$list) {
$a = undef;
@@ -775,7 +776,19 @@
$a = spec2data($spec);
} elsif (/([^\/]+\.src\.rpm)$/) {
$h = relpath($prefix, $_);
- $spec = rpm2spec($_);
+ if ($cache) {
+ $mtime = (stat $_)[9];
+ if (exists $cache->{"M$_"} &&
+ $cache->{"M$_"} == $mtime) {
+ $spec = $cache->{"S$_"};
+ } else {
+ $spec = rpm2spec($_);
+ $cache->{"S$_"} = $spec;
+ $cache->{"M$_"} = $mtime;
+ }
+ } else {
+ $spec = rpm2spec($_);
+ }
$a = spec2data($spec);
} elsif (/([^\/]+\.rpm)$/) {
$h = relpath($prefix, $_);
@@ -797,13 +810,19 @@
#####################################################################
-my($prefix,$list,$fh);
+my($prefix,$list,$fh,%cache);
if ($#ARGV < 0) {
- print "usage: $0 [-r resource] [-p platform] [-o index.rdf] [-c] [-i] dir
...\n";
+ print "usage: $0 [-r resource] [-p platform] [-C cache.db] [-o index.rdf] [-c]
[-i] dir ...\n";
die "\n";
}
+if ($opt_C) {
+ require DB_File;
+ tie %cache, 'DB_File', $opt_C, O_CREAT|O_RDWR, 0666, $DB_File::DB_HASH
+ or die "FATAL: cannot tie cache '$opt_C' ($!)\n";
+}
+
$opt_r = 'OpenPKG-CURRENT/Source/' unless defined $opt_r;
$opt_p = 'unknown' unless defined $opt_p;
@@ -833,7 +852,7 @@
} else {
$list = list_specdir($prefix);
}
- write_index($fh, $prefix, $opt_r, $opt_p, $list);
+ write_index($fh, $prefix, $opt_r, $opt_p, $list, $opt_C ? \%cache : undef);
}
xml_foot($fh);
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [EMAIL PROTECTED]