pkgCache::PkgIterator pkg = Cache->FindPkg(pkgname, pkgarch);
if(pkg.end() || pkg.VersionList().end())
continue;
- bool const newAuto = (PkgState[pkg->ID].Flags & Flag::Auto);
+ StateCache const &P = PkgState[pkg->ID];
+ bool newAuto = (P.Flags & Flag::Auto);
+ // skip not installed or now-removed ones if requested
+ if (InstalledOnly && (
+ (pkg->CurrentVer == 0 && P.Mode != ModeInstall) ||
+ (pkg->CurrentVer != 0 && P.Mode == ModeDelete)))
+ {
+ // The section is obsolete if it contains no other tag
+ unsigned int const count = section.Count();
+ if (count < 2 ||
+ (count == 2 && section.Exists("Auto-Installed")) ||
+ (count == 3 && section.Exists("Auto-Installed") && section.Exists("Architecture")))
+ continue;
+ else
+ newAuto = false;
+ }
if(_config->FindB("Debug::pkgAutoRemove",false))
std::clog << "Update existing AutoInstall info: "
<< pkg.FullName() << std::endl;
// then write the ones we have not seen yet
std::ostringstream ostr;
for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) {
- if(PkgState[pkg->ID].Flags & Flag::Auto) {
+ StateCache const &P = PkgState[pkg->ID];
+ if(P.Flags & Flag::Auto) {
if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) {
if(debug_autoremove)
std::clog << "Skipping already written " << pkg.FullName() << std::endl;
continue;
}
// skip not installed ones if requested
- if(InstalledOnly && pkg->CurrentVer == 0)
+ if (InstalledOnly && (
+ (pkg->CurrentVer == 0 && P.Mode != ModeInstall) ||
+ (pkg->CurrentVer != 0 && P.Mode == ModeDelete)))
continue;
const char* const pkgarch = pkg.Arch();
if (strcmp(pkgarch, "all") == 0)
if (P.end() == true) continue;
for (VerIterator V = P.VersionList(); V.end() != true; ++V)
{
- // FIXME: String comparison isn't a save indicator!
- if (strcmp(allV.VerStr(),V.VerStr()) != 0)
+ if (allV->Hash != V->Hash ||
+ strcmp(allV.VerStr(),V.VerStr()) != 0)
continue;
unsigned char const CurDepState = VersionState(V.DependsList(),DepInstall,DepInstMin,DepInstPolicy);
if ((CurDepState & DepInstMin) != DepInstMin)
break; // we found the correct version, but it is broken. Better try another arch or later again
+ RemoveSizes(P);
+ RemoveStates(P);
P->CurrentVer = V.Index();
+ PkgState[P->ID].InstallVer = V;
AddStates(P);
Update(P);
AddSizes(P);