]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-get.cc
merged from lp:~donkult/apt/sid
[apt.git] / cmdline / apt-get.cc
index dd5ef1743b5ca219e33c8c1b1419bba5d4e5f267..0ada46c73b598c128e29a54c14454e95f45b74ee 100644 (file)
@@ -40,7 +40,8 @@
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/md5.h>
 #include <apt-pkg/versionmatch.h>
-    
+#include <apt-pkg/cacheset.h>
+
 #include <config.h>
 #include <apti18n.h>
 
@@ -90,14 +91,14 @@ class CacheFile : public pkgCacheFile
    bool BuildCaches(bool WithLock = true)
    {
       OpTextProgress Prog(*_config);
-      if (pkgCacheFile::BuildCaches(Prog,WithLock) == false)
+      if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false)
         return false;
       return true;
    }
    bool Open(bool WithLock = true) 
    {
       OpTextProgress Prog(*_config);
-      if (pkgCacheFile::Open(Prog,WithLock) == false)
+      if (pkgCacheFile::Open(&Prog,WithLock) == false)
         return false;
       Sort();
       
@@ -837,9 +838,9 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
       return false;
 
    // Display statistics
-   double FetchBytes = Fetcher.FetchNeeded();
-   double FetchPBytes = Fetcher.PartialPresent();
-   double DebBytes = Fetcher.TotalNeeded();
+   unsigned long long FetchBytes = Fetcher.FetchNeeded();
+   unsigned long long FetchPBytes = Fetcher.PartialPresent();
+   unsigned long long DebBytes = Fetcher.TotalNeeded();
    if (DebBytes != Cache->DebSize())
    {
       c0out << DebBytes << ',' << Cache->DebSize() << endl;
@@ -1044,7 +1045,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
       if (Res == pkgPackageManager::Failed || _error->PendingError() == true)
         return false;
       if (Res == pkgPackageManager::Completed)
-        return true;
+        break;
       
       // Reload the fetcher object and loop again for media swapping
       Fetcher.Shutdown();
@@ -1052,7 +1053,24 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
         return false;
       
       _system->Lock();
-   }   
+   }
+
+   std::set<std::string> const disappearedPkgs = PM->GetDisappearedPackages();
+   if (disappearedPkgs.empty() == true)
+      return true;
+
+   string disappear;
+   for (std::set<std::string>::const_iterator d = disappearedPkgs.begin();
+       d != disappearedPkgs.end(); ++d)
+      disappear.append(*d).append(" ");
+
+   ShowList(c1out, P_("The following package disappeared from your system as\n"
+       "all files have been overwritten by other packages:",
+       "The following packages disappeared from your system as\n"
+       "all files have been overwritten by other packages:", disappearedPkgs.size()), disappear, "");
+   c0out << _("Note: This is done automatic and on purpose by dpkg.") << std::endl;
+
+   return true;
 }
                                                                        /*}}}*/
 // TryToInstall - Try to install a single package                      /*{{{*/
@@ -1763,51 +1781,24 @@ bool DoInstall(CommandLine &CmdL)
         Packages++;
         if (Pkg.end() == true)
         {
-           // Check if the name is a regex
-           const char *I;
-           for (I = S; *I != 0; I++)
-              if (*I == '?' || *I == '*' || *I == '|' ||
-                  *I == '[' || *I == '^' || *I == '$')
-                 break;
-           if (*I == 0)
+           APT::PackageSet pkgset = APT::PackageSet::FromRegEx(Cache, S, c1out);
+           if (pkgset.empty() == true)
               return _error->Error(_("Couldn't find package %s"),S);
 
            // Regexs must always be confirmed
            ExpectedInst += 1000;
-        
-           // Compile the regex pattern
-           regex_t Pattern;
-           int Res;
-           if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE |
-                              REG_NOSUB)) != 0)
-           {
-              char Error[300];     
-              regerror(Res,&Pattern,Error,sizeof(Error));
-              return _error->Error(_("Regex compilation error - %s"),Error);
-           }
-        
-           // Run over the matches
+
            bool Hit = false;
-           for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp)
+           for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
            {
-              if (regexec(&Pattern,Grp.Name(),0,0,0) != 0)
-                 continue;
-              Pkg = Grp.FindPkg("native");
-              if (unlikely(Pkg.end() == true))
-                 continue;
-
-              ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"),
-                       Pkg.Name(),S);
-           
               if (VerTag != 0)
                  if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false)
                     return false;
-           
+
               Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix,
                                   ExpectedInst,false);
            }
-           regfree(&Pattern);
-        
+
            if (Hit == false)
               return _error->Error(_("Couldn't find package %s"),S);
         }
@@ -2289,6 +2280,33 @@ bool DoSource(CommandLine &CmdL)
       if (Last == 0)
         return _error->Error(_("Unable to find a source package for %s"),Src.c_str());
       
+      string srec = Last->AsStr();
+      string::size_type pos = srec.find("\nVcs-");
+      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, _("NOTICE: '%s' packaging is maintained in "
+                          "the '%s' version control system at:\n"
+                          "%s\n"),
+                 Src.c_str(), vcs.c_str(), uri.c_str());
+        if(vcs == "Bzr") 
+           ioprintf(c1out,_("Please use:\n"
+                            "bzr get %s\n"
+                            "to retrieve the latest (possibly unreleased) "
+                            "updates to the package.\n"),
+                    uri.c_str());
+        break;
+      }
+
       // Back track
       vector<pkgSrcRecords::File> Lst;
       if (Last->Files(Lst) == false)
@@ -2345,9 +2363,9 @@ bool DoSource(CommandLine &CmdL)
    }
    
    // Display statistics
-   double FetchBytes = Fetcher.FetchNeeded();
-   double FetchPBytes = Fetcher.PartialPresent();
-   double DebBytes = Fetcher.TotalNeeded();
+   unsigned long long FetchBytes = Fetcher.FetchNeeded();
+   unsigned long long FetchPBytes = Fetcher.PartialPresent();
+   unsigned long long DebBytes = Fetcher.TotalNeeded();
 
    // Check for enough free space
    struct statvfs Buf;
@@ -2951,7 +2969,6 @@ int main(int argc,const char *argv[])                                     /*{{{*/
                                    {"remove",&DoInstall},
                                    {"purge",&DoInstall},
                                   {"autoremove",&DoInstall},
-                                  {"purge",&DoInstall},
                                   {"markauto",&DoMarkAuto},
                                   {"unmarkauto",&DoMarkAuto},
                                    {"dist-upgrade",&DoDistUpgrade},