From: David Kalnischkies Date: Tue, 13 Sep 2011 15:52:22 +0000 (+0200) Subject: merge with debian/experimental X-Git-Tag: 0.9.0~57^2~1 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/74b220028595342028e3309002e4ec359af328f9?ds=inline;hp=-c merge with debian/experimental --- 74b220028595342028e3309002e4ec359af328f9 diff --combined apt-pkg/acquire-item.cc index d798c7107,223303ea8..9433e5c4a --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@@ -13,8 -13,6 +13,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -26,6 -24,8 +26,6 @@@ #include #include -#include - #include #include #include @@@ -33,8 -33,6 +33,8 @@@ #include #include #include + +#include /*}}}*/ using namespace std; @@@ -683,17 -681,17 +683,17 @@@ bool pkgAcqIndexDiffs::QueueNextDiff( // remove all patches until the next matching patch is found // this requires the Index file to be ordered for(vector::iterator I=available_patches.begin(); - available_patches.size() > 0 && + available_patches.empty() == false && I != available_patches.end() && - (*I).sha1 != local_sha1; - I++) + I->sha1 != local_sha1; + ++I) { available_patches.erase(I); } // error checking and falling back if no patch was found - if(available_patches.size() == 0) - { + if(available_patches.empty() == true) + { Failed("", NULL); return false; } @@@ -758,7 -756,7 +758,7 @@@ void pkgAcqIndexDiffs::Done(string Mess chmod(FinalFile.c_str(),0644); // see if there is more to download - if(available_patches.size() > 0) { + if(available_patches.empty() == false) { new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc, ExpectedHash, ServerSha1, available_patches); return Finish(); @@@ -810,6 -808,13 +810,13 @@@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Ow if (CompressionExtension.empty() == false) CompressionExtension.erase(CompressionExtension.end()-1); + // only verify non-optional targets, see acquire-item.h for a FIXME + // to make this more flexible + if (Target->IsOptional()) + Verify = false; + else + Verify = true; + Init(Target->URI, Target->Description, Target->ShortDesc); } /*}}}*/ @@@ -907,6 -912,7 +914,7 @@@ void pkgAcqIndex::Done(string Message,u /* Verify the index file for correctness (all indexes must * have a Package field) (LP: #346386) (Closes: #627642) */ + if (Verify == true) { FileFd fd(DestFile, FileFd::ReadOnly); pkgTagSection sec; @@@ -1260,8 -1266,9 +1268,9 @@@ void pkgAcqMetaIndex::Done(string Messa if (SigFile == "") { // There was no signature file, so we are finished. Download - // the indexes without verification. - QueueIndexes(false); + // the indexes and do only hashsum verification + MetaIndexParser->Load(DestFile); + QueueIndexes(true); } else { @@@ -1376,7 -1383,7 +1385,7 @@@ void pkgAcqMetaIndex::QueueIndexes(boo #endif for (vector ::const_iterator Target = IndexTargets->begin(); Target != IndexTargets->end(); - Target++) + ++Target) { HashString ExpectedIndexHash; if (verify) @@@ -1398,6 -1405,7 +1407,7 @@@ { std::cerr << "Queueing: " << (*Target)->URI << std::endl; std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl; + std::cerr << "For: " << Record->MetaKeyFilename << std::endl; } if (ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false) { @@@ -1673,7 -1681,7 +1683,7 @@@ pkgAcqArchive::pkgAcqArchive(pkgAcquir // check if we have one trusted source for the package. if so, switch // to "TrustedOnly" mode - for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; i++) + for (pkgCache::VerFileIterator i = Version.FileList(); i.end() == false; ++i) { pkgIndexFile *Index; if (Sources->FindIndex(i.File(),Index) == false) @@@ -1710,7 -1718,7 +1720,7 @@@ bool pkgAcqArchive::QueueNext() { string const ForceHash = _config->Find("Acquire::ForceHash"); - for (; Vf.end() == false; Vf++) + for (; Vf.end() == false; ++Vf) { // Ignore not source sources if ((Vf.File()->Flags & pkgCache::Flag::NotSource) != 0) @@@ -1825,7 -1833,7 +1835,7 @@@ Desc.ShortDesc = Version.ParentPkg().Name(); QueueURI(Desc); - Vf++; + ++Vf; return true; } return false; @@@ -1899,7 -1907,7 +1909,7 @@@ void pkgAcqArchive::Failed(string Messa StringToBool(LookupTag(Message,"Transient-Failure"),false) == true) { // Vf = Version.FileList(); - while (Vf.end() == false) Vf++; + while (Vf.end() == false) ++Vf; StoreFilename = string(); Item::Failed(Message,Cnf); return; @@@ -2073,13 -2081,3 +2083,3 @@@ string pkgAcqFile::Custom600Headers( return ""; } /*}}}*/ - bool IndexTarget::IsOptional() const { - if (strncmp(ShortDesc.c_str(), "Translation", 11) != 0) - return false; - return true; - } - bool IndexTarget::IsSubIndex() const { - if (ShortDesc != "TranslationIndex") - return false; - return true; - } diff --combined apt-pkg/acquire-method.cc index 69f7b1c57,25c6c674d..1ae139b40 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@@ -15,8 -15,6 +15,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -83,7 -81,7 +83,7 @@@ void pkgAcqMethod::Fail(bool Transient void pkgAcqMethod::Fail(string Err,bool Transient) { // Strip out junk from the error messages - for (string::iterator I = Err.begin(); I != Err.end(); I++) + for (string::iterator I = Err.begin(); I != Err.end(); ++I) { if (*I == '\r') *I = ' '; @@@ -427,12 -425,8 +427,8 @@@ void pkgAcqMethod::Status(const char *F to keep the pipeline synchronized. */ void pkgAcqMethod::Redirect(const string &NewURI) { - std::cout << "103 Redirect\nURI: "; - if (Queue != 0) - std::cout << Queue->Uri << "\n"; - else - std::cout << "\n"; - std::cout << "New-URI: " << NewURI << "\n" + std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n" + << "New-URI: " << NewURI << "\n" << "\n" << std::flush; // Change the URI for the request. diff --combined apt-pkg/acquire.cc index e33dbb5d5,8c00748b2..3a547fb3a --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@@ -13,8 -13,6 +13,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -23,6 -21,8 +23,6 @@@ #include #include -#include - #include #include #include @@@ -30,8 -30,6 +30,8 @@@ #include #include #include + +#include /*}}}*/ using namespace std; @@@ -118,7 -116,7 +118,7 @@@ pkgAcquire::~pkgAcquire( /* */ void pkgAcquire::Shutdown() { - while (Items.size() != 0) + while (Items.empty() == false) { if (Items[0]->Status == Item::StatFetching) Items[0]->Status = Item::StatError; @@@ -157,7 -155,7 +157,7 @@@ void pkgAcquire::Remove(Item *Itm I = Items.begin(); } else - I++; + ++I; } } /*}}}*/ @@@ -413,7 -411,7 +413,7 @@@ pkgAcquire::RunResult pkgAcquire::Run(i I->Shutdown(false); // Shut down the items - for (ItemIterator I = Items.begin(); I != Items.end(); I++) + for (ItemIterator I = Items.begin(); I != Items.end(); ++I) (*I)->Finished(); if (_error->PendingError()) @@@ -469,7 -467,7 +469,7 @@@ bool pkgAcquire::Clean(string Dir // Look in the get list ItemCIterator I = Items.begin(); - for (; I != Items.end(); I++) + for (; I != Items.end(); ++I) if (flNotDir((*I)->DestFile) == Dir->d_name) break; @@@ -490,7 -488,7 +490,7 @@@ unsigned long long pkgAcquire::TotalNeeded() { unsigned long long Total = 0; - for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++) + for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) Total += (*I)->FileSize; return Total; } @@@ -501,7 -499,7 +501,7 @@@ unsigned long long pkgAcquire::FetchNeeded() { unsigned long long Total = 0; - for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++) + for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) if ((*I)->Local == false) Total += (*I)->FileSize; return Total; @@@ -513,7 -511,7 +513,7 @@@ unsigned long long pkgAcquire::PartialPresent() { unsigned long long Total = 0; - for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); I++) + for (ItemCIterator I = ItemsBegin(); I != ItemsEnd(); ++I) if ((*I)->Local == false) Total += (*I)->PartialSize; return Total; @@@ -783,11 -781,11 +783,11 @@@ bool pkgAcquireStatus::Pulse(pkgAcquir unsigned int Unknown = 0; unsigned int Count = 0; for (pkgAcquire::ItemCIterator I = Owner->ItemsBegin(); I != Owner->ItemsEnd(); - I++, Count++) + ++I, ++Count) { TotalItems++; if ((*I)->Status == pkgAcquire::Item::StatDone) - CurrentItems++; + ++CurrentItems; // Totally ignore local items if ((*I)->Local == true) @@@ -797,7 -795,7 +797,7 @@@ if ((*I)->Complete == true) CurrentBytes += (*I)->FileSize; if ((*I)->FileSize == 0 && (*I)->Complete == false) - Unknown++; + ++Unknown; } // Compute the current completion @@@ -851,7 -849,9 +851,9 @@@ char msg[200]; long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems; - unsigned long long const ETA = (TotalBytes - CurrentBytes) / CurrentCPS; + unsigned long long ETA = 0; + if(CurrentCPS > 0) + ETA = (TotalBytes - CurrentBytes) / CurrentCPS; // only show the ETA if it makes sense if (ETA > 0 && ETA < 172800 /* two days */ ) diff --combined apt-pkg/algorithms.cc index d5652791c,08d1f8cb7..40368c91f --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@@ -14,8 -14,6 +14,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -24,13 -22,13 +24,13 @@@ #include #include -#include #include #include #include #include - #include + +#include /*}}}*/ using namespace std; @@@ -96,7 -94,7 +96,7 @@@ bool pkgSimulate::Install(PkgIterator i Sim.MarkInstall(Pkg,false); // Look for broken conflicts+predepends. - for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I) { if (Sim[I].InstallVer == 0) continue; @@@ -145,7 -143,7 +145,7 @@@ bool pkgSimulate::Configure(PkgIterato Sim.Update(); // Print out each package and the failed dependencies - for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Sim[Pkg].InstVerIter(Sim).DependsList(); D.end() == false; ++D) { if (Sim.IsImportantDep(D) == false || (Sim[D] & pkgDepCache::DepInstall) != 0) @@@ -209,7 -207,7 +209,7 @@@ bool pkgSimulate::Remove(PkgIterator iP void pkgSimulate::ShortBreaks() { cout << " ["; - for (PkgIterator I = Sim.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Sim.PkgBegin(); I.end() == false; ++I) { if (Sim[I].InstBroken() == true) { @@@ -231,7 -229,7 +231,7 @@@ bool pkgApplyStatus(pkgDepCache &Cache { pkgDepCache::ActionGroup group(Cache); - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (I->VersionList == 0) continue; @@@ -300,13 -298,13 +300,13 @@@ bool pkgFixBroken(pkgDepCache &Cache pkgDepCache::ActionGroup group(Cache); // Auto upgrade all broken packages - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if (Cache[I].NowBroken() == true) Cache.MarkInstall(I, true, 0, false); /* Fix packages that are in a NeedArchive state but don't have a downloadable install version */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (I.State() != pkgCache::PkgIterator::NeedsUnpack || Cache[I].Delete() == true) @@@ -349,19 -347,19 +349,19 @@@ bool pkgDistUpgrade(pkgDepCache &Cache /* Auto upgrade all installed packages, this provides the basis for the installation */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if (I->CurrentVer != 0) Cache.MarkInstall(I, true, 0, false); /* Now, auto upgrade all essential packages - this ensures that the essential packages are present and working */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if ((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential) Cache.MarkInstall(I, true, 0, false); /* We do it again over all previously installed packages to force conflict resolution on them all. */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) if (I->CurrentVer != 0) Cache.MarkInstall(I, false, 0, false); @@@ -370,7 -368,7 +370,7 @@@ // 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) { @@@ -404,7 -402,7 +404,7 @@@ bool pkgAllUpgrade(pkgDepCache &Cache return false; // Upgrade all installed packages - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].Install() == true) Fix.Protect(I); @@@ -438,7 -436,7 +438,7 @@@ bool pkgMinimizeUpgrade(pkgDepCache &Ca do { Change = false; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { // Not interesting if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true) @@@ -455,7 -453,7 +455,7 @@@ Change = true; } } - Count++; + ++Count; } while (Change == true && Count < 10); @@@ -542,7 -540,7 +542,7 @@@ void pkgProblemResolver::MakeScores( << " AddEssential => " << AddEssential << endl; // Generate the base scores for a package based on its properties - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].InstallVer == 0) continue; @@@ -569,12 -567,12 +569,12 @@@ } // Now that we have the base scores we go and propogate dependencies - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].InstallVer == 0) continue; - for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false; ++D) { if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) @@@ -591,12 -589,12 +591,12 @@@ /* Now we cause 1 level of dependency inheritance, that is we add the score of the packages that depend on the target Package. This fortifies high scoring packages */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].InstallVer == 0) continue; - for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = I.RevDependsList(); D.end() == false; ++D) { // Only do it for the install version if ((pkgCache::Version *)D.ParentVer() != Cache[D.ParentPkg()].InstallVer || @@@ -611,9 -609,9 +611,9 @@@ /* Now we propogate along provides. This makes the packages that provide important packages extremely important */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { - for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; P++) + for (pkgCache::PrvIterator P = I.ProvidesList(); P.end() == false; ++P) { // Only do it once per package if ((pkgCache::Version *)P.OwnerVer() != Cache[P.OwnerPkg()].InstallVer) @@@ -624,7 -622,7 +624,7 @@@ /* Protected things are pushed really high up. This number should put them ahead of everything */ - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if ((Flags[I->ID] & Protected) != 0) Scores[I->ID] += AddProtected; @@@ -721,7 -719,7 +721,7 @@@ bool pkgProblemResolver::DoUpgrade(pkgC if (Start == End) break; - Start++; + ++Start; } if (Fail == true) break; @@@ -778,7 -776,7 +778,7 @@@ bool pkgProblemResolver::ResolveInterna do { Again = false; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (Cache[I].Install() == true) Flags[I->ID] |= PreInstalled; @@@ -811,7 -809,7 +811,7 @@@ would cause the removal of even lower score packages. */ SPtrArray PList = new pkgCache::Package *[Size]; pkgCache::Package **PEnd = PList; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; This = this; qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); @@@ -931,7 -929,7 +931,7 @@@ } else { - Start++; + ++Start; // We only worry about critical deps. if (Start.IsCritical() != true) continue; @@@ -1180,7 -1178,7 +1180,7 @@@ { // See if this is the result of a hold pkgCache::PkgIterator I = Cache.PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (Cache[I].InstBroken() == false) continue; @@@ -1192,7 -1190,7 +1192,7 @@@ // set the auto-flags (mvo: I'm not sure if we _really_ need this) pkgCache::PkgIterator I = Cache.PkgBegin(); - for (;I.end() != true; I++) { + for (;I.end() != true; ++I) { if (Cache[I].NewInstall() && !(Flags[I->ID] & PreInstalled)) { if(_config->FindI("Debug::pkgAutoRemove",false)) { std::clog << "Resolve installed new pkg: " << I.FullName(false) @@@ -1265,7 -1263,7 +1265,7 @@@ bool pkgProblemResolver::ResolveByKeepI would cause the removal of even lower score packages. */ pkgCache::Package **PList = new pkgCache::Package *[Size]; pkgCache::Package **PEnd = PList; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; This = this; qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); @@@ -1362,7 -1360,7 +1362,7 @@@ if (Start == End) break; - Start++; + ++Start; } if (InstOrNewPolicyBroken(I) == false) @@@ -1389,7 -1387,7 +1389,7 @@@ void pkgProblemResolver::InstallProtect { pkgDepCache::ActionGroup group(Cache); - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if ((Flags[I->ID] & Protected) == Protected) { @@@ -1469,7 -1467,7 +1469,7 @@@ bool ListUpdate(pkgAcquireStatus &Stat bool Failed = false; bool TransientNetworkFailure = false; for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); - I != Fetcher.ItemsEnd(); I++) + I != Fetcher.ItemsEnd(); ++I) { if ((*I)->Status == pkgAcquire::Item::StatDone) continue; diff --combined apt-pkg/aptconfiguration.cc index 71e0b8e73,6ec5fa03a..e1bc94f31 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@@ -8,8 -8,6 +8,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -55,7 -53,7 +55,7 @@@ const Configuration::getCompressionType // load the order setting into our vector std::vector const order = _config->FindVector("Acquire::CompressionTypes::Order"); for (std::vector::const_iterator o = order.begin(); - o != order.end(); o++) { + o != order.end(); ++o) { if ((*o).empty() == true) continue; // ignore types we have no method ready to use @@@ -276,7 -274,7 +276,7 @@@ std::vector const Configur // then needed and ensure the codes are not listed twice. bool noneSeen = false; for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) { + l != lang.end(); ++l) { if (*l == "environment") { for (std::vector::const_iterator e = environment.begin(); e != environment.end(); ++e) { @@@ -354,7 -352,7 +354,7 @@@ std::vector const Configur if (archs.empty() == true || std::find(archs.begin(), archs.end(), arch) == archs.end()) - archs.push_back(arch); + archs.insert(archs.begin(), arch); // erase duplicates and empty strings for (std::vector::reverse_iterator a = archs.rbegin(); diff --combined apt-pkg/cdrom.cc index c432cf509,df1ffedf2..392cd890e --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@@ -1,6 -1,5 +1,6 @@@ /* */ +#include #include #include @@@ -11,6 -10,8 +11,6 @@@ #include #include -#include -#include #include #include #include @@@ -21,8 -22,6 +21,8 @@@ #include "indexcopy.h" +#include + using namespace std; // FindPackages - Find the package files on the CDROM /*{{{*/ @@@ -311,7 -310,7 +311,7 @@@ void pkgCdrom::ReduceSourcelist(string sort(List.begin(),List.end()); // Collect similar entries - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Find a space.. string::size_type Space = (*I).find(' '); @@@ -323,7 -322,7 +323,7 @@@ string Word1 = string(*I,Space,SSpace-Space); string Prefix = string(*I,0,Space); - for (vector::iterator J = List.begin(); J != I; J++) + for (vector::iterator J = List.begin(); J != I; ++J) { // Find a space.. string::size_type Space2 = (*J).find(' '); @@@ -406,7 -405,7 +406,7 @@@ bool pkgCdrom::WriteDatabase(Configurat that were the same. */ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) { - if (List.size() == 0) + if (List.empty() == true) return true; string File = _config->FindFile("Dir::Etc::sourcelist"); @@@ -456,7 -455,7 +456,7 @@@ if (First == true) { - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@@ -490,7 -489,7 +490,7 @@@ // Just in case the file was empty if (First == true) { - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@@ -662,13 -661,13 +662,13 @@@ bool pkgCdrom::Add(pkgCdromStatus *log if (_config->FindB("Debug::aptcdrom",false) == true) { cout << "I found (binary):" << endl; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) cout << *I << endl; cout << "I found (source):" << endl; - for (vector::iterator I = SourceList.begin(); I != SourceList.end(); I++) + for (vector::iterator I = SourceList.begin(); I != SourceList.end(); ++I) cout << *I << endl; cout << "I found (Signatures):" << endl; - for (vector::iterator I = SigList.begin(); I != SigList.end(); I++) + for (vector::iterator I = SigList.begin(); I != SigList.end(); ++I) cout << *I << endl; } @@@ -689,7 -688,7 +689,7 @@@ log->Update(msg.str(), STEP_SCAN); } - if (List.size() == 0 && SourceList.size() == 0) + if (List.empty() == true && SourceList.empty() == true) { if (_config->FindB("APT::CDROM::NoMount",false) == false) UnmountCdrom(CDROM); @@@ -713,7 -712,7 +713,7 @@@ { // Escape special characters string::iterator J = Name.begin(); - for (; J != Name.end(); J++) + for (; J != Name.end(); ++J) if (*J == '"' || *J == ']' || *J == '[') *J = '_'; @@@ -758,7 -757,7 +758,7 @@@ // Escape special characters string::iterator J = Name.begin(); - for (; J != Name.end(); J++) + for (; J != Name.end(); ++J) if (*J == '"' || *J == ']' || *J == '[') *J = '_'; @@@ -805,7 -804,7 +805,7 @@@ if(log != NULL) log->Update(_("Source list entries for this disc are:\n")); - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@@ -824,7 -823,7 +824,7 @@@ } } - for (vector::iterator I = SourceList.begin(); I != SourceList.end(); I++) + for (vector::iterator I = SourceList.begin(); I != SourceList.end(); ++I) { string::size_type Space = (*I).find(' '); if (Space == string::npos) @@@ -875,9 -874,7 +875,7 @@@ pkgUdevCdromDevices::Dlopen( libudev_handle = h; udev_new = (udev* (*)(void)) dlsym(h, "udev_new"); udev_enumerate_add_match_property = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_property"); - #if 0 // FIXME: uncomment on next ABI break udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(h, "udev_enumerate_add_match_sysattr"); - #endif udev_enumerate_scan_devices = (int (*)(udev_enumerate*))dlsym(h, "udev_enumerate_scan_devices"); udev_enumerate_get_list_entry = (udev_list_entry* (*)(udev_enumerate*))dlsym(h, "udev_enumerate_get_list_entry"); udev_device_new_from_syspath = (udev_device* (*)(udev*, const char*))dlsym(h, "udev_device_new_from_syspath"); @@@ -891,10 -888,8 +889,8 @@@ return true; } /*}}}*/ - /*{{{*/ - // compatiblity only with the old API/ABI, can be removed on the next - // ABI break + // convenience interface, this will just call ScanForRemovable vector pkgUdevCdromDevices::Scan() { @@@ -919,10 -914,6 +915,6 @@@ pkgUdevCdromDevices::ScanForRemovable(b if (CdromOnly) udev_enumerate_add_match_property(enumerate, "ID_CDROM", "1"); else { - #if 1 // FIXME: remove the next two lines on the next ABI break - int (*udev_enumerate_add_match_sysattr)(struct udev_enumerate *udev_enumerate, const char *property, const char *value); - udev_enumerate_add_match_sysattr = (int (*)(udev_enumerate*, const char*, const char*))dlsym(libudev_handle, "udev_enumerate_add_match_sysattr"); - #endif udev_enumerate_add_match_sysattr(enumerate, "removable", "1"); } diff --combined apt-pkg/clean.cc index 2e5fd675a,9850b93b4..1f96e941b --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@@ -8,19 -8,17 +8,19 @@@ ##################################################################### */ /*}}}*/ // Includes /*{{{*/ +#include + #include #include #include #include #include -#include - #include #include #include + +#include /*}}}*/ // ArchiveCleaner::Go - Perform smart cleanup of the archive /*{{{*/ // --------------------------------------------------------------------- @@@ -87,12 -85,12 +87,12 @@@ bool pkgArchiveCleaner::Go(string Dir,p if (P.end() != true) { pkgCache::VerIterator V = P.VersionList(); - for (; V.end() == false; V++) + for (; V.end() == false; ++V) { // See if we can fetch this version at all bool IsFetchable = false; for (pkgCache::VerFileIterator J = V.FileList(); - J.end() == false; J++) + J.end() == false; ++J) { if (CleanInstalled == true && (J.File()->Flags & pkgCache::Flag::NotSource) != 0) diff --combined apt-pkg/contrib/cdromutl.cc index 7f30f132d,e25caf1a5..9de795b60 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@@ -10,8 -10,6 +10,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -19,6 -17,8 +19,6 @@@ #include #include -#include - #include #include #include @@@ -26,8 -26,6 +26,8 @@@ #include #include #include + +#include /*}}}*/ // IsMounted - Returns true if the mount point is mounted /*{{{*/ @@@ -260,7 -258,9 +260,9 @@@ string FindMountPointForDevice(const ch if(TokSplitString(' ', buf, out, 10)) { fclose(f); - return string(out[1]); + // unescape the \0XXX chars in the path + string mount_point = out[1]; + return DeEscapeString(mount_point); } } } diff --combined apt-pkg/contrib/configuration.cc index b3e9d8863,ece05e8f6..0f7b37ee9 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@@ -15,19 -15,16 +15,19 @@@ ##################################################################### */ /*}}}*/ // Include files /*{{{*/ +#include + #include #include #include #include -#include #include #include #include +#include + using namespace std; /*}}}*/ @@@ -348,7 -345,7 +348,7 @@@ void Configuration::Set(const char *Nam // Configuration::Set - Set an integer value /*{{{*/ // --------------------------------------------------------------------- /* */ - void Configuration::Set(const char *Name,int const Value) + void Configuration::Set(const char *Name,int const &Value) { Item *Itm = Lookup(Name,true); if (Itm == 0) @@@ -675,9 -672,9 +675,9 @@@ bool ReadConfigFile(Configuration &Conf // Put the last fragment into the buffer std::string::const_iterator NonWhitespaceStart = Start; std::string::const_iterator NonWhitespaceStop = I; - for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; NonWhitespaceStart++) + for (; NonWhitespaceStart != I && isspace(*NonWhitespaceStart) != 0; ++NonWhitespaceStart) ; - for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; NonWhitespaceStop--) + for (; NonWhitespaceStop != NonWhitespaceStart && isspace(NonWhitespaceStop[-1]) != 0; --NonWhitespaceStop) ; if (LineBuffer.empty() == false && NonWhitespaceStop - NonWhitespaceStart != 0) LineBuffer += ' '; @@@ -853,7 -850,7 +853,7 @@@ bool ReadConfigDir(Configuration &Conf, vector const List = GetListOfFilesInDir(Dir, "conf", true, true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadConfigFile(Conf,*I,AsSectional,Depth) == false) return false; return true; diff --combined apt-pkg/contrib/error.cc index 56bbd1c60,edb290f34..122e2c809 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@@ -13,8 -13,6 +13,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include @@@ -26,7 -24,8 +26,7 @@@ #include #include -#include "config.h" - /*}}}*/ + /*}}}*/ // Global Error Object /*{{{*/ /* If the implementation supports posix threads then the accessor function @@@ -194,7 -193,7 +194,7 @@@ bool GlobalError::PopMessage(std::strin // check if another error message is pending for (std::list::const_iterator m = Messages.begin(); - m != Messages.end(); m++) + m != Messages.end(); ++m) if (m->Type == ERROR || m->Type == FATAL) return Ret; @@@ -211,7 -210,7 +211,7 @@@ void GlobalError::DumpErrors(std::ostre Messages.insert(Messages.begin(), s->Messages.begin(), s->Messages.end()); for (std::list::const_iterator m = Messages.begin(); - m != Messages.end(); m++) + m != Messages.end(); ++m) if (m->Type >= threshold) out << (*m) << std::endl; Discard(); @@@ -232,7 -231,7 +232,7 @@@ bool GlobalError::empty(MsgType const & return true; for (std::list::const_iterator m = Messages.begin(); - m != Messages.end(); m++) + m != Messages.end(); ++m) if (m->Type >= trashhold) return false; diff --combined apt-pkg/contrib/fileutl.cc index 2e62846d9,85dc6f600..95058cbde --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@@ -18,14 -18,14 +18,14 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include -#include - #include #include #include @@@ -43,11 -43,10 +43,11 @@@ #include #include -#include #ifdef WORDS_BIGENDIAN #include #endif + +#include /*}}}*/ using namespace std; @@@ -133,10 -132,10 +133,10 @@@ bool CopyFile(FileFd &From,FileFd &To // Buffered copy between fds SPtrArray Buf = new unsigned char[64000]; - unsigned long Size = From.Size(); + unsigned long long Size = From.Size(); while (Size != 0) { - unsigned long ToRead = Size; + unsigned long long ToRead = Size; if (Size > 64000) ToRead = 64000; @@@ -447,6 -446,17 +447,17 @@@ string SafeGetCWD( return S; } /*}}}*/ + // GetModificationTime - Get the mtime of the given file or -1 on error /*{{{*/ + // --------------------------------------------------------------------- + /* We return / on failure. */ + time_t GetModificationTime(string const &Path) + { + struct stat St; + if (stat(Path.c_str(), &St) < 0) + return -1; + return St.st_mtime; + } + /*}}}*/ // flNotDir - Strip the directory from the filename /*{{{*/ // --------------------------------------------------------------------- /* */ @@@ -800,7 -810,7 +811,7 @@@ FileFd::~FileFd( // --------------------------------------------------------------------- /* We are carefull to handle interruption by a signal while reading gracefully. */ -bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual) +bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual) { int Res; errno = 0; @@@ -839,13 -849,13 +850,13 @@@ } Flags |= Fail; - return _error->Error(_("read, still have %lu to read but none left"),Size); + return _error->Error(_("read, still have %llu to read but none left"), Size); } /*}}}*/ // FileFd::Write - Write to the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool FileFd::Write(const void *From,unsigned long Size) +bool FileFd::Write(const void *From,unsigned long long Size) { int Res; errno = 0; @@@ -872,13 -882,13 +883,13 @@@ return true; Flags |= Fail; - return _error->Error(_("write, still have %lu to write but couldn't"),Size); + return _error->Error(_("write, still have %llu to write but couldn't"), Size); } /*}}}*/ // FileFd::Seek - Seek in the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool FileFd::Seek(unsigned long To) +bool FileFd::Seek(unsigned long long To) { int res; if (gz) @@@ -888,7 -898,7 +899,7 @@@ if (res != (signed)To) { Flags |= Fail; - return _error->Error("Unable to seek to %lu",To); + return _error->Error("Unable to seek to %llu", To); } return true; @@@ -897,7 -907,7 +908,7 @@@ // FileFd::Skip - Seek in the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool FileFd::Skip(unsigned long Over) +bool FileFd::Skip(unsigned long long Over) { int res; if (gz) @@@ -907,7 -917,7 +918,7 @@@ if (res < 0) { Flags |= Fail; - return _error->Error("Unable to seek ahead %lu",Over); + return _error->Error("Unable to seek ahead %llu",Over); } return true; @@@ -916,7 -926,7 +927,7 @@@ // FileFd::Truncate - Truncate the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool FileFd::Truncate(unsigned long To) +bool FileFd::Truncate(unsigned long long To) { if (gz) { @@@ -926,7 -936,7 +937,7 @@@ if (ftruncate(iFd,To) != 0) { Flags |= Fail; - return _error->Error("Unable to truncate to %lu",To); + return _error->Error("Unable to truncate to %llu",To); } return true; @@@ -935,7 -945,7 +946,7 @@@ // FileFd::Tell - Current seek position /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long FileFd::Tell() +unsigned long long FileFd::Tell() { off_t Res; if (gz) @@@ -950,7 -960,7 +961,7 @@@ // FileFd::FileSize - Return the size of the file /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long FileFd::FileSize() +unsigned long long FileFd::FileSize() { struct stat Buf; @@@ -962,9 -972,9 +973,9 @@@ // FileFd::Size - Return the size of the content in the file /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long FileFd::Size() +unsigned long long FileFd::Size() { - unsigned long size = FileSize(); + unsigned long long size = FileSize(); // only check gzsize if we are actually a gzip file, just checking for // "gz" is not sufficient as uncompressed files will be opened with @@@ -974,7 -984,6 +985,7 @@@ /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do * this ourselves; the original (uncompressed) file size is the last 32 * bits of the file */ + // FIXME: Size for gz-files is limited by 32bit… no largefile support off_t orig_pos = lseek(iFd, 0, SEEK_CUR); if (lseek(iFd, -4, SEEK_END) < 0) return _error->Errno("lseek","Unable to seek to end of gzipped file"); diff --combined apt-pkg/contrib/fileutl.h index 0f2dd4194,a1b177f38..973a38cff --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@@ -49,36 -49,21 +49,36 @@@ class FileF enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip, WriteAtomic}; - inline bool Read(void *To,unsigned long Size,bool AllowEof) + inline bool Read(void *To,unsigned long long Size,bool AllowEof) { - unsigned long Jnk; + unsigned long long Jnk; if (AllowEof) return Read(To,Size,&Jnk); return Read(To,Size); } - bool Read(void *To,unsigned long Size,unsigned long *Actual = 0); - bool Write(const void *From,unsigned long Size); - bool Seek(unsigned long To); - bool Skip(unsigned long To); - bool Truncate(unsigned long To); - unsigned long Tell(); - unsigned long Size(); - unsigned long FileSize(); + bool Read(void *To,unsigned long long Size,unsigned long long *Actual = 0); + bool Write(const void *From,unsigned long long Size); + bool Seek(unsigned long long To); + bool Skip(unsigned long long To); + bool Truncate(unsigned long long To); + unsigned long long Tell(); + unsigned long long Size(); + unsigned long long FileSize(); + + /* You want to use 'unsigned long long' if you are talking about a file + to be able to support large files (>2 or >4 GB) properly. + This shouldn't happen all to often for the indexes, but deb's might be… + And as the auto-conversation converts a 'unsigned long *' to a 'bool' + instead of 'unsigned long long *' we need to provide this explicitely - + otherwise applications magically start to fail… */ + __deprecated bool Read(void *To,unsigned long long Size,unsigned long *Actual) + { + unsigned long long R; + bool const T = Read(To, Size, &R); + *Actual = R; + return T; + } + bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666); bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false); bool Close(); @@@ -112,6 -97,7 +112,7 @@@ bool FileExists(string File) bool RealFileExists(string File); bool DirectoryExists(string const &Path) __attrib_const; bool CreateDirectory(string const &Parent, string const &Path); + time_t GetModificationTime(string const &Path); /** \brief Ensure the existence of the given Path * diff --combined apt-pkg/contrib/netrc.cc index 456ada950,9ff5796c5..b9d0749e2 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@@ -11,7 -11,6 +11,7 @@@ ##################################################################### */ /*}}}*/ +#include #include #include @@@ -48,10 -47,7 +48,7 @@@ int parsenetrc (char *host, char *login int specific_login = (login[0] != 0); char *home = NULL; bool netrc_alloc = false; - int state = NOTHING; - char state_login = 0; /* Found a login keyword */ - char state_password = 0; /* Found a password keyword */ int state_our_login = false; /* With specific_login, found *our* login name */ @@@ -82,6 -78,10 +79,10 @@@ bool done = false; char netrcbuffer[256]; + int state = NOTHING; + char state_login = 0; /* Found a login keyword */ + char state_password = 0; /* Found a password keyword */ + while (!done && fgets(netrcbuffer, sizeof (netrcbuffer), file)) { tok = strtok_r (netrcbuffer, " \t\n", &tok_buf); while (!done && tok) { diff --combined apt-pkg/contrib/sha1.cc index 31c576611,5b9db202d..b5a6a2440 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@@ -29,8 -29,6 +29,8 @@@ */ /*}}} */ // Include Files /*{{{*/ +#include + #include #include #include @@@ -38,6 -36,7 +38,6 @@@ #include #include #include -#include /*}}}*/ // SHA1Transform - Alters an existing SHA-1 hash /*{{{*/ @@@ -75,10 -74,9 +75,9 @@@ static void SHA1Transform(uint32_t stat uint32_t l[16]; } CHAR64LONG16; - CHAR64LONG16 *block; + CHAR64LONG16 workspace, *block; - uint8_t workspace[64]; - block = (CHAR64LONG16 *)workspace; + block = &workspace; memcpy(block,buffer,sizeof(workspace)); /* Copy context->state[] to working vars */ @@@ -243,7 -241,7 +242,7 @@@ SHA1SumValue SHA1Summation::Result( // SHA1Summation::Add - Adds content of buffer into the checksum /*{{{*/ // --------------------------------------------------------------------- /* May not be called after Result() is called */ -bool SHA1Summation::Add(const unsigned char *data,unsigned long len) +bool SHA1Summation::Add(const unsigned char *data,unsigned long long len) { if (Done) return false; diff --combined apt-pkg/contrib/strutl.cc index 04226f1b4,867bb313b..aaf44b7ff --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@@ -15,12 -15,12 +15,12 @@@ ##################################################################### */ /*}}}*/ // Includes /*{{{*/ +#include + #include #include #include -#include - #include #include #include @@@ -31,7 -31,7 +31,7 @@@ #include #include -#include "config.h" +#include using namespace std; /*}}}*/ @@@ -271,7 -271,7 +271,7 @@@ bool ParseCWord(const char *&String,str string QuoteString(const string &Str, const char *Bad) { string Res; - for (string::const_iterator I = Str.begin(); I != Str.end(); I++) + for (string::const_iterator I = Str.begin(); I != Str.end(); ++I) { if (strchr(Bad,*I) != 0 || isprint(*I) == 0 || *I == 0x25 || // percent '%' char @@@ -298,7 -298,7 +298,7 @@@ string DeQuoteString(string::const_iter string::const_iterator const &end) { string Res; - for (string::const_iterator I = begin; I != end; I++) + for (string::const_iterator I = begin; I != end; ++I) { if (*I == '%' && I + 2 < end && isxdigit(I[1]) && isxdigit(I[2])) @@@ -632,7 -632,7 +632,7 @@@ string LookupTag(const string &Message, { // Look for a matching tag. int Length = strlen(Tag); - for (string::const_iterator I = Message.begin(); I + Length < Message.end(); I++) + for (string::const_iterator I = Message.begin(); I + Length < Message.end(); ++I) { // Found the tag if (I[Length] == ':' && stringcasecmp(I,I+Length,Tag) == 0) @@@ -640,14 -640,14 +640,14 @@@ // Find the end of line and strip the leading/trailing spaces string::const_iterator J; I += Length + 1; - for (; isspace(*I) != 0 && I < Message.end(); I++); - for (J = I; *J != '\n' && J < Message.end(); J++); - for (; J > I && isspace(J[-1]) != 0; J--); + for (; isspace(*I) != 0 && I < Message.end(); ++I); + for (J = I; *J != '\n' && J < Message.end(); ++J); + for (; J > I && isspace(J[-1]) != 0; --J); return string(I,J); } - for (; *I != '\n' && I < Message.end(); I++); + for (; *I != '\n' && I < Message.end(); ++I); } // Failed to find a match @@@ -970,34 -970,6 +970,34 @@@ bool StrToNum(const char *Str,unsigned return true; } /*}}}*/ +// StrToNum - Convert a fixed length string to a number /*{{{*/ +// --------------------------------------------------------------------- +/* This is used in decoding the crazy fixed length string headers in + tar and ar files. */ +bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base) +{ + char S[30]; + if (Len >= sizeof(S)) + return false; + memcpy(S,Str,Len); + S[Len] = 0; + + // All spaces is a zero + Res = 0; + unsigned I; + for (I = 0; S[I] == ' '; I++); + if (S[I] == 0) + return true; + + char *End; + Res = strtoull(S,&End,Base); + if (End == S) + return false; + + return true; +} + /*}}}*/ + // Base256ToNum - Convert a fixed length binary to a number /*{{{*/ // --------------------------------------------------------------------- /* This is used in decoding the 256bit encoded fixed length fields in @@@ -1252,7 -1224,7 +1252,7 @@@ int tolower_ascii(int const c bool CheckDomainList(const string &Host,const string &List) { string::const_iterator Start = List.begin(); - for (string::const_iterator Cur = List.begin(); Cur <= List.end(); Cur++) + for (string::const_iterator Cur = List.begin(); Cur <= List.end(); ++Cur) { if (Cur < List.end() && *Cur != ',') continue; @@@ -1268,7 -1240,68 +1268,68 @@@ return false; } /*}}}*/ + // DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/ + // --------------------------------------------------------------------- + /* */ + string DeEscapeString(const string &input) + { + char tmp[3]; + string::const_iterator it, escape_start; + string output, octal, hex; + for (it = input.begin(); it != input.end(); ++it) + { + // just copy non-escape chars + if (*it != '\\') + { + output += *it; + continue; + } + // deal with double escape + if (*it == '\\' && + (it + 1 < input.end()) && it[1] == '\\') + { + // copy + output += *it; + // advance iterator one step further + ++it; + continue; + } + + // ensure we have a char to read + if (it + 1 == input.end()) + continue; + + // read it + ++it; + switch (*it) + { + case '0': + if (it + 2 <= input.end()) { + tmp[0] = it[1]; + tmp[1] = it[2]; + tmp[2] = 0; + output += (char)strtol(tmp, 0, 8); + it += 2; + } + break; + case 'x': + if (it + 2 <= input.end()) { + tmp[0] = it[1]; + tmp[1] = it[2]; + tmp[2] = 0; + output += (char)strtol(tmp, 0, 16); + it += 2; + } + break; + default: + // FIXME: raise exception here? + break; + } + } + return output; + } + /*}}}*/ // URI::CopyFrom - Copy from an object /*{{{*/ // --------------------------------------------------------------------- /* This parses the URI into all of its components */ @@@ -1277,7 -1310,7 +1338,7 @@@ void URI::CopyFrom(const string &U string::const_iterator I = U.begin(); // Locate the first colon, this separates the scheme - for (; I < U.end() && *I != ':' ; I++); + for (; I < U.end() && *I != ':' ; ++I); string::const_iterator FirstColon = I; /* Determine if this is a host type URI with a leading double // @@@ -1289,7 -1322,7 +1350,7 @@@ /* Find the / indicating the end of the hostname, ignoring /'s in the square brackets */ bool InBracket = false; - for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); SingleSlash++) + for (; SingleSlash < U.end() && (*SingleSlash != '/' || InBracket == true); ++SingleSlash) { if (*SingleSlash == '[') InBracket = true; @@@ -1322,11 -1355,11 +1383,11 @@@ I = FirstColon + 1; if (I > SingleSlash) I = SingleSlash; - for (; I < SingleSlash && *I != ':'; I++); + for (; I < SingleSlash && *I != ':'; ++I); string::const_iterator SecondColon = I; // Search for the @ after the colon - for (; I < SingleSlash && *I != '@'; I++); + for (; I < SingleSlash && *I != '@'; ++I); string::const_iterator At = I; // Now write the host and user/pass diff --combined apt-pkg/contrib/strutl.h index b32198f25,fba85cf94..ab4b54722 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@@ -39,6 -39,10 +39,10 @@@ bool ParseCWord(const char *&String,str string QuoteString(const string &Str,const char *Bad); string DeQuoteString(const string &Str); string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end); + + // unescape (\0XX and \xXX) from a string + string DeEscapeString(const string &input); + string SizeToStr(double Bytes); string TimeToStr(unsigned long Sec); string Base64Encode(const string &Str); @@@ -52,7 -56,6 +56,7 @@@ string LookupTag(const string &Message, int StringToBool(const string &Text,int Default = -1); bool ReadMessages(int Fd, vector &List); bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0); +bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base = 0); bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len); bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length); bool TokSplitString(char Tok,char *Input,char **List, diff --combined apt-pkg/deb/debindexfile.cc index 303dab796,e3d4063dc..27c1f7f32 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@@ -9,8 -9,6 +9,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -354,7 -352,7 +354,7 @@@ pkgCache::PkgFileIterator debPackagesIn { string FileName = IndexFile("Packages"); pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (File.FileName() == NULL || FileName != File.FileName()) continue; @@@ -542,7 -540,7 +542,7 @@@ pkgCache::PkgFileIterator debTranslatio string FileName = IndexFile(Language); pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (FileName != File.FileName()) continue; @@@ -622,7 -620,7 +622,7 @@@ bool debStatusIndex::Merge(pkgCacheGene pkgCache::PkgFileIterator debStatusIndex::FindInCache(pkgCache &Cache) const { pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (this->File != File.FileName()) continue; diff --combined apt-pkg/deb/deblistparser.cc index 6b8fbce99,952433428..a4a974897 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@@ -10,8 -10,6 +10,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -200,7 -198,7 +200,7 @@@ string debListParser::DescriptionLangua std::vector const lang = APT::Configuration::getLanguages(true); for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) + l != lang.end(); ++l) if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false) return *l; @@@ -458,7 -456,7 +458,7 @@@ const char *debListParser::ConvertRelat * * The complete architecture, consisting of -. */ - static string CompleteArch(std::string& arch) { + static string CompleteArch(std::string const &arch) { if (arch == "armel") return "linux-arm"; if (arch == "armhf") return "linux-arm"; if (arch == "lpia") return "linux-i386"; @@@ -497,9 -495,13 +497,13 @@@ const char *debListParser::ParseDepends Package.assign(Start,I - Start); // We don't want to confuse library users which can't handle MultiArch + string const arch = _config->Find("APT::Architecture"); if (StripMultiArch == true) { size_t const found = Package.rfind(':'); - if (found != string::npos) + if (found != string::npos && + (strcmp(Package.c_str() + found, ":any") == 0 || + strcmp(Package.c_str() + found, ":native") == 0 || + strcmp(Package.c_str() + found + 1, arch.c_str()) == 0)) Package = Package.substr(0,found); } @@@ -540,7 -542,6 +544,6 @@@ if (ParseArchFlags == true) { - string arch = _config->Find("APT::Architecture"); string completeArch = CompleteArch(arch); // Parse an architecture @@@ -778,7 -779,9 +781,9 @@@ bool debListParser::LoadReleaseInfo(pkg size_t len = 0; // Skip empty lines - for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len); + for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len) + /* nothing */ + ; if (buffer[len] == '\0') continue; @@@ -792,13 -795,25 +797,25 @@@ } // seperate the tag from the data - for (; buffer[len] != ':' && buffer[len] != '\0'; ++len); + for (; buffer[len] != ':' && buffer[len] != '\0'; ++len) + /* nothing */ + ; if (buffer[len] == '\0') continue; char* dataStart = buffer + len; - for (++dataStart; *dataStart == ' '; ++dataStart); + for (++dataStart; *dataStart == ' '; ++dataStart) + /* nothing */ + ; char* dataEnd = dataStart; - for (++dataEnd; *dataEnd != '\0'; ++dataEnd); + for (++dataEnd; *dataEnd != '\0'; ++dataEnd) + /* nothing */ + ; + // The last char should be a newline, but we can never be sure: #633350 + char* lineEnd = dataEnd; + for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd) + /* nothing */ + ; + ++lineEnd; // which datastorage need to be updated map_ptrloc* writeTo = NULL; @@@ -813,7 -828,7 +830,7 @@@ APT_PARSER_WRITETO(FileI->Label, "Label") #undef APT_PARSER_WRITETO #define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \ - pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, dataEnd-1); + pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd); APT_PARSER_FLAGIT(NotAutomatic) APT_PARSER_FLAGIT(ButAutomaticUpgrades) #undef APT_PARSER_FLAGIT diff --combined apt-pkg/deb/debmetaindex.cc index aaae906dd,e1f8219e3..1d3754b00 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@@ -1,5 -1,4 +1,5 @@@ // ijones, walters +#include #include #include @@@ -209,7 -208,7 +209,7 @@@ vector * debRelea for (std::set::const_iterator s = sections.begin(); s != sections.end(); ++s) { for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) { + l != lang.end(); ++l) { if (*l == "none") continue; IndexTarget * Target = new OptionalIndexTarget(); Target->ShortDesc = "Translation-" + *l; @@@ -239,7 -238,7 +239,7 @@@ bool debReleaseIndex::GetIndexes(pkgAcq // special case for --print-uris if (GetAll) { vector *targets = ComputeIndexTargets(); - for (vector ::const_iterator Target = targets->begin(); Target != targets->end(); Target++) { + for (vector ::const_iterator Target = targets->begin(); Target != targets->end(); ++Target) { new pkgAcqIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, HashString()); } @@@ -296,7 -295,7 +296,7 @@@ vector *debReleaseInde if (src != ArchEntries.end()) { vector const SectionEntries = src->second; for (vector::const_iterator I = SectionEntries.begin(); - I != SectionEntries.end(); I++) + I != SectionEntries.end(); ++I) Indexes->push_back(new debSourcesIndex (URI, Dist, (*I)->Section, IsTrusted())); } @@@ -311,7 -310,7 +311,7 @@@ if (a->first == "source") continue; for (vector::const_iterator I = a->second.begin(); - I != a->second.end(); I++) { + I != a->second.end(); ++I) { Indexes->push_back(new debPackagesIndex (URI, Dist, (*I)->Section, IsTrusted(), a->first)); sections[(*I)->Section].insert(lang.begin(), lang.end()); } @@@ -320,7 -319,7 +320,7 @@@ for (map >::const_iterator s = sections.begin(); s != sections.end(); ++s) for (set::const_iterator l = s->second.begin(); - l != s->second.end(); l++) { + l != s->second.end(); ++l) { if (*l == "none") continue; Indexes->push_back(new debTranslationsIndex(URI,Dist,s->first,(*l).c_str())); } @@@ -369,7 -368,7 +369,7 @@@ class debSLTypeDebian : public pkgSourc map::const_iterator const trusted = Options.find("trusted"); for (vector::const_iterator I = List.begin(); - I != List.end(); I++) + I != List.end(); ++I) { // We only worry about debian entries here if (strcmp((*I)->GetType(), "deb") != 0) diff --combined apt-pkg/deb/debrecords.cc index db62d6c45,2571aae52..4dfc8b56a --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@@ -8,8 -8,6 +8,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -103,6 -101,15 +103,15 @@@ string debRecordParser::Maintainer( return Section.FindS("Maintainer"); } /*}}}*/ + // RecordParser::RecordField - Return the value of an arbitrary field /*{{*/ + // --------------------------------------------------------------------- + /* */ + string debRecordParser::RecordField(const char *fieldName) + { + return Section.FindS(fieldName); + } + + /*}}}*/ // RecordParser::ShortDesc - Return a 1 line description /*{{{*/ // --------------------------------------------------------------------- /* */ @@@ -128,7 -135,7 +137,7 @@@ string debRecordParser::LongDesc( { vector const lang = APT::Configuration::getLanguages(); for (vector::const_iterator l = lang.begin(); - orig.empty() && l != lang.end(); l++) + orig.empty() && l != lang.end(); ++l) orig = Section.FindS(string("Description-").append(*l).c_str()); } diff --combined apt-pkg/deb/dpkgpm.cc index 7733390c0,3c4c244cc..2c34465c0 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@@ -8,8 -8,6 +8,8 @@@ ##################################################################### */ /*}}}*/ // Includes /*{{{*/ +#include + #include #include #include @@@ -42,6 -40,7 +42,6 @@@ #include #include -#include #include /*}}}*/ @@@ -230,7 -229,7 +230,7 @@@ bool pkgDPkgPM::SendV2Pkgs(FILE *F fprintf(F,"\n"); // Write out the package actions in order. - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { if(I->Pkg.end() == true) continue; @@@ -352,7 -351,7 +352,7 @@@ bool pkgDPkgPM::RunScriptsWithPkgs(cons // Feed it the filenames. if (Version <= 1) { - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Only deal with packages to be installed from .deb if (I->Op != Item::Install) @@@ -707,7 -706,7 +707,7 @@@ bool pkgDPkgPM::OpenLog( chmod(history_name.c_str(), 0644); fprintf(d->history_out, "\nStart-Date: %s\n", timestr); string remove, purge, install, reinstall, upgrade, downgrade; - for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { enum { CANDIDATE, CANDIDATE_AUTO, CURRENT_CANDIDATE, CURRENT } infostring; string *line = NULL; @@@ -885,14 -884,14 +885,14 @@@ bool pkgDPkgPM::Go(int OutStatusFd // that will be [installed|configured|removed|purged] and add // them to the PackageOps map (the dpkg states it goes through) // and the PackageOpsTranslations (human readable strings) - for (vector::const_iterator I = List.begin(); I != List.end();I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) { if((*I).Pkg.end() == true) continue; string const name = (*I).Pkg.Name(); PackageOpsDone[name] = 0; - for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; i++) + for(int i=0; (DpkgStatesOpMap[(*I).Op][i]).state != NULL; ++i) { PackageOps[name].push_back(DpkgStatesOpMap[(*I).Op][i]); PackagesTotal++; @@@ -910,7 -909,7 +910,7 @@@ // Do all actions with the same Op in one run vector::const_iterator J = I; if (TriggersPending == true) - for (; J != List.end(); J++) + for (; J != List.end(); ++J) { if (J->Op == I->Op) continue; @@@ -922,7 -921,7 +922,7 @@@ break; } else - for (; J != List.end() && J->Op == I->Op; J++) + for (; J != List.end() && J->Op == I->Op; ++J) /* nothing */; // Generate the argument list @@@ -1028,7 -1027,7 +1028,7 @@@ // Write in the file or package names if (I->Op == Item::Install) { - for (;I != J && Size < MaxArgBytes; I++) + for (;I != J && Size < MaxArgBytes; ++I) { if (I->File[0] != '/') return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str()); @@@ -1040,7 -1039,7 +1040,7 @@@ { string const nativeArch = _config->Find("APT::Architecture"); unsigned long const oldSize = I->Op == Item::Configure ? Size : 0; - for (;I != J && Size < MaxArgBytes; I++) + for (;I != J && Size < MaxArgBytes; ++I) { if((*I).Pkg.end() == true) continue; @@@ -1478,7 -1477,7 +1478,7 @@@ void pkgDPkgPM::WriteApportReport(cons // log the ordering const char *ops_str[] = {"Install", "Configure","Remove","Purge"}; fprintf(report, "AptOrdering:\n"); - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) fprintf(report, " %s: %s\n", (*I).Pkg.Name(), ops_str[(*I).Op]); // attach dmesg log (to learn about segfaults) diff --combined apt-pkg/depcache.cc index 8dde7c173,e9527647e..f816630ae --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@@ -8,8 -8,6 +8,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -25,12 -23,12 +25,12 @@@ #include #include -#include +#include #include #include -#include +#include /*}}}*/ // helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/ static bool @@@ -131,7 -129,7 +131,7 @@@ bool pkgDepCache::Init(OpProgress *Prog /* Set the current state of everything. In this state all of the packages are kept exactly as is. See AllUpgrade */ int Done = 0; - for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++) + for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done) { if (Prog != 0 && Done%20 == 0) Prog->Progress(Done); @@@ -171,14 -169,14 +171,14 @@@ bool pkgDepCache::readStateFile(OpProgr string const state = _config->FindFile("Dir::State::extended_states"); if(RealFileExists(state)) { state_file.Open(state, FileFd::ReadOnly); - int const file_size = state_file.Size(); + off_t const file_size = state_file.Size(); if(Prog != NULL) Prog->OverallProgress(0, file_size, 1, _("Reading state information")); pkgTagFile tagfile(&state_file); pkgTagSection section; - int amt = 0; + off_t amt = 0; bool const debug_autoremove = _config->FindB("Debug::pkgAutoRemove",false); while(tagfile.Step(section)) { string const pkgname = section.FindS("Package"); @@@ -294,7 -292,7 +294,7 @@@ bool pkgDepCache::writeStateFile(OpProg // then write the ones we have not seen yet std::ostringstream ostr; - for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); pkg++) { + for(pkgCache::PkgIterator pkg=Cache->PkgBegin(); !pkg.end(); ++pkg) { StateCache const &P = PkgState[pkg->ID]; if(P.Flags & Flag::Auto) { if (pkgs_seen.find(pkg.FullName()) != pkgs_seen.end()) { @@@ -367,7 -365,7 +367,7 @@@ bool pkgDepCache::CheckDep(DepIterator // Check the providing packages PrvIterator P = Dep.TargetPkg().ProvidesList(); PkgIterator Pkg = Dep.ParentPkg(); - for (; P.end() != true; P++) + for (; P.end() != true; ++P) { /* Provides may never be applied against the same package (or group) if it is a conflicts. See the comment above. */ @@@ -536,7 -534,7 +536,7 @@@ void pkgDepCache::BuildGroupOrs(VerIter { unsigned char Group = 0; - for (DepIterator D = V.DependsList(); D.end() != true; D++) + for (DepIterator D = V.DependsList(); D.end() != true; ++D) { // Build the dependency state. unsigned char &State = DepState[D->ID]; @@@ -576,7 -574,7 +576,7 @@@ unsigned char pkgDepCache::VersionState // Compute a single dependency element (glob or) DepIterator Start = D; unsigned char State = 0; - for (bool LastOR = true; D.end() == false && LastOR == true; D++) + for (bool LastOR = true; D.end() == false && LastOR == true; ++D) { State |= DepState[D->ID]; LastOR = (D->CompareOp & Dep::Or) == Dep::Or; @@@ -666,15 -664,15 +666,15 @@@ void pkgDepCache::Update(OpProgress *Pr // Perform the depends pass int Done = 0; - for (PkgIterator I = PkgBegin(); I.end() != true; I++,Done++) + for (PkgIterator I = PkgBegin(); I.end() != true; ++I, ++Done) { if (Prog != 0 && Done%20 == 0) Prog->Progress(Done); - for (VerIterator V = I.VersionList(); V.end() != true; V++) + for (VerIterator V = I.VersionList(); V.end() != true; ++V) { unsigned char Group = 0; - for (DepIterator D = V.DependsList(); D.end() != true; D++) + for (DepIterator D = V.DependsList(); D.end() != true; ++D) { // Build the dependency state. unsigned char &State = DepState[D->ID]; @@@ -711,7 -709,7 +711,7 @@@ void pkgDepCache::Update(DepIterator D) { // Update the reverse deps - for (;D.end() != true; D++) + for (;D.end() != true; ++D) { unsigned char &State = DepState[D->ID]; State = DependencyState(D); @@@ -744,13 -742,13 +744,13 @@@ void pkgDepCache::Update(PkgIterator co // Update the provides map for the current ver if (Pkg->CurrentVer != 0) for (PrvIterator P = Pkg.CurrentVer().ProvidesList(); - P.end() != true; P++) + P.end() != true; ++P) Update(P.ParentPkg().RevDependsList()); // Update the provides map for the candidate ver if (PkgState[Pkg->ID].CandidateVer != 0) for (PrvIterator P = PkgState[Pkg->ID].CandidateVerIter(*this).ProvidesList(); - P.end() != true; P++) + P.end() != true; ++P) Update(P.ParentPkg().RevDependsList()); } /*}}}*/ @@@ -1011,7 -1009,7 +1011,7 @@@ bool pkgDepCache::MarkInstall(PkgIterat DepIterator Start = Dep; bool Result = true; unsigned Ors = 0; - for (bool LastOR = true; Dep.end() == false && LastOR == true; Dep++,Ors++) + for (bool LastOR = true; Dep.end() == false && LastOR == true; ++Dep, ++Ors) { LastOR = (Dep->CompareOp & Dep::Or) == Dep::Or; @@@ -1477,12 -1475,12 +1477,12 @@@ pkgCache::VerIterator pkgDepCache::Poli unless they are already installed */ VerIterator Last(*(pkgCache *)this,0); - for (VerIterator I = Pkg.VersionList(); I.end() == false; I++) + for (VerIterator I = Pkg.VersionList(); I.end() == false; ++I) { if (Pkg.CurrentVer() == I) return I; - for (VerFileIterator J = I.FileList(); J.end() == false; J++) + for (VerFileIterator J = I.FileList(); J.end() == false; ++J) { if ((J.File()->Flags & Flag::NotSource) != 0) continue; @@@ -1513,7 -1511,7 +1513,7 @@@ bool pkgDepCache::Policy::IsImportantDe return true; else if(Dep->Type == pkgCache::Dep::Recommends) { - if ( _config->FindB("APT::Install-Recommends", false)) + if (InstallRecommends) return true; // we suport a special mode to only install-recommends for certain // sections @@@ -1524,7 -1522,7 +1524,7 @@@ return true; } else if(Dep->Type == pkgCache::Dep::Suggests) - return _config->FindB("APT::Install-Suggests", false); + return InstallSuggests; return false; } diff --combined apt-pkg/indexcopy.cc index f52ecbbcb,747e464be..4df018ef4 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@@ -10,7 -10,7 +10,7 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "indexcopy.h" +#include #include #include @@@ -21,6 -21,7 +21,6 @@@ #include #include #include -#include #include #include @@@ -29,10 -30,6 +29,10 @@@ #include #include #include +#include + +#include "indexcopy.h" +#include /*}}}*/ using namespace std; @@@ -46,7 -43,7 +46,7 @@@ bool IndexCopy::CopyPackages(string CDR pkgCdromStatus *log) { OpProgress *Progress = NULL; - if (List.size() == 0) + if (List.empty() == true) return true; if(log) @@@ -56,8 -53,8 +56,8 @@@ bool Debug = _config->FindB("Debug::aptcdrom",false); // Prepare the progress indicator - unsigned long TotalSize = 0; + off_t TotalSize = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { struct stat Buf; if (stat(string(*I + GetFileName()).c_str(),&Buf) != 0 && @@@ -67,14 -64,14 +67,14 @@@ TotalSize += Buf.st_size; } - unsigned long CurrentSize = 0; + off_t CurrentSize = 0; unsigned int NotFound = 0; unsigned int WrongSize = 0; unsigned int Packages = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string OrigPath = string(*I,CDROM.length()); - unsigned long FileSize = 0; + off_t FileSize = 0; // Open the package file FileFd Pkg; @@@ -167,7 -164,7 +167,7 @@@ if(Progress) Progress->Progress(Parser.Offset()); string File; - unsigned long Size; + unsigned long long Size; if (GetFile(File,Size) == false) { fclose(TargetFl); @@@ -222,7 -219,7 +222,7 @@@ } // Size match - if ((unsigned)Buf.st_size != Size) + if ((unsigned long long)Buf.st_size != Size) { if (Debug == true) clog << "Wrong Size: " << File << endl; @@@ -456,7 -453,7 +456,7 @@@ bool IndexCopy::GrabFirst(string Path,s // PackageCopy::GetFile - Get the file information from the section /*{{{*/ // --------------------------------------------------------------------- /* */ -bool PackageCopy::GetFile(string &File,unsigned long &Size) +bool PackageCopy::GetFile(string &File,unsigned long long &Size) { File = Section->FindS("Filename"); Size = Section->FindI("Size"); @@@ -482,7 -479,7 +482,7 @@@ bool PackageCopy::RewriteEntry(FILE *Ta // SourceCopy::GetFile - Get the file information from the section /*{{{*/ // --------------------------------------------------------------------- /* */ -bool SourceCopy::GetFile(string &File,unsigned long &Size) +bool SourceCopy::GetFile(string &File,unsigned long long &Size) { string Files = Section->FindS("Files"); if (Files.empty() == true) @@@ -505,7 -502,7 +505,7 @@@ return _error->Error("Error parsing file record"); // Parse the size and append the directory - Size = atoi(sSize.c_str()); + Size = strtoull(sSize.c_str(), NULL, 10); File = Base + File; return true; } @@@ -586,13 -583,13 +586,13 @@@ bool SigVerify::CopyMetaIndex(string CD bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, /*{{{*/ vector PkgList,vector SrcList) { - if (SigList.size() == 0) + if (SigList.empty() == true) return true; bool Debug = _config->FindB("Debug::aptcdrom",false); // Read all Release files - for (vector::iterator I = SigList.begin(); I != SigList.end(); I++) + for (vector::iterator I = SigList.begin(); I != SigList.end(); ++I) { if(Debug) cout << "Signature verify for: " << *I << endl; @@@ -636,7 -633,7 +636,7 @@@ // go over the Indexfiles and see if they verify // if so, remove them from our copy of the lists vector keys = MetaIndex->MetaKeys(); - for (vector::iterator I = keys.begin(); I != keys.end(); I++) + for (vector::iterator I = keys.begin(); I != keys.end(); ++I) { if(!Verify(prefix,*I, MetaIndex)) { // something went wrong, don't copy the Release.gpg @@@ -779,7 -776,7 +779,7 @@@ bool TranslationsCopy::CopyTranslations vector &List, pkgCdromStatus *log) { OpProgress *Progress = NULL; - if (List.size() == 0) + if (List.empty() == true) return true; if(log) @@@ -788,8 -785,8 +788,8 @@@ bool Debug = _config->FindB("Debug::aptcdrom",false); // Prepare the progress indicator - unsigned long TotalSize = 0; + off_t TotalSize = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { struct stat Buf; if (stat(string(*I).c_str(),&Buf) != 0 && @@@ -799,14 -796,14 +799,14 @@@ TotalSize += Buf.st_size; } - unsigned long CurrentSize = 0; + off_t CurrentSize = 0; unsigned int NotFound = 0; unsigned int WrongSize = 0; unsigned int Packages = 0; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { string OrigPath = string(*I,CDROM.length()); - unsigned long FileSize = 0; + off_t FileSize = 0; // Open the package file FileFd Pkg; @@@ -888,7 -885,6 +888,6 @@@ this->Section = &Section; string Prefix; unsigned long Hits = 0; - unsigned long Chop = 0; while (Parser.Step(Section) == true) { if(Progress) @@@ -906,7 -902,7 +905,7 @@@ fclose(TargetFl); if (Debug == true) - cout << " Processed by using Prefix '" << Prefix << "' and chop " << Chop << endl; + cout << " Processed by using Prefix '" << Prefix << "' and chop " << endl; if (_config->FindB("APT::CDROM::NoAct",false) == false) { diff --combined apt-pkg/indexfile.cc index b56d9dc6c,f18ddbfaa..68e9df4c8 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@@ -8,8 -8,6 +8,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -29,7 -27,8 +29,8 @@@ unsigned long pkgIndexFile::Type::Globa pkgIndexFile::Type::Type() { ItmList[GlobalListLen] = this; - GlobalListLen++; + GlobalListLen++; + Label = NULL; } /*}}}*/ // Type::GetType - Locate the type by name /*{{{*/ diff --combined apt-pkg/orderlist.cc index 4dcb31b7e,a58efa987..eb19e18db --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@@ -63,8 -63,6 +63,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -147,13 -145,13 +147,13 @@@ bool pkgOrderList::DoRun( Depth = 0; WipeFlags(Added | AddPending | Loop | InList); - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) Flag(*I,InList); // Rebuild the main list into the temp list. iterator OldEnd = End; End = NList; - for (iterator I = List; I != OldEnd; I++) + for (iterator I = List; I != OldEnd; ++I) if (VisitNode(PkgIterator(Cache,*I)) == false) { End = OldEnd; @@@ -199,7 -197,7 +199,7 @@@ bool pkgOrderList::OrderCritical( { clog << "** Critical Unpack ordering done" << endl; - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsNow(P) == true) @@@ -224,7 -222,7 +224,7 @@@ bool pkgOrderList::OrderUnpack(string * WipeFlags(After); // Set the inlist flag - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsMissing(P) == true && IsNow(P) == true) @@@ -272,7 -270,7 +272,7 @@@ { clog << "** Unpack ordering done" << endl; - for (iterator I = List; I != End; I++) + for (iterator I = List; I != End; ++I) { PkgIterator P(Cache,*I); if (IsNow(P) == true) @@@ -325,7 -323,7 +325,7 @@@ int pkgOrderList::Score(PkgIterator Pkg Score += ScoreImmediate; for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); - D.end() == false; D++) + D.end() == false; ++D) if (D->Type == pkgCache::Dep::PreDepends) { Score += ScorePreDepends; @@@ -490,7 -488,7 +490,7 @@@ bool pkgOrderList::VisitRProvides(DepFu return true; bool Res = true; - for (PrvIterator P = Ver.ProvidesList(); P.end() == false; P++) + for (PrvIterator P = Ver.ProvidesList(); P.end() == false; ++P) Res &= (this->*F)(P.ParentPkg().RevDependsList()); return Res; } @@@ -617,7 -615,7 +617,7 @@@ bool pkgOrderList::VisitNode(PkgIterato Loops are preprocessed and logged. */ bool pkgOrderList::DepUnPackCrit(DepIterator D) { - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { if (D.Reverse() == true) { @@@ -695,7 -693,7 +695,7 @@@ bool pkgOrderList::DepUnPackPreD(DepIte if (D.Reverse() == true) return DepUnPackCrit(D); - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { if (D.IsCritical() == false) continue; @@@ -738,7 -736,7 +738,7 @@@ bool pkgOrderList::DepUnPackPre(DepIter if (D.Reverse() == true) return true; - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { /* Only consider the PreDepends or Depends. Depends are only considered at the lowest depth or in the case of immediate @@@ -793,7 -791,7 +793,7 @@@ bool pkgOrderList::DepUnPackDep(DepIterator D) { - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D.IsCritical() == true) { if (D.Reverse() == true) @@@ -848,7 -846,7 +848,7 @@@ bool pkgOrderList::DepConfigure(DepIter if (D.Reverse() == true) return true; - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D->Type == pkgCache::Dep::Depends) if (VisitProvides(D,false) == false) return false; @@@ -870,7 -868,7 +870,7 @@@ bool pkgOrderList::DepRemove(DepIterato { if (D.Reverse() == false) return true; - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { // Duplication elimination, consider the current version only diff --combined apt-pkg/packagemanager.cc index 6f9f4748f,a3ba26f7c..fa28dc5b2 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@@ -13,8 -13,6 +13,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -24,10 -22,10 +24,10 @@@ #include #include #include - -#include + +#include #include -#include +#include /*}}}*/ using namespace std; @@@ -65,7 -63,7 +65,7 @@@ bool pkgPackageManager::GetArchives(pkg if (ordering == false) return _error->Error("Internal ordering error"); - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); FileNames[Pkg->ID] = string(); @@@ -101,7 -99,7 +101,7 @@@ bool pkgPackageManager::FixMissing( List->SetFileList(FileNames); bool Bad = false; - for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { if (List->IsMissing(I) == false) continue; @@@ -142,7 -140,7 +142,7 @@@ void pkgPackageManager::ImmediateAdd(Pk D = I.CurrentVer().DependsList(); } - for ( /* nothing */ ; D.end() == false; D++) + for ( /* nothing */ ; D.end() == false; ++D) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { if(!List->IsFlag(D.TargetPkg(), pkgOrderList::Immediate)) @@@ -171,7 -169,7 +171,7 @@@ bool pkgPackageManager::CreateOrderList static bool const NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); // Generate the list of affected packages and sort it - for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) + for (PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) { // Ignore no-version packages if (I->VersionList == 0) @@@ -231,7 -229,7 +231,7 @@@ bool pkgPackageManager::DepAlwaysTrue(D bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D, const char *Ver) { - for (;D.end() == false; D++) + for (;D.end() == false; ++D) { if (D->Type != pkgCache::Dep::Conflicts && D->Type != pkgCache::Dep::Obsoletes) @@@ -264,7 -262,7 +264,7 @@@ bool pkgPackageManager::ConfigureAll( pkgOrderList OList(&Cache); // Populate the order list - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) if (List->IsFlag(pkgCache::PkgIterator(Cache,*I), pkgOrderList::UnPacked) == true) OList.push_back(*I); @@@ -276,7 -274,7 +276,7 @@@ bool const ConfigurePkgs = (conf == "all"); // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) + for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I) { PkgIterator Pkg(Cache,*I); @@@ -311,7 -309,7 +311,7 @@@ bool pkgPackageManager::SmartConfigure( return false; // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) + for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); ++I) { PkgIterator Pkg(Cache,*I); @@@ -366,13 -364,13 +366,13 @@@ bool pkgPackageManager::DepAdd(pkgOrder { if (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends) { - D++; + ++D; continue; } // Grok or groups Bad = true; - for (bool LastOR = true; D.end() == false && LastOR == true; D++) + for (bool LastOR = true; D.end() == false && LastOR == true; ++D) { LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; @@@ -380,7 -378,7 +380,7 @@@ continue; SPtrArray VList = D.AllTargets(); - for (Version **I = VList; *I != 0 && Bad == true; I++) + for (Version **I = VList; *I != 0 && Bad == true; ++I) { VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); @@@ -446,7 -444,7 +446,7 @@@ bool pkgPackageManager::EarlyRemove(Pkg if (Pkg->CurrentVer != 0) { for (DepIterator D = Pkg.RevDependsList(); D.end() == false && - IsEssential == false; D++) + IsEssential == false; ++D) if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) if ((D.ParentPkg()->Flags & pkgCache::Flag::Essential) != 0) IsEssential = true; @@@ -566,7 -564,7 +566,7 @@@ bool pkgPackageManager::SmartUnPack(Pkg return _error->Error("Couldn't configure pre-depend %s for %s, " "probably a dependency cycle.", End.TargetPkg().Name(),Pkg.Name()); - Start++; + ++Start; } else break; @@@ -599,7 -597,7 +599,7 @@@ return false; for (PrvIterator P = instVer.ProvidesList(); - P.end() == false; P++) + P.end() == false; ++P) CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); @@@ -654,7 -652,7 +654,7 @@@ pkgPackageManager::OrderResult pkgPacka clog << "Done ordering" << endl; bool DoneSomething = false; - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { PkgIterator Pkg(Cache,*I); @@@ -703,7 -701,7 +703,7 @@@ return Failed; // Sanity check - for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) + for (pkgOrderList::iterator I = List->begin(); I != List->end(); ++I) { if (List->IsFlag(*I,pkgOrderList::Configured) == false) { diff --combined apt-pkg/pkgcache.cc index 0a81cb791,faccafbef..94c58f1f0 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@@ -20,8 -20,6 +20,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -31,12 -29,13 +31,12 @@@ #include #include -#include - #include #include #include - #include + +#include /*}}}*/ using std::string; @@@ -85,6 -84,8 +85,8 @@@ pkgCache::Header::Header( memset(PkgHashTable,0,sizeof(PkgHashTable)); memset(GrpHashTable,0,sizeof(GrpHashTable)); memset(Pools,0,sizeof(Pools)); + + CacheFileSize = 0; } /*}}}*/ // Cache::Header::CheckSizes - Check if the two headers have same *sz /*{{{*/ @@@ -156,6 -157,9 +158,9 @@@ bool pkgCache::ReMap(bool const &Errorc HeaderP->CheckSizes(DefHeader) == false) return _error->Error(_("The package cache file is an incompatible version")); + if (Map.Size() < HeaderP->CacheFileSize) + return _error->Error(_("The package cache file is corrupted, it is too small")); + // Locate our VS.. if (HeaderP->VerSysName == 0 || (VS = pkgVersioningSystem::GetVS(StrP + HeaderP->VerSysName)) == 0) @@@ -176,7 -180,7 +181,7 @@@ unsigned long pkgCache::sHash(const string &Str) const { unsigned long Hash = 0; - for (string::const_iterator I = Str.begin(); I != Str.end(); I++) + for (string::const_iterator I = Str.begin(); I != Str.end(); ++I) Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->PkgHashTable); } @@@ -184,7 -188,7 +189,7 @@@ unsigned long pkgCache::sHash(const char *Str) const { unsigned long Hash = 0; - for (const char *I = Str; *I != 0; I++) + for (const char *I = Str; *I != 0; ++I) Hash = 5*Hash + tolower_ascii(*I); return Hash % _count(HeaderP->PkgHashTable); } @@@ -570,7 -574,7 +575,7 @@@ bool pkgCache::DepIterator::SmartTarget virtual package libc-dev which is provided by libc5-dev and libc6-dev we must ignore libc5-dev when considering the provides list. */ PrvIterator PStart = Result.ProvidesList(); - for (; PStart.end() != true && PStart.OwnerPkg() == ParentPkg(); PStart++); + for (; PStart.end() != true && PStart.OwnerPkg() == ParentPkg(); ++PStart); // Nothing but indirect self provides if (PStart.end() == true) @@@ -578,7 -582,7 +583,7 @@@ // Check for single packages in the provides list PrvIterator P = PStart; - for (; P.end() != true; P++) + for (; P.end() != true; ++P) { // Skip over self provides if (P.OwnerPkg() == ParentPkg()) @@@ -612,7 -616,7 +617,7 @@@ pkgCache::Version **pkgCache::DepIterat PkgIterator DPkg = TargetPkg(); // Walk along the actual package providing versions - for (VerIterator I = DPkg.VersionList(); I.end() == false; I++) + for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I) { if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false) continue; @@@ -627,7 -631,7 +632,7 @@@ } // Follow all provides - for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; I++) + for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I) { if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false) continue; @@@ -718,7 -722,7 +723,7 @@@ int pkgCache::VerIterator::CompareVer(c /* Start at A and look for B. If B is found then A > B otherwise B was before A so A < B */ VerIterator I = *this; - for (;I.end() == false; I++) + for (;I.end() == false; ++I) if (I == B) return 1; return -1; @@@ -730,7 -734,7 +735,7 @@@ bool pkgCache::VerIterator::Downloadable() const { VerFileIterator Files = FileList(); - for (; Files.end() == false; Files++) + for (; Files.end() == false; ++Files) if ((Files.File()->Flags & pkgCache::Flag::NotSource) != pkgCache::Flag::NotSource) return true; return false; @@@ -743,7 -747,7 +748,7 @@@ bool pkgCache::VerIterator::Automatic() const { VerFileIterator Files = FileList(); - for (; Files.end() == false; Files++) + for (; Files.end() == false; ++Files) // Do not check ButAutomaticUpgrades here as it is kind of automatic… if ((Files.File()->Flags & pkgCache::Flag::NotAutomatic) != pkgCache::Flag::NotAutomatic) return true; @@@ -758,7 -762,7 +763,7 @@@ pkgCache::VerFileIterator pkgCache::Ver { VerFileIterator Files = FileList(); VerFileIterator Highest = Files; - for (; Files.end() == false; Files++) + for (; Files.end() == false; ++Files) { if (Owner->VS->CmpReleaseVer(Files.File().Version(),Highest.File().Version()) > 0) Highest = Files; @@@ -775,7 -779,7 +780,7 @@@ string pkgCache::VerIterator::RelStr() { bool First = true; string Res; - for (pkgCache::VerFileIterator I = this->FileList(); I.end() == false; I++) + for (pkgCache::VerFileIterator I = this->FileList(); I.end() == false; ++I) { // Do not print 'not source' entries' pkgCache::PkgFileIterator File = I.File(); @@@ -784,7 -788,7 +789,7 @@@ // See if we have already printed this out.. bool Seen = false; - for (pkgCache::VerFileIterator J = this->FileList(); I != J; J++) + for (pkgCache::VerFileIterator J = this->FileList(); I != J; ++J) { pkgCache::PkgFileIterator File2 = J.File(); if (File2->Label == 0 || File->Label == 0) @@@ -885,7 -889,7 +890,7 @@@ pkgCache::DescIterator pkgCache::VerIte { std::vector const lang = APT::Configuration::getLanguages(); for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); l++) + l != lang.end(); ++l) { pkgCache::DescIterator Desc = DescriptionList(); for (; Desc.end() == false; ++Desc) diff --combined apt-pkg/pkgcachegen.cc index 1cae23134,f41bb5a0a..a39aa9f59 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@@ -11,7 -11,6 +11,7 @@@ /*}}}*/ // Include Files /*{{{*/ #define APT_COMPATIBILITY 986 +#include #include #include @@@ -24,15 -23,17 +24,15 @@@ #include #include #include - #include -#include - #include - #include #include #include #include + +#include /*}}}*/ typedef vector::iterator FileIterator; template std::vector pkgCacheGenerator::Dynamic::toReMap; @@@ -97,6 -98,7 +97,7 @@@ pkgCacheGenerator::~pkgCacheGenerator( return; Cache.HeaderP->Dirty = false; + Cache.HeaderP->CacheFileSize = Map.Size(); Map.Sync(0,sizeof(pkgCache::Header)); } /*}}}*/ @@@ -104,6 -106,9 +105,9 @@@ void pkgCacheGenerator::ReMap(void cons if (oldMap == newMap) return; + if (_config->FindB("Debug::pkgCacheGen", false)) + std::clog << "Remaping from " << oldMap << " to " << newMap << std::endl; + Cache.ReMap(false); CurrentFile += (pkgCache::PackageFile*) newMap - (pkgCache::PackageFile*) oldMap; @@@ -216,7 -221,7 +220,7 @@@ bool pkgCacheGenerator::MergeList(ListP // don't add a new description if we have one for the given // md5 && language - for ( ; Desc.end() == false; Desc++) + for ( ; Desc.end() == false; ++Desc) if (MD5SumValue(Desc.md5()) == CurMd5 && Desc.LanguageCode() == List.DescriptionLanguage()) duplicate=true; @@@ -225,7 -230,7 +229,7 @@@ for (Desc = Ver.DescriptionList(); Desc.end() == false; - LastDesc = &Desc->NextDesc, Desc++) + LastDesc = &Desc->NextDesc, ++Desc) { if (MD5SumValue(Desc.md5()) == CurMd5) { @@@ -391,7 -396,7 +395,7 @@@ bool pkgCacheGenerator::MergeFileProvid unsigned long Hash = List.VersionHash(); pkgCache::VerIterator Ver = Pkg.VersionList(); Dynamic DynVer(Ver); - for (; Ver.end() == false; Ver++) + for (; Ver.end() == false; ++Ver) { if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr()) { @@@ -507,7 -512,7 +511,7 @@@ bool pkgCacheGenerator::NewFileVer(pkgC // Link it to the end of the list map_ptrloc *Last = &Ver->FileList; - for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; V++) + for (pkgCache::VerFileIterator V = Ver.FileList(); V.end() == false; ++V) Last = &V->NextFile; VF->NextFile = *Last; *Last = VF.Index(); @@@ -564,7 -569,7 +568,7 @@@ bool pkgCacheGenerator::NewFileDesc(pkg // Link it to the end of the list map_ptrloc *Last = &Desc->FileList; - for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; D++) + for (pkgCache::DescFileIterator D = Desc.FileList(); D.end() == false; ++D) Last = &D->NextFile; DF->NextFile = *Last; @@@ -619,7 -624,7 +623,7 @@@ bool pkgCacheGenerator::FinishCache(OpP // Create Conflicts in between the group pkgCache::GrpIterator G = GetCache().GrpBegin(); Dynamic DynG(G); - for (; G.end() != true; G++) + for (; G.end() != true; ++G) { string const PkgName = G.Name(); pkgCache::PkgIterator P = G.PackageList(); @@@ -630,9 -635,11 +634,11 @@@ Dynamic DynallPkg(allPkg); pkgCache::VerIterator V = P.VersionList(); Dynamic DynV(V); - for (; V.end() != true; V++) + for (; V.end() != true; ++V) { - char const * const Arch = P.Arch(); + // copy P.Arch() into a string here as a cache remap + // in NewDepends() later may alter the pointer location + string Arch = P.Arch() == NULL ? "" : P.Arch(); map_ptrloc *OldDepLast = NULL; /* MultiArch handling introduces a lot of implicit Dependencies: - MultiArch: same → Co-Installable if they have the same version @@@ -641,7 -648,7 +647,7 @@@ bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same); for (vector::const_iterator A = archs.begin(); A != archs.end(); ++A) { - if (Arch == 0 || *A == Arch) + if (*A == Arch) continue; /* We allow only one installed arch at the time per group, therefore each group member conflicts @@@ -683,7 -690,7 +689,7 @@@ bool pkgCacheGenerator::NewDepends(pkgC string const &Version, unsigned int const &Op, unsigned int const &Type, - map_ptrloc *OldDepLast) + map_ptrloc* &OldDepLast) { void const * const oldMap = Map.Data(); // Get a structure @@@ -722,7 -729,7 +728,7 @@@ if (OldDepLast == NULL) { OldDepLast = &Ver->DependsList; - for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) OldDepLast = &D->NextDepends; } else if (oldMap != Map.Data()) OldDepLast += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; @@@ -914,8 -921,11 +920,11 @@@ unsigned long pkgCacheGenerator::WriteU /* This just verifies that each file in the list of index files exists, has matching attributes with the cache and the cache does not have any extra files. */ - static bool CheckValidity(const string &CacheFile, FileIterator Start, - FileIterator End,MMap **OutMap = 0) + static bool CheckValidity(const string &CacheFile, + pkgSourceList &List, + FileIterator Start, + FileIterator End, + MMap **OutMap = 0) { bool const Debug = _config->FindB("Debug::pkgCacheGen", false); // No file, certainly invalid @@@ -926,6 -936,13 +935,13 @@@ return false; } + if (List.GetLastModifiedTime() > GetModificationTime(CacheFile)) + { + if (Debug == true) + std::clog << "sources.list is newer than the cache" << std::endl; + return false; + } + // Map it FileFd CacheF(CacheFile,FileFd::ReadOnly); SPtr Map = new MMap(CacheF,0); @@@ -942,7 -959,7 +958,7 @@@ verify the IMS data and check that it is on the disk too.. */ SPtrArray Visited = new bool[Cache.HeaderP->PackageFileCount]; memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount); - for (; Start != End; Start++) + for (; Start != End; ++Start) { if (Debug == true) std::clog << "Checking PkgFile " << (*Start)->Describe() << ": "; @@@ -1009,7 -1026,7 +1025,7 @@@ static unsigned long ComputeSize(FileIterator Start,FileIterator End) { unsigned long TotalSize = 0; - for (; Start != End; Start++) + for (; Start != End; ++Start) { if ((*Start)->HasPackages() == false) continue; @@@ -1027,7 -1044,7 +1043,7 @@@ static bool BuildCache(pkgCacheGenerato FileIterator Start, FileIterator End) { FileIterator I; - for (I = Start; I != End; I++) + for (I = Start; I != End; ++I) { if ((*I)->HasPackages() == false) continue; @@@ -1057,7 -1074,7 +1073,7 @@@ Progress->Done(); TotalSize = ComputeSize(Start, End); CurrentSize = 0; - for (I = Start; I != End; I++) + for (I = Start; I != End; ++I) { unsigned long Size = (*I)->Size(); if (Progress != NULL) @@@ -1104,12 -1121,12 +1120,12 @@@ bool pkgCacheGenerator::MakeStatusCache vector Files; for (vector::const_iterator i = List.begin(); i != List.end(); - i++) + ++i) { vector *Indexes = (*i)->GetIndexFiles(); for (vector::const_iterator j = Indexes->begin(); j != Indexes->end(); - j++) + ++j) Files.push_back (*j); } @@@ -1151,7 -1168,7 +1167,7 @@@ Progress->OverallProgress(0,1,1,_("Reading package lists")); // Cache is OK, Fin. - if (CheckValidity(CacheFile,Files.begin(),Files.end(),OutMap) == true) + if (CheckValidity(CacheFile, List, Files.begin(),Files.end(),OutMap) == true) { if (Progress != NULL) Progress->OverallProgress(1,1,1,_("Reading package lists")); @@@ -1204,7 -1221,7 +1220,7 @@@ // Lets try the source cache. unsigned long CurrentSize = 0; unsigned long TotalSize = 0; - if (CheckValidity(SrcCacheFile,Files.begin(), + if (CheckValidity(SrcCacheFile, List, Files.begin(), Files.begin()+EndOfSource) == true) { if (Debug == true) diff --combined apt-pkg/pkgrecords.cc index 9459f7def,1a7585d8f..7709f133a --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@@ -9,14 -9,12 +9,14 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include - -#include + +#include /*}}}*/ // Records::pkgRecords - Constructor /*{{{*/ @@@ -26,7 -24,7 +26,7 @@@ pkgRecords::pkgRecords(pkgCache &Cache Files(Cache.HeaderP->PackageFileCount) { for (pkgCache::PkgFileIterator I = Cache.FileBegin(); - I.end() == false; I++) + I.end() == false; ++I) { const pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(I.IndexType()); if (Type == 0) diff --combined apt-pkg/pkgrecords.h index 840454e18,ce92cacc4..8741533b9 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@@ -19,6 -19,7 +19,6 @@@ #include -#include #include class pkgRecords /*{{{*/ @@@ -68,7 -69,10 +68,10 @@@ class pkgRecords::Parser /*{{{* virtual string LongDesc() {return string();}; virtual string Name() {return string();}; virtual string Homepage() {return string();} - + + // An arbitrary custom field + virtual string RecordField(const char *fieldName) { return string();}; + // The record in binary form virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;}; diff --combined apt-pkg/policy.cc index 372b58a7c,0cc77e0af..e6c44ebe2 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@@ -23,8 -23,6 +23,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -33,10 -31,10 +33,10 @@@ #include #include -#include - #include #include + +#include /*}}}*/ using namespace std; @@@ -58,8 -56,22 +58,22 @@@ pkgPolicy::pkgPolicy(pkgCache *Owner) // The config file has a master override. string DefRel = _config->Find("APT::Default-Release"); if (DefRel.empty() == false) - CreatePin(pkgVersionMatch::Release,"",DefRel,990); - + { + bool found = false; + // FIXME: make ExpressionMatches static to use it here easily + pkgVersionMatch vm("", pkgVersionMatch::None); + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) + { + if ((F->Archive != 0 && vm.ExpressionMatches(DefRel, F.Archive()) == true) || + (F->Codename != 0 && vm.ExpressionMatches(DefRel, F.Codename()) == true) || + (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true)) + found = true; + } + if (found == false) + _error->Error(_("The value '%s' is invalid for APT::Default-Release as such a release is not available in the sources"), DefRel.c_str()); + else + CreatePin(pkgVersionMatch::Release,"",DefRel,990); + } InitDefaults(); } /*}}}*/ @@@ -69,7 -81,7 +83,7 @@@ bool pkgPolicy::InitDefaults() { // Initialize the priorities based on the status of the package file - for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I != Cache->FileEnd(); I++) + for (pkgCache::PkgFileIterator I = Cache->FileBegin(); I != Cache->FileEnd(); ++I) { PFPriority[I->ID] = 500; if ((I->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource) @@@ -86,10 -98,10 +100,10 @@@ signed Cur = 989; StatusOverride = false; for (vector::const_iterator I = Defaults.begin(); I != Defaults.end(); - I++, Cur--) + ++I, --Cur) { pkgVersionMatch Match(I->Data,I->Type); - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) { if (Match.FileMatch(F) == true && Fixed[F->ID] == false) { @@@ -110,7 -122,7 +124,7 @@@ } if (_config->FindB("Debug::pkgPolicy",false) == true) - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) std::clog << "Prio of " << F.FileName() << ' ' << PFPriority[F->ID] << std::endl; return true; @@@ -150,12 -162,12 +164,12 @@@ pkgCache::VerIterator pkgPolicy::GetCan tracks the default when the default is taken away, and a permanent pin that stays at that setting. */ - for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; Ver++) + for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { /* Lets see if this version is the installed version */ bool instVer = (Pkg.CurrentVer() == Ver); - for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = Ver.FileList(); 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) @@@ -348,7 -360,7 +362,7 @@@ bool ReadPinDir(pkgPolicy &Plcy,string vector const List = GetListOfFilesInDir(Dir, "pref", true, true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadPinFile(Plcy, *I) == false) return false; return true; diff --combined apt-pkg/sourcelist.cc index d4eec5c8d,47800b0c2..e20ec4704 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@@ -8,17 -8,15 +8,17 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include -#include - #include + +#include /*}}}*/ using namespace std; @@@ -175,7 -173,7 +175,7 @@@ pkgSourceList::pkgSourceList(string Fil /* */ pkgSourceList::~pkgSourceList() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; } /*}}}*/ @@@ -220,7 -218,7 +220,7 @@@ bool pkgSourceList::ReadMainList( /* */ void pkgSourceList::Reset() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; SrcList.erase(SrcList.begin(),SrcList.end()); } @@@ -298,11 -296,11 +298,11 @@@ bool pkgSourceList::ReadAppend(string F bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, pkgIndexFile *&Found) const { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) { vector *Indexes = (*I)->GetIndexFiles(); for (vector::const_iterator J = Indexes->begin(); - J != Indexes->end(); J++) + J != Indexes->end(); ++J) { if ((*J)->FindInCache(*File.Cache()) == File) { @@@ -320,7 -318,7 +320,7 @@@ /* */ bool pkgSourceList::GetIndexes(pkgAcquire *Owner, bool GetAll) const { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) if ((*I)->GetIndexes(Owner,GetAll) == false) return false; return true; @@@ -336,11 -334,33 +336,33 @@@ bool pkgSourceList::ReadSourceDir(strin vector const List = GetListOfFilesInDir(Dir, "list", true); // Read the files - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) if (ReadAppend(*I) == false) return false; return true; } /*}}}*/ + // GetLastModified() /*{{{*/ + // --------------------------------------------------------------------- + /* */ + time_t pkgSourceList::GetLastModifiedTime() + { + vector List; + + string Main = _config->FindFile("Dir::Etc::sourcelist"); + string Parts = _config->FindDir("Dir::Etc::sourceparts"); + + // go over the parts + if (DirectoryExists(Parts) == true) + List = GetListOfFilesInDir(Parts, "list", true); + + // calculate the time + time_t mtime_sources = GetModificationTime(Main); + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) + mtime_sources = std::max(mtime_sources, GetModificationTime(*I)); + + return mtime_sources; + } + /*}}}*/ diff --combined apt-pkg/srcrecords.cc index b368322f5,946ac1a1a..8c1de2ea5 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@@ -11,14 -11,12 +11,14 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include - -#include + +#include /*}}}*/ // SrcRecords::pkgSrcRecords - Constructor /*{{{*/ @@@ -26,11 -24,11 +26,11 @@@ /* Open all the source index files */ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0) { - for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); I++) + for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); ++I) { vector *Indexes = (*I)->GetIndexFiles(); for (vector::const_iterator J = Indexes->begin(); - J != Indexes->end(); J++) + J != Indexes->end(); ++J) { Parser* P = (*J)->CreateSrcParser(); if (_error->PendingError() == true) @@@ -68,7 -66,7 +68,7 @@@ bool pkgSrcRecords::Restart( { Current = Files.begin(); for (vector::iterator I = Files.begin(); - I != Files.end(); I++) + I != Files.end(); ++I) (*I)->Restart(); return true; @@@ -91,7 -89,7 +91,7 @@@ pkgSrcRecords::Parser *pkgSrcRecords::F { if (_error->PendingError() == true) return 0; - Current++; + ++Current; if (Current == Files.end()) return 0; } @@@ -109,7 -107,7 +109,7 @@@ // Check for a binary hit const char **I = (*Current)->Binaries(); - for (; I != 0 && *I != 0; I++) + for (; I != 0 && *I != 0; ++I) if (strcmp(Package,*I) == 0) return *Current; } diff --combined apt-pkg/tagfile.h index 87d070d28,3a2dee7c7..28f7fcc24 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@@ -78,7 -78,7 +78,7 @@@ class pkgTagSectio Stop = this->Stop; }; - pkgTagSection() : Section(0), Stop(0) {}; + pkgTagSection() : Section(0), TagCount(0), Stop(0) {}; virtual ~pkgTagSection() {}; }; @@@ -94,9 -94,9 +94,9 @@@ class pkgTagFil bool Step(pkgTagSection &Section); unsigned long Offset(); - bool Jump(pkgTagSection &Tag,unsigned long Offset); + bool Jump(pkgTagSection &Tag,unsigned long long Offset); - pkgTagFile(FileFd *F,unsigned long Size = 32*1024); + pkgTagFile(FileFd *F,unsigned long long Size = 32*1024); virtual ~pkgTagFile(); }; diff --combined apt-pkg/vendorlist.cc index 8432091e8,4cc500727..731f11acf --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@@ -1,5 -1,3 +1,5 @@@ +#include + #include #include #include @@@ -13,7 -11,7 +13,7 @@@ pkgVendorList::~pkgVendorList() { for (vector::const_iterator I = VendorList.begin(); - I != VendorList.end(); I++) + I != VendorList.end(); ++I) delete *I; } @@@ -51,7 -49,7 +51,7 @@@ bool pkgVendorList::Read(string File bool pkgVendorList::CreateList(Configuration& Cnf) /*{{{*/ { for (vector::const_iterator I = VendorList.begin(); - I != VendorList.end(); I++) + I != VendorList.end(); ++I) delete *I; VendorList.erase(VendorList.begin(),VendorList.end()); @@@ -131,7 -129,7 +131,7 @@@ const Vendor* pkgVendorList::LookupFing /*}}}*/ const Vendor* pkgVendorList::FindVendor(const std::vector GPGVOutput) /*{{{*/ { - for (std::vector::const_iterator I = GPGVOutput.begin(); I != GPGVOutput.end(); I++) + for (std::vector::const_iterator I = GPGVOutput.begin(); I != GPGVOutput.end(); ++I) { string::size_type pos = (*I).find("VALIDSIG "); if (_config->FindB("Debug::Vendor", false)) diff --combined apt-pkg/versionmatch.cc index c23b4c3bf,6d667acad..f336b3c35 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@@ -11,9 -11,8 +11,9 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include +#include +#include #include #include @@@ -22,6 -21,7 +22,6 @@@ #include #include #include - /*}}}*/ // VersionMatch::pkgVersionMatch - Constructor /*{{{*/ @@@ -60,7 -60,7 +60,7 @@@ pkgVersionMatch::pkgVersionMatch(strin // Are we a simple specification? string::const_iterator I = Data.begin(); - for (; I != Data.end() && *I != '='; I++); + for (; I != Data.end() && *I != '='; ++I); if (I == Data.end()) { // Temporary @@@ -152,7 -152,7 +152,7 @@@ bool pkgVersionMatch::MatchVer(const ch pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg) { pkgCache::VerIterator Ver = Pkg.VersionList(); - for (; Ver.end() == false; Ver++) + for (; Ver.end() == false; ++Ver) { if (Type == Version) { @@@ -163,7 -163,7 +163,7 @@@ continue; } - for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; ++VF) if (FileMatch(VF.File()) == true) return Ver; } diff --combined cmdline/apt-cache.cc index 588c3c409,db5475227..a4cdf784e --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@@ -13,9 -13,8 +13,9 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include -#include #include #include #include @@@ -32,16 -31,17 +32,16 @@@ #include #include -#include -#include - +#include #include #include #include #include #include #include - #include + +#include /*}}}*/ using namespace std; @@@ -141,7 -141,7 +141,7 @@@ bool ShowUnMet(pkgCache::VerIterator co if (Start == End) break; - Start++; + ++Start; } while (1); @@@ -169,7 -169,7 +169,7 @@@ if (Start == End) break; cout << " | "; - Start++; + ++Start; } while (1); @@@ -187,7 -187,7 +187,7 @@@ bool UnMet(CommandLine &CmdL if (CmdL.FileSize() <= 1) { - for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; ++P) for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) if (ShowUnMet(V, Important) == false) return false; @@@ -217,13 -217,13 +217,13 @@@ bool DumpPackage(CommandLine &CmdL { cout << "Package: " << Pkg.FullName(true) << endl; cout << "Versions: " << endl; - for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur) { cout << Cur.VerStr(); - for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++) + for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; ++Vf) cout << " (" << Vf.File().FileName() << ")"; cout << endl; - for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; D++) + for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; ++D) { cout << " Description Language: " << D.LanguageCode() << endl << " File: " << D.FileList().File().FileName() << endl @@@ -235,7 -235,7 +235,7 @@@ cout << endl; cout << "Reverse Depends: " << endl; - for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; D++) + for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; ++D) { cout << " " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true); if (D->Version != 0) @@@ -245,24 -245,24 +245,24 @@@ } cout << "Dependencies: " << endl; - for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur) { cout << Cur.VerStr() << " - "; - for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++) + for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; ++Dep) cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") "; cout << endl; } cout << "Provides: " << endl; - for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur) { cout << Cur.VerStr() << " - "; - for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++) + for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; ++Prv) cout << Prv.ParentPkg().FullName(true) << " "; cout << endl; } cout << "Reverse Provides: " << endl; - for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++) + for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; ++Prv) cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl; } @@@ -290,7 -290,7 +290,7 @@@ bool Stats(CommandLine &Cmd int DVirt = 0; int Missing = 0; pkgCache::PkgIterator I = Cache->PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (I->VersionList != 0 && I->ProvidesList == 0) { @@@ -353,11 -353,11 +353,11 @@@ cout << _("Total globbed strings: ") << Count << " (" << SizeToStr(Size) << ')' << endl; unsigned long DepVerSize = 0; - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { - for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) + for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) { - for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D) { if (D->Version != 0) DepVerSize += strlen(D.TargetVer()) + 1; @@@ -394,17 -394,17 +394,17 @@@ bool Dump(CommandLine &Cmd cout << "Using Versioning System: " << Cache->VS->Label << endl; - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { cout << "Package: " << P.FullName(true) << endl; - for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) + for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) { cout << " Version: " << V.VerStr() << endl; cout << " File: " << V.FileList().File().FileName() << endl; - for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D) cout << " Depends: " << D.TargetPkg().FullName(true) << ' ' << DeNull(D.TargetVer()) << endl; - for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; D++) + for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; ++D) { cout << " Description Language: " << D.LanguageCode() << endl << " File: " << D.FileList().File().FileName() << endl @@@ -413,7 -413,7 +413,7 @@@ } } - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F) { cout << "File: " << F.FileName() << endl; cout << " Type: " << F.IndexType() << endl; @@@ -449,7 -449,7 +449,7 @@@ bool DumpAvail(CommandLine &Cmd memset(VFList,0,sizeof(*VFList)*Count); // Map versions that we want to write out onto the VerList array. - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { if (P->VersionList == 0) continue; @@@ -466,7 -466,7 +466,7 @@@ } pkgCache::VerFileIterator VF = V.FileList(); - for (; VF.end() == false ; VF++) + for (; VF.end() == false ; ++VF) if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0) break; @@@ -480,9 -480,9 +480,9 @@@ handling works OK. */ if (VF.end() == true) { - for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; ++Cur) { - for (VF = Cur.FileList(); VF.end() == false; VF++) + for (VF = Cur.FileList(); VF.end() == false; ++VF) { if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0) { @@@ -615,7 -615,7 +615,7 @@@ bool ShowDepends(CommandLine &CmdL, boo if (RevDepends == true) cout << "Reverse Depends:" << endl; for (pkgCache::DepIterator D = RevDepends ? Pkg.RevDependsList() : Ver.DependsList(); - D.end() == false; D++) + D.end() == false; ++D) { switch (D->Type) { case pkgCache::Dep::PreDepends: if (!ShowPreDepends) continue; break; @@@ -741,7 -741,7 +741,7 @@@ bool XVcg(CommandLine &CmdL memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount); // Map the shapes - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Pkg->VersionList == 0) { @@@ -788,7 -788,7 +788,7 @@@ while (Act == true) { Act = false; - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { // See we need to show this package if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR) @@@ -814,14 -814,14 +814,14 @@@ continue; pkgCache::VerIterator Ver = Pkg.VersionList(); - for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) { // See if anything can meet this dep // Walk along the actual package providing versions bool Hit = false; pkgCache::PkgIterator DPkg = D.TargetPkg(); for (pkgCache::VerIterator I = DPkg.VersionList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true) Hit = true; @@@ -829,7 -829,7 +829,7 @@@ // Follow all provides for (pkgCache::PrvIterator I = DPkg.ProvidesList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false) Hit = true; @@@ -889,7 -889,7 +889,7 @@@ /* Draw the box colours after the fact since we can not tell what colour they should be until everything is finished drawing */ - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Show[Pkg->ID] < DoneNR) continue; @@@ -953,7 -953,7 +953,7 @@@ bool Dotty(CommandLine &CmdL memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount); // Map the shapes - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Pkg->VersionList == 0) { @@@ -1000,7 -1000,7 +1000,7 @@@ while (Act == true) { Act = false; - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { // See we need to show this package if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR) @@@ -1024,14 -1024,14 +1024,14 @@@ continue; pkgCache::VerIterator Ver = Pkg.VersionList(); - for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) { // See if anything can meet this dep // Walk along the actual package providing versions bool Hit = false; pkgCache::PkgIterator DPkg = D.TargetPkg(); for (pkgCache::VerIterator I = DPkg.VersionList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true) Hit = true; @@@ -1039,7 -1039,7 +1039,7 @@@ // Follow all provides for (pkgCache::PrvIterator I = DPkg.ProvidesList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false) Hit = true; @@@ -1094,7 -1094,7 +1094,7 @@@ /* Draw the box colours after the fact since we can not tell what colour they should be until everything is finished drawing */ - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Show[Pkg->ID] < DoneNR) continue; @@@ -1127,7 -1127,7 +1127,7 @@@ bool DisplayRecord(pkgCacheFile &CacheF // Find an appropriate file pkgCache::VerFileIterator Vf = V.FileList(); - for (; Vf.end() == false; Vf++) + for (; Vf.end() == false; ++Vf) if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0) break; if (Vf.end() == true) @@@ -1272,7 -1272,7 +1272,7 @@@ bool Search(CommandLine &CmdL continue; // Include all the packages that provide matching names too - for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++) + for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; ++Prv) { pkgCache::VerIterator V = Plcy->GetCandidateVer(Prv.OwnerPkg()); if (V.end() == true) @@@ -1341,13 -1341,13 +1341,13 @@@ bool ShowAuto(CommandLine &CmdL std::vector packages; packages.reserve(Cache->HeaderP->PackageCount / 3); - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) if ((*DepCache)[P].Flags & pkgCache::Flag::Auto) packages.push_back(P.Name()); std::sort(packages.begin(), packages.end()); - for (vector::iterator I = packages.begin(); I != packages.end(); I++) + for (vector::iterator I = packages.begin(); I != packages.end(); ++I) cout << *I << "\n"; _error->Notice(_("This command is deprecated. Please use 'apt-mark showauto' instead.")); @@@ -1391,7 -1391,7 +1391,7 @@@ bool ShowPkgNames(CommandLine &CmdL if (CmdL.FileList[1] != 0) { - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (All == false && I->FirstPackage == 0) continue; @@@ -1405,7 -1405,7 +1405,7 @@@ } // Show all pkgs - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (All == false && I->FirstPackage == 0) continue; @@@ -1476,7 -1476,7 +1476,7 @@@ bool Policy(CommandLine &CmdL if (CmdL.FileList[1] == 0) { cout << _("Package files:") << endl; - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F) { // Locate the associated index files so we can derive a description pkgIndexFile *Indx; @@@ -1498,7 -1498,7 +1498,7 @@@ // Show any packages have explicit pins cout << _("Pinned packages:") << endl; pkgCache::PkgIterator I = Cache->PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (Plcy->GetPriority(I) == 0) continue; @@@ -1560,14 -1560,14 +1560,14 @@@ // Show the priority tables cout << _(" Version table:") << endl; - for (V = Pkg.VersionList(); V.end() == false; V++) + for (V = Pkg.VersionList(); V.end() == false; ++V) { if (Pkg.CurrentVer() == V) cout << " *** " << V.VerStr(); else cout << " " << V.VerStr(); cout << " " << Plcy->GetPriority(Pkg) << endl; - for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF) { // Locate the associated index files so we can derive a description pkgIndexFile *Indx; @@@ -1607,9 -1607,9 +1607,9 @@@ bool Madison(CommandLine &CmdL APT::PackageSet pkgset = APT::PackageSet::FromString(CacheFile, *I, helper); for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) { - for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; V++) + for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V) { - for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF) { // This might be nice, but wouldn't uniquely identify the source -mdz // if (VF.File().Archive() != 0) @@@ -1619,11 -1619,11 +1619,11 @@@ // } // Locate the associated index files so we can derive a description - for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); S++) + for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S) { vector *Indexes = (*S)->GetIndexFiles(); for (vector::const_iterator IF = Indexes->begin(); - IF != Indexes->end(); IF++) + IF != Indexes->end(); ++IF) { if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File()) { diff --combined cmdline/apt-get.cc index 9b9c0f0b0,4a05648fa..3e72749b4 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@@ -25,7 -25,8 +25,7 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#define _LARGEFILE_SOURCE -#define _LARGEFILE64_SOURCE +#include #include #include @@@ -45,6 -46,9 +45,6 @@@ #include #include -#include -#include - #include "acqprogress.h" #include @@@ -64,7 -68,8 +64,7 @@@ #include #include -#define statfs statfs64 -#define statvfs statvfs64 +#include /*}}}*/ #define RAMFS_MAGIC 0x858458f6 @@@ -363,7 -368,7 +363,7 @@@ void ShowBroken(ostream &out,CacheFile if (Start == End) break; - Start++; + ++Start; } } } @@@ -537,7 -542,7 +537,7 @@@ bool ShowEssential(ostream &out,CacheFi 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 && @@@ -574,7 -579,7 +574,7 @@@ void Stats(ostream &out,pkgDepCache &De 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++; @@@ -666,7 -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 @@@ -682,7 -687,7 +682,7 @@@ SPtrArray 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) @@@ -869,9 -874,7 +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)) {}; @@@ -923,7 -926,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; @@@ -955,7 -958,7 +953,7 @@@ bool CacheFile::CheckDeps(bool AllowBro 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); } @@@ -1046,7 -1049,7 +1044,7 @@@ bool InstallPackages(CacheFile &Cache,b 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); @@@ -1240,7 -1243,7 +1238,7 @@@ 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; @@@ -1264,7 -1267,7 +1262,7 @@@ { if ((*I)->Local == true) { - I++; + ++I; continue; } @@@ -1284,7 -1287,7 +1282,7 @@@ // 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) @@@ -1388,6 -1391,14 +1386,14 @@@ bool TryToInstallBuildDep(pkgCache::Pkg return AllowFail; } + if (_config->FindB("Debug::BuildDeps",false) == true) + { + if (Remove == true) + cout << " Trying to remove " << Pkg << endl; + else + cout << " Trying to install " << Pkg << endl; + } + if (Remove == true) { TryToRemove RemoveAction(Cache, &Fix); @@@ -1436,7 -1447,7 +1442,7 @@@ pkgSrcRecords::Parser *FindSrc(const ch // 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) @@@ -1457,7 -1468,7 +1463,7 @@@ 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) @@@ -1609,7 -1620,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; @@@ -1994,7 -2005,7 +2000,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() && @@@ -2017,7 -2028,7 +2023,7 @@@ if (Start >= End) break; - Start++; + ++Start; } if(foundInstalledInOrGroup == false) @@@ -2131,7 -2142,7 +2137,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 */ @@@ -2141,7 -2152,7 +2147,7 @@@ /* 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 */ @@@ -2150,7 -2161,7 +2156,7 @@@ } // 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 || @@@ -2167,7 -2178,7 +2173,7 @@@ // 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) { @@@ -2275,7 -2286,7 +2281,7 @@@ bool DoDownload(CommandLine &CmdL pkgAcquire Fetcher; AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0)); - if (_config->FindB("APT::Get::Print-URIs") == true) + if (_config->FindB("APT::Get::Print-URIs") == false) Fetcher.Setup(&Stat); pkgRecords Recs(Cache); @@@ -2315,7 -2326,7 +2321,7 @@@ 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; @@@ -2370,8 -2381,7 +2376,7 @@@ bool DoSource(CommandLine &CmdL // Create the download object AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); pkgAcquire Fetcher; - if (Fetcher.Setup(&Stat) == false) - return false; + Fetcher.SetLog(&Stat); DscFile *Dsc = new DscFile[CmdL.FileSize()]; @@@ -2434,7 -2444,7 +2439,7 @@@ // Load them into the fetcher for (vector::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") @@@ -2536,7 -2546,7 +2541,7 @@@ 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; @@@ -2552,7 -2562,7 +2557,7 @@@ // 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) @@@ -2581,7 -2591,7 +2586,7 @@@ 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()); @@@ -2617,12 -2627,17 +2622,17 @@@ // Try to compile it with dpkg-buildpackage if (_config->FindB("APT::Get::Compile",false) == true) { + string buildopts = _config->Find("APT::Get::Host-Architecture"); + if (buildopts.empty() == false) + buildopts = "-a " + buildopts + " "; + buildopts.append(_config->Find("DPkg::Build-Options","-b -uc")); + // Call dpkg-buildpackage char S[500]; snprintf(S,sizeof(S),"cd %s && %s %s", Dir.c_str(), _config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(), - _config->Find("DPkg::Build-Options","-b -uc").c_str()); + buildopts.c_str()); if (system(S) != 0) { @@@ -2684,8 -2699,19 +2694,19 @@@ bool DoBuildDep(CommandLine &CmdL if (Fetcher.Setup(&Stat) == false) return false; + bool StripMultiArch; + string hostArch = _config->Find("APT::Get::Host-Architecture"); + if (hostArch.empty() == false) + { + std::vector archs = APT::Configuration::getArchitectures(); + if (std::find(archs.begin(), archs.end(), hostArch) == archs.end()) + return _error->Error(_("No architecture information available for %s. See apt.conf(5) APT::Architectures for setup"), hostArch.c_str()); + StripMultiArch = false; + } + else + StripMultiArch = true; + unsigned J = 0; - bool const StripMultiArch = APT::Configuration::getArchitectures().size() <= 1; for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++) { string Src; @@@ -2714,22 -2740,32 +2735,32 @@@ BuildDeps.push_back(rec); } - if (BuildDeps.size() == 0) + if (BuildDeps.empty() == true) { ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str()); continue; } - + // Install the requested packages vector ::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); if (skipAlternatives == true) { + /* + * if there are alternatives, we've already picked one, so skip + * the rest + * + * TODO: this means that if there's a build-dep on A|B and B is + * installed, we'll still try to install A; more importantly, + * if A is currently broken, we cannot go back and try B. To fix + * this would require we do a Resolve cycle for each package we + * add to the install list. Ugh + */ if (!hasAlternatives) skipAlternatives = false; // end of or group continue; @@@ -2738,27 -2774,117 +2769,117 @@@ if ((*D).Type == pkgSrcRecords::Parser::BuildConflict || (*D).Type == pkgSrcRecords::Parser::BuildConflictIndep) { - pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package); + pkgCache::GrpIterator Grp = Cache->FindGrp((*D).Package); // Build-conflicts on unknown packages are silently ignored - if (Pkg.end() == true) + if (Grp.end() == true) continue; - pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); - - /* - * Remove if we have an installed version that satisfies the - * version criteria - */ - if (IV.end() == false && - Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - TryToInstallBuildDep(Pkg,Cache,Fix,true,false); + for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg)) + { + pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); + /* + * Remove if we have an installed version that satisfies the + * version criteria + */ + if (IV.end() == false && + Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) + TryToInstallBuildDep(Pkg,Cache,Fix,true,false); + } } else // BuildDep || BuildDepIndep { - pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package); if (_config->FindB("Debug::BuildDeps",false) == true) cout << "Looking for " << (*D).Package << "...\n"; + pkgCache::PkgIterator Pkg; + + // Cross-Building? + if (StripMultiArch == false) + { + size_t const colon = D->Package.find(":"); + if (colon != string::npos && + (strcmp(D->Package.c_str() + colon, ":any") == 0 || strcmp(D->Package.c_str() + colon, ":native") == 0)) + Pkg = Cache->FindPkg(D->Package.substr(0,colon)); + else + Pkg = Cache->FindPkg(D->Package); + + // We need to decide if host or build arch, so find a version we can look at + pkgCache::VerIterator Ver; + + // a bad version either is invalid or doesn't satify dependency + #define BADVER(Ver) Ver.end() == true || \ + (Ver.end() == false && D->Version.empty() == false && \ + Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false) + + if (Pkg.end() == false) + { + Ver = (*Cache)[Pkg].InstVerIter(*Cache); + if (BADVER(Ver)) + Ver = (*Cache)[Pkg].CandidateVerIter(*Cache); + } + if (BADVER(Ver)) + { + pkgCache::PkgIterator HostPkg = Cache->FindPkg(D->Package, hostArch); + if (HostPkg.end() == false) + { + Ver = (*Cache)[HostPkg].InstVerIter(*Cache); + if (BADVER(Ver)) + Ver = (*Cache)[HostPkg].CandidateVerIter(*Cache); + } + } + if ((BADVER(Ver)) == false) + { + string forbidden; + if (Ver->MultiArch == pkgCache::Version::None || Ver->MultiArch == pkgCache::Version::All); + else if (Ver->MultiArch == pkgCache::Version::Same) + { + if (colon != string::npos) + Pkg = Ver.ParentPkg().Group().FindPkg(hostArch); + else if (strcmp(D->Package.c_str() + colon, ":any") == 0) + forbidden = "Multi-Arch: same"; + // :native gets the buildArch + } + else if (Ver->MultiArch == pkgCache::Version::Foreign || Ver->MultiArch == pkgCache::Version::AllForeign) + { + if (colon != string::npos) + forbidden = "Multi-Arch: foreign"; + } + else if (Ver->MultiArch == pkgCache::Version::Allowed || Ver->MultiArch == pkgCache::Version::AllAllowed) + { + if (colon == string::npos) + Pkg = Ver.ParentPkg().Group().FindPkg(hostArch); + else if (strcmp(D->Package.c_str() + colon, ":any") == 0) + { + // prefer any installed over preferred non-installed architectures + pkgCache::GrpIterator Grp = Ver.ParentPkg().Group(); + // we don't check for version here as we are better of with upgrading than remove and install + for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg)) + if (Pkg.CurrentVer().end() == false) + break; + if (Pkg.end() == true) + Pkg = Grp.FindPreferredPkg(true); + } + // native gets buildArch + } + if (forbidden.empty() == false) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " :any is not allowed from M-A: same package " << (*D).Package << endl; + if (hasAlternatives) + continue; + return _error->Error(_("%s dependency for %s can't be satisfied " + "because %s is not allowed on '%s' packages"), + Last->BuildDepType(D->Type), Src.c_str(), + D->Package.c_str(), "Multi-Arch: same"); + } + } + else if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl; + #undef BADVER + } + else + Pkg = Cache->FindPkg(D->Package); + if (Pkg.end() == true) { if (_config->FindB("Debug::BuildDeps",false) == true) @@@ -2773,99 -2899,74 +2894,74 @@@ (*D).Package.c_str()); } - /* - * if there are alternatives, we've already picked one, so skip - * the rest - * - * TODO: this means that if there's a build-dep on A|B and B is - * installed, we'll still try to install A; more importantly, - * if A is currently broken, we cannot go back and try B. To fix - * this would require we do a Resolve cycle for each package we - * add to the install list. Ugh - */ - - /* - * If this is a virtual package, we need to check the list of - * packages that provide it and see if any of those are - * installed - */ - pkgCache::PrvIterator Prv = Pkg.ProvidesList(); - for (; Prv.end() != true; Prv++) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; - - if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) - break; - } - - // Get installed version and version we are going to install pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); + if (IV.end() == false) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Is installed\n"; - if ((*D).Version[0] != '\0') { - // Versioned dependency - - pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache); - - for (; CV.end() != true; CV++) - { - if (Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - break; - } - if (CV.end() == true) - { - if (hasAlternatives) - { - continue; - } - else - { - return _error->Error(_("%s dependency for %s cannot be satisfied " - "because no available versions of package %s " - "can satisfy version requirements"), - Last->BuildDepType((*D).Type),Src.c_str(), - (*D).Package.c_str()); - } - } - } - else - { - // Only consider virtual packages if there is no versioned dependency - if (Prv.end() == false) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl; - skipAlternatives = hasAlternatives; - continue; - } - } + if (D->Version.empty() == true || + Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) + { + skipAlternatives = hasAlternatives; + continue; + } - if (IV.end() == false) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Is installed\n"; + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " ...but the installed version doesn't meet the version requirement\n"; - if (Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - { - skipAlternatives = hasAlternatives; - continue; - } + if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq) + return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"), + Last->BuildDepType((*D).Type), Src.c_str(), Pkg.FullName(true).c_str()); + } - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " ...but the installed version doesn't meet the version requirement\n"; - - if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq) - { - return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"), - Last->BuildDepType((*D).Type), - Src.c_str(), - Pkg.FullName(true).c_str()); - } - } + // Only consider virtual packages if there is no versioned dependency + if ((*D).Version.empty() == true) + { + /* + * If this is a virtual package, we need to check the list of + * packages that provide it and see if any of those are + * installed + */ + pkgCache::PrvIterator Prv = Pkg.ProvidesList(); + for (; Prv.end() != true; ++Prv) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; + if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) + break; + } - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Trying to install " << (*D).Package << endl; + if (Prv.end() == false) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl; + skipAlternatives = hasAlternatives; + continue; + } + } + else // versioned dependency + { + pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache); + if (CV.end() == true || + Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == false) + { + if (hasAlternatives) + continue; + else if (CV.end() == false) + return _error->Error(_("%s dependency for %s cannot be satisfied " + "because candidate version of package %s " + "can't satisfy version requirements"), + Last->BuildDepType(D->Type), Src.c_str(), + D->Package.c_str()); + else + return _error->Error(_("%s dependency for %s cannot be satisfied " + "because package %s has no candidate version"), + Last->BuildDepType(D->Type), Src.c_str(), + D->Package.c_str()); + } + } if (TryToInstallBuildDep(Pkg,Cache,Fix,false,false) == true) { @@@ -3252,6 -3353,7 +3348,7 @@@ int main(int argc,const char *argv[] {'m',"ignore-missing","APT::Get::Fix-Missing",0}, {'t',"target-release","APT::Default-Release",CommandLine::HasArg}, {'t',"default-release","APT::Default-Release",CommandLine::HasArg}, + {'a',"host-architecture","APT::Get::Host-Architecture",CommandLine::HasArg}, {0,"download","APT::Get::Download",0}, {0,"fix-missing","APT::Get::Fix-Missing",0}, {0,"ignore-hold","APT::Ignore-Hold",0}, diff --combined cmdline/apt-sortpkgs.cc index 219e7ddff,f95a434cc..44b74cf6c --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@@ -12,8 -12,6 +12,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -21,13 -19,14 +21,13 @@@ #include #include -#include -#include - #include #include #include #include + +#include /*}}}*/ using namespace std; @@@ -107,7 -106,7 +107,7 @@@ bool DoIt(string InFile // Emit unsigned char *Buffer = new unsigned char[Largest+1]; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Read in the Record. if (Fd.Seek(I->Offset) == false || Fd.Read(Buffer,I->Length) == false) diff --combined configure.in index 965bcb5d1,89c4b240c..e37160cb9 --- a/configure.in +++ b/configure.in @@@ -18,7 -18,7 +18,7 @@@ AC_CONFIG_AUX_DIR(buildlib AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in) dnl -- SET THIS TO THE RELEASE VERSION -- - AC_DEFINE_UNQUOTED(VERSION,"0.8.15") + AC_DEFINE_UNQUOTED(VERSION,"0.8.16~exp5") PACKAGE="apt" AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE") AC_SUBST(PACKAGE) @@@ -31,10 -31,6 +31,10 @@@ AC_CHECK_TOOL_PREFI AC_PROG_CC AC_ISC_POSIX +dnl check for large file support and enable it if possible +dnl do this early as other stuff might depend on it +AC_SYS_LARGEFILE + dnl Check for other programs AC_PROG_CXX AC_PROG_CPP @@@ -155,7 -151,7 +155,7 @@@ if test "$cross_compiling" = "yes" -a " AC_MSG_ERROR(When cross compiling, architecture must be present in sizetable) fi AC_C_BIGENDIAN - + dnl We do not need this if we have inttypes! HAVE_C9X=yes if test x"$apt_cv_c9x_ints" = x"no"; then diff --combined debian/changelog index dd91d3aa8,c9439b0d4..f14930aa4 --- a/debian/changelog +++ b/debian/changelog @@@ -1,11 -1,55 +1,64 @@@ - apt (0.8.16~exp3+nmu1) experimental; urgency=low ++apt (0.8.16~exp6) experimental; urgency=low + + [ David Kalnischkies ] + * Support large files in the complete toolset. Indexes of this + size are pretty unlikely for now, but we need it for deb + packages which could become bigger than 4GB now (LP: #815895) + - -- David Kalnischkies Tue, 13 Sep 2011 17:44:00 +0200 ++ -- David Kalnischkies Tue, 13 Sep 2011 17:51:49 +0200 ++ + apt (0.8.16~exp5) experimental; urgency=low + + * merged the latest debian-sid fixes + * apt-pkg/makefile: + - install sha256.h compat header + * apt-pkg/pkgcachegen.{cc,h}: + - use ref-to-ptr semantic in NewDepends() to ensure that the + libapt does not segfault if the cache is remapped in between + (LP: #812862) + - fix crash when P.Arch() was used but the cache got remapped + * apt-pkg/acquire-item.{cc,h}: + - do not check for a "Package" tag in optional index targets + like the translations index + * apt-pkg/acquire.cc: + - fix potential divide-by-zero + * methods/mirror.cc: + - include the architecture(s) in the query string as well so + that the server can make better decisions + + -- Michael Vogt Mon, 15 Aug 2011 14:52:54 +0200 + + apt (0.8.16~exp4) experimental; urgency=low + + [ Julian Andres Klode ] + * apt-pkg/pkgcache.h: + - [ABI break] Add pkgCache::Header::CacheFileSize, storing the cache size + * apt-pkg/pkgcachegen.cc: + - Write the file size to the cache + * apt-pkg/pkgcache.cc: + - Check that cache is at least CacheFileSize bytes large (LP: #16467) + + [ Michael Vogt ] + * merged latest fixes from debian-sid + * apt-pkg/cdrom.{cc,h}: + - cleanup old ABI break avoidance hacks + * [ABI break] apt-pkg/acquire-item.{cc,h}: + - cleanup around OptionalIndexTarget and SubIndexTarget + * [ABI break] merged patch from Jonathan Thomas to have a new + RecordField() function in the pkgRecorder parser. Many thanks + Thomas + * [ABI break] merge patch from Jonathan Thomas to speed up the + depcache by caching the install-recommends and install-suggests + values + * apt-pkg/contrib/fileutl.{cc,h}: + - add GetModificationTime() helper + * apt-pkg/pkgcachegen.cc: + - regenerate the cache if the sources.list changes to ensure + that changes in the ordering there will be honored by apt + * apt-pkg/sourcelist.{cc,h}: + - add pkgSourceList::GetLastModifiedTime() helper + + -- Michael Vogt Thu, 28 Jul 2011 16:57:08 +0200 apt (0.8.16~exp3) experimental; urgency=low @@@ -71,7 -115,59 +124,59 @@@ apt (0.8.16~exp1) experimental; urgency -- Michael Vogt Wed, 29 Jun 2011 12:40:31 +0200 - apt (0.8.15.3) UNRELEASED; urgency=low + apt (0.8.15.6) unstable; urgency=low + + [ Michael Vogt ] + * apt-pkg/contrib/fileutl.{cc,h}: + - add GetModificationTime() helper + * apt-pkg/pkgcachegen.cc: + - regenerate the cache if the sources.list changes to ensure + that changes in the ordering there will be honored by apt + * apt-pkg/sourcelist.{cc,h}: + - add pkgSourceList::GetLastModifiedTime() helper + * apt-pkg/pkgcachegen.{cc,h}: + - use ref-to-ptr semantic in NewDepends() to ensure that the + libapt does not segfault if the cache is remapped in between + (LP: #812862) + - fix crash when P.Arch() was used but the cache got remapped + * test/integration/test-hashsum-verification: + - add regression test for hashsum verification + * apt-pkg/acquire-item.cc: + - if no Release.gpg file is found, still load the hashes for + verification (closes: #636314) and add test + + [ David Kalnischkies ] + * lots of cppcheck fixes + + -- Michael Vogt Mon, 15 Aug 2011 09:20:35 +0200 + + apt (0.8.15.5) unstable; urgency=low + + [ David Kalnischkies ] + * apt-pkg/deb/deblistparser.cc: + - do not assume that the last char on a line is a \n (Closes: #633350) + + -- Michael Vogt Thu, 28 Jul 2011 16:49:15 +0200 + + apt (0.8.15.4) unstable; urgency=low + + [ David Miller ] + * apt-pkg/contrib/sha1.cc: + - fix illegally casts of on-stack buffer to a type requiring more + alignment than it has resulting in segfaults on sparc (Closes: #634696) + + [ Michael Vogt ] + * apt-pkg/contrib/cdromutl.cc: + - fix escape problem when looking for the mounted devices + * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc: + - add new DeEscapeString() similar to DeQuoteString but + unescape character escapes like \0XX and \xXX (plus added + test) + * refresh po/* + + -- Michael Vogt Tue, 26 Jul 2011 12:12:27 +0200 + + apt (0.8.15.3) unstable; urgency=low [ Michael Vogt ] * apt-pkg/acquire-item.cc: @@@ -79,6 -175,8 +184,8 @@@ * apt-pkg/algorithms.cc: - Hold back packages that would enter "policy-broken" state on upgrade when doing a "apt-get upgrade" + * cmdline/apt-get.cc: + - fix missing download progress in apt-get download [ David Kalnischkies ] * apt-pkg/pkgcachegen.cc: @@@ -90,12 -188,30 +197,30 @@@ - document APT::Architectures list (Closes: #612102) * cmdline/apt-get.cc: - restore all important dependencies for garbage packages (LP: #806274) + - do not require unused partial dirs in 'source' (Closes: #633510) + - buildconflicts effect all architectures + - implement MultiarchCross for build-dep and source (Closes: #632221) * apt-pkg/init.cc: - use CndSet in pkgInitConfig (Closes: #629617) * apt-pkg/depcache.cc: - change default of APT::AutoRemove::SuggestsImportant to true - - -- David Kalnischkies Fri, 15 Jul 2011 09:29:37 +0200 + * cmdline/apt-key: + - use a tmpfile instead of /etc/apt/secring.gpg (Closes: #632596) + * debian/apt.postinst: + - remove /etc/apt/secring.gpg if it is an empty file + * doc/apt-cache.8.xml: + - apply madison typofix from John Feuerstein, thanks! (Closes: #633455) + * apt-pkg/policy.cc: + - emit an error on unknown APT::Default-Release value (Closes: #407511) + * apt-pkg/aptconfiguration.cc: + - ensure that native architecture is if not specified otherwise the + first architecture in the Architectures vector + * apt-pkg/deb/deblistparser.cc: + - Strip only :any and :native if MultiArch should be stripped as it is + save to ignore them in non-MultiArch contexts but if the dependency + is a specific architecture (and not the native) do not strip + + -- Michael Vogt Mon, 25 Jul 2011 15:04:43 +0200 apt (0.8.15.2) unstable; urgency=high diff --combined ftparchive/apt-ftparchive.cc index 5721fe409,fabaaec1d..f289eb00d --- a/ftparchive/apt-ftparchive.cc +++ b/ftparchive/apt-ftparchive.cc @@@ -10,25 -10,24 +10,25 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "apt-ftparchive.h" - +#include + #include #include #include #include #include -#include -#include #include #include #include #include +#include "apt-ftparchive.h" #include "contents.h" #include "multicompress.h" -#include "writer.h" +#include "writer.h" + +#include /*}}}*/ using namespace std; @@@ -206,7 -205,7 +206,7 @@@ bool PackageMap::GenPackages(Configurat Packages.Output = 0; // Just in case // Finish compressing - unsigned long Size; + unsigned long long Size; if (Comp.Finalize(Size) == false) { c0out << endl; @@@ -292,7 -291,7 +292,7 @@@ bool PackageMap::GenSources(Configurati Sources.Output = 0; // Just in case // Finish compressing - unsigned long Size; + unsigned long long Size; if (Comp.Finalize(Size) == false) { c0out << endl; @@@ -363,11 -362,11 +363,11 @@@ bool PackageMap::GenContents(Configurat if (_error->PendingError() == true) return false; - unsigned long Size = Head.Size(); + unsigned long long Size = Head.Size(); unsigned char Buf[4096]; while (Size != 0) { - unsigned long ToRead = Size; + unsigned long long ToRead = Size; if (Size > sizeof(Buf)) ToRead = sizeof(Buf); @@@ -385,7 -384,7 +385,7 @@@ files associated with this contents file into one great big honking memory structure, then dump the sorted version */ c0out << ' ' << this->Contents << ":" << flush; - for (vector::iterator I = Begin; I != End; I++) + for (vector::iterator I = Begin; I != End; ++I) { if (I->Contents != this->Contents) continue; @@@ -401,7 -400,7 +401,7 @@@ Contents.Finish(); // Finish compressing - unsigned long Size; + unsigned long long Size; if (Comp.Finalize(Size) == false || _error->PendingError() == true) { c0out << endl; @@@ -771,10 -770,10 +771,10 @@@ bool Generate(CommandLine &CmdL // Generate packages if (CmdL.FileSize() <= 2) { - for (vector::iterator I = PkgList.begin(); I != PkgList.end(); I++) + for (vector::iterator I = PkgList.begin(); I != PkgList.end(); ++I) if (I->GenPackages(Setup,Stats) == false) _error->DumpErrors(); - for (vector::iterator I = PkgList.begin(); I != PkgList.end(); I++) + for (vector::iterator I = PkgList.begin(); I != PkgList.end(); ++I) if (I->GenSources(Setup,SrcStats) == false) _error->DumpErrors(); } @@@ -783,7 -782,7 +783,7 @@@ // Make a choice list out of the package list.. RxChoiceList *List = new RxChoiceList[2*PkgList.size()+1]; RxChoiceList *End = List; - for (vector::iterator I = PkgList.begin(); I != PkgList.end(); I++) + for (vector::iterator I = PkgList.begin(); I != PkgList.end(); ++I) { End->UserData = &(*I); End->Str = I->BaseDir.c_str(); @@@ -833,7 -832,7 +833,7 @@@ } // close the Translation master files - for (vector::reverse_iterator I = PkgList.rbegin(); I != PkgList.rend(); I++) + for (vector::reverse_iterator I = PkgList.rbegin(); I != PkgList.rend(); ++I) if (I->TransWriter != NULL && I->TransWriter->DecreaseRefCounter() == 0) delete I->TransWriter; @@@ -844,7 -843,7 +844,7 @@@ // Sort the contents file list by date string ArchiveDir = Setup.FindDir("Dir::ArchiveDir"); - for (vector::iterator I = PkgList.begin(); I != PkgList.end(); I++) + for (vector::iterator I = PkgList.begin(); I != PkgList.end(); ++I) { struct stat A; if (MultiCompress::GetStat(flCombine(ArchiveDir,I->Contents), @@@ -861,7 -860,7 +861,7 @@@ hashes of the .debs this means they have not changed either so the contents must be up to date. */ unsigned long MaxContentsChange = Setup.FindI("Default::MaxContentsChange",UINT_MAX)*1024; - for (vector::iterator I = PkgList.begin(); I != PkgList.end(); I++) + for (vector::iterator I = PkgList.begin(); I != PkgList.end(); ++I) { // This record is not relevent if (I->ContentsDone == true || @@@ -937,7 -936,7 +937,7 @@@ bool Clean(CommandLine &CmdL _error->DumpErrors(); string CacheDB = I->BinCacheDB; - for (; I != PkgList.end() && I->BinCacheDB == CacheDB; I++); + for (; I != PkgList.end() && I->BinCacheDB == CacheDB; ++I); } return true; diff --combined ftparchive/multicompress.cc index a80d6a34d,08853b0aa..bf0f858d9 --- a/ftparchive/multicompress.cc +++ b/ftparchive/multicompress.cc @@@ -14,20 -14,18 +14,20 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "multicompress.h" - -#include +#include + #include #include #include - + #include #include #include #include -#include +#include + +#include "multicompress.h" +#include /*}}}*/ using namespace std; @@@ -50,11 -48,11 +50,11 @@@ MultiCompress::MultiCompress(string con string::const_iterator I = Compress.begin(); for (; I != Compress.end();) { - for (; I != Compress.end() && isspace(*I); I++); + for (; I != Compress.end() && isspace(*I); ++I); // Grab a word string::const_iterator Start = I; - for (; I != Compress.end() && !isspace(*I); I++); + for (; I != Compress.end() && !isspace(*I); ++I); // Find the matching compressor std::vector Compressors = APT::Configuration::getCompressors(); @@@ -131,11 -129,11 +131,11 @@@ bool MultiCompress::GetStat(string cons bool DidStat = false; for (; I != Compress.end();) { - for (; I != Compress.end() && isspace(*I); I++); + for (; I != Compress.end() && isspace(*I); ++I); // Grab a word string::const_iterator Start = I; - for (; I != Compress.end() && !isspace(*I); I++); + for (; I != Compress.end() && !isspace(*I); ++I); // Find the matching compressor std::vector Compressors = APT::Configuration::getCompressors(); @@@ -215,7 -213,7 +215,7 @@@ bool MultiCompress::Die( // MultiCompress::Finalize - Finish up writing /*{{{*/ // --------------------------------------------------------------------- /* This is only necessary for statistics reporting. */ -bool MultiCompress::Finalize(unsigned long &OutSize) +bool MultiCompress::Finalize(unsigned long long &OutSize) { OutSize = 0; if (Input == 0 || Die() == false) @@@ -383,7 -381,7 +383,7 @@@ bool MultiCompress::Child(int const &FD stash a hash of the data to use later. */ SetNonBlock(FD,false); unsigned char Buffer[32*1024]; - unsigned long FileSize = 0; + unsigned long long FileSize = 0; MD5Summation MD5; while (1) { @@@ -445,7 -443,7 +445,7 @@@ // Compute the hash MD5Summation OldMD5; - unsigned long NewFileSize = 0; + unsigned long long NewFileSize = 0; while (1) { int Res = read(CompFd,Buffer,sizeof(Buffer)); diff --combined ftparchive/override.cc index a101fa6d1,bd583a66f..d363fd0fe --- a/ftparchive/override.cc +++ b/ftparchive/override.cc @@@ -10,14 -10,14 +10,14 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "override.h" - +#include + #include #include #include #include - + #include "override.h" /*}}}*/ @@@ -34,7 -34,7 +34,7 @@@ bool Override::ReadOverride(string cons return _error->Errno("fopen",_("Unable to open %s"),File.c_str()); char Line[500]; - unsigned long Counter = 0; + unsigned long long Counter = 0; while (fgets(Line,sizeof(Line),F) != 0) { Counter++; @@@ -57,7 -57,7 +57,7 @@@ for (; isspace(*End) == 0 && *End != 0; End++); if (*End == 0) { - _error->Warning(_("Malformed override %s line %lu #1"),File.c_str(), + _error->Warning(_("Malformed override %s line %llu #1"),File.c_str(), Counter); continue; } @@@ -71,7 -71,7 +71,7 @@@ for (; isspace(*End) == 0 && *End != 0; End++); if (*End == 0) { - _error->Warning(_("Malformed override %s line %lu #2"),File.c_str(), + _error->Warning(_("Malformed override %s line %llu #2"),File.c_str(), Counter); continue; } @@@ -85,7 -85,7 +85,7 @@@ for (; isspace(*End) == 0 && *End != 0; End++); if (*End == 0) { - _error->Warning(_("Malformed override %s line %lu #3"),File.c_str(), + _error->Warning(_("Malformed override %s line %llu #3"),File.c_str(), Counter); continue; } @@@ -142,7 -142,7 +142,7 @@@ bool Override::ReadExtraOverride(strin return _error->Errno("fopen",_("Unable to open %s"),File.c_str()); char Line[500]; - unsigned long Counter = 0; + unsigned long long Counter = 0; while (fgets(Line,sizeof(Line),F) != 0) { Counter++; @@@ -163,7 -163,7 +163,7 @@@ for (; isspace(*End) == 0 && *End != 0; End++); if (*End == 0) { - _error->Warning(_("Malformed override %s line %lu #1"),File.c_str(), + _error->Warning(_("Malformed override %s line %llu #1"),File.c_str(), Counter); continue; } @@@ -175,7 -175,7 +175,7 @@@ for (; isspace(*End) == 0 && *End != 0; End++); if (*End == 0) { - _error->Warning(_("Malformed override %s line %lu #2"),File.c_str(), + _error->Warning(_("Malformed override %s line %llu #2"),File.c_str(), Counter); continue; } @@@ -188,7 -188,7 +188,7 @@@ for (; isspace(*(End-1)) && End > Value; End--); if (End == Value) { - _error->Warning(_("Malformed override %s line %lu #3"),File.c_str(), + _error->Warning(_("Malformed override %s line %llu #3"),File.c_str(), Counter); continue; } @@@ -231,7 -231,7 +231,7 @@@ Override::Item* Override::GetItem(strin if (R->OldMaint != "") result->OldMaint = R->OldMaint; if (R->NewMaint != "") result->NewMaint = R->NewMaint; for (map::const_iterator foI = R->FieldOverride.begin(); - foI != R->FieldOverride.end(); foI++) + foI != R->FieldOverride.end(); ++foI) { result->FieldOverride[foI->first] = foI->second; } @@@ -268,7 -268,7 +268,7 @@@ string Override::Item::SwapMaint(strin string::const_iterator Start = End; for (; End < OldMaint.end() && (End + 3 >= OldMaint.end() || End[0] != ' ' || - End[1] != '/' || End[2] != '/'); End++); + End[1] != '/' || End[2] != '/'); ++End); if (stringcasecmp(Start,End,Orig.begin(),Orig.end()) == 0) return NewMaint; @@@ -276,7 -276,7 +276,7 @@@ break; // Skip the divider and white space - for (; End < OldMaint.end() && (*End == '/' || *End == ' '); End++); + for (; End < OldMaint.end() && (*End == '/' || *End == ' '); ++End); } #else if (stringcasecmp(OldMaint.begin(),OldMaint.end(),Orig.begin(),Orig.end()) == 0) diff --combined ftparchive/writer.cc index c4e700b59,9741aec78..27e53faf8 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@@ -11,8 -11,9 +11,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "writer.h" - -#include +#include + #include #include #include @@@ -29,13 -30,10 +29,13 @@@ #include #include #include - + +#include "writer.h" #include "cachedb.h" #include "apt-ftparchive.h" #include "multicompress.h" + +#include /*}}}*/ using namespace std; FTWScanner *FTWScanner::Owner; @@@ -248,8 -246,8 +248,8 @@@ bool FTWScanner::LoadFileList(string co // --------------------------------------------------------------------- /* */ bool FTWScanner::Delink(string &FileName,const char *OriginalPath, - unsigned long &DeLinkBytes, - off_t const &FileSize) + unsigned long long &DeLinkBytes, + unsigned long long const &FileSize) { // See if this isn't an internaly prefix'd file name. if (InternalPrefix.empty() == false && @@@ -379,7 -377,7 +379,7 @@@ bool PackagesWriter::DoPackage(string F return false; } - off_t FileSize = Db.GetFileSize(); + unsigned long long FileSize = Db.GetFileSize(); if (Delink(FileName,OriginalPath,Stats.DeLinkBytes,FileSize) == false) return false; @@@ -415,7 -413,7 +415,7 @@@ } char Size[40]; - sprintf(Size,"%lu", (unsigned long) FileSize); + sprintf(Size,"%llu", (unsigned long long) FileSize); // Strip the DirStrip prefix from the FileName and add the PathPrefix string NewFileName; @@@ -496,7 -494,7 +496,7 @@@ } for (map::const_iterator I = OverItem->FieldOverride.begin(); - I != OverItem->FieldOverride.end(); I++) + I != OverItem->FieldOverride.end(); ++I) SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str()); SetTFRewriteData(Changes[End++], 0, 0); @@@ -612,7 -610,7 +612,7 @@@ bool SourcesWriter::DoPackage(string Fi if (St.st_size > 128*1024) return _error->Error("DSC file '%s' is too large!",FileName.c_str()); - if (BufSize < (unsigned)St.st_size+1) + if (BufSize < (unsigned long long)St.st_size+1) { BufSize = St.st_size+1; Buffer = (char *)realloc(Buffer,St.st_size+1); @@@ -832,7 -830,7 +832,7 @@@ SetTFRewriteData(Changes[End++], "Maintainer", NewMaint.c_str()); for (map::const_iterator I = SOverItem->FieldOverride.begin(); - I != SOverItem->FieldOverride.end(); I++) + I != SOverItem->FieldOverride.end(); ++I) SetTFRewriteData(Changes[End++],I->first.c_str(),I->second.c_str()); SetTFRewriteData(Changes[End++], 0, 0); @@@ -1067,7 -1065,7 +1067,7 @@@ void ReleaseWriter::Finish( for(map::const_iterator I = CheckSums.begin(); I != CheckSums.end(); ++I) { - fprintf(Output, " %s %16ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.MD5.c_str(), (*I).second.size, (*I).first.c_str()); @@@ -1079,7 -1077,7 +1079,7 @@@ for(map::const_iterator I = CheckSums.begin(); I != CheckSums.end(); ++I) { - fprintf(Output, " %s %16ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.SHA1.c_str(), (*I).second.size, (*I).first.c_str()); @@@ -1091,7 -1089,7 +1091,7 @@@ for(map::const_iterator I = CheckSums.begin(); I != CheckSums.end(); ++I) { - fprintf(Output, " %s %16ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.SHA256.c_str(), (*I).second.size, (*I).first.c_str()); @@@ -1103,7 -1101,7 +1103,7 @@@ I != CheckSums.end(); ++I) { - fprintf(Output, " %s %32ld %s\n", + fprintf(Output, " %s %16llu %s\n", (*I).second.SHA512.c_str(), (*I).second.size, (*I).first.c_str()); diff --combined methods/cdrom.cc index 82d806e9d,ae699dfc3..bc115d259 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@@ -8,8 -8,6 +8,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -56,7 -54,8 +56,8 @@@ class CDROMMethod : public pkgAcqMetho CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly | SendConfig | NeedsCleanup | Removable), - DatabaseLoaded(false), + DatabaseLoaded(false), + Debug(false), MountedByApt(false) { UdevCdroms.Dlopen(); diff --combined methods/ftp.cc index 87aa8d798,eb7fedd85..861647aea --- a/methods/ftp.cc +++ b/methods/ftp.cc @@@ -15,8 -15,6 +15,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -32,6 -30,7 +32,6 @@@ #include #include #include -#include // Internet stuff #include @@@ -42,7 -41,6 +42,7 @@@ #include "rfc2553emu.h" #include "connect.h" #include "ftp.h" +#include /*}}}*/ using namespace std; @@@ -71,7 -69,8 +71,8 @@@ time_t FtpMethod::FailTime = 0 // --------------------------------------------------------------------- /* */ FTPConn::FTPConn(URI Srv) : Len(0), ServerFd(-1), DataFd(-1), - DataListenFd(-1), ServerName(Srv) + DataListenFd(-1), ServerName(Srv), + ForceExtended(false), TryPassive(true) { Debug = _config->FindB("Debug::Acquire::Ftp",false); PasvAddr = 0; @@@ -561,7 -560,7 +562,7 @@@ bool FTPConn::ExtGoPasv( string::const_iterator List[4]; unsigned Count = 0; Pos++; - for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); I++) + for (string::const_iterator I = Msg.begin() + Pos; I < Msg.end(); ++I) { if (*I != Msg[Pos]) continue; @@@ -629,7 -628,7 +630,7 @@@ // FTPConn::Size - Return the size of a file /*{{{*/ // --------------------------------------------------------------------- /* Grab the file size from the server, 0 means no size or empty file */ -bool FTPConn::Size(const char *Path,unsigned long &Size) +bool FTPConn::Size(const char *Path,unsigned long long &Size) { // Query the size unsigned int Tag; @@@ -639,7 -638,7 +640,7 @@@ return false; char *End; - Size = strtol(Msg.c_str(),&End,10); + Size = strtoull(Msg.c_str(),&End,10); if (Tag >= 400 || End == Msg.c_str()) Size = 0; return true; @@@ -841,7 -840,7 +842,7 @@@ bool FTPConn::Finalize( // --------------------------------------------------------------------- /* This opens a data connection, sends REST and RETR and then transfers the file over. */ -bool FTPConn::Get(const char *Path,FileFd &To,unsigned long Resume, +bool FTPConn::Get(const char *Path,FileFd &To,unsigned long long Resume, Hashes &Hash,bool &Missing) { Missing = false; @@@ -1004,7 -1003,7 +1005,7 @@@ bool FtpMethod::Fetch(FetchItem *Itm // Get the files information Status(_("Query")); - unsigned long Size; + unsigned long long Size; if (Server->Size(File,Size) == false || Server->ModTime(File,FailTime) == false) { @@@ -1026,7 -1025,7 +1027,7 @@@ struct stat Buf; if (stat(Itm->DestFile.c_str(),&Buf) == 0) { - if (Size == (unsigned)Buf.st_size && FailTime == Buf.st_mtime) + if (Size == (unsigned long long)Buf.st_size && FailTime == Buf.st_mtime) { Res.Size = Buf.st_size; Res.LastModified = Buf.st_mtime; @@@ -1036,7 -1035,7 +1037,7 @@@ } // Resume? - if (FailTime == Buf.st_mtime && Size > (unsigned)Buf.st_size) + if (FailTime == Buf.st_mtime && Size > (unsigned long long)Buf.st_size) Res.ResumePoint = Buf.st_size; } diff --combined methods/gpgv.cc index 9de29ddf3,3ad3e8d84..251bcbc90 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@@ -1,10 -1,9 +1,10 @@@ +#include + #include #include #include #include #include -#include #include #include @@@ -13,10 -12,9 +13,10 @@@ #include #include #include - #include +#include + #define GNUPGPREFIX "[GNUPG:]" #define GNUPGBADSIG "[GNUPG:] BADSIG" #define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY" @@@ -215,21 -213,21 +215,21 @@@ bool GPGVMethod::Fetch(FetchItem *Itm { errmsg += _("The following signatures were invalid:\n"); for (vector::iterator I = BadSigners.begin(); - I != BadSigners.end(); I++) + I != BadSigners.end(); ++I) errmsg += (*I + "\n"); } if (!WorthlessSigners.empty()) { errmsg += _("The following signatures were invalid:\n"); for (vector::iterator I = WorthlessSigners.begin(); - I != WorthlessSigners.end(); I++) + I != WorthlessSigners.end(); ++I) errmsg += (*I + "\n"); } if (!NoPubKeySigners.empty()) { errmsg += _("The following signatures couldn't be verified because the public key is not available:\n"); for (vector::iterator I = NoPubKeySigners.begin(); - I != NoPubKeySigners.end(); I++) + I != NoPubKeySigners.end(); ++I) errmsg += (*I + "\n"); } } diff --combined methods/http.cc index 51fdaa0cd,65a0cbbb7..b60cfeb9e --- a/methods/http.cc +++ b/methods/http.cc @@@ -25,8 -25,6 +25,8 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@@ -43,6 -41,8 +43,6 @@@ #include #include #include -#include - // Internet stuff #include @@@ -51,8 -51,6 +51,8 @@@ #include "connect.h" #include "rfc2553emu.h" #include "http.h" + +#include /*}}}*/ using namespace std; @@@ -65,15 -63,15 +65,15 @@@ bool AllowRedirect = false bool Debug = false; URI Proxy; -unsigned long CircleBuf::BwReadLimit=0; -unsigned long CircleBuf::BwTickReadData=0; +unsigned long long CircleBuf::BwReadLimit=0; +unsigned long long CircleBuf::BwTickReadData=0; struct timeval CircleBuf::BwReadTick={0,0}; const unsigned int CircleBuf::BW_HZ=10; // CircleBuf::CircleBuf - Circular input buffer /*{{{*/ // --------------------------------------------------------------------- /* */ -CircleBuf::CircleBuf(unsigned long Size) : Size(Size), Hash(0) +CircleBuf::CircleBuf(unsigned long long Size) : Size(Size), Hash(0) { Buf = new unsigned char[Size]; Reset(); @@@ -89,7 -87,7 +89,7 @@@ void CircleBuf::Reset( InP = 0; OutP = 0; StrPos = 0; - MaxGet = (unsigned int)-1; + MaxGet = (unsigned long long)-1; OutQueue = string(); if (Hash != 0) { @@@ -104,7 -102,7 +104,7 @@@ is non-blocking.. */ bool CircleBuf::Read(int Fd) { - unsigned long BwReadMax; + unsigned long long BwReadMax; while (1) { @@@ -119,7 -117,7 +119,7 @@@ struct timeval now; gettimeofday(&now,0); - unsigned long d = (now.tv_sec-CircleBuf::BwReadTick.tv_sec)*1000000 + + unsigned long long d = (now.tv_sec-CircleBuf::BwReadTick.tv_sec)*1000000 + now.tv_usec-CircleBuf::BwReadTick.tv_usec; if(d > 1000000/BW_HZ) { CircleBuf::BwReadTick = now; @@@ -133,7 -131,7 +133,7 @@@ } // Write the buffer segment - int Res; + ssize_t Res; if(CircleBuf::BwReadLimit) { Res = read(Fd,Buf + (InP%Size), BwReadMax > LeftRead() ? LeftRead() : BwReadMax); @@@ -182,7 -180,7 +182,7 @@@ void CircleBuf::FillOut( return; // Write the buffer segment - unsigned long Sz = LeftRead(); + unsigned long long Sz = LeftRead(); if (OutQueue.length() - StrPos < Sz) Sz = OutQueue.length() - StrPos; memcpy(Buf + (InP%Size),OutQueue.c_str() + StrPos,Sz); @@@ -216,7 -214,7 +216,7 @@@ bool CircleBuf::Write(int Fd return true; // Write the buffer segment - int Res; + ssize_t Res; Res = write(Fd,Buf + (OutP%Size),LeftWrite()); if (Res == 0) @@@ -242,7 -240,7 +242,7 @@@ bool CircleBuf::WriteTillEl(string &Data,bool Single) { // We cheat and assume it is unneeded to have more than one buffer load - for (unsigned long I = OutP; I < InP; I++) + for (unsigned long long I = OutP; I < InP; I++) { if (Buf[I%Size] != '\n') continue; @@@ -260,7 -258,7 +260,7 @@@ Data = ""; while (OutP < I) { - unsigned long Sz = LeftWrite(); + unsigned long long Sz = LeftWrite(); if (Sz == 0) return false; if (I - OutP < Sz) @@@ -404,10 -402,10 +404,10 @@@ ServerState::RunHeadersResult ServerSta if (Debug == true) clog << Data; - for (string::const_iterator I = Data.begin(); I < Data.end(); I++) + for (string::const_iterator I = Data.begin(); I < Data.end(); ++I) { string::const_iterator J = I; - for (; J != Data.end() && *J != '\n' && *J != '\r';J++); + for (; J != Data.end() && *J != '\n' && *J != '\r'; ++J); if (HeaderLine(string(I,J)) == false) return RUN_HEADERS_PARSE_ERROR; I = J; @@@ -455,7 -453,7 +455,7 @@@ bool ServerState::RunData( return false; // See if we are done - unsigned long Len = strtol(Data.c_str(),0,16); + unsigned long long Len = strtoull(Data.c_str(),0,16); if (Len == 0) { In.Limit(-1); @@@ -598,7 -596,7 +598,7 @@@ bool ServerState::HeaderLine(string Lin if (StartPos != 0) return true; - if (sscanf(Val.c_str(),"%lu",&Size) != 1) + if (sscanf(Val.c_str(),"%llu",&Size) != 1) return _error->Error(_("The HTTP server sent an invalid Content-Length header")); return true; } @@@ -613,9 -611,9 +613,9 @@@ { HaveContent = true; - if (sscanf(Val.c_str(),"bytes %lu-%*u/%lu",&StartPos,&Size) != 2) + if (sscanf(Val.c_str(),"bytes %llu-%*u/%llu",&StartPos,&Size) != 2) return _error->Error(_("The HTTP server sent an invalid Content-Range header")); - if ((unsigned)StartPos > Size) + if ((unsigned long long)StartPos > Size) return _error->Error(_("This HTTP server has broken range support")); return true; } @@@ -718,7 -716,7 +718,7 @@@ void HttpMethod::SendReq(FetchItem *Itm if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0) { // In this case we send an if-range query with a range header - sprintf(Buf,"Range: bytes=%li-\r\nIf-Range: %s\r\n",(long)SBuf.st_size - 1, + sprintf(Buf,"Range: bytes=%lli-\r\nIf-Range: %s\r\n",(long long)SBuf.st_size - 1, TimeRFC1123(SBuf.st_mtime).c_str()); Req += Buf; } @@@ -1327,7 -1325,7 +1327,7 @@@ int HttpMethod::Loop( StopRedirects = true; else { - for (StringVectorIterator I = R.begin(); I != R.end(); I++) + for (StringVectorIterator I = R.begin(); I != R.end(); ++I) if (Queue->Uri == *I) { R[0] = "STOP"; diff --combined methods/http.h index b74740ab3,6302807c5..c47d7184a --- a/methods/http.h +++ b/methods/http.h @@@ -23,29 -23,29 +23,29 @@@ class HttpMethod class CircleBuf { unsigned char *Buf; - unsigned long Size; - unsigned long InP; - unsigned long OutP; + unsigned long long Size; + unsigned long long InP; + unsigned long long OutP; string OutQueue; - unsigned long StrPos; - unsigned long MaxGet; + unsigned long long StrPos; + unsigned long long MaxGet; struct timeval Start; - static unsigned long BwReadLimit; - static unsigned long BwTickReadData; + static unsigned long long BwReadLimit; + static unsigned long long BwTickReadData; static struct timeval BwReadTick; static const unsigned int BW_HZ; - unsigned long long LeftRead() - unsigned long LeftRead() const ++ unsigned long long LeftRead() const { - unsigned long Sz = Size - (InP - OutP); + unsigned long long Sz = Size - (InP - OutP); if (Sz > Size - (InP%Size)) Sz = Size - (InP%Size); return Sz; } - unsigned long long LeftWrite() - unsigned long LeftWrite() const ++ unsigned long long LeftWrite() const { - unsigned long Sz = InP - OutP; + unsigned long long Sz = InP - OutP; if (InP > MaxGet) Sz = MaxGet - OutP; if (Sz > Size - (OutP%Size)) @@@ -67,19 -67,19 +67,19 @@@ bool WriteTillEl(string &Data,bool Single = false); // Control the write limit - void Limit(long Max) {if (Max == -1) MaxGet = 0-1; else MaxGet = OutP + Max;} + void Limit(long long Max) {if (Max == -1) MaxGet = 0-1; else MaxGet = OutP + Max;} - bool IsLimit() {return MaxGet == OutP;}; - void Print() {cout << MaxGet << ',' << OutP << endl;}; + bool IsLimit() const {return MaxGet == OutP;}; + void Print() const {cout << MaxGet << ',' << OutP << endl;}; // Test for free space in the buffer - bool ReadSpace() {return Size - (InP - OutP) > 0;}; - bool WriteSpace() {return InP - OutP > 0;}; + bool ReadSpace() const {return Size - (InP - OutP) > 0;}; + bool WriteSpace() const {return InP - OutP > 0;}; // Dump everything void Reset(); void Stats(); - CircleBuf(unsigned long Size); + CircleBuf(unsigned long long Size); ~CircleBuf() {delete [] Buf; delete Hash;}; }; @@@ -92,8 -92,8 +92,8 @@@ struct ServerStat char Code[MAXLEN]; // These are some statistics from the last parsed header lines - unsigned long Size; - signed long StartPos; + unsigned long long Size; + signed long long StartPos; time_t Date; bool HaveContent; enum {Chunked,Stream,Closes} Encoding; @@@ -113,7 -113,7 +113,7 @@@ URI ServerName; bool HeaderLine(string Line); - bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;}; + bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;}; void Reset() {Major = 0; Minor = 0; Result = 0; Size = 0; StartPos = 0; Encoding = Closes; time(&Date); ServerFd = -1; Pipeline = true;}; diff --combined methods/mirror.cc index 768e6b3a3,a3e60ab15..61a7f12fd --- a/methods/mirror.cc +++ b/methods/mirror.cc @@@ -8,8 -8,7 +8,9 @@@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + + #include #include #include #include @@@ -35,7 -34,7 +36,7 @@@ using namespace std #include "mirror.h" #include "http.h" -#include "apti18n.h" +#include /*}}}*/ /* Done: @@@ -56,7 -55,7 +57,7 @@@ */ MirrorMethod::MirrorMethod() - : HttpMethod(), DownloadedMirrorFile(false) + : HttpMethod(), DownloadedMirrorFile(false), Debug(false) { }; @@@ -109,7 -108,7 +110,7 @@@ bool MirrorMethod::Clean(string Dir continue; // see if we have that uri - for(I=list.begin(); I != list.end(); I++) + for(I=list.begin(); I != list.end(); ++I) { string uri = (*I)->GetURI(); if(uri.find("mirror://") != 0) @@@ -136,9 -135,24 +137,24 @@@ bool MirrorMethod::DownloadMirrorFile(s string fetch = BaseUri; fetch.replace(0,strlen("mirror://"),"http://"); + #if 0 // no need for this, the getArchitectures() will also include the main + // arch + // append main architecture + fetch += "?arch=" + _config->Find("Apt::Architecture"); + #endif + + // append all architectures + std::vector vec = APT::Configuration::getArchitectures(); + for (std::vector::const_iterator I = vec.begin(); + I != vec.end(); I++) + if (I == vec.begin()) + fetch += "?arch" + (*I); + else + fetch += "&arch=" + (*I); + // append the dist as a query string if (Dist != "") - fetch += "?dist=" + Dist; + fetch += "&dist=" + Dist; if(Debug) clog << "MirrorMethod::DownloadMirrorFile(): '" << fetch << "'" @@@ -332,7 -346,7 +348,7 @@@ string MirrorMethod::GetMirrorFileName( vector::const_iterator I; pkgSourceList list; list.ReadMainList(); - for(I=list.begin(); I != list.end(); I++) + for(I=list.begin(); I != list.end(); ++I) { string uristr = (*I)->GetURI(); if(Debug) diff --combined methods/rred.cc index 57d9a8437,6c55880ca..bc941ed04 --- a/methods/rred.cc +++ b/methods/rred.cc @@@ -1,6 -1,4 +1,6 @@@ // Includes /*{{{*/ +#include + #include #include #include @@@ -53,7 -51,7 +53,7 @@@ protected virtual bool Fetch(FetchItem *Itm); public: - RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig) {}; + RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig), Debug(false) {}; }; /*}}}*/ /** \brief applyFile - in reverse order with a tail recursion {{{ @@@ -241,7 -239,9 +241,9 @@@ RredMethod::State RredMethod::patchFile return result; } /*}}}*/ - struct EdCommand { /*{{{*/ + /* struct EdCommand {{{*/ + #ifdef _POSIX_MAPPED_FILES + struct EdCommand { size_t data_start; size_t data_end; size_t data_lines; @@@ -250,13 -250,14 +252,14 @@@ char type; }; #define IOV_COUNT 1024 /* Don't really want IOV_MAX since it can be arbitrarily large */ + #endif /*}}}*/ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ FileFd &out_file, Hashes *hash) const { #ifdef _POSIX_MAPPED_FILES MMap ed_cmds(MMap::ReadOnly); if (Patch.gzFd() != NULL) { - unsigned long mapSize = Patch.Size(); + unsigned long long mapSize = Patch.Size(); DynamicMMap* dyn = new DynamicMMap(0, mapSize, 0); if (dyn->validData() == false) { delete dyn; diff --combined methods/rsh.h index b4c76479a,98ca6a88c..c81396b5f --- a/methods/rsh.h +++ b/methods/rsh.h @@@ -34,17 -34,17 +34,17 @@@ class RSHCon // Raw connection IO bool WriteMsg(string &Text,bool Sync,const char *Fmt,...); bool Connect(string Host, string User); - bool Comp(URI Other) {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;}; + bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;}; // Connection control bool Open(); void Close(); // Query - bool Size(const char *Path,unsigned long &Size); + bool Size(const char *Path,unsigned long long &Size); bool ModTime(const char *Path, time_t &Time); - bool Get(const char *Path,FileFd &To,unsigned long Resume, - Hashes &Hash,bool &Missing, unsigned long Size); + bool Get(const char *Path,FileFd &To,unsigned long long Resume, + Hashes &Hash,bool &Missing, unsigned long long Size); RSHConn(URI Srv); ~RSHConn();