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

Modified Files:
        ChangeLog Engine.pm Package.pm PkgVersion.pm 
Log Message:
        * Engine.pm: Remove 'rescan' command, nobody knows what it's for and
        nobody uses it.
        * Package.pm, PkgVersion.pm: Cleanup and document. More cleaning to 
come!


Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.385
retrieving revision 1.386
diff -u -d -r1.385 -r1.386
--- PkgVersion.pm       21 Apr 2005 14:04:55 -0000      1.385
+++ PkgVersion.pm       21 Apr 2005 18:58:55 -0000      1.386
@@ -624,7 +624,7 @@
        }
        
        # instantiate the splitoff
-       @splitoffs = Fink::Package->setup_package_object($properties, 
$filename);
+       @splitoffs = Fink::Package->packages_from_properties($properties, 
$filename);
        
        # return the new object(s)
        return @splitoffs;

Index: Package.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Package.pm,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- Package.pm  21 Apr 2005 17:33:58 -0000      1.109
+++ Package.pm  21 Apr 2005 18:58:55 -0000      1.110
@@ -468,45 +468,8 @@
        if ($db_outdated) {
                Fink::Package->update_db();
        }
-
-       # Get data from dpkg's status file. Note that we do *not* store this 
-       # information into the package database.
-       $dlist = Fink::Status->list();
-       foreach $pkgname (keys %$dlist) {
-               $po = Fink::Package->package_by_name_create($pkgname);
-               next if exists 
$po->{_versions}->{$dlist->{$pkgname}->{version}};
-               $hash = $dlist->{$pkgname};
-
-               # create dummy object
-               if (@versions = parse_fullversion($hash->{version})) {
-                       $hash->{epoch} = $versions[0] if defined($versions[0]);
-                       $hash->{version} = $versions[1] if 
defined($versions[1]);
-                       $hash->{revision} = $versions[2] if 
defined($versions[2]);
-                       $hash->{type} = "dummy";
-                       $hash->{filename} = "";
-
-                       Fink::Package->inject_description($po, $hash);
-               }
-       }
-       # Get data from VirtPackage.pm. Note that we do *not* store this 
-       # information into the package database.
-       $dlist = Fink::VirtPackage->list();
-       foreach $pkgname (keys %$dlist) {
-               $po = Fink::Package->package_by_name_create($pkgname);
-               next if exists 
$po->{_versions}->{$dlist->{$pkgname}->{version}};
-               $hash = $dlist->{$pkgname};
-
-               # create dummy object
-               if (@versions = parse_fullversion($hash->{version})) {
-                       $hash->{epoch} = $versions[0] if defined($versions[0]);
-                       $hash->{version} = $versions[1] if 
defined($versions[1]);
-                       $hash->{revision} = $versions[2] if 
defined($versions[2]);
-                       $hash->{type} = "dummy";
-                       $hash->{filename} = "";
-
-                       Fink::Package->inject_description($po, $hash);
-               }
-       }
+       
+       Fink::Package->insert_runtime_packages;
        $have_packages = 1;
 
        if (&get_term_width) {
@@ -617,7 +580,7 @@
        $db_outdated = 0;
 }
 
