X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/9e830fd5e9c71c384275f0c63dfe80595723d614..b09e09c756861ab167647ec61ac59b85c2928be6:/cmdline/apt-get.cc

diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 51bcfde12..46172332f 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -53,6 +53,7 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+#include <sys/statfs.h>
 #include <sys/statvfs.h>
 #include <signal.h>
 #include <unistd.h>
@@ -63,6 +64,8 @@
 #include <sstream>
 									/*}}}*/
 
+#define RAMFS_MAGIC     0x858458f6
+
 using namespace std;
 
 ostream c0out(0);
@@ -835,16 +838,16 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
    if (DebBytes != FetchBytes)
       ioprintf(c1out,_("Need to get %sB/%sB of archives.\n"),
 	       SizeToStr(FetchBytes).c_str(),SizeToStr(DebBytes).c_str());
-   else
+   else if (DebBytes != 0)
       ioprintf(c1out,_("Need to get %sB of archives.\n"),
 	       SizeToStr(DebBytes).c_str());
 
    // Size delta
    if (Cache->UsrSize() >= 0)
-      ioprintf(c1out,_("After unpacking %sB of additional disk space will be used.\n"),
+      ioprintf(c1out,_("After this operation, %sB of additional disk space will be used.\n"),
 	       SizeToStr(Cache->UsrSize()).c_str());
    else
-      ioprintf(c1out,_("After unpacking %sB disk space will be freed.\n"),
+      ioprintf(c1out,_("After this operation, %sB disk space will be freed.\n"),
 	       SizeToStr(-1*Cache->UsrSize()).c_str());
 
    if (_error->PendingError() == true)
@@ -861,8 +864,13 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
 	 return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
 			      OutputDir.c_str());
       if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
-	 return _error->Error(_("You don't have enough free space in %s."),
-			      OutputDir.c_str());
+      {
+         struct statfs Stat;
+         if (statfs(OutputDir.c_str(),&Stat) != 0 ||
+			 unsigned(Stat.f_type) != RAMFS_MAGIC)
+            return _error->Error(_("You don't have enough free space in %s."),
+                OutputDir.c_str());
+      }
    }
    
    // Fail safe check
@@ -918,7 +926,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
       pkgAcquire::UriIterator I = Fetcher.UriBegin();
       for (; I != Fetcher.UriEnd(); I++)
 	 cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
-	       I->Owner->FileSize << ' ' << I->Owner->MD5Sum() << endl;
+	       I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
       return true;
    }
 
@@ -1343,14 +1351,15 @@ bool DoUpdate(CommandLine &CmdL)
 	 return _error->Error(_("Unable to lock the list directory"));
    }
    
-   // Create the download object
+   // Create the progress
    AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
-   pkgAcquire Fetcher(&Stat);
-
-   
+      
    // Just print out the uris an exit if the --print-uris flag was used
    if (_config->FindB("APT::Get::Print-URIs") == true)
    {
+      // get a fetcher
+      pkgAcquire Fetcher(&Stat);
+
       // Populate it with the source selection and get all Indexes 
       // (GetAll=true)
       if (List.GetIndexes(&Fetcher,true) == false)
@@ -1359,58 +1368,18 @@ bool DoUpdate(CommandLine &CmdL)
       pkgAcquire::UriIterator I = Fetcher.UriBegin();
       for (; I != Fetcher.UriEnd(); I++)
 	 cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
-	       I->Owner->FileSize << ' ' << I->Owner->MD5Sum() << endl;
+	       I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
       return true;
    }
 
-   // Populate it with the source selection
-   if (List.GetIndexes(&Fetcher) == false)
-	 return false;
-   
-   // Run it
-   if (Fetcher.Run() == pkgAcquire::Failed)
-      return false;
-
-   bool Failed = false;
-   bool TransientNetworkFailure = false;
-   for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
-   {
-      if ((*I)->Status == pkgAcquire::Item::StatDone)
-	 continue;
-
-      (*I)->Finished();
-
-      fprintf(stderr,_("Failed to fetch %s  %s\n"),(*I)->DescURI().c_str(),
-	      (*I)->ErrorText.c_str());
-
-      if ((*I)->Status == pkgAcquire::Item::StatTransientNetworkError) 
-      {
-	 TransientNetworkFailure = true;
-	 continue;
-      }
-
-      Failed = true;
-   }
-   
-   // Clean out any old list files
-   if (!TransientNetworkFailure &&
-       _config->FindB("APT::Get::List-Cleanup",true) == true)
-   {
-      if (Fetcher.Clean(_config->FindDir("Dir::State::lists")) == false ||
-	  Fetcher.Clean(_config->FindDir("Dir::State::lists") + "partial/") == false)
-	 return false;
-   }
-   
-   // Prepare the cache.   
+   // do the work
    CacheFile Cache;
