* merge the remaining Ubuntu change:
[ntk/apt.git] / cmdline / apt-get.cc
index 52e90fc..eaf04ee 100644 (file)
@@ -258,8 +258,8 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now)
       }
       
       // Print out each package and the failed dependencies
-      out <<"  " <<  I.Name() << ":";
-      unsigned Indent = strlen(I.Name()) + 3;
+      out << " " << I.FullName(true) << " :";
+      unsigned const Indent = I.FullName(true).size() + 3;
       bool First = true;
       pkgCache::VerIterator Ver;
       
@@ -312,7 +312,7 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now)
               out << ' ' << End.DepType() << ": ";
            FirstOr = false;
            
-           out << Start.TargetPkg().Name();
+           out << Start.TargetPkg().FullName(true);
         
            // Show a quick summary of the version requirements
            if (Start.TargetVer() != 0)
@@ -374,7 +374,9 @@ void ShowNew(ostream &out,CacheFile &Cache)
    {
       pkgCache::PkgIterator I(Cache,Cache.List[J]);
       if (Cache[I].NewInstall() == true) {
-         List += string(I.Name()) + " ";
+        if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
+           continue;
+         List += I.FullName(true) + " ";
          VersionsList += string(Cache[I].CandVersion) + "\n";
       }
    }
@@ -396,10 +398,12 @@ void ShowDel(ostream &out,CacheFile &Cache)
       pkgCache::PkgIterator I(Cache,Cache.List[J]);
       if (Cache[I].Delete() == true)
       {
+        if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
+           continue;
         if ((Cache[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge)
-           List += string(I.Name()) + "* ";
+           List += I.FullName(true) + "* ";
         else
-           List += string(I.Name()) + " ";
+           List += I.FullName(true) + " ";
      
      VersionsList += string(Cache[I].CandVersion)+ "\n";
       }
@@ -424,7 +428,7 @@ void ShowKept(ostream &out,CacheFile &Cache)
          I->CurrentVer == 0 || Cache[I].Delete() == true)
         continue;
       
-      List += string(I.Name()) + " ";
+      List += I.FullName(true) + " ";
       VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n";
    }
    ShowList(out,_("The following packages have been kept back:"),List,VersionsList);
@@ -444,8 +448,10 @@ void ShowUpgraded(ostream &out,CacheFile &Cache)
       // Not interesting
       if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
         continue;
-      
-      List += string(I.Name()) + " ";
+      if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
+        continue;
+
+      List += I.FullName(true) + " ";
       VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n";
    }
    ShowList(out,_("The following packages will be upgraded:"),List,VersionsList);
@@ -465,8 +471,10 @@ bool ShowDowngraded(ostream &out,CacheFile &Cache)
       // Not interesting
       if (Cache[I].Downgrade() == false || Cache[I].NewInstall() == true)
         continue;
-      
-      List += string(I.Name()) + " ";
+      if (Cache[I].CandidateVerIter(Cache).Pseudo() == true)
+        continue;
+
+      List += I.FullName(true) + " ";
       VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n";
    }
    return ShowList(out,_("The following packages will be DOWNGRADED:"),List,VersionsList);
@@ -484,7 +492,7 @@ bool ShowHold(ostream &out,CacheFile &Cache)
       pkgCache::PkgIterator I(Cache,Cache.List[J]);
       if (Cache[I].InstallVer != (pkgCache::Version *)I.CurrentVer() &&
           I->SelectedState == pkgCache::State::Hold) {
-         List += string(I.Name()) + " ";
+         List += I.FullName(true) + " ";
                 VersionsList += string(Cache[I].CurVersion) + " => " + Cache[I].CandVersion + "\n";
       }
    }
@@ -518,7 +526,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache)
         if (Added[I->ID] == false)
         {
            Added[I->ID] = true;
-           List += string(I.Name()) + " ";
+           List += I.FullName(true) + " ";
         //VersionsList += string(Cache[I].CurVersion) + "\n"; ???
         }
       }
