diff options
author | Michael Vogt <mvo@debian.org> | 2013-10-22 16:53:32 +0200 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-10-22 16:53:32 +0200 |
commit | f62f17b489405432a3125e51471d8a00e78c5170 (patch) | |
tree | ce2a6e077cb0846e75cbb3d583f4152608100adb /apt-private/private-cachefile.cc | |
parent | 9aa9db9c88fca3a9266427b0d5cc9ad53df7207e (diff) | |
parent | c08cf1dc784a98a253296a51433f6de7d16d3125 (diff) |
Merge branch 'debian/sid' into ubuntu/master
Conflicts:
cmdline/apt-key
configure.ac
debian/apt.auto-removal.sh
debian/changelog
debian/control
debian/rules
po/apt-all.pot
po/ar.po
po/ast.po
po/bg.po
po/bs.po
po/ca.po
po/cs.po
po/cy.po
po/da.po
po/de.po
po/dz.po
po/el.po
po/es.po
po/eu.po
po/fi.po
po/fr.po
po/gl.po
po/hu.po
po/it.po
po/ja.po
po/km.po
po/ko.po
po/ku.po
po/lt.po
po/mr.po
po/nb.po
po/ne.po
po/nl.po
po/nn.po
po/pl.po
po/pt.po
po/pt_BR.po
po/ro.po
po/ru.po
po/sk.po
po/sl.po
po/sv.po
po/th.po
po/tl.po
po/uk.po
po/vi.po
po/zh_CN.po
po/zh_TW.po
Diffstat (limited to 'apt-private/private-cachefile.cc')
-rw-r--r-- | apt-private/private-cachefile.cc | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/apt-private/private-cachefile.cc b/apt-private/private-cachefile.cc new file mode 100644 index 000000000..25f65ef09 --- /dev/null +++ b/apt-private/private-cachefile.cc @@ -0,0 +1,109 @@ +// Include files /*{{{*/ +#include<config.h> + +#include <apt-pkg/algorithms.h> +#include <apt-pkg/error.h> + +#include <cstdlib> + +#include "private-output.h" +#include "private-cachefile.h" + +#include <apti18n.h> + /*}}}*/ + +using namespace std; + +// CacheFile::NameComp - QSort compare by name /*{{{*/ +// --------------------------------------------------------------------- +/* */ +pkgCache *CacheFile::SortCache = 0; +int CacheFile::NameComp(const void *a,const void *b) +{ + if (*(pkgCache::Package **)a == 0 || *(pkgCache::Package **)b == 0) + return *(pkgCache::Package **)a - *(pkgCache::Package **)b; + + const pkgCache::Package &A = **(pkgCache::Package **)a; + const pkgCache::Package &B = **(pkgCache::Package **)b; + + return strcmp(SortCache->StrP + A.Name,SortCache->StrP + B.Name); +} + /*}}}*/ +// CacheFile::Sort - Sort by name /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void CacheFile::Sort() +{ + delete [] List; + 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) + List[I->ID] = I; + + SortCache = *this; + qsort(List,Cache->Head().PackageCount,sizeof(*List),NameComp); +} + /*}}}*/ +// CacheFile::CheckDeps - Open the cache file /*{{{*/ +// --------------------------------------------------------------------- +/* This routine generates the caches and then opens the dependency cache + and verifies that the system is OK. */ +bool CacheFile::CheckDeps(bool AllowBroken) +{ + bool FixBroken = _config->FindB("APT::Get::Fix-Broken",false); + + if (_error->PendingError() == true) + return false; + + // Check that the system is OK + if (DCache->DelCount() != 0 || DCache->InstCount() != 0) + return _error->Error("Internal error, non-zero counts"); + + // Apply corrections for half-installed packages + if (pkgApplyStatus(*DCache) == false) + return false; + + if (_config->FindB("APT::Get::Fix-Policy-Broken",false) == true) + { + FixBroken = true; + if ((DCache->PolicyBrokenCount() > 0)) + { + // upgrade all policy-broken packages with ForceImportantDeps=True + for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); ++I) + if ((*DCache)[I].NowPolicyBroken() == true) + DCache->MarkInstall(I,true,0, false, true); + } + } + + // Nothing is broken + if (DCache->BrokenCount() == 0 || AllowBroken == true) + return true; + + // Attempt to fix broken things + if (FixBroken == true) + { + c1out << _("Correcting dependencies...") << flush; + if (pkgFixBroken(*DCache) == false || DCache->BrokenCount() != 0) + { + c1out << _(" failed.") << endl; + ShowBroken(c1out,*this,true); + + return _error->Error(_("Unable to correct dependencies")); + } + if (pkgMinimizeUpgrade(*DCache) == false) + return _error->Error(_("Unable to minimize the upgrade set")); + + c1out << _(" Done") << endl; + } + else + { + c1out << _("You might want to run 'apt-get -f install' to correct these.") << endl; + ShowBroken(c1out,*this,true); + + return _error->Error(_("Unmet dependencies. Try using -f.")); + } + + return true; +} + /*}}}*/ |