reorder includes: add <config.h> if needed and include it at first
[ntk/apt.git] / cmdline / acqprogress.cc
index a5fee1d..fd80ea1 100644 (file)
@@ -8,17 +8,21 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Include files                                                       /*{{{*/
-#include "acqprogress.h"
+#include<config.h>
+
 #include <apt-pkg/acquire-item.h>
 #include <apt-pkg/acquire-worker.h>
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 
-#include <apti18n.h>
-    
 #include <stdio.h>
 #include <signal.h>
 #include <iostream>
+#include <unistd.h>
+
+#include "acqprogress.h"
+#include <apti18n.h>
                                                                        /*}}}*/
 
 using namespace std;
@@ -145,12 +149,12 @@ void AcqTextStatus::Stop()
    bandwidth and ETA indicator. */
 bool AcqTextStatus::Pulse(pkgAcquire *Owner)
 {
+   pkgAcquireStatus::Pulse(Owner);
+   
    if (Quiet > 0)
       return true;
    
-   pkgAcquireStatus::Pulse(Owner);
-   
-   enum {Long = 0,Medium,Short} Mode = Long;
+   enum {Long = 0,Medium,Short} Mode = Medium;
    
    char Buffer[sizeof(BlankLine)];
    char *End = Buffer + sizeof(Buffer);
@@ -198,7 +202,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
             
       // Add the current progress
       if (Mode == Long)
-        snprintf(S,End-S," %lu",I->CurrentSize);
+        snprintf(S,End-S," %llu",I->CurrentSize);
       else
       {
         if (Mode == Medium || I->TotalSize == 0)
@@ -266,6 +270,16 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
 /* Prompt for a media swap */
 bool AcqTextStatus::MediaChange(string Media,string Drive)
 {
+   // If we do not output on a terminal and one of the options to avoid user
+   // interaction is given, we assume that no user is present who could react
+   // on your media change request
+   if (isatty(STDOUT_FILENO) != 1 && Quiet >= 2 &&
+       (_config->FindB("APT::Get::Assume-Yes",false) == true ||
+       _config->FindB("APT::Get::Force-Yes",false) == true ||
+       _config->FindB("APT::Get::Trivial-Only",false) == true))
+
+      return false;
+
    if (Quiet <= 0)
       cout << '\r' << BlankLine << '\r';
    ioprintf(cout,_("Media change: please insert the disc labeled\n"