@@ -542,7 +550,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache)
            Added[P->ID] = true;
            
            char S[300];
-           snprintf(S,sizeof(S),_("%s (due to %s) "),P.Name(),I.Name());
+           snprintf(S,sizeof(S),_("%s (due to %s) "),P.FullName(true).c_str(),I.FullName(true).c_str());
            List += S;
         //VersionsList += "\n"; ???
         }       
@@ -566,6 +574,9 @@ void Stats(ostream &out,pkgDepCache &Dep)
    unsigned long ReInstall = 0;
    for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; I++)
    {
+      if (pkgCache::VerIterator(Dep, Dep[I].CandidateVer).Pseudo() == true)
+        continue;
+
       if (Dep[I].NewInstall() == true)
         Install++;
       else
@@ -681,7 +692,7 @@ bool CacheFile::CheckDeps(bool AllowBroken)
    }
    else
    {
-      c1out << _("You might want to run `apt-get -f install' to correct these.") << endl;
+      c1out << _("You might want to run 'apt-get -f install' to correct these.") << endl;
       ShowBroken(c1out,*this,true);
 
       return _error->Error(_("Unmet dependencies. Try using -f."));
@@ -800,20 +811,19 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
    pkgRecords Recs(Cache);
    if (_error->PendingError() == true)
       return false;
-   
-   // Lock the archive directory
-   FileFd Lock;
-   if (_config->FindB("Debug::NoLocking",false) == false &&
-       _config->FindB("APT::Get::Print-URIs") == false)
-   {
-      Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"));
-      if (_error->PendingError() == true)
-        return _error->Error(_("Unable to lock the download directory"));
-   }
-   
+
    // Create the download object
+   pkgAcquire Fetcher;
    AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));   
-   pkgAcquire Fetcher(&Stat);
+   if (_config->FindB("APT::Get::Print-URIs", false) == true)
+   {
+      // force a hashsum for compatibility reasons
+      _config->CndSet("Acquire::ForceHash", "md5sum");
+      if (Fetcher.Setup(&Stat, "") == false)
+        return false;
+   }
+   else if (Fetcher.Setup(&Stat, _config->FindDir("Dir::Cache::Archives")) == false)
+      return false;
 
    // Read the source list
    pkgSourceList List;
@@ -1034,7 +1044,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();
@@ -1042,7 +1052,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                      /*{{{*/
@@ -1084,7 +1111,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
       if (found_one == true)
       {
         ioprintf(c1out,_("Note, selecting %s instead of %s\n"),
-                 Prov.Name(),Pkg.Name());
+                 Prov.FullName(true).c_str(),Pkg.FullName(true).c_str());
         Pkg = Prov;
       }
    }
@@ -1095,10 +1122,20 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
    {
       if (AllowFail == true)
         ioprintf(c1out,_("Skipping %s, it is already installed and upgrade is not set.\n"),
+                 Pkg.FullName(true).c_str());
+      return true;
+   }
+
+   // Ignore request for install if package would be new
+   if (_config->FindB("APT::Get::Only-Upgrade", false) == true &&
+       Pkg->CurrentVer == 0)
+   {
+      if (AllowFail == true)
+        ioprintf(c1out,_("Skipping %s, it is not installed and only upgrades are requested.\n"),
                  Pkg.Name());
       return true;
    }
-   
+
    // Check if there is something at all to install
    pkgDepCache::StateCache &State = Cache[Pkg];
    if (Remove == true && Pkg->CurrentVer == 0)
@@ -1112,7 +1149,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
       if (AllowFail == false)
         return false;
       
-      ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.Name());
+      ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str());
       return true;
    }
    
@@ -1124,30 +1161,37 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
       if (Pkg->ProvidesList != 0)
       {
         ioprintf(c1out,_("Package %s is a virtual package provided by:\n"),
-                 Pkg.Name());
+                 Pkg.FullName(true).c_str());
         
         pkgCache::PrvIterator I = Pkg.ProvidesList();
+        unsigned short provider = 0;
         for (; I.end() == false; I++)
         {
            pkgCache::PkgIterator Pkg = I.OwnerPkg();
            
            if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer())
            {
+              c1out << "  " << Pkg.FullName(true) << " " << I.OwnerVer().VerStr();
               if (Cache[Pkg].Install() == true && Cache[Pkg].NewInstall() == false)
-                 c1out << "  " << Pkg.Name() << " " << I.OwnerVer().VerStr() <<
-                 _(" [Installed]") << endl;
-              else
-                 c1out << "  " << Pkg.Name() << " " << I.OwnerVer().VerStr() << endl;
-           }      
+                 c1out << _(" [Installed]");
+              c1out << endl;
+              ++provider;
+           }
         }
-        c1out << _("You should explicitly select one to install.") << endl;
+        // if we found no candidate which provide this package, show non-candidates
+        if (provider == 0)
+           for (I = Pkg.ProvidesList(); I.end() == false; I++)
+              c1out << "  " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr()
+               << _(" [Not candidate version]") << endl;
+        else
+           c1out << _("You should explicitly select one to install.") << endl;
       }
       else
       {
         ioprintf(c1out,
         _("Package %s is not available, but is referred to by another package.\n"
           "This may mean that the package is missing, has been obsoleted, or\n"
-           "is only available from another source\n"),Pkg.Name());
+           "is only available from another source\n"),Pkg.FullName(true).c_str());
         
         string List;
         string VersionsList;
@@ -1161,13 +1205,13 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
            if (Seen[Dep.ParentPkg()->ID] == true)
               continue;
            Seen[Dep.ParentPkg()->ID] = true;
-           List += string(Dep.ParentPkg().Name()) + " ";
+           List += Dep.ParentPkg().FullName(true) + " ";
         //VersionsList += string(Dep.ParentPkg().CurVersion) + "\n"; ???
         }          
         ShowList(c1out,_("However the following packages replace it:"),List,VersionsList);
       }
       
-      _error->Error(_("Package %s has no installation candidate"),Pkg.Name());
+      _error->Error(_("Package %s has no installation candidate"),Pkg.FullName(true).c_str());
       return false;
    }
 
@@ -1188,7 +1232,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
       {
         if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false)
            ioprintf(c1out,_("Reinstallation of %s is not possible, it cannot be downloaded.\n"),
-                    Pkg.Name());
+                    Pkg.FullName(true).c_str());
         else
            Cache.SetReInstall(Pkg,true);
       }      
@@ -1196,7 +1240,7 @@ bool TryToInstall(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
       {
         if (AllowFail == true)
            ioprintf(c1out,_("%s is already the newest version.\n"),
-                    Pkg.Name());
+                    Pkg.FullName(true).c_str());
       }      
    }   
    else
@@ -1225,18 +1269,23 @@ bool TryToChangeVer(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
    {
       if (IsRel == true)
         return _error->Error(_("Release '%s' for '%s' was not found"),
-                             VerTag,Pkg.Name());
+                             VerTag,Pkg.FullName(true).c_str());
       return _error->Error(_("Version '%s' for '%s' was not found"),
-                          VerTag,Pkg.Name());
+                          VerTag,Pkg.FullName(true).c_str());
    }
    
    if (strcmp(VerTag,Ver.VerStr()) != 0)
    {
       ioprintf(c1out,_("Selected version %s (%s) for %s\n"),
-              Ver.VerStr(),Ver.RelStr().c_str(),Pkg.Name());
+              Ver.VerStr(),Ver.RelStr().c_str(),Pkg.FullName(true).c_str());
    }
    
    Cache.SetCandidateVersion(Ver);
+
+   // Set the all package to the same candidate
+   if (Ver.Pseudo() == true)
+      Cache.SetCandidateVersion(Match.Find(Pkg.Group().FindPkg("all")));
+
    return true;
 }
                                                                        /*}}}*/
@@ -1270,12 +1319,30 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
    {
       if(VerTag.empty() == false || DefRel.empty() == false) 
       {
+        bool fuzzy = false;
         // we have a default release, try to locate the pkg. we do it like
         // this because GetCandidateVer() will not "downgrade", that means
         // "apt-get source -t stable apt" won't work on a unstable system
-        for (pkgCache::VerIterator Ver = Pkg.VersionList();
-             Ver.end() == false; Ver++) 
+        for (pkgCache::VerIterator Ver = Pkg.VersionList();; Ver++)
         {
+           // try first only exact matches, later fuzzy matches
+           if (Ver.end() == true)
+           {
+              if (fuzzy == true)
+                 break;
+              fuzzy = true;
+              Ver = Pkg.VersionList();
+              // exit right away from the Pkg.VersionList() loop if we
+              // don't have any versions
+              if (Ver.end() == true)
+                 break;
+           }
+           // We match against a concrete version (or a part of this version)
+           if (VerTag.empty() == false &&
+               (fuzzy == true || Cache.VS().CmpVersion(VerTag, Ver.VerStr()) != 0) && // exact match
+               (fuzzy == false || strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)) // fuzzy match
+              continue;
+
            for (pkgCache::VerFileIterator VF = Ver.FileList();
                 VF.end() == false; VF++) 
            {
@@ -1288,10 +1355,6 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
                   pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver)
                  continue;
 
-              // We match against a concrete version (or a part of this version)
-              if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.VerStr(), VerTag.size()) != 0)
-                 continue;
-
               // or we match against a release
               if(VerTag.empty() == false ||
                  (VF.File().Archive() != 0 && VF.File().Archive() == DefRel) ||
@@ -1299,31 +1362,42 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
               {
                  pkgRecords::Parser &Parse = Recs.Lookup(VF);
                  Src = Parse.SourcePkg();
+                 // no SourcePkg name, so it is the "binary" name
+                 if (Src.empty() == true)
+                    Src = TmpSrc;
+                 // the Version we have is possibly fuzzy or includes binUploads,
+                 // so we use the Version of the SourcePkg (empty if same as package)
+                 VerTag = Parse.SourceVer();
                  if (VerTag.empty() == true)
-                    VerTag = Parse.SourceVer();
+                    VerTag = Ver.VerStr();
                  break;
               }
            }
+           if (Src.empty() == false)
+              break;
         }
         if (Src.empty() == true) 
         {
-           if (VerTag.empty() == false)
-              _error->Warning(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
-           else
-              _error->Warning(_("Ignore unavailable target release '%s' of package '%s'"), DefRel.c_str(), TmpSrc.c_str());
-           VerTag.clear();
-           DefRel.clear();
+           // Sources files have no codename information
+           if (VerTag.empty() == true && DefRel.empty() == false) 
+           {
+              _error->Error(_("Ignore unavailable target release '%s' of package '%s'"), DefRel.c_str(), TmpSrc.c_str());
+              return 0;
+           }
         }
       }
-      if (VerTag.empty() == true && DefRel.empty() == true) 
+      if (Src.empty() == true)
       {
-        // if we don't have a version or default release, use the CandidateVer to find the Source
+        // if we don't have found a fitting package yet so we will
+        // choose a good candidate and proceed with that.
+        // Maybe we will find a source later on with the right VerTag
         pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg);
         if (Ver.end() == false) 
         {
            pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList());
            Src = Parse.SourcePkg();
-           VerTag = Parse.SourceVer();
+           if (VerTag.empty() == true)
+              VerTag = Parse.SourceVer();
         }
       }
    }
@@ -1359,7 +1433,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
         const string Ver = Parse->Version();
 
         // Ignore all versions which doesn't fit
-        if (VerTag.empty() == false && strncmp(VerTag.c_str(), Ver.c_str(), VerTag.size()) != 0)
+        if (VerTag.empty() == false &&
+            Cache.VS().CmpVersion(VerTag, Ver) != 0) // exact match
            continue;
 
         // Newer version or an exact match? Save the hit
@@ -1376,8 +1451,8 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
       if (Last != 0 || VerTag.empty() == true)
         break;
       //if (VerTag.empty() == false && Last == 0)
-      _error->Warning(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
-      VerTag.clear();
+      _error->Error(_("Ignore unavailable version '%s' of package '%s'"), VerTag.c_str(), TmpSrc.c_str());
+      return 0;
    }
 
    if (Last == 0 || Last->Jump(Offset) == false)
@@ -1399,23 +1474,19 @@ bool DoUpdate(CommandLine &CmdL)
    if (List.ReadMainList() == false)
       return false;
 
-   // Lock the list directory
-   FileFd Lock;
-   if (_config->FindB("Debug::NoLocking",false) == false)
-   {
-      Lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock"));
-      if (_error->PendingError() == true)
-        return _error->Error(_("Unable to lock the list directory"));
-   }
-   
    // Create the progress
    AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
       
    // Just print out the uris an exit if the --print-uris flag was used
    if (_config->FindB("APT::Get::Print-URIs") == true)
    {
+      // force a hashsum for compatibility reasons
+      _config->CndSet("Acquire::ForceHash", "md5sum");
+
       // get a fetcher
-      pkgAcquire Fetcher(&Stat);
+      pkgAcquire Fetcher;
+      if (Fetcher.Setup(&Stat) == false)
+        return false;
 
       // Populate it with the source selection and get all Indexes 
       // (GetAll=true)
@@ -1479,7 +1550,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
       {
         if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
            if(Debug)
-              std::cout << "We could delete %s" <<  Pkg.Name() << std::endl;
+              std::cout << "We could delete %s" <<  Pkg.FullName(true).c_str() << std::endl;
 
         if (doAutoRemove)
         {
@@ -1494,12 +1565,11 @@ bool DoAutomaticRemove(CacheFile &Cache)
            // only show stuff in the list that is not yet marked for removal
            if(Cache[Pkg].Delete() == false) 
            {
+              ++autoRemoveCount;
               // we don't need to fill the strings if we don't need them
-              if (smallList == true)
-                 ++autoRemoveCount;
-              else
+              if (smallList == false)
               {
-                autoremovelist += string(Pkg.Name()) + " ";
+                autoremovelist += Pkg.FullName(true) + " ";
                 autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
               }
            }
@@ -1510,9 +1580,12 @@ bool DoAutomaticRemove(CacheFile &Cache)
    if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0))
    {
       if (smallList == false)
-        ShowList(c1out, _("The following packages were automatically installed and are no longer required:"), autoremovelist, autoremoveversions);
+        ShowList(c1out, P_("The following package is automatically installed and is no longer required:",
+                 "The following packages were automatically installed and are no longer required:",
+                 autoRemoveCount), autoremovelist, autoremoveversions);
       else
-        ioprintf(c1out, _("%lu packages were automatically installed and are no longer required.\n"), autoRemoveCount);
+        ioprintf(c1out, P_("%lu package was automatically installed and is no longer required.\n",
+                 "%lu packages were automatically installed and are no longer required.\n", autoRemoveCount), autoRemoveCount);
       c1out << _("Use 'apt-get autoremove' to remove them.") << std::endl;
    }
    // Now see if we had destroyed anything (if we had done anything)
@@ -1732,11 +1805,14 @@ bool DoInstall(CommandLine &CmdL)
         
            // Run over the matches
            bool Hit = false;
-           for (Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+           for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp)
            {
-              if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0)
+              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);
            
@@ -1766,10 +1842,12 @@ bool DoInstall(CommandLine &CmdL)
            if(!Remove && 
               Cache[Pkg].Install() == false && 
               (Cache[Pkg].Flags & pkgCache::Flag::Auto) &&
-              _config->FindB("APT::Get::ReInstall",false) == false)
+              _config->FindB("APT::Get::ReInstall",false) == false &&
+              _config->FindB("APT::Get::Only-Upgrade",false) == false &&
+              _config->FindB("APT::Get::Download-Only",false) == false)
            {
               ioprintf(c1out,_("%s set to manually installed.\n"),
-                       Pkg.Name());
+                       Pkg.FullName(true).c_str());
               Cache->MarkAuto(Pkg,false);
               AutoMarkChanged++;
            }
@@ -1781,7 +1859,7 @@ bool DoInstall(CommandLine &CmdL)
         packages */
       if (BrokenFix == true && Cache->BrokenCount() != 0)
       {
-        c1out << _("You might want to run `apt-get -f install' to correct these:") << endl;
+        c1out << _("You might want to run 'apt-get -f install' to correct these:") << endl;
         ShowBroken(c1out,Cache,false);
 
         return _error->Error(_("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."));
@@ -1838,7 +1916,7 @@ bool DoInstall(CommandLine &CmdL)
                break;
         
         if (*J == 0) {
-           List += string(I.Name()) + " ";
+           List += I.FullName(true) + " ";
            VersionsList += string(Cache[I].CandVersion) + "\n";
         }
       }
@@ -1874,10 +1952,11 @@ bool DoInstall(CommandLine &CmdL)
            for(;;)
            {
               /* Skip if package is  installed already, or is about to be */
-              string target = string(Start.TargetPkg().Name()) + " ";
-              
-              if ((*Start.TargetPkg()).SelectedState == pkgCache::State::Install
-                  || Cache[Start.TargetPkg()].Install())
+              string target = Start.TargetPkg().FullName(true) + " ";
+              pkgCache::PkgIterator const TarPkg = Start.TargetPkg();
+              if (TarPkg->SelectedState == pkgCache::State::Install ||
+                  TarPkg->SelectedState == pkgCache::State::Hold ||
+                  Cache[Start.TargetPkg()].Install())
               {
                  foundInstalledInOrGroup=true;
                  break;
@@ -1952,6 +2031,46 @@ bool DoInstall(CommandLine &CmdL)
 
    return InstallPackages(Cache,false);   
 }
+
+/* mark packages as automatically/manually installed. */
+bool DoMarkAuto(CommandLine &CmdL)
+{
+   bool Action = true;
+   int AutoMarkChanged = 0;
+   OpTextProgress progress;
+   CacheFile Cache;
+   if (Cache.Open() == false)
+      return false;
+
+   if (strcasecmp(CmdL.FileList[0],"markauto") == 0)
+      Action = true;
+   else if (strcasecmp(CmdL.FileList[0],"unmarkauto") == 0)
+      Action = false;
+
+   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+   {
+      const char *S = *I;
+      // Locate the package
+      pkgCache::PkgIterator Pkg = Cache->FindPkg(S);
+      if (Pkg.end() == true) {
+         return _error->Error(_("Couldn't find package %s"),S);
+      }
+      else
+      {
+         if (!Action)
+            ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.Name());
+         else
+            ioprintf(c1out,_("%s set to automatically installed.\n"),
+                      Pkg.Name());
+
+         Cache->MarkAuto(Pkg,Action);
+         AutoMarkChanged++;
+      }
+   }
+   if (AutoMarkChanged && ! _config->FindB("APT::Get::Simulate",false))
+      return Cache->writeStateFile(NULL);
+   return false;
+}
                                                                        /*}}}*/
 // DoDistUpgrade - Automatic smart upgrader                            /*{{{*/
 // ---------------------------------------------------------------------
@@ -2160,13 +2279,23 @@ bool DoSource(CommandLine &CmdL)
 
    // Create the download object
    AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));   
-   pkgAcquire Fetcher(&Stat);
+   pkgAcquire Fetcher;
+   if (Fetcher.Setup(&Stat) == false)
+      return false;
 
    DscFile *Dsc = new DscFile[CmdL.FileSize()];
    
    // insert all downloaded uris into this set to avoid downloading them
    // twice
    set<string> queued;
+
+   // Diff only mode only fetches .diff files
+   bool const diffOnly = _config->FindB("APT::Get::Diff-Only", false);
+   // Tar only mode only fetches .tar files
+   bool const tarOnly = _config->FindB("APT::Get::Tar-Only", false);
+   // Dsc only mode only fetches .dsc files
+   bool const dscOnly = _config->FindB("APT::Get::Dsc-Only", false);
+
    // Load the requestd sources into the fetcher
    unsigned J = 0;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
@@ -2177,6 +2306,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)
@@ -2193,21 +2349,17 @@ bool DoSource(CommandLine &CmdL)
            Dsc[J].Version = Last->Version();
            Dsc[J].Dsc = flNotDir(I->Path);
         }
-        
-        // Diff only mode only fetches .diff files
-        if (_config->FindB("APT::Get::Diff-Only",false) == true &&
-            I->Type != "diff")
-           continue;
-        
-        // Tar only mode only fetches .tar files
-        if (_config->FindB("APT::Get::Tar-Only",false) == true &&
-            I->Type != "tar")
-           continue;
 
-        // Dsc only mode only fetches .dsc files
-        if (_config->FindB("APT::Get::Dsc-Only",false) == true &&
-            I->Type != "dsc")
-           continue;
+        // Handle the only options so that multiple can be used at once
+        if (diffOnly == true || tarOnly == true || dscOnly == true)
+        {
+           if ((diffOnly == true && I->Type == "diff") ||
+               (tarOnly == true && I->Type == "tar") ||
+               (dscOnly == true && I->Type == "dsc"))
+               ; // Fine, we want this file downloaded
+           else
+              continue;
+        }
 
         // don't download the same uri twice (should this be moved to
         // the fetcher interface itself?)
@@ -2275,6 +2427,7 @@ bool DoSource(CommandLine &CmdL)
    {
       for (unsigned I = 0; I != J; I++)
         ioprintf(cout,_("Fetch source %s\n"),Dsc[I].Package.c_str());
+      delete[] Dsc;
       return true;
    }
    
@@ -2285,6 +2438,7 @@ bool DoSource(CommandLine &CmdL)
       for (; I != Fetcher.UriEnd(); I++)
         cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << 
               I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
+      delete[] Dsc;
       return true;
    }
    
@@ -2310,6 +2464,7 @@ bool DoSource(CommandLine &CmdL)
    if (_config->FindB("APT::Get::Download-only",false) == true)
    {
       c1out << _("Download complete and in download only mode") << endl;
+      delete[] Dsc;
       return true;
    }
 
@@ -2318,6 +2473,7 @@ bool DoSource(CommandLine &CmdL)
    
    if (Process == 0)
    {
+      bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
       for (unsigned I = 0; I != J; I++)
       {
         string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str());
@@ -2330,7 +2486,7 @@ bool DoSource(CommandLine &CmdL)
 
         // See if the package is already unpacked
         struct stat Stat;
-        if (stat(Dir.c_str(),&Stat) == 0 &&
+        if (fixBroken == false && stat(Dir.c_str(),&Stat) == 0 &&
             S_ISDIR(Stat.st_mode) != 0)
         {
            ioprintf(c0out ,_("Skipping unpack of already unpacked source in %s\n"),
@@ -2371,7 +2527,8 @@ bool DoSource(CommandLine &CmdL)
       
       _exit(0);
    }
-   
+   delete[] Dsc;
+
    // Wait for the subprocess
    int Status = 0;
    while (waitpid(Process,&Status,0) != Process)
@@ -2413,7 +2570,9 @@ bool DoBuildDep(CommandLine &CmdL)
 
    // Create the download object
    AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));   
-   pkgAcquire Fetcher(&Stat);
+   pkgAcquire Fetcher;
+   if (Fetcher.Setup(&Stat) == false)
+      return false;
 
    unsigned J = 0;
    for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
@@ -2425,7 +2584,7 @@ bool DoBuildDep(CommandLine &CmdL)
             
       // Process the build-dependencies
       vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
-      if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",false)) == false)
+      if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",true)) == false)
        return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
    
       // Also ensure that build-essential packages are present
@@ -2524,7 +2683,7 @@ bool DoBuildDep(CommandLine &CmdL)
             for (; Prv.end() != true; Prv++)
            {
                if (_config->FindB("Debug::BuildDeps",false) == true)
-                    cout << "  Checking provider " << Prv.OwnerPkg().Name() << endl;
+                    cout << "  Checking provider " << Prv.OwnerPkg().FullName() << endl;
 
               if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false)
                  break;
@@ -2565,7 +2724,7 @@ bool DoBuildDep(CommandLine &CmdL)
                if (Prv.end() == false)
                {
                   if (_config->FindB("Debug::BuildDeps",false) == true)
-                     cout << "  Is provided by installed package " << Prv.OwnerPkg().Name() << endl;
+                     cout << "  Is provided by installed package " << Prv.OwnerPkg().FullName() << endl;
                   skipAlternatives = hasAlternatives;
                   continue;
                }
@@ -2590,7 +2749,7 @@ bool DoBuildDep(CommandLine &CmdL)
                   return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"),
                                        Last->BuildDepType((*D).Type),
                                        Src.c_str(),
-                                       Pkg.Name());
+                                       Pkg.FullName(true).c_str());
                }
             }
 
@@ -2639,7 +2798,6 @@ bool DoBuildDep(CommandLine &CmdL)
    return true;
 }
                                                                        /*}}}*/
-
 // DoMoo - Never Ask, Never Tell                                       /*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -2730,6 +2888,8 @@ bool ShowHelp(CommandLine &CmdL)
       "   clean - Erase downloaded archive files\n"
       "   autoclean - Erase old downloaded archive files\n"
       "   check - Verify that there are no broken dependencies\n"
+      "   markauto - Mark the given packages as automatically installed\n"
+      "   unmarkauto - Mark the given packages as manually installed\n"
       "\n"
       "Options:\n"
       "  -h  This help text.\n"
@@ -2808,9 +2968,11 @@ int main(int argc,const char *argv[])                                    /*{{{*/
       {0,"fix-missing","APT::Get::Fix-Missing",0},
       {0,"ignore-hold","APT::Ignore-Hold",0},      
       {0,"upgrade","APT::Get::upgrade",0},
+      {0,"only-upgrade","APT::Get::Only-Upgrade",0},
       {0,"force-yes","APT::Get::force-yes",0},
       {0,"print-uris","APT::Get::Print-URIs",0},
       {0,"diff-only","APT::Get::Diff-Only",0},
+      {0,"debian-only","APT::Get::Diff-Only",0},
       {0,"tar-only","APT::Get::Tar-Only",0},
       {0,"dsc-only","APT::Get::Dsc-Only",0},
       {0,"purge","APT::Get::Purge",0},
@@ -2833,7 +2995,8 @@ int main(int argc,const char *argv[])                                     /*{{{*/
                                    {"remove",&DoInstall},
                                    {"purge",&DoInstall},
                                   {"autoremove",&DoInstall},
-                                  {"purge",&DoInstall},
+                                  {"markauto",&DoMarkAuto},
+                                  {"unmarkauto",&DoMarkAuto},
                                    {"dist-upgrade",&DoDistUpgrade},
                                    {"dselect-upgrade",&DoDSelectUpgrade},
                                   {"build-dep",&DoBuildDep},