-### scan one tree for package desccriptions
+### scan one tree for package descriptions
 
 sub scan {
        shift;  # class method - ignore first parameter
@@ -638,36 +601,117 @@
        find({ wanted => $wanted, follow => 1, no_chdir => 1 }, $directory);
 
        foreach $filename (@filelist) {
-               # read the file and get the package name
-               $properties = &read_properties($filename);
-               $properties = Fink::Package->handle_infon_block($properties, 
$filename);
-               next unless keys %$properties;
-               $pkgname = $properties->{package};
-               unless ($pkgname) {
-                       print "No package name in $filename\n";
-                       next;
-               }
-               unless ($properties->{version}) {
-                       print "No version number for package $pkgname in 
$filename\n";
-                       next;
-               }
-               # fields that should be converted from multiline to
-               # single-line
-               for my $field ('builddepends', 'depends', 'files') {
-                       if (exists $properties->{$field}) {
-                               $properties->{$field} =~ s/[\r\n]+/ /gs;
-                               $properties->{$field} =~ s/\s+/ /gs;
-                       }
+               my @pvs = Fink::Package->packages_from_info_file($filename);
+               Fink::Package->insert_pkgversions(@pvs);
+       }
+}
+
+=item packages_from_info_file
+
+  my @packages = Fink::Package->packages_from_info_file $filename;
+  
+Create Fink::PkgVersion objects based on a .info file. Do not
+yet add these packages to the current package database.
+
+Returns all packages created, including split-offs.
+
+=cut
+
+sub packages_from_info_file {
+       shift;  # class method - ignore first parameter
+       my $filename = shift;
+       
+       # read the file and get the package name
+       my $properties = &read_properties($filename);
+       $properties = Fink::Package->handle_infon_block($properties, $filename);
+       return () unless keys %$properties;
+       
+       my $pkgname = $properties->{package};
+       unless ($pkgname) {
+               print "No package name in $filename\n";
+               next;
+       }
+       unless ($properties->{version}) {
+               print "No version number for package $pkgname in $filename\n";
+               next;
+       }
+       # fields that should be converted from multiline to
+       # single-line
+       for my $field ('builddepends', 'depends', 'files') {
+               if (exists $properties->{$field}) {
+                       $properties->{$field} =~ s/[\r\n]+/ /gs;
+                       $properties->{$field} =~ s/\s+/ /gs;
                }
+       }
 
-               Fink::Package->setup_package_object($properties, $filename);
+       return Fink::Package->packages_from_properties($properties, $filename);
+}
+
+
+=item insert_runtime_packages
+
+  Fink::Package->insert_runtime_packages;
+  
+Add all packages to the database which are dynamically generated, rather than
+created from .info files.
+
+=cut
+
+sub insert_runtime_packages {
+       # Get data from dpkg's status file. Note that we do *not* store this 
+       # information into the package database.
+       Fink::Package->insert_runtime_packages_hash(Fink::Status->list());
+
+       # Get data from VirtPackage.pm. Note that we do *not* store this 
+       # information into the package database.
+       Fink::Package->insert_runtime_packages_hash(Fink::VirtPackage->list());
+}
+
+=item insert_runtime_package_hash
+
+  Fink::Package->insert_runtime_package_hash $hashref;
+  
+Given a hash of package-name => property-list, insert the packages into the
+in-memory database.
+
+=cut
+
+sub insert_runtime_packages_hash {
+       shift;  # class method - ignore first parameter
+       
+       my $dlist = shift;
+       foreach my $pkgname (keys %$dlist) {
+               my $po = Fink::Package->package_by_name_create($pkgname);
+               next if exists 
$po->{_versions}->{$dlist->{$pkgname}->{version}};
+               my $hash = $dlist->{$pkgname};
+
+               # create dummy object
+               if (my @versions = parse_fullversion($hash->{version})) {
+                       $hash->{epoch} = $versions[0] if defined($versions[0]);
+                       $hash->{version} = $versions[1] if 
defined($versions[1]);
+                       $hash->{revision} = $versions[2] if 
defined($versions[2]);
+                       $hash->{type} = "dummy";
+                       $hash->{filename} = "";
+
+                       Fink::Package->insert_pkgversions(
+                               Fink::Package->packages_from_properties($hash));
+               }
        }
 }
 
-# Given $properties as a ref to a hash of .info lines in $filename,
-# instantiate the package(s) and return an array of Fink::PkgVersion
-# object(s) (i.e., the results of Fink::Package::inject_description().
-sub setup_package_object {
+=item packages_from_properties
+
+  my $properties = { field => $val, ... };
+  my @packages = Fink::Package->packages_from_properties $properties, 
$filename;
+
+Create Fink::PkgVersion objects based on a hash-ref of properties. Do not
+yet add these packages to the current package database.
+
+Returns all packages created, including split-offs.
+
+=cut
+
+sub packages_from_properties {
        shift;  # class method - ignore first parameter
        my $properties = shift;
        my $filename = shift;
@@ -689,7 +733,7 @@
                                # need new copy, not copy of ref to original
                                my $this_properties = {%{$properties}};
                                $this_properties->{type} =~ 
s/($type\s*)\(.*?\)/$type $_/;
-                               push @pkgversions, 
Fink::Package->setup_package_object($this_properties, $filename);
+                               push @pkgversions, 
Fink::Package->packages_from_properties($this_properties, $filename);
                        };
                        return @pkgversions;
                }
@@ -719,40 +763,41 @@
        # sure Maintainer doesn't have %type_*[] or other bad % constructs
        $properties->{package} = 
&expand_percent($properties->{package},\%pkg_expand, "$filename \"package\"");
 
-       # get/create package object
-       my $package = 
Fink::Package->package_by_name_create($properties->{package});
-
        # create object for this particular version
        $properties->{thefilename} = $filename;
-       my $pkgversion = Fink::Package->inject_description($package, 
$properties);
-       return ($pkgversion);
+       
+       my $pkgversion = Fink::PkgVersion->new_from_properties($properties);
+       
+       return $pkgversion->get_splitoffs(1, 1);
 }
 
