X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/e42eb508e01f4de6def088fe941344d3ca733fa5..d556d1a1cc89e0f99d1b76fd6da72fd0174f5862:/cmdline/apt-get.cc diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 043cc35bc..67352c868 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-get.cc,v 1.60 1999/05/23 05:45:12 jgg Exp $ +// $Id: apt-get.cc,v 1.69 1999/07/10 04:58:42 jgg Exp $ /* ###################################################################### apt-get - Cover for dpkg @@ -225,8 +225,15 @@ void ShowDel(ostream &out,pkgDepCache &Dep) pkgCache::PkgIterator I = Dep.PkgBegin(); string List; for (;I.end() != true; I++) + { if (Dep[I].Delete() == true) - List += string(I.Name()) + " "; + { + if ((Dep[I].iFlags & pkgDepCache::Purge) == pkgDepCache::Purge) + List += string(I.Name()) + "* "; + else + List += string(I.Name()) + " "; + } + } ShowList(out,"The following packages will be REMOVED:",List); } @@ -440,6 +447,16 @@ bool CacheFile::CheckDeps(bool AllowBroken) happen and then calls the download routines */ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey = true) { + if (_config->FindB("APT::Get::Purge",false) == true) + { + pkgCache::PkgIterator I = Cache->PkgBegin(); + for (; I.end() == false; I++) + { + if (I.Purge() == false && Cache[I].Mode == pkgDepCache::ModeDelete) + Cache->MarkDelete(I,true); + } + } + bool Fail = false; bool Essential = false; @@ -470,7 +487,12 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey = if (_config->FindB("APT::Get::Simulate") == true) { pkgSimulate PM(Cache); - return PM.DoInstall(); + pkgPackageManager::OrderResult Res = PM.DoInstall(); + if (Res == pkgPackageManager::Failed) + return false; + if (Res != pkgPackageManager::Completed) + return _error->Error("Internal Error, Ordering didn't finish"); + return true; } // Create the text record parser @@ -525,17 +547,17 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey = // Number of bytes c1out << "Need to get "; if (DebBytes != FetchBytes) - c1out << SizeToStr(FetchBytes) << "b/" << SizeToStr(DebBytes) << 'b'; + c1out << SizeToStr(FetchBytes) << "B/" << SizeToStr(DebBytes) << 'B'; else - c1out << SizeToStr(DebBytes) << 'b'; + c1out << SizeToStr(DebBytes) << 'B'; c1out << " of archives. After unpacking "; // Size delta if (Cache->UsrSize() >= 0) - c1out << SizeToStr(Cache->UsrSize()) << "b will be used." << endl; + c1out << SizeToStr(Cache->UsrSize()) << "B will be used." << endl; else - c1out << SizeToStr(-1*Cache->UsrSize()) << "b will be freed." << endl; + c1out << SizeToStr(-1*Cache->UsrSize()) << "B will be freed." << endl; if (_error->PendingError() == true) return false; @@ -589,57 +611,75 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey = } // Run it - if (Fetcher.Run() == false) - return false; - - // Print out errors - bool Failed = false; - bool Transient = false; - for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) + while (1) { - if ((*I)->Status == pkgAcquire::Item::StatDone && - (*I)->Complete == true) - continue; + if (_config->FindB("APT::Get::No-Download",false) == false) + if( Fetcher.Run() == pkgAcquire::Failed) + return false; - if ((*I)->Status == pkgAcquire::Item::StatIdle) + // Print out errors + bool Failed = false; + bool Transient = false; + for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) { - Transient = true; + if ((*I)->Status == pkgAcquire::Item::StatDone && + (*I)->Complete == true) + continue; + + (*I)->Finished(); + + if ((*I)->Status == pkgAcquire::Item::StatIdle) + { + Transient = true; + // Failed = true; + continue; + } + + cerr << "Failed to fetch " << (*I)->DescURI() << endl; + cerr << " " << (*I)->ErrorText << endl; Failed = true; - continue; } - cerr << "Failed to fetch " << (*I)->DescURI() << endl; - cerr << " " << (*I)->ErrorText << endl; - Failed = true; - } - - if (_config->FindB("APT::Get::Download-Only",false) == true) - { - if (Failed == false && _config->FindB("APT::Get::Fix-Missing",false) == false) - return _error->Error("Some files failed to download"); - return true; - } - - if (Failed == true && _config->FindB("APT::Get::Fix-Missing",false) == false) - { - if (Transient == true) + if (_config->FindB("APT::Get::Download-Only",false) == true) { - c2out << "Upgrading with disk swapping is not supported in this version." << endl; - c2out << "Try running multiple times with --fix-missing" << endl; + if (Failed == true && _config->FindB("APT::Get::Fix-Missing",false) == false) + return _error->Error("Some files failed to download"); + return true; } - return _error->Error("Unable to fetch some archives, maybe try with --fix-missing?"); - } - - // Try to deal with missing package files - if (PM.FixMissing() == false) - { - cerr << "Unable to correct missing packages." << endl; - return _error->Error("Aborting Install."); - } - - Cache.ReleaseLock(); - return PM.DoInstall(); + if (Failed == true && _config->FindB("APT::Get::Fix-Missing",false) == false) + { + /*if (Transient == true) + { + c2out << "Upgrading with disk swapping is not supported in this version." << endl; + c2out << "Try running multiple times with --fix-missing" << endl; + }*/ + + return _error->Error("Unable to fetch some archives, maybe try with --fix-missing?"); + } + + if (Transient == true && Failed == true) + return _error->Error("--fix-missing and media swapping is not currently supported"); + + // Try to deal with missing package files + if (Failed == true && PM.FixMissing() == false) + { + cerr << "Unable to correct missing packages." << endl; + return _error->Error("Aborting Install."); + } + + Cache.ReleaseLock(); + pkgPackageManager::OrderResult Res = PM.DoInstall(); + if (Res == pkgPackageManager::Failed || _error->PendingError() == true) + return false; + if (Res == pkgPackageManager::Completed) + return true; + + // Reload the fetcher object and loop again for media swapping + Fetcher.Shutdown(); + if (PM.GetArchives(&Fetcher,&List,&Recs) == false) + return false; + } } /*}}}*/ @@ -676,7 +716,7 @@ bool DoUpdate(CommandLine &) } // Run it - if (Fetcher.Run() == false) + if (Fetcher.Run() == pkgAcquire::Failed) return false; // Clean out any old list files @@ -745,19 +785,23 @@ bool DoInstall(CommandLine &CmdL) // See if we are removing the package bool Remove = DefRemove; - if (Cache->FindPkg(S).end() == true) + while (Cache->FindPkg(S).end() == true) { // Handle an optional end tag indicating what to do if (S[Length - 1] == '-') { Remove = true; S[--Length] = 0; + continue; } + if (S[Length - 1] == '+') { Remove = false; S[--Length] = 0; + continue; } + break; } // Locate the package @@ -822,7 +866,7 @@ bool DoInstall(CommandLine &CmdL) if (Remove == true) { Fix.Remove(Pkg); - Cache->MarkDelete(Pkg); + Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false)); continue; } @@ -843,10 +887,10 @@ 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); - return _error->Error("Unmet dependencies. Try using -f."); + return _error->Error("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution)."); } // Call the scored problem resolver @@ -962,7 +1006,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) // Remove packages if (I->SelectedState == pkgCache::State::DeInstall || I->SelectedState == pkgCache::State::Purge) - Cache->MarkDelete(I); + Cache->MarkDelete(I,I->SelectedState == pkgCache::State::Purge); } /* Resolve any problems that dselect created, allupgrade cannot handle @@ -1021,7 +1065,10 @@ class LogCleaner : public pkgArchiveCleaner protected: virtual void Erase(const char *File,string Pkg,string Ver,struct stat &St) { - cout << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "b]" << endl; + cout << "Del " << Pkg << " " << Ver << " [" << SizeToStr(St.st_size) << "B]" << endl; + + if (_config->FindB("APT::Get::Simulate") == false) + unlink(File); }; }; @@ -1191,9 +1238,9 @@ bool DoSource(CommandLine &CmdL) // Number of bytes c1out << "Need to get "; if (DebBytes != FetchBytes) - c1out << SizeToStr(FetchBytes) << "b/" << SizeToStr(DebBytes) << 'b'; + c1out << SizeToStr(FetchBytes) << "B/" << SizeToStr(DebBytes) << 'B'; else - c1out << SizeToStr(DebBytes) << 'b'; + c1out << SizeToStr(DebBytes) << 'B'; c1out << " of source archives." << endl; if (_config->FindB("APT::Get::Simulate",false) == true) @@ -1214,7 +1261,7 @@ bool DoSource(CommandLine &CmdL) } // Run it - if (Fetcher.Run() == false) + if (Fetcher.Run() == pkgAcquire::Failed) return false; // Print error messages @@ -1341,11 +1388,11 @@ bool ShowHelp(CommandLine &CmdL) cout << " -f Attempt to continue if the integrity check fails" << endl; cout << " -m Attempt to continue if archives are unlocatable" << endl; cout << " -u Show a list of upgraded packages as well" << endl; - cout << " -b Bulid the source package after fetching itl" << endl; + cout << " -b Build the source package after fetching it" << endl; cout << " -c=? Read this configuration file" << endl; cout << " -o=? Set an arbitary configuration option, eg -o dir::cache=/tmp" << endl; cout << "See the apt-get(8), sources.list(5) and apt.conf(5) manual" << endl; - cout << "pages for more information." << endl; + cout << "pages for more information and options." << endl; return 100; } /*}}}*/ @@ -1397,11 +1444,13 @@ int main(int argc,const char *argv[]) {'f',"fix-broken","APT::Get::Fix-Broken",0}, {'u',"show-upgraded","APT::Get::Show-Upgraded",0}, {'m',"ignore-missing","APT::Get::Fix-Missing",0}, + {0,"no-download","APT::Get::No-Download",0}, {0,"fix-missing","APT::Get::Fix-Missing",0}, {0,"ignore-hold","APT::Ingore-Hold",0}, {0,"no-upgrade","APT::Get::no-upgrade",0}, {0,"force-yes","APT::Get::force-yes",0}, {0,"print-uris","APT::Get::Print-URIs",0}, + {0,"purge","APT::Get::Purge",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}};