From: David Kalnischkies Date: Wed, 9 Jun 2010 08:50:32 +0000 (+0200) Subject: * apt-pkg/pkgcache.h: X-Git-Tag: 0.8.0~9^2~39^2~1 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/1aa9b2974d33015102224ffb738b2e8e0a4bcb42?ds=inline;hp=-c * apt-pkg/pkgcache.h: - switch {,Install-}Size to unsigned long long - deal with long long, not with int to remove 2GB Limit (LP: #250909) - deprecate AddSize with Multiplier as it is unused and switch to boolean instead to handle the sizes more gracefully. - switch i{Download,Usr}Size from double to (un)signed long long * cmdline/apt-get.cc: - use unsigned long long instead of double to store values it gets --- 1aa9b2974d33015102224ffb738b2e8e0a4bcb42 diff --combined apt-pkg/depcache.cc index 6c73b9cfd,786b20ec0..3ae5f5953 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@@ -165,7 -165,7 +165,7 @@@ bool pkgDepCache::Init(OpProgress *Prog bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/ { FileFd state_file; - string const state = _config->FindDir("Dir::State") + "extended_states"; + string const state = _config->FindFile("Dir::State::extended_states"); if(FileExists(state)) { state_file.Open(state, FileFd::ReadOnly); int const file_size = state_file.Size(); @@@ -222,7 -222,7 +222,7 @@@ bool pkgDepCache::writeStateFile(OpProg std::clog << "pkgDepCache::writeStateFile()" << std::endl; FileFd StateFile; - string const state = _config->FindDir("Dir::State") + "extended_states"; + string const state = _config->FindFile("Dir::State::extended_states"); // if it does not exist, create a empty one if(!FileExists(state)) @@@ -407,8 -407,11 +407,11 @@@ bool pkgDepCache::CheckDep(DepIterator /*}}}*/ // DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/ // --------------------------------------------------------------------- - /* Call with Mult = -1 to preform the inverse opration */ - void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult) + /* Call with Mult = -1 to preform the inverse opration + The Mult increases the complexity of the calulations here and is unused - + or do we really have a usecase for removing the size of a package two + times? So let us replace it with a simple bool and be done with it… */ + __deprecated void pkgDepCache::AddSizes(const PkgIterator &Pkg,signed long Mult) { StateCache &P = PkgState[Pkg->ID]; @@@ -422,8 -425,8 +425,8 @@@ // Compute the size data if (P.NewInstall() == true) { - iUsrSize += (signed)(Mult*P.InstVerIter(*this)->InstalledSize); - iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size); + iUsrSize += (signed long long)(Mult*P.InstVerIter(*this)->InstalledSize); + iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size); return; } @@@ -432,9 -435,9 +435,9 @@@ (P.InstallVer != (Version *)Pkg.CurrentVer() || (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0) { - iUsrSize += (signed)(Mult*((signed)P.InstVerIter(*this)->InstalledSize - - (signed)Pkg.CurrentVer()->InstalledSize)); - iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size); + iUsrSize += (signed long long)(Mult*((signed long long)P.InstVerIter(*this)->InstalledSize - + (signed long long)Pkg.CurrentVer()->InstalledSize)); + iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size); return; } @@@ -442,14 -445,80 +445,80 @@@ if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack && P.Delete() == false) { - iDownloadSize += (signed)(Mult*P.InstVerIter(*this)->Size); + iDownloadSize += (signed long long)(Mult*P.InstVerIter(*this)->Size); return; } // Removing if (Pkg->CurrentVer != 0 && P.InstallVer == 0) { - iUsrSize -= (signed)(Mult*Pkg.CurrentVer()->InstalledSize); + iUsrSize -= (signed long long)(Mult*Pkg.CurrentVer()->InstalledSize); + return; + } + } + /*}}}*/ + // DepCache::AddSizes - Add the packages sizes to the counters /*{{{*/ + // --------------------------------------------------------------------- + /* Call with Inverse = true to preform the inverse opration */ + void pkgDepCache::AddSizes(const PkgIterator &Pkg, bool const &Inverse) + { + StateCache &P = PkgState[Pkg->ID]; + + if (Pkg->VersionList == 0) + return; + + if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && + P.Keep() == true) + return; + + // Compute the size data + if (P.NewInstall() == true) + { + if (Inverse == false) { + iUsrSize += P.InstVerIter(*this)->InstalledSize; + iDownloadSize += P.InstVerIter(*this)->Size; + } else { + iUsrSize -= P.InstVerIter(*this)->InstalledSize; + iDownloadSize -= P.InstVerIter(*this)->Size; + } + return; + } + + // Upgrading + if (Pkg->CurrentVer != 0 && + (P.InstallVer != (Version *)Pkg.CurrentVer() || + (P.iFlags & ReInstall) == ReInstall) && P.InstallVer != 0) + { + if (Inverse == false) { + iUsrSize -= Pkg.CurrentVer()->InstalledSize; + iUsrSize += P.InstVerIter(*this)->InstalledSize; + iDownloadSize += P.InstVerIter(*this)->Size; + } else { + iUsrSize -= P.InstVerIter(*this)->InstalledSize; + iUsrSize += Pkg.CurrentVer()->InstalledSize; + iDownloadSize -= P.InstVerIter(*this)->Size; + } + return; + } + + // Reinstall + if (Pkg.State() == pkgCache::PkgIterator::NeedsUnpack && + P.Delete() == false) + { + if (Inverse == false) + iDownloadSize += P.InstVerIter(*this)->Size; + else + iDownloadSize -= P.InstVerIter(*this)->Size; + return; + } + + // Removing + if (Pkg->CurrentVer != 0 && P.InstallVer == 0) + { + if (Inverse == false) + iUsrSize -= Pkg.CurrentVer()->InstalledSize; + else + iUsrSize += Pkg.CurrentVer()->InstalledSize; return; } } @@@ -806,7 -875,7 +875,7 @@@ void pkgDepCache::Update(OpProgress *Pr a bit we increase with a kill, but we should do something more clever… */ while(recheck.empty() == false) for (std::set::const_iterator p = recheck.begin(); - p != recheck.end(); ++p) { + p != recheck.end();) { if (Prog != 0 && Done%20 == 0) Prog->Progress(Done); PkgIterator P = PkgIterator(*Cache, Cache->PkgP + *p); @@@ -814,7 -883,7 +883,7 @@@ ++killed; ++Done; } - recheck.erase(p); + recheck.erase(p++); } /* Okay, we have killed a great amount of pseudopackages - @@@ -849,7 -918,7 +918,7 @@@ unsigned long const G = *g; recheck.erase(g); if (unlikely(ReInstallPseudoForGroup(G, recheck) == false)) - _error->Warning(_("Internal error, group '%s' has no installable pseudo package"), GrpIterator(*Cache, Cache->GrpP + *g).Name()); + _error->Warning(_("Internal error, group '%s' has no installable pseudo package"), GrpIterator(*Cache, Cache->GrpP + G).Name()); } } @@@ -1638,11 -1707,8 +1707,11 @@@ bool pkgDepCache::MarkRequired(InRootSe { if(!(PkgState[p->ID].Flags & Flag::Auto) || (p->Flags & Flag::Essential) || - userFunc.InRootSet(p)) - + userFunc.InRootSet(p) || + // be nice even then a required package violates the policy (#583517) + // and do the full mark process also for required packages + (p.CurrentVer().end() != true && + p.CurrentVer()->Priority == pkgCache::State::Required)) { // the package is installed (and set to keep) if(PkgState[p->ID].Keep() && !p.CurrentVer().end()) @@@ -1719,6 -1785,10 +1788,6 @@@ void pkgDepCache::MarkPackage(const pkg // If the version belongs to a Multi-Arch all package // we will mark all others in this Group with this version also - // Beware: We compare versions here the lazy way: string comparision - // this is bad if multiple repositories provide different versions - // of the package with an identical version number - but even in this - // case the dependencies are likely the same. if (ver->MultiArch == pkgCache::Version::All && strcmp(ver.Arch(true), "all") == 0) { @@@ -1730,8 -1800,7 +1799,8 @@@ for (VerIterator V = P.VersionList(); V.end() != true; ++V) { - if (strcmp(VerStr, V.VerStr()) != 0) + if (ver->Hash != V->Hash || + strcmp(VerStr, V.VerStr()) != 0) continue; MarkPackage(P, V, follow_recommends, follow_suggests); break; diff --combined cmdline/apt-get.cc index c70dd56ac,661ca6147..2340a7e85 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@@ -40,8 -40,7 +40,8 @@@ #include #include #include - +#include + #include #include @@@ -91,14 -90,14 +91,14 @@@ class CacheFile : public pkgCacheFil bool BuildCaches(bool WithLock = true) { OpTextProgress Prog(*_config); - if (pkgCacheFile::BuildCaches(Prog,WithLock) == false) + if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false) return false; return true; } bool Open(bool WithLock = true) { OpTextProgress Prog(*_config); - if (pkgCacheFile::Open(Prog,WithLock) == false) + if (pkgCacheFile::Open(&Prog,WithLock) == false) return false; Sort(); @@@ -838,9 -837,9 +838,9 @@@ bool InstallPackages(CacheFile &Cache,b return false; // Display statistics - double FetchBytes = Fetcher.FetchNeeded(); - double FetchPBytes = Fetcher.PartialPresent(); - double DebBytes = Fetcher.TotalNeeded(); + unsigned long long FetchBytes = Fetcher.FetchNeeded(); + unsigned long long FetchPBytes = Fetcher.PartialPresent(); + unsigned long long DebBytes = Fetcher.TotalNeeded(); if (DebBytes != Cache->DebSize()) { c0out << DebBytes << ',' << Cache->DebSize() << endl; @@@ -1781,24 -1780,51 +1781,24 @@@ bool DoInstall(CommandLine &CmdL Packages++; if (Pkg.end() == true) { - // Check if the name is a regex - const char *I; - for (I = S; *I != 0; I++) - if (*I == '?' || *I == '*' || *I == '|' || - *I == '[' || *I == '^' || *I == '$') - break; - if (*I == 0) + APT::PackageSet pkgset = APT::PackageSet::FromRegEx(Cache, S, c1out); + if (pkgset.empty() == true) return _error->Error(_("Couldn't find package %s"),S); // Regexs must always be confirmed ExpectedInst += 1000; - - // Compile the regex pattern - regex_t Pattern; - int Res; - if ((Res = regcomp(&Pattern,S,REG_EXTENDED | REG_ICASE | - REG_NOSUB)) != 0) - { - char Error[300]; - regerror(Res,&Pattern,Error,sizeof(Error)); - return _error->Error(_("Regex compilation error - %s"),Error); - } - - // Run over the matches + bool Hit = false; - for (pkgCache::GrpIterator Grp = Cache->GrpBegin(); Grp.end() == false; ++Grp) + for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) { - if (regexec(&Pattern,Grp.Name(),0,0,0) != 0) - continue; - Pkg = Grp.FindPkg("native"); - if (unlikely(Pkg.end() == true)) - 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; - + Hit |= TryToInstall(Pkg,Cache,Fix,Remove,BrokenFix, ExpectedInst,false); } - regfree(&Pattern); - + if (Hit == false) return _error->Error(_("Couldn't find package %s"),S); } @@@ -2336,9 -2362,9 +2336,9 @@@ bool DoSource(CommandLine &CmdL } // Display statistics - double FetchBytes = Fetcher.FetchNeeded(); - double FetchPBytes = Fetcher.PartialPresent(); - double DebBytes = Fetcher.TotalNeeded(); + unsigned long long FetchBytes = Fetcher.FetchNeeded(); + unsigned long long FetchPBytes = Fetcher.PartialPresent(); + unsigned long long DebBytes = Fetcher.TotalNeeded(); // Check for enough free space struct statvfs Buf; diff --combined debian/changelog index 21093b056,cad4bf990..142d8359a --- a/debian/changelog +++ b/debian/changelog @@@ -1,47 -1,17 +1,55 @@@ apt (0.7.26~exp6) UNRELEASED; urgency=low [ David Kalnischkies ] + * apt-pkg/deb/dpkgpm.cc: + - write Disappeared also to the history.log + - forward manual-installed bit on package disappearance + * apt-pkg/deb/debsystem.cc: + - add better config item for extended_states file + * apt-pkg/pkgcache.h: + - switch {,Install-}Size to unsigned long long * apt-pkg/depcache.cc: + - do the autoremove mark process also for required packages to handle + these illegally depending on lower priority packages (Closes: #583517) + - try harder to find the other pseudo versions for autoremove multiarch + - correct "Dangerous iterator usage" pointed out by cppcheck + - deal with long long, not with int to remove 2GB Limit (LP: #250909) + - deprecate AddSize with Multiplier as it is unused and switch to + boolean instead to handle the sizes more gracefully. + - switch i{Download,Usr}Size from double to (un)signed long long + * apt-pkg/aptconfiguration.cc: + - remove duplicate architectures in getArchitectures() + * apt-pkg/indexrecords.{cc,h}: + - add a constant Exists check for MetaKeys + * apt-pkg/acquire-item.cc: + - do not try PDiff if it is not listed in the Meta file + * apt-pkg/cacheiterator.h: + - let pkgCache::Iterator inherent std::iterator + * ftparchive/writer.h: + - add a virtual destructor to FTWScanner class (for cppcheck) + * apt-pkg/cacheset.{cc,h}: + - add simple wrapper around std::set for cache structures + - move regex magic from apt-get to new FromRegEx method + - move cmdline parsing from apt-cache to new FromCommandLine method + - support special release-modifier 'installed' and 'candidate' + * apt-pkg/contrib/cmdline.cc: + - fix segfault in SaveInConfig caused by writing over char[] sizes + * apt-pkg/pkgcache.cc: + - get the best matching arch package from a group with FindPreferredPkg + * cmdline/apt-cache.cc: + - make the search multiarch compatible by using GrpIterator instead + - use pkgCacheFile and the new CacheSets all over the place + - add --target-release option (Closes: #115520) + - accept pkg/release and pkg=version in show and co. (Closes: #236270) + - accept package versions in the unmet command + * cmdline/apt-get.cc: + - use unsigned long long instead of double to store values it gets + * apt-pkg/cachefile.{cc,h}: + - split Open() into submethods to be able to build only parts + - make the OpProgress optional in the Cache buildprocess + - store also the SourceList we use internally for export - -- David Kalnischkies Sat, 05 Jun 2010 14:39:58 +0200 - -- David Kalnischkies Thu, 03 Jun 2010 10:46:46 +0200 ++ -- David Kalnischkies Wed, 09 Jun 2010 10:50:12 +0200 apt (0.7.26~exp5) experimental; urgency=low