9 use Packages::Config qw( $DBDIR );
11 our @ISA = qw( Exporter );
12 our ( %packages, %sources, %src2bin, %did2pkg, %descriptions,
14 $obj, $s_obj, $p_obj, $sp_obj );
15 our @EXPORT = qw( %packages %sources %src2bin %did2pkg %descriptions
17 $obj $s_obj $p_obj $sp_obj );
18 our $db_read_time ||= 0;
21 my $dbmodtime = (stat("$DBDIR/packages_small.db"))[9] || 0;
22 if ($dbmodtime >= $db_read_time) {
23 $obj = tie %packages, 'DB_File', "$DBDIR/packages_small.db",
24 O_RDONLY, 0666, $DB_BTREE
25 or die "couldn't tie DB $DBDIR/packages_small.db: $!";
26 $s_obj = tie %sources, 'DB_File', "$DBDIR/sources_small.db",
27 O_RDONLY, 0666, $DB_BTREE
28 or die "couldn't tie DB $DBDIR/sources_small.db: $!";
29 tie %src2bin, 'DB_File', "$DBDIR/sources_packages.db",
30 O_RDONLY, 0666, $DB_BTREE
31 or die "couldn't open $DBDIR/sources_packages.db: $!";
32 tie %descriptions, 'DB_File', "$DBDIR/descriptions.db",
33 O_RDONLY, 0666, $DB_BTREE
34 or die "couldn't tie DB $DBDIR/descriptions.db: $!";
35 tie %did2pkg, 'DB_File', "$DBDIR/descriptions_packages.db",
36 O_RDONLY, 0666, $DB_BTREE
37 or die "couldn't tie DB $DBDIR/descriptions_packages.db: $!";
38 $p_obj = tie %postf, 'DB_File', "$DBDIR/package_postfixes.db",
39 O_RDONLY, 0666, $DB_BTREE
40 or die "couldn't tie postfix db $DBDIR/package_postfixes.db: $!";
41 $sp_obj = tie %spostf, 'DB_File', "$DBDIR/source_postfixes.db",
42 O_RDONLY, 0666, $DB_BTREE
43 or die "couldn't tie postfix db $DBDIR/source_postfixes.db: $!";
45 debug( "tied databases ($dbmodtime > $db_read_time)" ) if DEBUG;
46 $db_read_time = $dbmodtime;