Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848

Modified Files:
        Bootstrap.pm ChangeLog Engine.pm Package.pm PkgVersion.pm 
        SelfUpdate.pm Shlibs.pm 
Log Message:
shlibs overhaul

Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.446
retrieving revision 1.447
diff -u -d -r1.446 -r1.447
--- PkgVersion.pm       26 Aug 2005 20:12:06 -0000      1.446
+++ PkgVersion.pm       26 Aug 2005 21:27:19 -0000      1.447
@@ -45,6 +45,7 @@
 use Fink::Bootstrap qw(&get_bsbase);
 use Fink::Command qw(mkdir_p rm_f rm_rf symlink_f du_sk chowname touch);
 use Fink::Notify;
+use Fink::Shlibs;
 use Fink::Validation;
 use Fink::Text::DelimMatch;
 use Fink::Text::ParseWords qw(&parse_line);
@@ -2881,15 +2882,15 @@
                import File::Find;
        };
 
-# Add a dependency on the kernel version (if not already present).
-#   We depend on the major version only, in order to prevent users from
-#   installing a .deb file created with an incorrect MACOSX_DEPLOYMENT_TARGET
-#   value.
-# TODO: move all this kernel-dependency stuff into pkglist()
-# FIXME: Actually, if the package states a kernel version we should combine
-#   the version given by the package with the one we want to impose.
-#   Instead, right now, we just use the package's version but this means
-#   that a package will need to be revised if the kernel major version changes.
+       # Add a dependency on the kernel version (if not already present).
+       #   We depend on the major version only, in order to prevent users from
+       #   installing a .deb file created with an incorrect 
MACOSX_DEPLOYMENT_TARGET
+       #   value.
+       # TODO: move all this kernel-dependency stuff into pkglist()
+       # FIXME: Actually, if the package states a kernel version we should 
combine
+       #   the version given by the package with the one we want to impose.
+       #   Instead, right now, we just use the package's version but this means
+       #   that a package will need to be revised if the kernel major version 
changes.
 
        my $kernel = lc((uname())[0]);
        my $kernel_version = lc((uname())[2]);
@@ -2903,45 +2904,45 @@
        }
 
        my $has_kernel_dep;
-       my $struct = &pkglist2lol($self->get_binary_depends()); 
+       my $deps = &pkglist2lol($self->get_binary_depends()); 
 