+   bool res = ListUpdate(Stat, List);
+     
+   // Rebuild the cache.   
    if (Cache.BuildCaches() == false)
       return false;
    
-   if (TransientNetworkFailure == true)
-      _error->Warning(_("Some index files failed to download, they have been ignored, or old ones used instead."));
-   else if (Failed == true)
-      return _error->Error(_("Some index files failed to download, they have been ignored, or old ones used instead."));
-
    return true;
 }
 									/*}}}*/
@@ -1507,7 +1476,8 @@ bool DoUpgrade(CommandLine &CmdL)
 bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix, 
 		    bool BrokenFix,
 		    unsigned int& ExpectedInst, 
-		    const char *taskname)
+		    const char *taskname,
+		    bool Remove)
 {
    const char *start, *end;
    pkgCache::PkgIterator Pkg;
@@ -1519,8 +1489,9 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix,
 
    // build regexp for the task
    char S[300];
-   snprintf(S, sizeof(S), "^Task:.*[^a-z]%s[^a-z].*\n", taskname);
-   regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
+   snprintf(S, sizeof(S), "^Task:.*[, ]%s([, ]|$)", taskname);
+   if(regcomp(&Pattern,S, REG_EXTENDED | REG_NOSUB | REG_NEWLINE) != 0)
+      return _error->Error("Failed to compile task regexp");
    
    bool found = false;
    bool res = true;
@@ -1535,7 +1506,7 @@ bool TryInstallTask(pkgDepCache &Cache, pkgProblemResolver &Fix,
       buf[end-start] = 0x0;
       if (regexec(&Pattern,buf,0,0,0) != 0)
 	 continue;
-      res &= TryToInstall(Pkg,Cache,Fix,false,true,ExpectedInst);
+      res &= TryToInstall(Pkg,Cache,Fix,Remove,true,ExpectedInst);
       found = true;
    }
    
@@ -1603,7 +1574,7 @@ bool DoInstall(CommandLine &CmdL)
             // tasks must always be confirmed
             ExpectedInst += 1000;
             // see if we can install it
-            TryInstallTask(Cache, Fix, BrokenFix, ExpectedInst, S);
+            TryInstallTask(Cache, Fix, BrokenFix, ExpectedInst, S, Remove);
             continue;
          }
 
@@ -1706,9 +1677,10 @@ bool DoInstall(CommandLine &CmdL)
 	    // where foo is marked automatic
 	    if(!Remove && 
 	       Cache[Pkg].Install() == false && 
-	       (Cache[Pkg].Flags & pkgCache::Flag::Auto))
+	       (Cache[Pkg].Flags & pkgCache::Flag::Auto) &&
+	       _config->FindB("APT::Get::ReInstall",false) == false)
 	    {
-	       ioprintf(c1out,_("%s set to manual installed.\n"),
+	       ioprintf(c1out,_("%s set to manually installed.\n"),
 			Pkg.Name());
 	       Cache->MarkAuto(Pkg,false);
 	       AutoMarkChanged++;
@@ -2116,24 +2088,29 @@ bool DoSource(CommandLine &CmdL)
       
       string srec = Last->AsStr();
       string::size_type pos = srec.find("\nVcs-");
-      if (pos != string::npos )
+      while (pos != string::npos)
       {
 	 pos += strlen("\nVcs-");
 	 string vcs = srec.substr(pos,srec.find(":",pos)-pos);
+	 if(vcs == "Browser") 
+	 {
+	    pos = srec.find("\nVcs-", pos);
+	    continue;
+	 }
 	 pos += vcs.length()+2;
 	 string::size_type epos = srec.find("\n", pos);
 	 string uri = srec.substr(pos,epos-pos).c_str();
-	 ioprintf(c1out, _("WARNING: '%s' is maintained in "
+	 ioprintf(c1out, _("NOTICE: '%s' packaging is maintained in "
 			   "the '%s' version control system at:\n"
-			   "'%s'\n"),
+			   "%s\n"),
 		  Src.c_str(), vcs.c_str(), uri.c_str());
 	 if(vcs == "Bzr") 
-	    ioprintf(c1out,_("Please use: 'bzr get %s'\n"
-			     "to modify the package.\n"),
+	    ioprintf(c1out,_("Please use:\n"
+			     "bzr get %s\n"
+			     "to retrieve the latest (possible unreleased) "
+			     "updates to the package.\n"),
 		     uri.c_str());
-	 ioprintf(c1out, "Are you sure you want to continue [yN]? ");
-	 if(!YnPrompt(false))
-	    return _error->Error(_("Abort."));
+	 break;
       }
 
       // Back track
@@ -2207,8 +2184,13 @@ bool DoSource(CommandLine &CmdL)
       return _error->Errno("statvfs",_("Couldn't determine free space in %s"),
 			   OutputDir.c_str());
    if (unsigned(Buf.f_bfree) < (FetchBytes - FetchPBytes)/Buf.f_bsize)
-      return _error->Error(_("You don't have enough free space in %s"),
-			   OutputDir.c_str());
+     {
+       struct statfs Stat;
+       if (statfs(OutputDir.c_str(),&Stat) != 0 || 
+           unsigned(Stat.f_type) != RAMFS_MAGIC) 
+          return _error->Error(_("You don't have enough free space in %s"),
+              OutputDir.c_str());
+      }
    
    // Number of bytes
    if (DebBytes != FetchBytes)
@@ -2231,7 +2213,7 @@ bool DoSource(CommandLine &CmdL)
       pkgAcquire::UriIterator I = Fetcher.UriBegin();
       for (; I != Fetcher.UriEnd(); I++)
 	 cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
-	       I->Owner->FileSize << ' ' << I->Owner->MD5Sum() << endl;
+	       I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
       return true;
    }
    
@@ -2491,6 +2473,7 @@ bool DoBuildDep(CommandLine &CmdL)
                            break;
                  }
                  if (CV.end() == true)
+		 {
 		   if (hasAlternatives)
 		   {
 		      continue;
@@ -2503,6 +2486,7 @@ bool DoBuildDep(CommandLine &CmdL)
                                            Last->BuildDepType((*D).Type),Src.c_str(),
                                            (*D).Package.c_str());
 		   }
+		 }
             }
             else
             {
@@ -2602,8 +2586,8 @@ bool DoMoo(CommandLine &CmdL)
 /* */
 bool ShowHelp(CommandLine &CmdL)
 {
-   ioprintf(cout,_("%s %s for %s %s compiled on %s %s\n"),PACKAGE,VERSION,
-	    COMMON_OS,COMMON_CPU,__DATE__,__TIME__);
+   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,VERSION,
+	    COMMON_ARCH,__DATE__,__TIME__);
 	    
    if (_config->FindB("version") == true)
    {
@@ -2661,6 +2645,7 @@ bool ShowHelp(CommandLine &CmdL)
       "   upgrade - Perform an upgrade\n"
       "   install - Install new packages (pkg is libc6 not libc6.deb)\n"
       "   remove - Remove packages\n"
+      "   autoremove - Remove all automatic unused packages\n"
       "   purge - Remove and purge packages\n"
       "   source - Download source archives\n"
       "   build-dep - Configure build-dependencies for source packages\n"
@@ -2771,7 +2756,9 @@ int main(int argc,const char *argv[])
                                    {"upgrade",&DoUpgrade},
                                    {"install",&DoInstall},
                                    {"remove",&DoInstall},
+                                   {"purge",&DoInstall},
 				   {"autoremove",&DoInstall},
+				   {"purge",&DoInstall},
                                    {"dist-upgrade",&DoDistUpgrade},
                                    {"dselect-upgrade",&DoDSelectUpgrade},
 				   {"build-dep",&DoBuildDep},