// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-get.cc,v 1.109 2001/07/01 22:59:04 jgg Exp $
+// $Id: apt-get.cc,v 1.121 2002/07/08 04:09:52 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>
void Sort();
bool CheckDeps(bool AllowBroken = false);
+ bool BuildCaches(bool WithLock = true)
+ {
+ OpTextProgress Prog(*_config);
+ if (pkgCacheFile::BuildCaches(Prog,WithLock) == false)
+ return false;
+ return true;
+ }
bool Open(bool WithLock = true)
{
OpTextProgress Prog(*_config);
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)
/* 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");
pkgDepCache::StateCache &State = Cache[Pkg];
if (Remove == true && Pkg->CurrentVer == 0)
{
+ Fix.Clear(Pkg);
+ Fix.Protect(Pkg);
+ Fix.Remove(Pkg);
+
/* We want to continue searching for regex hits, so we return false here
otherwise this is not really an error. */
if (AllowFail == false)
- return false;
+ return false;
+
ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.Name());
return true;
}
bool TryToChangeVer(pkgCache::PkgIterator Pkg,pkgDepCache &Cache,
const char *VerTag,bool IsRel)
{
- pkgVersionMatch Match(VerTag,(IsRel == true?pkgVersionMatch::Release:pkgVersionMatch::Version));
+ pkgVersionMatch Match(VerTag,(IsRel == true?pkgVersionMatch::Release :
+ pkgVersionMatch::Version));
pkgCache::VerIterator Ver = Match.Find(Pkg);
// 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;
// Prepare the cache.
CacheFile Cache;
- if (Cache.Open() == false)
+ if (Cache.BuildCaches() == false)
return false;
if (Failed == true)
// Check if the name is a regex
const char *I;
for (I = S; *I != 0; I++)
- if (*I == '.' || *I == '?' || *I == '*' || *I == '|')
+ if (*I == '?' || *I == '*' || *I == '|' ||
+ *I == '[' || *I == '^' || *I == '$')
break;
if (*I == 0)
return _error->Error(_("Couldn't find package %s"),S);
if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE |
REG_NOSUB)) != 0)
{
- char Error[300];
+ char Error[300];
regerror(Res,&Pattern,Error,sizeof(Error));
return _error->Error(_("Regex compilation error - %s"),Error);
}
if (regexec(&Pattern,Pkg.Name(),0,0,0) != 0)
continue;
+ ioprintf(c1out,_("Note, selecting %s for regex '%s'\n"),
+ Pkg.Name(),S);
+
if (VerTag != 0)
if (TryToChangeVer(Pkg,Cache,VerTag,VerIsRel) == false)
return false;
// 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 ||