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

Modified Files:
        ChangeLog Engine.pm Services.pm 
Log Message:
make things work without apt installed

Index: Services.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v
retrieving revision 1.202
retrieving revision 1.203
diff -u -d -r1.202 -r1.203
--- Services.pm 20 Mar 2006 18:35:39 -0000      1.202
+++ Services.pm 22 Mar 2006 01:04:19 -0000      1.203
@@ -69,7 +69,7 @@
                                          &store_rename &fix_gcc_repairperms
                                          &spec2struct &spec2string &get_options
                                          $VALIDATE_HELP $VALIDATE_ERROR 
$VALIDATE_OK
-                                         &find_subpackages);
+                                         &find_subpackages &apt_available);
 }
 our @EXPORT_OK;
 
@@ -2210,6 +2210,29 @@
        return @found;
 }
 
+=item apt_available
+
+  my $bool = apt_available;
+
+Check if apt-get seems usable on this system.
+
+=cut
+
+{
+       my $aptok;
+       
+       sub apt_available {
+               unless (defined $aptok) {
+                       require Fink::Config;
+                       $aptok = !execute(
+                               "$Fink::Config::basepath/bin/apt-get 
1>/dev/null 2>/dev/null",
+                               quiet => 1
+                       );
+               }
+               return $aptok;
+       }
+}
+
 =back
 
 =cut

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.359
retrieving revision 1.360
diff -u -d -r1.359 -r1.360
--- Engine.pm   21 Mar 2006 22:57:53 -0000      1.359
+++ Engine.pm   22 Mar 2006 01:04:19 -0000      1.360
@@ -29,7 +29,7 @@
                                          &count_files &get_arch
                                          &call_queue_clear &call_queue_add
                                          &dpkg_lockwait &aptget_lockwait 
&store_rename &get_options
-                                         $VALIDATE_HELP);
+                                         $VALIDATE_HELP &apt_available);
 use Fink::CLI qw(&print_breaking &print_breaking_stderr
                                 &prompt_boolean &prompt_selection
                                 &get_term_width);
@@ -199,7 +199,7 @@
                }
                # check if apt-get is available
                if (not $apt_problem) {
-                       if (&execute("$basepath/bin/apt-get 1>/dev/null 
2>/dev/null", quiet=>1)) {
+                       if (!apt_available) {
                                &print_breaking("ERROR: You have the 
'UseBinaryDist' option enabled ".
                                    "but apt-get could not be run. Try to 
install the 'apt' Fink package ".
                                    "(with e.g. 'fink install apt').");
@@ -614,10 +614,52 @@
        }
 }
 
+=item aptget_update
+
+  aptget_update $quiet;
 
-sub cmd_scanpackages {
+Update the apt-get package database.
+
+=cut
+
+sub aptget_update {
        my $quiet = shift || 0;
-       my @treelist = @_;
+       
+       return unless apt_available;
+       my $aptcmd = aptget_lockwait();
+       if ($quiet) {
+               $aptcmd .= " -qq";
+       } elsif ($config->verbosity_level < 2) {
+               $aptcmd .= " -q";
+       }
+       if (&execute($aptcmd . " update", quiet => 1)) {
+               print("WARNING: Failure while updating indexes.\n");
+       }
+}
+
+=item cmd_scanpackages
+
+  $ fink scanpackages [ TREE1 ... ]
+
+Command to update the packages in the given trees.
+
+=cut
+
+sub cmd_scanpackages {
+       scanpackages(0, @_);
+       aptget_update;
+}
+
+=item scanpackages
+
+  scanpackages $quiet, @trees;
+
+Update the apt-get package database in the given trees.
+
+=cut
+
+sub scanpackages {
+       my ($quiet, @treelist) = @_;
        
        # Use lowest verbosity
        $quiet = $config->verbosity_level if $quiet > $config->verbosity_level;
@@ -631,17 +673,6 @@
                verbosity => !$quiet,
                restrictive => $restrictive
        }, @treelist);
-       
-       # Update apt-get
-       my $aptcmd = aptget_lockwait() . " ";
-       if ($quiet) {
-               $aptcmd .= "-qq ";
-       } elsif ($config->verbosity_level < 2) {
-               $aptcmd .= "-q ";
-       }
-       if (&execute($aptcmd . "update", quiet => 1)) {
-               print("WARNING: Failure while updating indexes.\n");
-       }
 }
 
 ### package-related commands
@@ -1230,7 +1261,10 @@
                if ($opts{dryrun}) {
                        print "Skipping scanpackages and in dryrun mode\n";
                } else {
-                       &cmd_scanpackages(1);
+                       if (apt_available) {
+                               scanpackages(1);
+                               aptget_update(1);
+                       }
                }
        }
 }
@@ -1862,11 +1896,12 @@
                }
        }
        
-       # Default to AutoScanpackages: True
+       # Default to true
        my $autoscan = !$config->has_param("AutoScanpackages")
                || $config->param_boolean("AutoScanpackages");
-       if ($willbuild && $autoscan) {
-               &cmd_scanpackages(1);
+       if ($willbuild && $autoscan && apt_available) {
+               scanpackages(1);
+               aptget_update(1);
        }
 }
 

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1286
retrieving revision 1.1287
diff -u -d -r1.1286 -r1.1287
--- ChangeLog   22 Mar 2006 00:09:30 -0000      1.1286
+++ ChangeLog   22 Mar 2006 01:04:19 -0000      1.1287
@@ -1,3 +1,8 @@
+2006-03-21  Dave Vasilevsky  <[EMAIL PROTECTED]>
+
+       * Services.pm: New function apt_available, to check if apt is around.
+       * Engine.pm: Make things work with apt uninstalled.
+
 2006-03-21  Dave Morrison  <[EMAIL PROTECTED]>
 
        * PkgVersion.pm: when an error is generated on Intel hardware, warn 



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to