##################################################################### */
/*}}}*/
// Include Files /*{{{*/
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/cmndline.h>
#include <apt-pkg/init.h>
#include <apt-pkg/srcrecords.h>
#include <apt-pkg/version.h>
#include <apt-pkg/cachefile.h>
+#include <apt-pkg/cacheset.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/md5.h>
#include <apt-pkg/versionmatch.h>
#include <apti18n.h>
#include "acqprogress.h"
-#include "cacheset.h"
#include <set>
#include <locale.h>
#include <regex.h>
#include <sys/wait.h>
#include <sstream>
+
+#define statfs statfs64
+#define statvfs statvfs64
/*}}}*/
#define RAMFS_MAGIC 0x858458f6
pkgProblemResolver* Fix;
bool FixBroken;
unsigned long AutoMarkChanged;
+ APT::PackageSet doAutoInstallLater;
TryToInstall(pkgCacheFile &Cache, pkgProblemResolver &PM, bool const &FixBroken) : Cache(&Cache), Fix(&PM),
FixBroken(FixBroken), AutoMarkChanged(0) {};
void operator() (pkgCache::VerIterator const &Ver) {
pkgCache::PkgIterator Pkg = Ver.ParentPkg();
+
Cache->GetDepCache()->SetCandidateVersion(Ver);
pkgDepCache::StateCache &State = (*Cache)[Pkg];
// Install it with autoinstalling enabled (if we not respect the minial
// required deps or the policy)
- if ((State.InstBroken() == true || State.InstPolicyBroken() == true) && FixBroken == false)
- Cache->GetDepCache()->MarkInstall(Pkg,true);
+ if (FixBroken == false)
+ doAutoInstallLater.insert(Pkg);
}
// see if we need to fix the auto-mark flag
AutoMarkChanged++;
}
}
+
+ void doAutoInstall() {
+ for (APT::PackageSet::const_iterator P = doAutoInstallLater.begin();
+ P != doAutoInstallLater.end(); ++P) {
+ pkgDepCache::StateCache &State = (*Cache)[P];
+ if (State.InstBroken() == false && State.InstPolicyBroken() == false)
+ continue;
+ Cache->GetDepCache()->MarkInstall(P, true);
+ }
+ doAutoInstallLater.clear();
+ }
};
/*}}}*/
// TryToRemove - Mark a package for removal /*{{{*/
pkgCacheFile* Cache;
pkgProblemResolver* Fix;
bool FixBroken;
+ bool PurgePkgs;
unsigned long AutoMarkChanged;
- TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM) {};
+ TryToRemove(pkgCacheFile &Cache, pkgProblemResolver &PM) : Cache(&Cache), Fix(&PM),
+ PurgePkgs(_config->FindB("APT::Get::Purge", false)) {};
void operator() (pkgCache::VerIterator const &Ver)
{
Fix->Protect(Pkg);
Fix->Remove(Pkg);
- if (Pkg->CurrentVer == 0)
+ if ((Pkg->CurrentVer == 0 && PurgePkgs == false) ||
+ (PurgePkgs == true && Pkg->CurrentState == pkgCache::State::NotInstalled))
ioprintf(c1out,_("Package %s is not installed, so not removed\n"),Pkg.FullName(true).c_str());
else
- Cache->GetDepCache()->MarkDelete(Pkg,_config->FindB("APT::Get::Purge",false));
+ Cache->GetDepCache()->MarkDelete(Pkg, PurgePkgs);
}
};
/*}}}*/
return false;
// Read the source list
- pkgSourceList List;
- if (List.ReadMainList() == false)
- return _error->Error(_("The list of sources could not be read."));
+ if (Cache.BuildSourceList() == false)
+ return false;
+ pkgSourceList *List = Cache.GetSourceList();
// Create the package manager and prepare to download
SPtr<pkgPackageManager> PM= _system->CreatePM(Cache);
- if (PM->GetArchives(&Fetcher,&List,&Recs) == false ||
+ if (PM->GetArchives(&Fetcher,List,&Recs) == false ||
_error->PendingError() == true)
return false;
// Reload the fetcher object and loop again for media swapping
Fetcher.Shutdown();
- if (PM->GetArchives(&Fetcher,&List,&Recs) == false)
+ if (PM->GetArchives(&Fetcher,List,&Recs) == false)
return false;
_system->Lock();
} else if (Cache[Pkg].CandidateVer != 0) {
TryToInstall InstallAction(Cache, Fix, BrokenFix);
InstallAction(Cache[Pkg].CandidateVerIter(Cache));
+ InstallAction.doAutoInstall();
} else
return AllowFail;
{
if (CmdL.FileSize() != 1)
return _error->Error(_("The update command takes no arguments"));
-
+
+ CacheFile Cache;
+
// Get the source list
- pkgSourceList List;
- if (List.ReadMainList() == false)
+ if (Cache.BuildSourceList() == false)
return false;
+ pkgSourceList *List = Cache.GetSourceList();
// Create the progress
AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0));
// Populate it with the source selection and get all Indexes
// (GetAll=true)
- if (List.GetIndexes(&Fetcher,true) == false)
+ if (List->GetIndexes(&Fetcher,true) == false)
return false;
pkgAcquire::UriIterator I = Fetcher.UriBegin();
}
// do the work
- CacheFile Cache;
if (_config->FindB("APT::Get::Download",true) == true)
- ListUpdate(Stat, List);
+ ListUpdate(Stat, *List);
// Rebuild the cache.
if (Cache.BuildCaches() == false)
if (doAutoRemove == false && (autoremovelist.empty() == false || autoRemoveCount != 0))
{
if (smallList == false)
- ShowList(c1out, P_("The following package is automatically installed and is no longer required:",
+ ShowList(c1out, P_("The following package was automatically installed and is no longer required:",
"The following packages were automatically installed and are no longer required:",
autoRemoveCount), autoremovelist, autoremoveversions);
else
for (unsigned short i = 0; order[i] != 0; ++i)
{
- if (order[i] == MOD_INSTALL)
+ if (order[i] == MOD_INSTALL) {
InstallAction = std::for_each(verset[MOD_INSTALL].begin(), verset[MOD_INSTALL].end(), InstallAction);
+ InstallAction.doAutoInstall();
+ }
else if (order[i] == MOD_REMOVE)
RemoveAction = std::for_each(verset[MOD_REMOVE].begin(), verset[MOD_REMOVE].end(), RemoveAction);
}
return _error->Error(_("Must specify at least one package to fetch source for"));
// Read the source list
- pkgSourceList List;
- if (List.ReadMainList() == false)
- return _error->Error(_("The list of sources could not be read."));
+ if (Cache.BuildSourceList() == false)
+ return false;
+ pkgSourceList *List = Cache.GetSourceList();
// Create the text record parsers
pkgRecords Recs(Cache);
- pkgSrcRecords SrcRecs(List);
+ pkgSrcRecords SrcRecs(*List);
if (_error->PendingError() == true)
return false;
return _error->Error(_("Must specify at least one package to check builddeps for"));
// Read the source list
- pkgSourceList List;
- if (List.ReadMainList() == false)
- return _error->Error(_("The list of sources could not be read."));
+ if (Cache.BuildSourceList() == false)
+ return false;
+ pkgSourceList *List = Cache.GetSourceList();
// Create the text record parsers
pkgRecords Recs(Cache);
- pkgSrcRecords SrcRecs(List);
+ pkgSrcRecords SrcRecs(*List);
if (_error->PendingError() == true)
return false;
return false;
unsigned J = 0;
+ bool const StripMultiArch = APT::Configuration::getArchitectures().size() <= 1;
for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++)
{
string Src;
// Process the build-dependencies
vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
- if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only",true)) == false)
+ if (Last->BuildDepends(BuildDeps, _config->FindB("APT::Get::Arch-Only", false), StripMultiArch) == false)
return _error->Error(_("Unable to get build-dependency information for %s"),Src.c_str());
// Also ensure that build-essential packages are present
return true;
}
/*}}}*/
-// GetInitialize - Initialize things for apt-get /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-void GetInitialize()
-{
- _config->Set("quiet",0);
- _config->Set("help",false);
- _config->Set("APT::Get::Download-Only",false);
- _config->Set("APT::Get::Simulate",false);
- _config->Set("APT::Get::Assume-Yes",false);
- _config->Set("APT::Get::Fix-Broken",false);
- _config->Set("APT::Get::Force-Yes",false);
- _config->Set("APT::Get::List-Cleanup",true);
- _config->Set("APT::Get::AutomaticRemove",false);
-}
- /*}}}*/
// SigWinch - Window size change signal handler /*{{{*/
// ---------------------------------------------------------------------
/* */