Hi,
The patch attached makes m-a use of aptitude instead of apt-get as an
option, so you can call "module-assistant --aptitude" and
module-assistant will use your favorite APT tool :-)  It doesn't
detect aptitude automatically as Filippo suggested. I think that
should be handled in a configuration file as a lot of other things
suggested in #341981

Regards,
Javi
diff -r d64b0a90eb02 -r 2b96ab513f45 modass/packages/generic.sh
--- a/modass/packages/generic.sh	Fri May 04 17:10:36 2007 +0200
+++ b/modass/packages/generic.sh	Fri May 04 17:19:30 2007 +0200
@@ -203,7 +203,7 @@ unpack() {
 }
 
 download() {
-   action $ROOT_CMD apt-get $REINSTALL install $sourcepkg
+   action $ROOT_CMD $APT_GET_CMD $REINSTALL install $sourcepkg
 }
 
 # wipes the builddir
diff -r d64b0a90eb02 -r 2b96ab513f45 module-assistant
--- a/module-assistant	Fri May 04 17:10:36 2007 +0200
+++ b/module-assistant	Fri May 04 17:19:30 2007 +0200
@@ -95,6 +95,7 @@ Options:
  -O, --not-unpack  Don't unpack the source at all
  -s, --apt-search  Search for installation candidates in the Debian archive
  -S, --sudo-cmd    An alternative command for sudo
+ -a, --aptitude    Use aptitude instead of apt-get and apt-cache whenever possible
  -f, --force       Force duplicated work: source package reinstallation,
                    rebuild though existing packages are found, etc.
  -t, --text-mode   Text mode, no dialog boxes
@@ -128,6 +129,7 @@ my $distrib_id = get_distrib_id();
 my $distrib_id = get_distrib_id();
 
 my $usrc="/usr/src";
+my $apt_get, $apt_cache;
 
 my $opt_help;
 my @opt_kerneldirs;
@@ -144,6 +146,7 @@ my $opt_unponce;
 my $opt_unponce;
 my $opt_notunp;
 my $sudo;
+my $use_aptitude;
 
 %options = (
    "q|quiet"                => \$opt_quiet,
@@ -160,17 +163,28 @@ my $sudo;
    "t|text-mode"          => \$opt_nogui,
    "u|userdir|user-dir=s"          => \$opt_userdir,
    "s|apt-search"          => \$opt_search,
-   "S|sudo-cmd=s"          => \$sudo
+   "S|sudo-cmd=s"          => \$sudo,
+   "a|aptitude"           => \$use_aptitude
 );
 &help unless ( GetOptions(%options));
 &help if ($opt_help);
 $ENV{"VERBOSE"}=1 if($opt_verbose);
-$ENV{"REINSTALL"} .= " -y --force-yes ";
+$ENV{"REINSTALL"} .= ' -y  -o APT::Get::="--force-yes" ';
 #$ENV{"APT_LISTCHANGES_FRONTEND"} = "mail" if $opt_noninter; # STFU
 
 my $buildNumber = time();
 
 $opt_nogui=1 if $opt_noninter;
+
+if(defined($use_aptitude)) {
+   $apt_get = "aptitude";
+   $apt_cache = "aptitude";
+}
+else {
+   $apt_get = "apt-get";
+   $apt_cache = "apt-cache";
+
+}
 
 my $command=shift(@ARGV);
 @[EMAIL PROTECTED];
@@ -410,7 +424,7 @@ wrap('','',gettext("Bad luck, the kernel
 wrap('','',gettext("Bad luck, the kernel headers for the target kernel version could not be found and you did not specify other valid kernel headers to use.")) . "
       " if !$kernelwarned;
 
-      if (length(`apt-cache show $kheadpkg 2>/dev/null`) ) {
+      if (length(`$apt_cache show $kheadpkg 2>/dev/null`) ) {
          printmsg "\n" .sprintf(
 gettext(
 "However, you can install the header files for your kernel which are provided by the %s package. For most modules packages, these files are perfectly sufficient without having the original kernel source.
@@ -580,7 +594,7 @@ sub prep {
       }
       else {
          $opt_verbose=1;
-         withecho($sudo, "apt-get", ($opt_noninter?"-y":undef), "install", "$kheaders-$todo");
+         withecho($sudo, $apt_get, ($opt_noninter?"-y":undef), "install", "$kheaders-$todo");
          if($my_kvers eq $todo) {
             $symfrom="$kheaders-$todo";
          }
@@ -596,7 +610,7 @@ sub prep {
    }
 #   if(`apt-cache policy build-essential` =~ /Installed:..none/) {
       print STDERR gettext("Installing packages needed for the build environment...") . "\n" if (!opt_quiet);
-      withecho($sudo, "apt-get". ($opt_noninter?"-y":undef), "install", "build-essential");
+      withecho($sudo, $apt_get. ($opt_noninter?"-y":undef), "install", "build-essential");
 #   }
    print STDERR "\n". gettext("Done!") . "\n";
    %ENV=%envbackup;
@@ -686,6 +700,7 @@ sub get {
    my $faillog="";
    %envbackup=%ENV;
    $ENV{ROOT_CMD}=$sudo if ($sudo && !$ENV{ROOT_CMD});
+   $ENV{APT_GET_CMD}=$apt_get;
    SKIP: foreach $target (@_) {
       my $pkg;
       my $reti=0;
@@ -1011,7 +1026,7 @@ sub install {
    if($ret > $ret_save) {
       $ret--;
       print STDERR "\nI: " . gettext("Direct installation failed, trying to post-install the dependencies") . "\n\n";
-      $ret += withecho($sudo, "apt-get", $opt_noninter?"-fy":"-f","install");
+      $ret += withecho($sudo, $apt_get, $opt_noninter?"-fy":"-f","install");
    }
 }
 
@@ -1171,7 +1186,7 @@ sub init_packs_desc {
          else {
             # precache once with cummulative apt-get run
             if(!(keys %descache)) {
-               open($getdesc, "apt-cache show ".join(' ',keys %packs)." 2>/dev/null |");
+               open($getdesc, "$apt_cache show ".join(' ',keys %packs)." 2>/dev/null |");
                while(<$getdesc>) { 
                   $pkg=$1 if(/^Package: (.*)\n/);
                   if(/^Description: (.*)\n/) {
@@ -1215,10 +1230,10 @@ sub fakesrc {
    my $symverfile="$usrc/$kheaders-$kvers/Module.symvers";
    my $compileh="$usrc/$kheaders-$kvers/include/linux/compile.h";
    print gettext("Experimental kernel source recreating method...\nGetting source...") . "\n";
-   return 0 if withecho($sudo, "apt-get", ($opt_noninter?"-y":undef), "install", "$ksource-$knmbr");
+   return 0 if withecho($sudo, $apt_get, ($opt_noninter?"-y":undef), "install", "$ksource-$knmbr");
    if(! -f $confile) {
       print gettext("Config not found, getting headers to extract the config...") . "\n";
-      return 0 if withecho($sudo, "apt-get", ($opt_noninter?"-y":undef), "install", "$kheaders-$kvers");
+      return 0 if withecho($sudo, $apt_get, ($opt_noninter?"-y":undef), "install", "$kheaders-$kvers");
       $confile="$usrc/$kheaders-$kvers/.config";
    }
    $tmpdir="$writedir/tmp-".rand;

Reply via email to