summaryrefslogtreecommitdiff
path: root/cmdline/apt-get.cc
diff options
context:
space:
mode:
Diffstat (limited to 'cmdline/apt-get.cc')
-rw-r--r--cmdline/apt-get.cc87
1 files changed, 44 insertions, 43 deletions
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index a81e829e8..d8f207f0a 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -25,8 +25,7 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
+#include <config.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/error.h>
@@ -46,9 +45,6 @@
#include <apt-pkg/md5.h>
#include <apt-pkg/versionmatch.h>
-#include <config.h>
-#include <apti18n.h>
-
#include "acqprogress.h"
#include <set>
@@ -68,8 +64,7 @@
#include <sys/wait.h>
#include <sstream>
-#define statfs statfs64
-#define statvfs statvfs64
+#include <apti18n.h>
/*}}}*/
#define RAMFS_MAGIC 0x858458f6
@@ -368,7 +363,7 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now)
if (Start == End)
break;
- Start++;
+ ++Start;
}
}
}
@@ -542,7 +537,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache)
continue;
// Print out any essential package depenendents that are to be removed
- for (pkgCache::DepIterator D = I.CurrentVer().DependsList(); D.end() == false; D++)
+ for (pkgCache::DepIterator D = I.CurrentVer().DependsList(); D.end() == false; ++D)
{
// Skip everything but depends
if (D->Type != pkgCache::Dep::PreDepends &&
@@ -579,7 +574,7 @@ void Stats(ostream &out,pkgDepCache &Dep)
unsigned long Downgrade = 0;
unsigned long Install = 0;
unsigned long ReInstall = 0;
- for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; I++)
+ for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; ++I)
{
if (Dep[I].NewInstall() == true)
Install++;
@@ -671,7 +666,7 @@ public:
}
// if we found no candidate which provide this package, show non-candidates
if (provider == 0)
- for (I = Pkg.ProvidesList(); I.end() == false; I++)
+ for (I = Pkg.ProvidesList(); I.end() == false; ++I)
out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr()
<< _(" [Not candidate version]") << endl;
else
@@ -687,7 +682,7 @@ public:
SPtrArray<bool> Seen = new bool[Cache.GetPkgCache()->Head().PackageCount];
memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen));
for (pkgCache::DepIterator Dep = Pkg.RevDependsList();
- Dep.end() == false; Dep++) {
+ Dep.end() == false; ++Dep) {
if (Dep->Type != pkgCache::Dep::Replaces)
continue;
if (Seen[Dep.ParentPkg()->ID] == true)
@@ -874,9 +869,7 @@ struct TryToInstall {
struct TryToRemove {
pkgCacheFile* Cache;
pkgProblemResolver* Fix;
- bool FixBroken;
bool PurgePkgs;
- unsigned long AutoMarkChanged;
TryToRemove(pkgCacheFile &Cache, pkgProblemResolver *PM) : Cache(&Cache), Fix(PM),
PurgePkgs(_config->FindB("APT::Get::Purge", false)) {};
@@ -928,7 +921,7 @@ void CacheFile::Sort()
List = new pkgCache::Package *[Cache->Head().PackageCount];
memset(List,0,sizeof(*List)*Cache->Head().PackageCount);
pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; I++)
+ for (;I.end() != true; ++I)
List[I->ID] = I;
SortCache = *this;
@@ -960,7 +953,7 @@ bool CacheFile::CheckDeps(bool AllowBroken)
if ((DCache->PolicyBrokenCount() > 0))
{
// upgrade all policy-broken packages with ForceImportantDeps=True
- for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++)
+ for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); ++I)
if ((*DCache)[I].NowPolicyBroken() == true)
DCache->MarkInstall(I,true,0, false, true);
}
@@ -1051,7 +1044,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
if (_config->FindB("APT::Get::Purge",false) == true)
{
pkgCache::PkgIterator I = Cache->PkgBegin();
- for (; I.end() == false; I++)
+ for (; I.end() == false; ++I)
{
if (I.Purge() == false && Cache[I].Mode == pkgDepCache::ModeDelete)
Cache->MarkDelete(I,true);
@@ -1245,7 +1238,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
if (_config->FindB("APT::Get::Print-URIs") == true)
{
pkgAcquire::UriIterator I = Fetcher.UriBegin();
- for (; I != Fetcher.UriEnd(); I++)
+ for (; I != Fetcher.UriEnd(); ++I)
cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
return true;
@@ -1269,7 +1262,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
{
if ((*I)->Local == true)
{
- I++;
+ ++I;
continue;
}
@@ -1289,7 +1282,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,
// Print out errors
bool Failed = false;
- for (pkgAcquire::ItemIterator 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)
@@ -1449,7 +1442,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
// 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++)
+ for (pkgCache::VerIterator Ver = Pkg.VersionList();; ++Ver)
{
// try first only exact matches, later fuzzy matches
if (Ver.end() == true)
@@ -1470,7 +1463,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs,
continue;
for (pkgCache::VerFileIterator VF = Ver.FileList();
- VF.end() == false; VF++)
+ 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)
@@ -1622,7 +1615,7 @@ bool DoUpdate(CommandLine &CmdL)
return false;
pkgAcquire::UriIterator I = Fetcher.UriBegin();
- for (; I != Fetcher.UriEnd(); I++)
+ for (; I != Fetcher.UriEnd(); ++I)
cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
return true;
@@ -1632,7 +1625,8 @@ bool DoUpdate(CommandLine &CmdL)
if (_config->FindB("APT::Get::Download",true) == true)
ListUpdate(Stat, *List);
- // Rebuild the cache.
+ // Rebuild the cache.
+ pkgCacheFile::RemoveCaches();
if (Cache.BuildCaches() == false)
return false;
@@ -2007,7 +2001,7 @@ bool DoInstall(CommandLine &CmdL)
if(Start.TargetPkg().ProvidesList() != 0)
{
pkgCache::PrvIterator I = Start.TargetPkg().ProvidesList();
- for (; I.end() == false; I++)
+ for (; I.end() == false; ++I)
{
pkgCache::PkgIterator Pkg = I.OwnerPkg();
if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer() &&
@@ -2030,7 +2024,7 @@ bool DoInstall(CommandLine &CmdL)
if (Start >= End)
break;
- Start++;
+ ++Start;
}
if(foundInstalledInOrGroup == false)
@@ -2144,7 +2138,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// Install everything with the install flag set
pkgCache::PkgIterator I = Cache->PkgBegin();
- for (;I.end() != true; I++)
+ for (;I.end() != true; ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -2154,7 +2148,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
/* Now install their deps too, if we do this above then order of
the status file is significant for | groups */
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (I = Cache->PkgBegin();I.end() != true; ++I)
{
/* Install the package only if it is a new install, the autoupgrader
will deal with the rest */
@@ -2163,7 +2157,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
}
// Apply erasures now, they override everything else.
- for (I = Cache->PkgBegin();I.end() != true; I++)
+ for (I = Cache->PkgBegin();I.end() != true; ++I)
{
// Remove packages
if (I->SelectedState == pkgCache::State::DeInstall ||
@@ -2180,7 +2174,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
// Hold back held packages.
if (_config->FindB("APT::Ignore-Hold",false) == false)
{
- for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; I++)
+ for (pkgCache::PkgIterator I = Cache->PkgBegin(); I.end() == false; ++I)
{
if (I->SelectedState == pkgCache::State::Hold)
{
@@ -2212,10 +2206,14 @@ bool DoDSelectUpgrade(CommandLine &CmdL)
/* */
bool DoClean(CommandLine &CmdL)
{
+ std::string const archivedir = _config->FindDir("Dir::Cache::archives");
+ std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache");
+ std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache");
+
if (_config->FindB("APT::Get::Simulate") == true)
{
- cout << "Del " << _config->FindDir("Dir::Cache::archives") << "* " <<
- _config->FindDir("Dir::Cache::archives") << "partial/*" << endl;
+ cout << "Del " << archivedir << "* " << archivedir << "partial/*"<< endl
+ << "Del " << pkgcache << " " << srcpkgcache << endl;
return true;
}
@@ -2223,14 +2221,17 @@ bool DoClean(CommandLine &CmdL)
FileFd Lock;
if (_config->FindB("Debug::NoLocking",false) == false)
{
- Lock.Fd(GetLock(_config->FindDir("Dir::Cache::Archives") + "lock"));
+ Lock.Fd(GetLock(archivedir + "lock"));
if (_error->PendingError() == true)
return _error->Error(_("Unable to lock the download directory"));
}
pkgAcquire Fetcher;
- Fetcher.Clean(_config->FindDir("Dir::Cache::archives"));
- Fetcher.Clean(_config->FindDir("Dir::Cache::archives") + "partial/");
+ Fetcher.Clean(archivedir);
+ Fetcher.Clean(archivedir + "partial/");
+
+ pkgCacheFile::RemoveCaches();
+
return true;
}
/*}}}*/
@@ -2328,7 +2329,7 @@ bool DoDownload(CommandLine &CmdL)
if (_config->FindB("APT::Get::Print-URIs") == true)
{
pkgAcquire::UriIterator I = Fetcher.UriBegin();
- for (; I != Fetcher.UriEnd(); I++)
+ for (; I != Fetcher.UriEnd(); ++I)
cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
return true;
@@ -2446,7 +2447,7 @@ bool DoSource(CommandLine &CmdL)
// Load them into the fetcher
for (vector<pkgSrcRecords::File>::const_iterator I = Lst.begin();
- I != Lst.end(); I++)
+ I != Lst.end(); ++I)
{
// Try to guess what sort of file it is we are getting.
if (I->Type == "dsc")
@@ -2548,7 +2549,7 @@ bool DoSource(CommandLine &CmdL)
if (_config->FindB("APT::Get::Print-URIs") == true)
{
pkgAcquire::UriIterator I = Fetcher.UriBegin();
- for (; I != Fetcher.UriEnd(); I++)
+ for (; I != Fetcher.UriEnd(); ++I)
cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' <<
I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl;
delete[] Dsc;
@@ -2564,7 +2565,7 @@ bool DoSource(CommandLine &CmdL)
// Print error messages
bool Failed = false;
- for (pkgAcquire::ItemIterator 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)
@@ -2593,7 +2594,7 @@ bool DoSource(CommandLine &CmdL)
if (Process == 0)
{
bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false);
- for (unsigned I = 0; I != J; I++)
+ for (unsigned I = 0; I != J; ++I)
{
string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str());
@@ -2742,7 +2743,7 @@ bool DoBuildDep(CommandLine &CmdL)
BuildDeps.push_back(rec);
}
- if (BuildDeps.size() == 0)
+ if (BuildDeps.empty() == true)
{
ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str());
continue;
@@ -2752,7 +2753,7 @@ bool DoBuildDep(CommandLine &CmdL)
vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
pkgProblemResolver Fix(Cache);
bool skipAlternatives = false; // skip remaining alternatives in an or group
- for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+ for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D)
{
bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or);
@@ -2931,7 +2932,7 @@ bool DoBuildDep(CommandLine &CmdL)
* installed
*/
pkgCache::PrvIterator Prv = Pkg.ProvidesList();
- for (; Prv.end() != true; Prv++)
+ for (; Prv.end() != true; ++Prv)
{
if (_config->FindB("Debug::BuildDeps",false) == true)
cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl;