X-Git-Url: http://git.hcoop.net/ntk/apt.git/blobdiff_plain/06f02b954f5c4ca7cb9cc288ea5a8fcb6a1052d4..aca056a93dda08ad03690b4b70295832a723a655:/cmdline/apt-get.cc diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 6268f495..82f20210 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -541,7 +541,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache) } delete [] Added; - return ShowList(out,_("WARNING: The following essential packages will be removed\n" + return ShowList(out,_("WARNING: The following essential packages will be removed.\n" "This should NOT be done unless you know exactly what you are doing!"),List,VersionsList); } @@ -688,7 +688,7 @@ static bool CheckAuth(pkgAcquire& Fetcher) if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true) { - c2out << "Authentication warning overridden.\n"; + c2out << _("Authentication warning overridden.\n"); return true; } @@ -750,7 +750,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (Cache->BrokenCount() != 0) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, InstallPackages was called with broken packages!"); + return _error->Error(_("Internal error, InstallPackages was called with broken packages!")); } if (Cache->DelCount() == 0 && Cache->InstCount() == 0 && @@ -765,11 +765,12 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindB("APT::Get::Simulate") == true) { pkgSimulate PM(Cache); - pkgPackageManager::OrderResult Res = PM.DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM.DoInstall(status_fd); if (Res == pkgPackageManager::Failed) return false; if (Res != pkgPackageManager::Completed) - return _error->Error("Internal error, Ordering didn't finish"); + return _error->Error(_("Internal error, Ordering didn't finish")); return true; } @@ -810,7 +811,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (DebBytes != Cache->DebSize()) { c0out << DebBytes << ',' << Cache->DebSize() << endl; - c0out << "How odd.. The sizes didn't match, email apt@packages.debian.org" << endl; + c0out << _("How odd.. The sizes didn't match, email apt@packages.debian.org") << endl; } // Number of bytes @@ -840,7 +841,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, struct statvfs Buf; string OutputDir = _config->FindDir("Dir::Cache::Archives"); if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + 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."), @@ -862,7 +863,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, const char *Prompt = _("Yes, do as I say!"); ioprintf(c2out, - _("You are about to do something potentially harmful\n" + _("You are about to do something potentially harmful.\n" "To continue type in the phrase '%s'\n" " ?] "),Prompt); c2out << flush; @@ -994,7 +995,8 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, } _system->UnLock(); - pkgPackageManager::OrderResult Res = PM->DoInstall(); + int status_fd = _config->FindI("APT::Status-Fd",-1); + pkgPackageManager::OrderResult Res = PM->DoInstall(status_fd); if (Res == pkgPackageManager::Failed || _error->PendingError() == true) return false; if (Res == pkgPackageManager::Completed) @@ -1188,27 +1190,62 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, string VerTag; string TmpSrc = Name; string::size_type Slash = TmpSrc.rfind('='); + + // honor pining and default release + string DefRel = _config->Find("APT::Default-Release"); + + pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc); + pkgCache::VerIterator CandVer = Cache.GetCandidateVer(Pkg); + if(Pkg.end() == false) + { + VerTag = CandVer.VerStr(); + } + if (Slash != string::npos) { VerTag = string(TmpSrc.begin() + Slash + 1,TmpSrc.end()); TmpSrc = string(TmpSrc.begin(),TmpSrc.begin() + Slash); + } + else if(DefRel.empty() == 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::VerFileIterator VF = Ver.FileList(); VF.end() == false; + VF++) + { + /* If this is the status file, and the current version is not the + version in the status file (ie it is not installed, or somesuch) + then it is not a candidate for installation, ever. This weeds + out bogus entries that may be due to config-file states, or + other. */ + if ((VF.File()->Flags & pkgCache::Flag::NotSource) == + pkgCache::Flag::NotSource && Pkg.CurrentVer() != Ver) + continue; + + //std::cout << VF.File().Archive() << std::endl; + if(VF.File().Archive() == DefRel) + { + VerTag = Ver.VerStr(); + break; + } + } + } } - + /* Lookup the version of the package we would install if we were to install a version and determine the source package name, then look - in the archive for a source package of the same name. In theory - we could stash the version string as well and match that too but - today there aren't multi source versions in the archive. */ - if (_config->FindB("APT::Get::Only-Source") == false && - VerTag.empty() == true) + in the archive for a source package of the same name. */ + if (_config->FindB("APT::Get::Only-Source") == false) { - pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpSrc); if (Pkg.end() == false) { - pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg); - if (Ver.end() == false) + if (CandVer.end() == false) { - pkgRecords::Parser &Parse = Recs.Lookup(Ver.FileList()); + pkgRecords::Parser &Parse = Recs.Lookup(CandVer.FileList()); Src = Parse.SourcePkg(); } } @@ -1380,6 +1417,15 @@ bool DoUpgrade(CommandLine &CmdL) /* Install named packages */ bool DoInstall(CommandLine &CmdL) { + // 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")); + } + CacheFile Cache; if (Cache.OpenForInstall() == false || Cache.CheckDeps(CmdL.FileSize() != 1) == false) @@ -1648,7 +1694,7 @@ bool DoInstall(CommandLine &CmdL) // See if we need to prompt if (Cache->InstCount() == ExpectedInst && Cache->DelCount() == 0) return InstallPackages(Cache,false,false); - + return InstallPackages(Cache,false); } /*}}}*/ @@ -1734,7 +1780,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (Fix.Resolve() == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } } @@ -1742,7 +1788,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) if (pkgAllUpgrade(Cache) == false) { ShowBroken(c1out,Cache,false); - return _error->Error("Internal error, problem resolver broke stuff"); + return _error->Error(_("Internal error, problem resolver broke stuff")); } return InstallPackages(Cache,false); @@ -1913,7 +1959,7 @@ bool DoSource(CommandLine &CmdL) struct statvfs Buf; string OutputDir = "."; if (statvfs(OutputDir.c_str(),&Buf) != 0) - return _error->Errno("statvfs","Couldn't determine free space in %s", + 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"), @@ -2002,6 +2048,7 @@ bool DoSource(CommandLine &CmdL) if (system(S) != 0) { fprintf(stderr,_("Unpack command '%s' failed.\n"),S); + fprintf(stderr,_("Check if the 'dpkg-dev' package is installed.\n")); _exit(1); } }