-### create a version object from a properties hash and link it
-# first parameter: existing Package object
-# second parameter: ref to hash with fields
+=item insert_pkgversions
 
-sub inject_description {
-       shift;  # class method - ignore first parameter
-       my $po = shift;
-       my $properties = shift;
-       my ($version, $vp, $vpo);
+  Fink::Package->insert_pkgversions @pkgversions;
 
-       # create version object
-       $version = Fink::PkgVersion->new_from_properties($properties);
+Insert a list of Fink::PkgVersion into the current in-memory package database.
 
-       # link them together
-       $po->add_version($version);
+=cut
 
-       # track provided packages
-       if ($version->has_pkglist("Provides")) {
-               foreach $vp (split(/\s*\,\s*/, $version->pkglist("Provides"))) {
-                       $vpo = Fink::Package->package_by_name_create($vp);
-                       $vpo->add_provider($version);
+sub insert_pkgversions {
+       shift;  # class method - ignore first parameter
+       my @pvs = @_;
+       
+       for my $pv (@pvs) {
+               # get/create package object
+               my $po = Fink::Package->package_by_name_create($pv->get_name);
+       
+               # link them together
+               $po->add_version($pv);
+
+               # track provided packages
+               if ($pv->has_pkglist("Provides")) {
+                       foreach my $vp (split(/\s*\,\s*/, 
$pv->pkglist("Provides"))) {
+                               my $vpo = 
Fink::Package->package_by_name_create($vp);
+                               $vpo->add_provider($pv);
+                       }
                }
        }
-       
-       return $version;
 }
 
 =item handle_infon_block

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -d -r1.257 -r1.258
--- Engine.pm   8 Apr 2005 22:16:05 -0000       1.257
+++ Engine.pm   21 Apr 2005 18:58:54 -0000      1.258
@@ -64,7 +64,6 @@
 # '--ignore-breakage' option, 2, if it is called with '--ignore-breakage'
 our %commands =
        ( 'index'             => [\&cmd_index,             0, 1, 1],
-         'rescan'            => [\&cmd_rescan,            0, 0, 0],
          'configure'         => [\&cmd_configure,         0, 1, 0],
          'bootstrap'         => [\&cmd_bootstrap,         0, 1, 0],
          'fetch'             => [\&cmd_fetch,             1, 1, 0],
@@ -301,11 +300,6 @@
        Fink::Shlibs->update_shlib_db();
 }
 
-sub cmd_rescan {
-       Fink::Package->forget_packages();
-       Fink::Package->require_packages();
-}
-
 sub cmd_configure {
        require Fink::Configure;
        Fink::Configure::configure();

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.942
retrieving revision 1.943
diff -u -d -r1.942 -r1.943
--- ChangeLog   21 Apr 2005 17:33:58 -0000      1.942
+++ ChangeLog   21 Apr 2005 18:58:53 -0000      1.943
@@ -1,5 +1,11 @@
 2005-04-21  Dave Vasilevsky  <[EMAIL PROTECTED]>
 
+       * Engine.pm: Remove 'rescan' command, nobody knows what it's for and
+       nobody uses it.
+       * Package.pm, PkgVersion.pm: Cleanup and document. More cleaning to 
come!
+
+2005-04-21  Dave Vasilevsky  <[EMAIL PROTECTED]>
+
        * Package.pm, Shlibs.pm: Stop Shlibs inheriting from Package, for it is
        silly.
 



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to