// -*- 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
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);
}
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;
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
// 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;
}
// 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;
+ }
}
/*}}}*/
}
// Run it
- if (Fetcher.Run() == false)
+ if (Fetcher.Run() == pkgAcquire::Failed)
return false;
// Clean out any old list files
// 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
if (Remove == true)
{
Fix.Remove(Pkg);
- Cache->MarkDelete(Pkg);
+ Cache->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false));
continue;
}
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
// 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
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);
};
};
// 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)
}
// Run it
- if (Fetcher.Run() == false)
+ if (Fetcher.Run() == pkgAcquire::Failed)
return false;
// Print error messages
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;
}
/*}}}*/
{'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}};