-       ### 1) check for 'AddShlibDeps: true' else continue
+       foreach (@$deps) {
+               foreach (@$_) {
+                       $has_kernel_dep = 1 if /^\Q$kernel\E(\Z|\s|\()/;
+               }
+       }
+       push @$deps, ["$kernel (>= $kernel_major_version-1)"] if not 
$has_kernel_dep;
+
+       ### Automatically add dependencies based on shlibs, if requested
        if ($self->param_boolean("AddShlibDeps")) {
-               print "Writing shared library dependencies...\n";
+               print_breaking "Writing shared library dependencies...";
 
-               ### 2) get a list to replace it with
-               my @filelist = ();
+               # Get all the files to be installed
+               my @filelist;
                my $wanted = sub {
                        if (-f) {
                                # print "DEBUG: file: $File::Find::fullname\n";
                                push @filelist, $File::Find::fullname;
                        }
                };
-               ## Might need follow_skip but then need to change fullname
-               find({ wanted => $wanted, follow_fast => 1, no_chdir => 1 }, 
"$destdir"."$basepath");
-
-               my @shlib_deps = Fink::Shlibs->get_shlibs($pkgname, @filelist);
+               find({ wanted => $wanted, follow_fast => 1, no_chdir => 1 },
+                       "$destdir$basepath"); # Do we want to use follow_skip 
instead?
 
-               ### foreach loop and push into @$struct
-               ### 3) replace it in the debian control file
-               foreach my $shlib_dep (@shlib_deps) {
-                       push @$struct, ["$shlib_dep"];
+               # Add the deps based on the files
+               foreach my $shlib_dep (Fink::Shlibs->get_shlibs($self, 
@filelist)) {
+                       push @$deps, [ $shlib_dep ];
                        if ($config->verbosity_level() > 2) {
                                print "- Adding $shlib_dep to 'Depends' line\n";
                        }
                }
        }
-       foreach (@$struct) {
-               foreach (@$_) {
-                       $has_kernel_dep = 1 if /^\Q$kernel\E(\Z|\s|\()/;
-               }
-       }
-       push @$struct, ["$kernel (>= $kernel_major_version-1)"] if not 
$has_kernel_dep;
+       
+       $control .= "Depends: " . &lol2pkglist($deps) . "\n";
        if (Fink::Config::get_option("maintainermode")) {
-               print "- Depends line is: " . &lol2pkglist($struct) . "\n";
+               print "- Depends line is: " . &lol2pkglist($deps) . "\n";
        }
-       $control .= "Depends: " . &lol2pkglist($struct) . "\n";
 
+       ### Look at other pkglists
        foreach $field (qw(Provides Replaces Conflicts Pre-Depends
                                                                                
 Recommends Suggests Enhances)) {
                if ($self->has_pkglist($field)) {
@@ -4053,25 +4054,6 @@
        return ($rubydirectory, $rubyarchdir, $rubycmd);
 }
 
-### FIXME shlibs, crap no longer needed keeping for now incase the pdb needs it
-sub get_debdeps {
-       my $wantedpkg = shift;
-       my $field = "Depends";
-       my $deps = "";
-
-       ### get deb file
-       my $deb = $wantedpkg->find_debfile();
-
-       if (-f $deb) {
-               $deps = `dpkg-deb -f $deb $field 2> /dev/null`;
-               chomp($deps);
-       } else {
-               die "Can't find deb file: $deb\n";
-       }
-
-       return $deps;
-}
-
 =item get_install_directory
 
   my $dir = $pv->get_install_directory;
@@ -4231,7 +4213,7 @@
 
 sub dpkg_changed {
        Fink::Status->invalidate();
-       # Shlibs?
+       Fink::Shlibs->invalidate();
 }
 =back
 

Index: SelfUpdate.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/SelfUpdate.pm,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- SelfUpdate.pm       5 Aug 2005 07:13:36 -0000       1.98
+++ SelfUpdate.pm       26 Aug 2005 21:27:19 -0000      1.99
@@ -30,7 +30,6 @@
 use Fink::NetAccess qw(&fetch_url);
 use Fink::Engine;
 use Fink::Package;
-use Fink::Shlibs;
 use Fink::FinkVersion qw(&pkginfo_version);
 use Fink::Mirror;
 use Fink::Command qw(cat chowname mkdir_p mv rm_f rm_rf touch);
@@ -516,14 +515,8 @@
        # forget the package info
        Fink::Package->forget_packages();
 
-       # delete the old shlibs DB
-       if (-e "$dbpath/shlibs.db") {
-               unlink "$dbpath/shlibs.db";
-       }
-
        # ...and then read it back in
        Fink::Package->require_packages();
-       Fink::Shlibs->scan_all();
 
        # update the package manager itself first if necessary (that is, if a
        # newer version is available).

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1107
retrieving revision 1.1108
diff -u -d -r1.1107 -r1.1108
--- ChangeLog   26 Aug 2005 20:12:06 -0000      1.1107
+++ ChangeLog   26 Aug 2005 21:27:19 -0000      1.1108
@@ -1,5 +1,19 @@
 2005-08-26  Dave Vasilevsky  <[EMAIL PROTECTED]>
 
+       * Bootstrap.pm, Engine.pm, Package.pm, SelfUpdate.pm: Remove unneeded
+       references to Shlibs.
+       * PkgVersion.pm: Remove unused method for getting Depends from deb, a 
more
+       general solution for all pkglists is needed, see bug #1249916.
+       * PkgVersion.pm: When dpkg status changes, invalidate Shlibs.
+       * PkgVersion.pm: Cleanup of Shlibs getting.
+       * Shlibs.pm: Don't use a DB, since it the shlibs list needs to be
+       regenerated so often (every time a package is installed or removed!).
+       Instead re-generate on demand, like Fink::Status.
+       * Shlibs.pm: Remove random autoflush until somebody tells me what it's 
for,
+       or it's documented.
+
+2005-08-26  Dave Vasilevsky  <[EMAIL PROTECTED]>
+
        * PkgVersion.pm: Abstract out invalidating caches when dpkg state 
changes.
        * Engine.pm: Remove redundant invalidate calls.
 

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.312
retrieving revision 1.313
diff -u -d -r1.312 -r1.313
--- Engine.pm   26 Aug 2005 20:12:06 -0000      1.312
+++ Engine.pm   26 Aug 2005 21:27:19 -0000      1.313
@@ -34,7 +34,6 @@
                                 &get_term_width);
 use Fink::Configure qw(&spotlight_warning);
 use Fink::Package;
-use Fink::Shlibs;
 use Fink::PkgVersion;
 use Fink::Config qw($config $basepath $debarch $dbpath);
 use File::Find;
@@ -232,7 +231,6 @@
        # read package descriptions if needed
        if ($pkgflag) {
                Fink::Package->require_packages();
-               Fink::Shlibs->scan_all();
        }
 
        if (Fink::Config::get_option("maintainermode")) {
@@ -343,7 +341,6 @@
                Fink::Package->forget_packages();
        }
        Fink::Package->update_db(no_load => 1, no_fastload => 1);
-       Fink::Shlibs->update_shlib_db();
 }
 
 sub cmd_configure {
@@ -461,7 +458,6 @@
                $desclen = 0;
        }
        Fink::Package->require_packages();
-       Fink::Shlibs->scan_all();
        @_ = @ARGV;
        @ARGV = @temp_ARGV;
        @allnames = Fink::Package->list_packages();
@@ -1028,7 +1024,6 @@
        }
 
        Fink::Package->require_packages();
-       Fink::Shlibs->scan_all(quiet => 1);
        @_ = @ARGV;
        @ARGV = @temp_ARGV;
        @plist = Fink::Package->list_packages();
@@ -2026,11 +2021,8 @@
                        Fink::PkgVersion::phase_activate(@batch_install) unless 
(@batch_install == 0);
                        # Reinstall buildconficts after the build
                        &real_install($OP_INSTALL, 1, 1, $dryrun, @removals) if 
(scalar(@removals) > 0);
-                       ### Update shlibs after each install for next build
-                       Fink::Shlibs->forget_packages();
-                       Fink::Shlibs->scan_all(quiet => 1);
-                       # Mark all installed items as installed
 
+                       # Mark all installed items as installed
                        foreach $pkg (@batch_install) {
                                        $deps{$pkg->get_name()}->[FLAG] |= 2;
                        }
@@ -2198,7 +2190,6 @@
        }
 
        Fink::Package->require_packages();
-       Fink::Shlibs->scan_all();
        @_ = @ARGV;
        @ARGV = @temp_ARGV;
 

Index: Shlibs.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Shlibs.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Shlibs.pm   21 Apr 2005 17:33:58 -0000      1.21
+++ Shlibs.pm   26 Aug 2005 21:27:19 -0000      1.22
@@ -21,22 +21,14 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA     02111-1307, 
USA.
 #
 
-$|++;
-
 package Fink::Shlibs;
 
 use Fink::Base;
 use Fink::Services qw(&version_cmp);
-use Fink::CLI qw(&get_term_width &print_breaking &print_breaking_stderr);
-use Fink::Config qw($config $basepath $dbpath);
+use Fink::CLI qw(&print_breaking_stderr);
+use Fink::Config qw($basepath);
 use Fink::PkgVersion;
-use Fink::Command qw(mkdir_p);
-use Fink::Package;
-
 use File::Find;
-use Fcntl ':mode'; # for search_comparedb
-use Symbol qw();
-use Fcntl qw(:flock);
 
 use strict;
 use warnings;
@@ -48,52 +40,103 @@
        $VERSION        = 1.00;
        @ISA            = qw(Exporter Fink::Base);
        @EXPORT         = qw();
-       @EXPORT_OK      = qw(&get_shlibs);
+       @EXPORT_OK      = qw();
        %EXPORT_TAGS    = ( );
 }
 our @EXPORT_OK;
 
-our $have_shlibs = 0;
-our $shlibs = {};
-our $shlib_db_outdated = 1;
-our $shlib_db_mtime = 0;
+# The cached shlibs information, set to undef if not valid
+our $shlibs = undef;
 
 END { }                                # module clean-up code here (global 
destructor)
 
 
-### get shlibs depends line
-sub get_shlibs {
-       my $self = shift;
-       my $pkgname = shift;
-       my @filelist = @_;
-       my ($depend, @depends, %SHLIBS);
+=head1 NAME
 
-       @depends = $self->check_files($pkgname, @filelist);
+Fink::Shlibs - Find dependencies based on shared libs.
 
-       foreach $depend (@depends) {
+=head1 SYNOPSIS
+
+  # Get the dependencies for the files to be installed
+  my @deps = Fink::Shlibs->get_shlibs $pkgname, @files;
+  
+  # Invalidate the current internal cache of shlibs when dpkg changes
+  Fink::Shlibs->invalidate;
+
+=head1 DESCRIPTION
+
+Most of the dependencies needed for a package to be installed are simply to
+supply the shared libraries which it links to. Because each package which
+supplies a shared library lists it in the 'Shlibs' field, these dependencies
+can be determined automatically.
+
+=head1 FUNCTIONS
+
+=over 4
+
+=item get_shlibs
+
+  my @depspecs = Fink::Shlibs->get_shlibs $pv, @files;
+
+Get the dependency specifications needed to supply the shared libs linked to
+by the given files.
+
+Pass in the PkgVersion object for which we are getting the depends, and
+the list of files which should be checked.
+
+A dependency specification is a package name and a version specification,
+eg: 'foo (>= 1.0-1)'.
+
+=cut
+
+sub get_shlibs {
+       my ($class, $pv, @filelist) = @_;
+
+       my @depends = $class->_check_files($pv, @filelist);
+       
+       my %found; # don't duplicate
+       foreach my $depend (@depends) {
                if (length($depend) > 1) {
-                       $SHLIBS{$depend} = 1;
+                       $found{$depend} = 1;
                }
        }
 
-       return sort keys %SHLIBS;
+       return sort keys %found;
 }
 
-### check the files for depends
-sub check_files {
-       my $self = shift;
-       my $package = shift;
-       my @files = @_;
+=item invalidate
+
+  Fink::Shlibs->invalidate;
+
+When the state of dpkg changes (ie: when a package is installed or removed),
+the cache of installed shlibs needs to be regenerated. This function notifies
+Shlibs when this is the case.
+
+=back
+
+=cut
+
+sub invalidate {
+       $shlibs = undef;
+}
+
+=begin private
+
+  my @depspecs = Fink::Shlibs->_check_files $pv, @filelist;
+  
+Similar to get_shlibs, but unchecked output, so depspecs may be empty or
+duplicate.
+
+=end private
+
+=cut
+
+sub _check_files {
+       my ($self, $pkg, @files) = @_;
+       
        my ($file, @depends, $deb, $currentlib, $lib, $compat);
        my (@splits, $split, $tmpdep, $dep, $vers, @dsplits, $dsplit);
-       my (@deplines, @builddeps, $depline, $builddep, $pkg);
-
-       # Get package object
-       $pkg = Fink::PkgVersion->match_package($package);
-       unless (defined $pkg) {
-               print STDERR "no package found for specification '$package'!\n";
-               return;
-       }
+       my (@deplines, @builddeps, $depline, $builddep);
 
        # get parent and split names to envoke a = %v-%r override
        @splits = $pkg->get_splitoffs(1, 1);
@@ -131,7 +174,7 @@
 
                                ### This should drop any depends on it's self
                                ### Strictly on it's self not a child
-                               $deb = $self->get_shlib($lib, $compat);
+                               $deb = $self->_get_shlib($lib, $compat);
                                unless ($deb) {
                                        # Add a big warning about 
/usr/local/lib being
                                        # in the way if $basepath isn't 
/usr/local
@@ -148,7 +191,7 @@
                                $tmpdep = $deb;
                                $tmpdep =~ s/^(\S*)\s*\(.*\)$/$1/g;
 
-                               if ($tmpdep eq $package) {
+                               if ($tmpdep eq $pkg->get_name) {
                                        next OTOOLLOOP;
                                }
 
@@ -244,7 +287,7 @@
        # $depvers hash and @newdeps array.
 
        for my $dep (@depends) {
-               my @depobj = get_depobj($dep);
+               my @depobj = _get_depobj($dep);
                my $name;
 
                # get_depobj() returns multiple entries when the source depend
@@ -265,11 +308,11 @@
                        $name = join('|', @depnames);
                        undef @depnames;
                        for my $obj (@depobj) {
-                               $depvers = update_version_hash($depvers, $obj);
+                               $depvers = _update_version_hash($depvers, $obj);
                        }
                } else {
                        $name = $depobj[0]->{tuplename};
-                       $depvers = update_version_hash($depvers, $depobj[0]);
+                       $depvers = _update_version_hash($depvers, $depobj[0]);
                }
 
                next if (not defined $name);
@@ -333,7 +376,7 @@
 
 ### this is a scary subroutine to update the name,operator cache
 ### for handling duplicates -- it's just plain evil.  EVIL.  EEEEVIIIILLLL.
-sub update_version_hash {
+sub _update_version_hash {
        my $hash   = shift;
        my $depobj = shift;
 
@@ -392,7 +435,7 @@
 }
 
 # get a dependency "object" (just a data structure with dep info)
-sub get_depobj {
+sub _get_depobj {
        my $depdef = shift;
        my ($depobj, $name, $operator, $version);
        my @return;
@@ -423,10 +466,13 @@
 }
 
 ### get package name
-sub get_shlib {
+sub _get_shlib {
        my $self = shift;
        my $lib = shift;
        my $compat = shift;
+       
+       $self->_validate; # Ensure the cache exists
+       
        my ($dep, $shlib, $count, $pkgnum, $vernum, $total);
 
        $dep = "";
@@ -448,225 +494,96 @@
        return $dep;
 }
 
+=begin private
 
-### forget about all shlibs
-sub forget_packages {
-       my $self = shift;
-
-       $have_shlibs = 0;
-       $shlibs = {};
-       $shlib_db_outdated = 1;
-}
-
-### read list of shlibs, either from cache or files
-sub scan_all {
-       my $self= shift;
-       my %args = @_;
-       my ($time) = time;
-       my ($shlibname);
+  Fink::Shlibs->_validate;
+  
+Ensure that the current shlib cache is valid.
 
-       my $dbfile = "$dbpath/shlibs.db";
-       my $conffile = "$basepath/etc/fink.conf";
+=end private
 
-       $self->forget_packages();
-       
-       # If we have the Storable perl module, try to use the package index
-       if (-e $dbfile) {
-               eval {
-                       require Storable; 
+=cut
 
-                       # We assume the DB is up-to-date unless proven otherwise
-                       $shlib_db_outdated = 0;
-               
-                       # Unless the NoAutoIndex option is set, check whether
-                       # we should regenerate the index based on its
-                       # modification date.
-                       if (not $config->param_boolean("NoAutoIndex")) {
-                               $shlib_db_mtime = (stat($dbfile))[9];
-                               if (((lstat($conffile))[9] > $shlib_db_mtime)
-                                       or ((stat($conffile))[9] > 
$shlib_db_mtime)) {
-                                       $shlib_db_outdated = 1;
-                               } else {
-                                       $shlib_db_outdated = &search_comparedb( 
"$basepath/var/lib/dpkg/info" );
-                               }
-                       }
-                       
-                       # If the index is not outdated, we can use it,
-                       # and thus safe a lot of time
-                       if (not $shlib_db_outdated) {
-                               $shlibs = Storable::lock_retrieve($dbfile);
-                       }
-               }
-       }
+sub _validate {
+       my $class = shift;
+       return if defined $shlibs; # Cache ok
        
-       # Regenerate the DB if it is outdated
-       if ($shlib_db_outdated) {
-               $self->update_shlib_db();
-       }
-
-       $have_shlibs = 1;
-
-       unless ($args{'quiet'}) {
-               if (&get_term_width) {
-                       printf STDERR "Information about %d shared libraries 
read in %d seconds.\n",
-                               scalar(values %$shlibs), (time - $time);
-               }
-       }
+       $class->_scan();
 }
 
-### scan for info files and compare to $db_shlibs_mtime
-
-# returns true if any are newer than $db_shlibs_mtime, false if not
-sub search_comparedb {
-       my $path = shift;
-       $path .= "/";  # forces find to follow the symlink
-       my $dbfile = "$dbpath/shlibs.db";
-
-       # Using find is much faster than doing it in Perl
-       open NEWER_FILES, "/usr/bin/find $path \\( -type f -or -type l \\) -and 
-name '*.shlibs' -newer $dbfile |"
-               or die "/usr/bin/find failed: $!\n";
-
-       # If there is anything on find's STDOUT, we know at least one
-       # .info is out-of-date. No reason to check them all.
-       my $file_found = defined <NEWER_FILES>;
+=begin private
 
-       close NEWER_FILES;
+  Fink::Shlibs->_scan;
 
-       return $file_found;
-}
+Scan the shlibs files and generate the shlibs cache
 
-### read shlibs and update the database, if needed and we are root
+=end private
 
-sub update_shlib_db {
-       my $self = shift;
-       my ($dir);
+=cut
 
-       my $dbfile = "$dbpath/shlibs.db";
-       my $lockfile = "$dbfile.lock";
-       my $lockfile_FH;
-       my $dbtemp = "$dbfile.tmp";
+sub _scan {
+       my $class = shift;
+       
+       print_breaking_stderr "Scanning for shlibs...";
+       
+       # Where to look for .shlibs files?
+       my $directory = "$basepath/var/lib/dpkg/info";
+       return if not -d $directory;
+       
+       # Scan for .shlibs files
+       my @filelist;
+       find({
+               wanted => sub {
+                       push @filelist, $_ if -f and not /^[\.\#]/ and 
/\.shlibs$/;
+               },
+               follow => 1, no_chdir => 1
+       }, $directory);
+       
+       my ($shlibname, $compat, $package);
 
-       # check if we should update index cache
-       my $writable_cache = 0;
-       eval "require Storable";
-       if ($@) {
-               my $perlver = sprintf '%*vd', '', $^V;
-               &print_breaking_stderr( "Fink could not load the perl Storable 
module, which is required in order to keep a cache of the shlibs list. You 
should install the fink \"storable-pm$perlver\" package to enable this 
functionality.\n" );
-       } elsif ($> != 0) {
-               &print_breaking_stderr( "Fink has detected that your shlibs 
list cache is missing or out of date, but does not have privileges to modify 
it. Re-run fink as root, for example with a \"fink index\" command, to update 
the cache.\n" );
-       } else {
-               # we have Storable.pm and are root
-               $writable_cache = 1;
-       }
+       foreach my $filename (@filelist) {
+               open(SHLIB, $filename) or die "can't open $filename: $!\n";
+                       while(my $line = <SHLIB>) {
+                               chomp($line);
+                               $line =~ s/^\s*//;
+                               $line =~ s/\s*$//;
+                               if ($line =~ /^(.+)\s+([.0-9]+)\s+(.*)$/) {
+                                       my $shlibname = $1;
+                                       my $compat = $2;
+                                       my $package = $3;
 
-       if ($writable_cache) {
-               $lockfile_FH = Symbol::gensym();
-               unless (open $lockfile_FH, "+>> $lockfile") {
-                       &print_breaking_stderr("Warning: Package index cache 
disabled because cannot access indexer lock $lockfile: $!");
-                       $writable_cache = 0;
-               }
-       }
+                                       unless ($shlibname) {
+                                               print_breaking_stderr "WARNING: 
No lib name in $filename";
+                                               next;
+                                       }
+                                       unless ($compat) {
+                                               print_breaking_stderr "WARNING: 
No lib compatability version for $shlibname";
+                                               next;
+                                       }
+                                       unless ($package) {
+                                               print_breaking_stderr "WARNING: 
No owner package(s) for $shlibname";
+                                               next;
+                                       }
 
-       if ($writable_cache) {
-               unless (flock $lockfile_FH, LOCK_EX | LOCK_NB) {
-                       # couldn't get exclusive lock, meaning another fink 
process has it
-                       print STDERR "\nWaiting for another reindex to 
finish...";
-                       if (flock $lockfile_FH, LOCK_EX) {
-                               print STDERR " done.\n";
-                               # nearly-concurrent indexing run finished so 
just grab its results
-                               $shlibs = Storable::lock_retrieve($dbfile);
-                               close $lockfile_FH;
-                               $shlib_db_outdated = 0;
-                               return;
+                                       $class->_inject_shlib($shlibname, 
$compat, $package);
+                               }
                        }
-                       print STDERR "error: could not lock $lockfile: $!\n";
-               }
-               # getting here means we got the lock on the first try
-       }
-
-       # read data from descriptions
-       if (&get_term_width) {
-               print STDERR "Reading shared library info...\n";
+               close(SHLIB);
        }
-       $dir = "$basepath/var/lib/dpkg/info";
-       $self->scan($dir);
-
-       if ($writable_cache) {
-               if (&get_term_width) {
-                       print STDERR "Updating shared library index... ";
-               }
-
-               if (Storable::lock_store($shlibs, $dbtemp)) {
-                       if (rename $dbtemp, $dbfile) {
-                               print STDERR "done.\n";
-                       } else {
-                               print STDERR "error: could not activate 
temporary file $dbtemp: $!\n";
-                       }
-               } else {
-                       print STDERR "error: could not write temporary file 
$dbtemp: $!\n";
-               }
-               close $lockfile_FH;
-       };
-
-       $shlib_db_outdated = 0;
 }
 
-### scan for shlibs
-sub scan {
-       my $self = shift;
-       my $directory = shift;
-       my (@filelist, $wanted);
-       my ($filename, $shlibname, $compat, $package, $line, @lines);
-
-       return if not -d $directory;
+=begin private
 
-       # search for .shlibs files
-       @filelist = ();
-       $wanted =
-               sub {
-                       if (-f and not /^[\.#]/ and /\.shlibs$/) {
-                               push @filelist, $File::Find::fullname;
-                       }
-               };
-       find({ wanted => $wanted, follow => 1, no_chdir => 1 }, $directory);
+  Fink::Shlibs->_inject_shlib $lib, $compat, $supplied_by;
 
-       foreach $filename (@filelist) {
-               open(SHLIB, $filename) or die "can't open $filename: $!\n";
-                       while(<SHLIB>) {
-                               @lines = split(/\n/, $_);
-                               foreach $line (@lines) {
-                                       chomp($line);
-                                       $line =~ s/^\s*//;
-                                       $line =~ s/\s*$//;
-                                       if ($line =~ 
/^(.+)\s+([.0-9]+)\s+(.*)$/) {
-                                               $shlibname = $1;
-                                               $compat = $2;
-                                               $package = $3;
+Add a shared lib into the shlibs cache.
 
-                                               unless ($shlibname) {
-                                                       print STDERR "No lib 
name in $filename\n";
-                                                       next;
-                                               }
-                                               unless ($compat) {
-                                                       print STDERR "No lib 
compatability version for $shlibname\n";
-                                                       next;
-                                               }
-                                               unless ($package) {
-                                                       print STDERR "No owner 
package(s) for $shlibname\n";
-                                                       next;
-                                               }
+=end private
 
-                                               $self->inject_shlib($shlibname, 
$compat, $package);
-                                       }
-                               }
-                       }
-               close(SHLIB);
-       }
-}
+=cut
 
-### create the hash
-sub inject_shlib {
-       my $self = shift;
+sub _inject_shlib {
+       my $class = shift;
        my $shlibname = shift;
        my $compat = shift;
        my $package = shift;

Index: Package.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Package.pm,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- Package.pm  26 Aug 2005 05:29:54 -0000      1.156
+++ Package.pm  26 Aug 2005 21:27:19 -0000      1.157
@@ -32,7 +32,6 @@
 use Fink::Command qw(&touch &mkdir_p &rm_rf &rm_f);
 use Fink::PkgVersion;
 use Fink::FinkVersion;
-use Fink::Shlibs;
 use File::Find;
 use File::Basename;
 use Symbol qw();
@@ -445,9 +444,6 @@
 # 1 => shlibs
 # 2 => package
        $class->load_packages unless defined $packages;
-#      if (!$have_shlibs && $oper != 2) {
-#              Fink::Shlibs->scan_all(@_);
-#      }
 }
 
 =item check_dbdirs

Index: Bootstrap.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Bootstrap.pm,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- Bootstrap.pm        19 Aug 2005 01:44:35 -0000      1.118
+++ Bootstrap.pm        26 Aug 2005 21:27:19 -0000      1.119
@@ -27,7 +27,6 @@
 use Fink::Services qw(&execute &file_MD5_checksum &enforce_gcc 
&eval_conditional);
 use Fink::CLI qw(&print_breaking &prompt_boolean);
 use Fink::Package;
-use Fink::Shlibs;
 use Fink::PkgVersion;
 use Fink::Engine;
 use Fink::Command qw(cat mkdir_p rm_rf touch);
@@ -422,9 +421,8 @@
        # disable UseBinaryDist during bootstrap
        Fink::Config::set_options( { 'use_binary' => -1 });
 
-       # make sure we have the package descriptions and shlibs
+       # make sure we have the package descriptions
        Fink::Package->require_packages();
-       Fink::Shlibs->scan_all();
 
        # determine essential packages
        @elist = Fink::Package->list_essential_packages();



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to