// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-get.cc,v 1.103 2001/03/03 23:12:07 jgg Exp $
+// $Id: apt-get.cc,v 1.118 2002/04/02 07:16:24 jgg Exp $
/* ######################################################################
apt-get - Cover for dpkg
#include "acqprogress.h"
-#include <fstream.h>
+#include <locale.h>
+#include <fstream>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/wait.h>
/*}}}*/
-ostream c0out;
-ostream c1out;
-ostream c2out;
+using namespace std;
+
+ostream c0out(0);
+ostream c1out(0);
+ostream c2out(0);
ofstream devnull("/dev/null");
unsigned int ScreenWidth = 80;
return true;
};
+ bool OpenForInstall()
+ {
+ if (_config->FindB("APT::Get::Print-URIs") == true)
+ return Open(false);
+ else
+ return Open(true);
+ }
CacheFile() : List(0) {};
};
/*}}}*/
{
pkgCache::PkgIterator I(Cache,Cache.List[J]);
- if (Cache[I].InstBroken() == false)
- continue;
-
+ if (Now == true)
+ {
+ if (Cache[I].NowBroken() == false)
+ continue;
+ }
+ else
+ {
+ if (Cache[I].InstBroken() == false)
+ continue;
+ }
+
// Print out each package and the failed dependencies
out <<" " << I.Name() << ":";
unsigned Indent = strlen(I.Name()) + 3;
bool First = true;
- if (Cache[I].InstVerIter(Cache).end() == true)
+ pkgCache::VerIterator Ver;
+
+ if (Now == true)
+ Ver = I.CurrentVer();
+ else
+ Ver = Cache[I].InstVerIter(Cache);
+
+ if (Ver.end() == true)
{
- cout << endl;
+ out << endl;
continue;
}
- for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false;)
+ for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false;)
{
// Compute a single dependency element (glob or)
pkgCache::DepIterator Start;
pkgCache::DepIterator End;
D.GlobOr(Start,End);
- if (Cache->IsImportantDep(End) == false ||
- (Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall)
+ if (Cache->IsImportantDep(End) == false)
continue;
-
+
+ if (Now == true)
+ {
+ if ((Cache[End] & pkgDepCache::DepGNow) == pkgDepCache::DepGNow)
+ continue;
+ }
+ else
+ {
+ if ((Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall)
+ continue;
+ }
+
bool FirstOr = true;
while (1)
{
{
out << ' ';
pkgCache::VerIterator Ver = Cache[Targ].InstVerIter(Cache);
+ if (Now == true)
+ Ver = Targ.CurrentVer();
+
if (Ver.end() == false)
{
if (Now == true)
Added[P->ID] = true;
char S[300];
- sprintf(S,_("%s (due to %s) "),P.Name(),I.Name());
+ snprintf(S,sizeof(S),_("%s (due to %s) "),P.Name(),I.Name());
List += S;
}
}
if (Downgrade != 0)
ioprintf(out,_("%lu downgraded, "),Downgrade);
- ioprintf(out,_("%lu to remove and %lu not upgraded.\n"),
+ ioprintf(out,_("%lu to remove and %lu not upgraded.\n"),
Dep.DelCount(),Dep.KeepCount());
if (Dep.BadCount() != 0)
// Lock the archive directory
FileFd Lock;
- if (_config->FindB("Debug::NoLocking",false) == false)
+ 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)
/* Check for enough free space, but only if we are actually going to
download */
- if (_config->FindB("APT::Get::Print-URIs") == false)
+ if (_config->FindB("APT::Get::Print-URIs") == false &&
+ _config->FindB("APT::Get::Download",true) == true)
{
struct statvfs Buf;
string OutputDir = _config->FindDir("Dir::Cache::Archives");
bool Transient = false;
if (_config->FindB("APT::Get::Download",true) == false)
{
- for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd();)
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd();)
{
if ((*I)->Local == true)
{
// Print out errors
bool Failed = false;
- for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
{
if ((*I)->Status == pkgAcquire::Item::StatDone &&
(*I)->Complete == true)
if (_config->FindB("APT::Get::ReInstall",false) == true)
{
if (Pkg->CurrentVer == 0 || Pkg.CurrentVer().Downloadable() == false)
- ioprintf(c1out,_("Sorry, re-installation of %s is not possible, it cannot be downloaded."),
+ ioprintf(c1out,_("Sorry, re-installation of %s is not possible, it cannot be downloaded.\n"),
Pkg.Name());
else
Cache.SetReInstall(Pkg,true);
// Create the download object
AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
pkgAcquire Fetcher(&Stat);
-
+
// Populate it with the source selection
if (List.GetIndexes(&Fetcher) == false)
return false;
+ // Just print out the uris an exit if the --print-uris flag was used
+ if (_config->FindB("APT::Get::Print-URIs") == true)
+ {
+ pkgAcquire::UriIterator I = Fetcher.UriBegin();
+ for (; I != Fetcher.UriEnd(); I++)
+ cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
+ I->Owner->FileSize << ' ' << I->Owner->MD5Sum() << endl;
+ return true;
+ }
+
// Run it
if (Fetcher.Run() == pkgAcquire::Failed)
return false;
bool Failed = false;
- for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
{
if ((*I)->Status == pkgAcquire::Item::StatDone)
continue;
bool DoUpgrade(CommandLine &CmdL)
{
CacheFile Cache;
- if (Cache.Open() == false || Cache.CheckDeps() == false)
+ if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
// Do the upgrade
bool DoInstall(CommandLine &CmdL)
{
CacheFile Cache;
- if (Cache.Open() == false || Cache.CheckDeps(CmdL.FileSize() != 1) == false)
+ if (Cache.OpenForInstall() == false ||
+ Cache.CheckDeps(CmdL.FileSize() != 1) == false)
return false;
// Enter the special broken fixing mode if the user specified arguments
bool DoDistUpgrade(CommandLine &CmdL)
{
CacheFile Cache;
- if (Cache.Open() == false || Cache.CheckDeps() == false)
+ if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
c0out << _("Calculating Upgrade... ") << flush;
bool DoDSelectUpgrade(CommandLine &CmdL)
{
CacheFile Cache;
- if (Cache.Open() == false || Cache.CheckDeps() == false)
+ if (Cache.OpenForInstall() == false || Cache.CheckDeps() == false)
return false;
// Install everything with the install flag set
// Print error messages
bool Failed = false;
- for (pkgAcquire::Item **I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
+ for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++)
{
if ((*I)->Status == pkgAcquire::Item::StatDone &&
(*I)->Complete == true)
// Process the build-dependencies
vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
- if (Last->BuildDepends(BuildDeps) == false)
+ if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",false)) == false)
return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
+ // Also ensure that build-essential packages are present
+ Configuration::Item const *Opts = _config->Tree("APT::Build-Essential");
+ if (Opts)
+ Opts = Opts->Child;
+ for (; Opts; Opts = Opts->Next)
+ {
+ if (Opts->Value.empty() == true)
+ continue;
+
+ pkgSrcRecords::Parser::BuildDepRec rec;
+ rec.Package = Opts->Value;
+ rec.Type = pkgSrcRecords::Parser::BuildDependIndep;
+ rec.Op = 0;
+ BuildDeps.insert(BuildDeps.begin(), rec);
+ }
+
if (BuildDeps.size() == 0)
{
ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str());
{
pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package);
if (Pkg.end() == true)
+ {
+ /* for a build-conflict; ignore unknown packages */
+ if ((*D).Type == pkgSrcRecords::Parser::BuildConflict ||
+ (*D).Type == pkgSrcRecords::Parser::BuildConflictIndep)
+ continue;
+
return _error->Error(_("%s dependency on %s cannot be satisfied because the package %s cannot be found"),
Last->BuildDepType((*D).Type),Src.c_str(),(*D).Package.c_str());
+ }
pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
if ((*D).Type == pkgSrcRecords::Parser::BuildConflict ||
{0,"trivial-only","APT::Get::Trivial-Only",0},
{0,"remove","APT::Get::Remove",0},
{0,"only-source","APT::Get::Only-Source",0},
+ {0,"arch-only","APT::Get::Arch-Only",0},
{'c',"config-file",0,CommandLine::ConfigFile},
{'o',"option",0,CommandLine::ArbItem},
{0,0,0,0}};
{"clean",&DoClean},
{"autoclean",&DoAutoClean},
{"check",&DoCheck},
- {"source",&DoSource},
+ {"source",&DoSource},
{"moo",&DoMoo},
- {"help",&ShowHelp},
+ {"help",&ShowHelp},
{0,0}};
-
+
+ // Set up gettext support
+ setlocale(LC_ALL,"");
+ textdomain(PACKAGE);
+
// Parse the command line and initialize the package library
CommandLine CmdL(Args,_config);
if (pkgInitConfig(*_config) == false ||