9 use Packages::Config qw( $TOPDIR $DBDIR );
11 our @ISA = qw( Exporter );
12 our ( %packages, %sources, %src2bin, %did2pkg, %descriptions,
13 %postf, %spostf, %debtags, %desctrans,
14 $obj, $s_obj, $p_obj, $sp_obj );
15 our @EXPORT = qw( %packages %sources %src2bin %did2pkg %descriptions
16 %postf %spostf %debtags %desctrans
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 %desctrans, 'DB_File', "$DBDIR/descriptions_translated.db",
36 O_RDONLY, 0666, $DB_BTREE
37 or die "couldn't tie DB $DBDIR/descriptions_translated.db: $!";
38 tie %did2pkg, 'DB_File', "$DBDIR/descriptions_packages.db",
39 O_RDONLY, 0666, $DB_BTREE
40 or die "couldn't tie DB $DBDIR/descriptions_packages.db: $!";
41 tie %debtags, 'DB_File', "$TOPDIR/files/debtags/vocabulary.db",
42 O_RDONLY, 0666, $DB_BTREE
43 or die "couldn't tie DB $TOPDIR/files/debtags/vocabulary.db: $!";
44 $p_obj = tie %postf, 'DB_File', "$DBDIR/package_postfixes.db",
45 O_RDONLY, 0666, $DB_BTREE
46 or die "couldn't tie postfix db $DBDIR/package_postfixes.db: $!";
47 $sp_obj = tie %spostf, 'DB_File', "$DBDIR/source_postfixes.db",
48 O_RDONLY, 0666, $DB_BTREE
49 or die "couldn't tie postfix db $DBDIR/source_postfixes.db: $!";
51 debug( "tied databases ($dbmodtime > $db_read_time)" ) if DEBUG;
52 $db_read_time = $dbmodtime;