Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1:/tmp/cvs-serv31660/perlmod/Fink
Modified Files:
ChangeLog Engine.pm Package.pm
Log Message:
Backing out partial db changes
Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.240
retrieving revision 1.241
diff -u -r1.240 -r1.241
--- ChangeLog 13 Jan 2003 21:56:49 -0000 1.240
+++ ChangeLog 14 Jan 2003 14:08:56 -0000 1.241
@@ -1,7 +1,5 @@
2003-01-13 Finlay Dobbie <[EMAIL PROTECTED]>
- * Package.pm: Added support for partial db updates.
-
* PkgVersion.pm (merge): Added warning to if we try to merge a
non-dummy package.
Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- Engine.pm 13 Jan 2003 21:56:51 -0000 1.82
+++ Engine.pm 14 Jan 2003 14:08:57 -0000 1.83
@@ -51,7 +51,6 @@
# read, the second flag whether root permissions are needed.
our %commands =
( 'index' => [\&cmd_index, 0, 1],
- 'reindex' => [\&cmd_index, 0, 1],
'rescan' => [\&cmd_rescan, 0, 0],
'configure' => [\&cmd_configure, 0, 1],
'bootstrap' => [\&cmd_bootstrap, 0, 1],
@@ -204,7 +203,7 @@
### simple commands
sub cmd_index {
- Fink::Package->force_update_db();
+ Fink::Package->update_db();
}
sub cmd_rescan {
Index: Package.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Package.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Package.pm 13 Jan 2003 21:56:52 -0000 1.26
+++ Package.pm 14 Jan 2003 14:08:59 -0000 1.27
@@ -44,13 +44,13 @@
our @EXPORT_OK;
our ($have_packages, @package_list, @essential_packages, $essential_valid,
%package_hash,
- $use_cache, $db_modified, $db_mtime);
+ $use_cache, $db_outdated, $db_mtime);
$have_packages = 0;
@package_list = ();
%package_hash = ();
@essential_packages = ();
$essential_valid = 0;
-$db_modified = 0;
+$db_outdated = 1;
$db_mtime = 0;
END { } # module clean-up code here (global destructor)
@@ -112,7 +112,7 @@
my $version_object = shift;
my $version = $version_object->get_fullversion();
- if (exists $self->{_versions}->{$version} &&
$self->{_versions}->{$version}->{_type} eq 'dummy') {
+ if (exists $self->{_versions}->{$version}) {
$self->{_versions}->{$version}->merge($version_object);
} else {
$self->{_versions}->{$version} = $version_object;
@@ -315,6 +315,7 @@
%package_hash = ();
@essential_packages = ();
$essential_valid = 0;
+ $db_outdated = 1;
}
### read list of packages, either from cache or files
@@ -322,56 +323,45 @@
sub scan_all {
shift; # class method - ignore first parameter
my ($time) = time;
- my ($dlist, $pkgname, $po, $hash, $fullversion, $pkgtmp);
- my ($tree, $dir);
+ my ($dlist, $pkgname, $po, $hash, $fullversion);
Fink::Package->forget_packages();
- print "Reading package info...\n";
-
- # if we have the Storable perl module, try to use the package index
+
+ # If we have the Storable perl module, try to use the package index
if (-e "$basepath/var/db/fink.db") {
eval {
require Storable;
# We assume the DB is up-to-date unless proven otherwise
- $db_modified = 0;
- $db_mtime = (stat("$basepath/var/db/fink.db"))[9];
-
- # Retrieve the pkg db from storable.
- %package_hash = %{Storable::retrieve("$basepath/var/db/fink.db")};
- foreach $pkgtmp (keys %package_hash) {
- push @package_list, $package_hash{$pkgtmp};
+ $db_outdated = 0;
+
+ # Unless the NoAutoIndex option is set, check whether we should regenerate
+ # the index based on its modification date and that of the package descs.
+ if (not $config->param_boolean("NoAutoIndex")) {
+ $db_mtime = (stat("$basepath/var/db/fink.db"))[9];
+ if (((lstat("$basepath/etc/fink.conf"))[9] > $db_mtime)
+ or ((stat("$basepath/etc/fink.conf"))[9] > $db_mtime)) {
+ $db_outdated = 1;
+ } else {
+ $db_outdated = &search_comparedb( "$basepath/fink/dists" );
+ }
+ }
+
+ # If the index is not outdated, we can use it, and thus safe a lot of time
+ if (not $db_outdated) {
+ %package_hash = %{Storable::retrieve("$basepath/var/db/fink.db")};
+ my ($pkgtmp);
+ foreach $pkgtmp (keys %package_hash) {
+ push @package_list, $package_hash{$pkgtmp};
+ }
}
}
- } else {
- $db_mtime = 0;
- }
-
- # scan each tree in turn
- foreach $tree ($config->get_treelist()) {
- $dir = "$basepath/fink/dists/$tree/finkinfo";
- Fink::Package->scan($dir);
}
- # save the db if it has been modified
- if ($db_modified) {
- eval {
- require Storable;
- if ($> == 0) {
- print "Updating package index... ";
- unless (-d "$basepath/var/db") {
- mkdir("$basepath/var/db", 0755) || die "Error: Could not create directory
$basepath/var/db";
- }
- Storable::store (\%package_hash, "$basepath/var/db/fink.db");
- print "done.\n";
- } else {
- &print_breaking( "\nFink has detected that your package cache is out of date
and needs" .
- " an update, but does not have privileges to modify it. Please re-run fink
as root," .
- " for example with a \"fink index\" command.\n" );
- }
- };
+ # Regenerate the DB if it is outdated
+ if ($db_outdated) {
+ Fink::Package->update_db();
}
- $db_modified = 0;
# Get data from dpkg's status file. Note that we do *not* store this
# information into the package database.
@@ -399,14 +389,66 @@
(time - $time), " seconds.\n\n";
}
-### force the database to be regenerated
+### scan for info files and compare to $db_mtime
-sub force_update_db {
- shift; # class method - ignore first parameter
- if (-e "$basepath/var/db/fink.db") {
- unlink "$basepath/var/db/fink.db";
+sub search_comparedb {
+ my $path = shift;
+ my (@files, $file, $newpath, @stats);
+
+ opendir(DIR, $path) || die "can't opendir $path: $!";
+ @files = readdir(DIR);
+ closedir DIR;
+
+ foreach $file (@files) {
+ next if substr($file, 0, 1) eq ".";
+ next if $file eq "CVS";
+
+ $newpath = "$path/$file";
+
+ @stats = stat($newpath);
+
+ if (S_ISDIR($stats[2])) {
+ return 1 if (&search_comparedb($newpath));
+ }
+
+ if (substr($file, length($file)-5) eq ".info") {
+ return 1 if ($stats[9] > $db_mtime);
+ }
}
- Fink::Package->scan_all;
+
+ return 0;
+}
+
+### read the packages and update the database, if needed and we are root
+
+sub update_db {
+ shift; # class method - ignore first parameter
+ my ($tree, $dir);
+
+ print "Reading package info...\n";
+
+ # read data from descriptions
+ foreach $tree ($config->get_treelist()) {
+ $dir = "$basepath/fink/dists/$tree/finkinfo";
+ Fink::Package->scan($dir);
+ }
+
+ eval {
+ require Storable;
+ if ($> == 0) {
+ print "Updating package index... ";
+ unless (-d "$basepath/var/db") {
+ mkdir("$basepath/var/db", 0755) || die "Error: Could not create directory
+$basepath/var/db";
+ }
+ Storable::store (\%package_hash, "$basepath/var/db/fink.db");
+ print "done.\n";
+ } else {
+ &print_breaking( "\nFink has detected that your package cache is out of date
+and needs" .
+ " an update, but does not have privileges to modify it. Please re-run fink as
+root," .
+ " for example with a \"fink index\" command.\n" );
+ }
+ };
+ $db_outdated = 0;
}
### scan one tree for package desccriptions
@@ -430,9 +472,6 @@
find({ wanted => $wanted, follow => 1, no_chdir => 1 }, $directory);
foreach $filename (@filelist) {
- # skip file if it's older than the db
- next unless ((stat($filename))[9] > $db_mtime);
-
# read the file and get the package name
$properties = &read_properties($filename);
$pkgname = $properties->{package};
@@ -451,7 +490,6 @@
# create object for this particular version
$properties->{thefilename} = $filename;
Fink::Package->inject_description($package, $properties);
- $db_modified = 1;
}
}
-------------------------------------------------------
This SF.NET email is sponsored by: FREE SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits