From 4264ebebe1826781e5b863a13041a6972ace01db Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 27 Jun 2011 14:34:00 +0100 Subject: Initial commit from my GSoC project. Added a verification function (VerifyConfigure) to the configuration methods. --- apt-pkg/packagemanager.cc | 91 +++++++++++++++++++++++++++++++++++++++++++++-- apt-pkg/packagemanager.h | 4 ++- 2 files changed, 92 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index fe9f6eb68..de7f410e6 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -278,7 +278,7 @@ bool pkgPackageManager::ConfigureAll() { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && Configure(Pkg) == false) + if (ConfigurePkgs == true && VerifyConfigure(Pkg) == false) return false; List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); @@ -313,7 +313,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && Configure(Pkg) == false) + if (ConfigurePkgs == true && VerifyConfigure(Pkg) == false) return false; List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); @@ -336,6 +336,93 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); return true; +} + +// PM::VerifyConfigure - Check configuration of dependancies /*{{{*/ +// --------------------------------------------------------------------- +/* This routine checks that all a packages dependancies have been + configured, before it is going to be configured. If this gives a warning + on a virtual package, it means that the package thats providing it is not + configured*/ +bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList) +{ + // If this is true at the end, then the package should not be configured + bool error=true; + // This holds the the OR status of the previous dependancy + bool previousOr=false; + + // First iterate through the dependancies of Pkg + for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); D.end() == false; D++) + { + + /* If the dependancy is of type Depends or PreDepends, we need to check it, but only if it is going to be + configured at some point */ + if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { + + /* If the previous package and this package are OR dependancies, and the previous package satisfied the dependancy + then skip this dependancy as it is not relevent, this will repeat for the next package if the situation is the + same */ + if (previousOr && !error) { // As error has not been reset, this refers to the previous dependancy + previousOr = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; + continue; + } + + // Reset error + error = true; + + // Check thorugh all possible versions of this dependancy (D) + SPtrArray VList = D.AllTargets(); + for (Version **I = VList; *I != 0; I++) + { + VerIterator DepVer(Cache,*I); + PkgIterator DepPkg = DepVer.ParentPkg(); + VerIterator DepInstallVer(Cache,Cache[DepPkg].InstallVer); + + if (DepPkg.CurrentVer() == DepVer && !List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { + clog << "Version " << DepPkg.CurrentVer() << " is installed on the system, satifying this dependancy" << endl; + error=false; + break; + } + + if (Cache[DepPkg].InstallVer == DepVer && + (List->IsFlag(DepPkg,pkgOrderList::Configured) || OList.IsFlag(DepPkg,pkgOrderList::InList))) { + clog << "Version " << DepInstallVer.VerStr() << " is going to be installed on the system, satifying this dependancy" << endl; + error=false; + break; + } + } + + /* Only worry here if this package is a OR with the next, as even though this package does not satisfy the OR + the next one might */ + if (error && !((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)) { + _error->Error("Package %s should not be configured because package %s is not configured",Pkg.Name(),D.TargetPkg().Name()); + return false; + /* If the previous package is a OR but not this package, but there is still an error then fail as it will not + be satisfied */ + } else if (error && previousOr && !((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)) { + _error->Error("Package %s should not be configured because package %s (or any alternatives) are not configured",Pkg.Name(),D.TargetPkg().Name()); + return false; + } + + previousOr = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; + } else { + previousOr=false; + } + } + return true; +} + +// PM::VerifyAndConfigure - Check configuration of dependancies /*{{{*/ +// --------------------------------------------------------------------- +/* This routine verifies if a package can be configured and if so + configures it */ +bool pkgPackageManager::VerifyAndConfigure(PkgIterator Pkg, pkgOrderList &OList) +{ + if (VerifyConfigure(Pkg, OList)) + return Configure(Pkg); + else + return false; + } /*}}}*/ // PM::DepAdd - Add all dependents to the oder list /*{{{*/ diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 053b4dc13..070b9c04b 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -73,7 +73,9 @@ class pkgPackageManager : protected pkgCache::Namespace bool SmartUnPack(PkgIterator Pkg); bool SmartUnPack(PkgIterator Pkg, bool const Immediate); bool SmartRemove(PkgIterator Pkg); - bool EarlyRemove(PkgIterator Pkg); + bool EarlyRemove(PkgIterator Pkg); + bool VerifyAndConfigure(PkgIterator Pkg, pkgOrderList &OList); + bool VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList); // The Actual installation implementation virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;}; -- cgit v1.2.3 From b9f3f1f93323cf5982ee3d9d361a11697a1ecc74 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 27 Jun 2011 14:52:41 +0100 Subject: Fixed missing argument in VerifyConfigure call. --- apt-pkg/packagemanager.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index de7f410e6..63becb370 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -278,7 +278,7 @@ bool pkgPackageManager::ConfigureAll() { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && VerifyConfigure(Pkg) == false) + if (ConfigurePkgs == true && VerifyConfigure(Pkg,OList) == false) return false; List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); @@ -313,7 +313,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && VerifyConfigure(Pkg) == false) + if (ConfigurePkgs == true && VerifyConfigure(Pkg,OList) == false) return false; List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); -- cgit v1.2.3 From b873565f6cdffee78d3a5a84d34b7efbda127c5b Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 27 Jun 2011 14:56:07 +0100 Subject: Removed temp debug lines. --- apt-pkg/packagemanager.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 63becb370..f49df8327 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -379,14 +379,12 @@ bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList) VerIterator DepInstallVer(Cache,Cache[DepPkg].InstallVer); if (DepPkg.CurrentVer() == DepVer && !List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { - clog << "Version " << DepPkg.CurrentVer() << " is installed on the system, satifying this dependancy" << endl; error=false; break; } if (Cache[DepPkg].InstallVer == DepVer && (List->IsFlag(DepPkg,pkgOrderList::Configured) || OList.IsFlag(DepPkg,pkgOrderList::InList))) { - clog << "Version " << DepInstallVer.VerStr() << " is going to be installed on the system, satifying this dependancy" << endl; error=false; break; } -- cgit v1.2.3 From cfcdf7fe9f8c925847fe8d8a18bb0996dd9391a5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 2 Jul 2011 15:33:25 +0100 Subject: The modification to orderlist.cc is from a patch DonKult (David) gave me, The modifications to the packagemanager should fix the test-provides-gone-with-upgrade testcase. --- apt-pkg/orderlist.cc | 6 ++++++ apt-pkg/packagemanager.cc | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index ba43bc757..6dd494027 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -1073,6 +1073,12 @@ bool pkgOrderList::CheckDep(DepIterator D) just needs one */ if (D.IsNegative() == false) { + // ignore provides by older versions of this package + if (((D.Reverse() == false && Pkg == D.ParentPkg()) || + (D.Reverse() == true && Pkg == D.TargetPkg())) && + Cache[Pkg].InstallVer != *I) + continue; + /* Try to find something that does not have the after flag set if at all possible */ if (IsFlag(Pkg,After) == true) diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index f49df8327..2219f876a 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -575,6 +575,9 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) } bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) { + if (Debug == true) + clog << "SmartUnPack " << Pkg.Name() << endl; + // Check if it is already unpacked if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && Cache[Pkg].Keep() == true) @@ -674,6 +677,20 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } } } + + // Check for breaks + if (End->Type == pkgCache::Dep::DpkgBreaks) { + SPtrArray VList = End.AllTargets(); + for (Version **I = VList; *I != 0; I++) + { + VerIterator Ver(Cache,*I); + PkgIterator Pkg = Ver.ParentPkg(); + // Found a break, so unpack the package + if (List->IsNow(Pkg)) { + SmartUnPack(Pkg, false); + } + } + } } // Check for reverse conflicts. -- cgit v1.2.3 From ea974eaa32b3cdeae8c8f8fe53f255f0d439bd3e Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 3 Jul 2011 20:45:07 +0100 Subject: Added debug output to package manager. --- apt-pkg/packagemanager.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 2219f876a..e367b0495 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -346,6 +346,9 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) configured*/ bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList) { + if (Debug == true) + clog << "VerifyConfigure " << Pkg.Name() << endl; + // If this is true at the end, then the package should not be configured bool error=true; // This holds the the OR status of the previous dependancy -- cgit v1.2.3 From e2ca62725f8c511e53cf6b3abeede435a59eae3f Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 4 Jul 2011 12:12:13 +0100 Subject: Added temp debug statement. --- apt-pkg/packagemanager.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index e367b0495..ab1b13de8 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -479,6 +479,8 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) continue; } + std::clog << OutputInDepth(Depth) << Pkg.Name() << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << " Unpacked " << List->IsFlag(Pkg,pkgOrderList::UnPacked) << std::endl; + // Not the install version if (Cache[Pkg].InstallVer != *I || (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) -- cgit v1.2.3 From 4e9ccfb2ff599b7a65ecec3c2f1383636f068f0c Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 5 Jul 2011 11:30:35 +0100 Subject: Removed some debug stuff, corrected the VerifyConfigure calls to VerifyAndConfigure --- apt-pkg/packagemanager.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index ab1b13de8..f0ad74ca8 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -278,7 +278,7 @@ bool pkgPackageManager::ConfigureAll() { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && VerifyConfigure(Pkg,OList) == false) + if (ConfigurePkgs == true && VerifyAndConfigure(Pkg,OList) == false) return false; List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); @@ -313,7 +313,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && VerifyConfigure(Pkg,OList) == false) + if (ConfigurePkgs == true && VerifyAndConfigure(Pkg,OList) == false) return false; List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); @@ -346,9 +346,6 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) configured*/ bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList) { - if (Debug == true) - clog << "VerifyConfigure " << Pkg.Name() << endl; - // If this is true at the end, then the package should not be configured bool error=true; // This holds the the OR status of the previous dependancy @@ -419,7 +416,7 @@ bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList) configures it */ bool pkgPackageManager::VerifyAndConfigure(PkgIterator Pkg, pkgOrderList &OList) { - if (VerifyConfigure(Pkg, OList)) + if (VerifyConfigure(Pkg, OList)) return Configure(Pkg); else return false; @@ -472,15 +469,13 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) PkgIterator Pkg = Ver.ParentPkg(); // See if the current version is ok - if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && + if (Pkg.CurrentVer() == Ver && List->IsFlag(Pkg,pkgOrderList::Configured) == true && Pkg.State() == PkgIterator::NeedsNothing) { Bad = false; continue; } - std::clog << OutputInDepth(Depth) << Pkg.Name() << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << " Unpacked " << List->IsFlag(Pkg,pkgOrderList::UnPacked) << std::endl; - // Not the install version if (Cache[Pkg].InstallVer != *I || (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) -- cgit v1.2.3 From 55c04aa4c9f9704137822fac3a8392280667dfb6 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 5 Jul 2011 13:04:30 +0100 Subject: Changed check in the SmartUnpack method, reverted change in the DepAdd method. --- apt-pkg/packagemanager.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index f0ad74ca8..ac11b5d51 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -469,7 +469,7 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) PkgIterator Pkg = Ver.ParentPkg(); // See if the current version is ok - if (Pkg.CurrentVer() == Ver && List->IsFlag(Pkg,pkgOrderList::Configured) == true && + if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && Pkg.State() == PkgIterator::NeedsNothing) { Bad = false; @@ -685,8 +685,9 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) { VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); - // Found a break, so unpack the package - if (List->IsNow(Pkg)) { + // Check if it needs to be unpacked + if (List->IsFlag(Pkg,pkgOrderList::InList) && Cache[Pkg].Delete() == false) { + // Found a break, so unpack the package SmartUnPack(Pkg, false); } } -- cgit v1.2.3 From d8a982700668dd0d5ecf98c47b0ee5f224f4f8f4 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 5 Jul 2011 14:14:24 +0100 Subject: Fix for reinstallation of packages --- apt-pkg/packagemanager.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 7fcaa8d41..4cba19dc0 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -475,17 +475,11 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) Bad = false; continue; } - - // Check if this package is being re-installed - if ((Cache[Pkg].iFlags & pkgDepCache::ReInstall) == pkgDepCache::ReInstall && Cache[Pkg].InstallVer != *I && - List->IsNow(Pkg) == true && Pkg.State() == PkgIterator::NeedsNothing) { - Bad = false; - continue; - } - + // Not the install version if (Cache[Pkg].InstallVer != *I || - (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) + (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing && + (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) continue; if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == true) -- cgit v1.2.3 From 8b1f5756624cf30c59c708c102cc71d53188e737 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 5 Jul 2011 16:20:09 +0100 Subject: Flag the package in the SmartUnPack method as UnPacked while solving breakages to prevent loops. --- apt-pkg/packagemanager.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 4cba19dc0..a39e412bd 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -685,11 +685,15 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) for (Version **I = VList; *I != 0; I++) { VerIterator Ver(Cache,*I); - PkgIterator Pkg = Ver.ParentPkg(); + PkgIterator BrokenPkg = Ver.ParentPkg(); // Check if it needs to be unpacked - if (List->IsFlag(Pkg,pkgOrderList::InList) && Cache[Pkg].Delete() == false) { + if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && + !List->IsFlag(BrokenPkg,pkgOrderList::UnPacked)) { + /* FIXME Setting the flag here prevents breakage loops, that can occur if BrokenPkg (or one of the + packages it breaks) breaks Pkg */ + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); // Found a break, so unpack the package - SmartUnPack(Pkg, false); + SmartUnPack(BrokenPkg, false); } } } -- cgit v1.2.3 From a6c8798a6390b5c3a0775f8914e1cff2795e4cc1 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 6 Jul 2011 22:13:59 +0100 Subject: Added a APT::Immediate-Configure-All option to enable imediate configuration for all packages. Began adding to the SmartUnpack method to prevent dependancy loops breaking apt. --- apt-pkg/packagemanager.cc | 105 +++++++++++++++++++++++++++++++++++++++++----- apt-pkg/packagemanager.h | 1 + 2 files changed, 95 insertions(+), 11 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index a39e412bd..ad59470ac 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -167,6 +167,10 @@ bool pkgPackageManager::CreateOrderList() List = new pkgOrderList(&Cache); static bool const NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); + ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",true); + + if (Debug && ImmConfigureAll) + clog << "CreateOrderList(): Adding Immediate flag for all packages because of APT::Immediate-Configure-All" << endl; // Generate the list of affected packages and sort it for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++) @@ -176,19 +180,23 @@ bool pkgPackageManager::CreateOrderList() continue; // Mark the package and its dependends for immediate configuration - if (((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential || + if ((((I->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential || (I->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important) && - NoImmConfigure == false) + NoImmConfigure == false) || ImmConfigureAll) { - if(Debug) + if(Debug && !ImmConfigureAll) clog << "CreateOrderList(): Adding Immediate flag for " << I.Name() << endl; List->Flag(I,pkgOrderList::Immediate); + + if (!ImmConfigureAll) { + continue; - // Look for other install packages to make immediate configurea - ImmediateAdd(I, true); + // Look for other install packages to make immediate configurea + ImmediateAdd(I, true); - // And again with the current version. - ImmediateAdd(I, false); + // And again with the current version. + ImmediateAdd(I, false); + } } // Not interesting @@ -467,7 +475,33 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) { VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); - + VerIterator InstallVer(Cache,Cache[Pkg].InstallVer); + + if (Debug) { + if (Ver==0) { + cout << OutputInDepth(Depth) << "Checking if the dependancy on " << Ver << " of " << Pkg.Name() << " is satisfied" << endl; + } else { + cout << OutputInDepth(Depth) << "Checking if the dependancy on " << Ver.VerStr() << " of " << Pkg.Name() << " is satisfied" << endl; + } + } + if (Debug) { + if (Pkg.CurrentVer()==0) { + cout << OutputInDepth(Depth) << " CurrentVer " << Pkg.CurrentVer() << " IsNow " << List->IsNow(Pkg) << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << endl; + } else { + cout << OutputInDepth(Depth) << " CurrentVer " << Pkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(Pkg) << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << endl; + } + } + + if (Debug) { + if (InstallVer==0) { + cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer << endl; + } else { + cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer.VerStr() << endl; + } + } + if (Debug) + cout << OutputInDepth(Depth) << " Keep " << Cache[Pkg].Keep() << " Unpacked " << List->IsFlag(Pkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(Pkg,pkgOrderList::Configured) << endl; + // See if the current version is ok if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && Pkg.State() == PkgIterator::NeedsNothing) @@ -475,6 +509,8 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) Bad = false; continue; } + + // Keep() , if upgradable, is the package left at the install version // Not the install version if (Cache[Pkg].InstallVer != *I || @@ -591,7 +627,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg.Name()); return true; } - + VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* See if this packages install version has any predependencies @@ -655,7 +691,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) End.TargetPkg().Name(),Pkg.Name()); Start++; } - else + else break; } @@ -693,10 +729,56 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) packages it breaks) breaks Pkg */ List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); // Found a break, so unpack the package + if (Debug) + cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; SmartUnPack(BrokenPkg, false); } } } + + // Check for dependanices that have not been unpacked, probably due to loops. + bool Bad = true; + while (End->Type == pkgCache::Dep::Depends) { + PkgIterator DepPkg; + SPtrArray VList = Start.AllTargets(); + + for (Version **I = VList; *I != 0; I++) { + VerIterator Ver(Cache,*I); + DepPkg = Ver.ParentPkg(); + + if (!Bad) continue; + + if (Debug) + cout << " Checking dep on " << DepPkg.Name() << endl; + // Check if it satisfies this dependancy + if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true && + DepPkg.State() == PkgIterator::NeedsNothing) + { + Bad = false; + continue; + } + + if (Cache[DepPkg].InstallVer == *I && !List->IsNow(DepPkg)) { + Bad = false; + continue; + } + } + + if (Start==End) { + if (Bad) { + // FIXME Setting the flag here prevents a loop forming + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + // Found a break, so unpack the package + if (Debug) + cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; + //SmartUnPack(DepPkg, false); + } + break; + + } else { + Start++; + } + } } // Check for reverse conflicts. @@ -728,7 +810,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) if (Immediate == true && List->IsFlag(Pkg,pkgOrderList::Immediate) == true) if (SmartConfigure(Pkg) == false) - return _error->Error(_("Could not perform immediate configuration on '%s'. " + //return + _error->Error(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2); return true; diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 070b9c04b..dcc9dc2a2 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -48,6 +48,7 @@ class pkgPackageManager : protected pkgCache::Namespace pkgDepCache &Cache; pkgOrderList *List; bool Debug; + bool ImmConfigureAll; /** \brief saves packages dpkg let disappear -- cgit v1.2.3 From 9fc57a5900275aa7d32b1b433c1413d0e1a4b9e2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 13 Jul 2011 09:12:19 +0100 Subject: More changes to the SmartUnpack method to allow imediate configuration of all packages. --- apt-pkg/packagemanager.cc | 209 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 155 insertions(+), 54 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index ad59470ac..38e0a0e1f 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -476,32 +476,32 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); VerIterator InstallVer(Cache,Cache[Pkg].InstallVer); + VerIterator CandVer(Cache,Cache[Pkg].CandidateVer); - if (Debug) { + if (Debug && false) { if (Ver==0) { - cout << OutputInDepth(Depth) << "Checking if the dependancy on " << Ver << " of " << Pkg.Name() << " is satisfied" << endl; + cout << OutputInDepth(Depth) << "Checking if " << Ver << " of " << Pkg.Name() << " satisfies this dependancy" << endl; } else { - cout << OutputInDepth(Depth) << "Checking if the dependancy on " << Ver.VerStr() << " of " << Pkg.Name() << " is satisfied" << endl; + cout << OutputInDepth(Depth) << "Checking if " << Ver.VerStr() << " of " << Pkg.Name() << " satisfies this dependancy" << endl; } - } - if (Debug) { + if (Pkg.CurrentVer()==0) { cout << OutputInDepth(Depth) << " CurrentVer " << Pkg.CurrentVer() << " IsNow " << List->IsNow(Pkg) << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << endl; } else { cout << OutputInDepth(Depth) << " CurrentVer " << Pkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(Pkg) << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << endl; } - } - - if (Debug) { + if (InstallVer==0) { cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer << endl; } else { cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer.VerStr() << endl; } - } - if (Debug) + if (CandVer != 0) + cout << " CandVer " << CandVer.VerStr() << endl; + cout << OutputInDepth(Depth) << " Keep " << Cache[Pkg].Keep() << " Unpacked " << List->IsFlag(Pkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(Pkg,pkgOrderList::Configured) << endl; + } // See if the current version is ok if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && Pkg.State() == PkgIterator::NeedsNothing) @@ -510,10 +510,8 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) continue; } - // Keep() , if upgradable, is the package left at the install version - // Not the install version - if (Cache[Pkg].InstallVer != *I || + if ((Cache[Pkg].InstallVer != *I && Cache[Pkg].CandidateVer != *I) || (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing && (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) continue; @@ -642,7 +640,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) while (End->Type == pkgCache::Dep::PreDepends) { - if (Debug == true) + if (Debug) clog << "PreDepends order for " << Pkg.Name() << std::endl; // Look for possible ok targets. @@ -658,7 +656,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) Pkg.State() == PkgIterator::NeedsNothing) { Bad = false; - if (Debug == true) + if (Debug) clog << "Found ok package " << Pkg.Name() << endl; continue; } @@ -675,7 +673,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) continue; - if (Debug == true) + if (Debug) clog << "Trying to SmartConfigure " << Pkg.Name() << endl; Bad = !SmartConfigure(Pkg); } @@ -704,13 +702,48 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) for (Version **I = VList; *I != 0; I++) { VerIterator Ver(Cache,*I); - PkgIterator Pkg = Ver.ParentPkg(); + PkgIterator ConflictPkg = Ver.ParentPkg(); + VerIterator InstallVer(Cache,Cache[ConflictPkg].InstallVer); + + if (Debug) + cout << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; + + if (Debug && false) { + if (Ver==0) { + cout << " Checking if " << Ver << " of " << ConflictPkg.Name() << " satisfies this dependancy" << endl; + } else { + cout << " Checking if " << Ver.VerStr() << " of " << ConflictPkg.Name() << " satisfies this dependancy" << endl; + } + + if (ConflictPkg.CurrentVer()==0) { + cout << " CurrentVer " << ConflictPkg.CurrentVer() << " IsNow " << List->IsNow(ConflictPkg) << " NeedsNothing " << (ConflictPkg.State() == PkgIterator::NeedsNothing) << endl; + } else { + cout << " CurrentVer " << ConflictPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(ConflictPkg) << " NeedsNothing " << (ConflictPkg.State() == PkgIterator::NeedsNothing) << endl; + } + + if (InstallVer==0) { + cout << " InstallVer " << InstallVer << endl; + } else { + cout << " InstallVer " << InstallVer.VerStr() << endl; + } + + cout << " Keep " << Cache[ConflictPkg].Keep() << " Unpacked " << List->IsFlag(ConflictPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(ConflictPkg,pkgOrderList::Configured) << endl; + cout << " Delete " << Cache[ConflictPkg].Delete() << endl; + } // See if the current version is conflicting - if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true) + if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) { - if (EarlyRemove(Pkg) == false) - return _error->Error("Internal Error, Could not early remove %s",Pkg.Name()); + if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { + cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; + /* FIXME Setting the flag here prevents breakage loops, that can occur if BrokenPkg (or one of the + packages it breaks) breaks Pkg */ + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + SmartUnPack(ConflictPkg,false); + } else { + if (EarlyRemove(ConflictPkg) == false) + return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); + } } } } @@ -733,13 +766,73 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; SmartUnPack(BrokenPkg, false); } + // Check if a package needs to be removed + if (Cache[BrokenPkg].Delete() == true) { + if (Debug) + cout << " Removing " << BrokenPkg.Name() << " to avoid break" << endl; + SmartRemove(BrokenPkg); + } } } + } + + // FIXME: Crude but effective fix, allows the SmartUnPack method to be used for packages that new to the system + if (instVer != 0) { + //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << instVer.VerStr() << endl; + + // Check for reverse conflicts. + if (CheckRConflicts(Pkg,Pkg.RevDependsList(), + instVer.VerStr()) == false) + return false; + + for (PrvIterator P = instVer.ProvidesList(); + P.end() == false; P++) + CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); + + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + + if (instVer->MultiArch == pkgCache::Version::Same) + for (PkgIterator P = Pkg.Group().PackageList(); + P.end() == false; P = Pkg.Group().NextPkg(P)) + { + if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true || + Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && + (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) + continue; + SmartUnPack(P, false); + } + } else { + VerIterator InstallVer(Cache,Cache[Pkg].InstallVer); + //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << InstallVer.VerStr() << endl; + + // Check for reverse conflicts. + if (CheckRConflicts(Pkg,Pkg.RevDependsList(), + InstallVer.VerStr()) == false) + return false; + + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + } + + if(Install(Pkg,FileNames[Pkg->ID]) == false) + return false; + + /* Because of the ordered list, most dependancies should be unpacked, + however if there is a loop this is not the case, so check for dependancies before configuring. + This is done after the package installation as it makes it easier to deal with conflicts problems */ + for (DepIterator D = instVer.DependsList(); + D.end() == false; ) + { + // Compute a single dependency element (glob or) + pkgCache::DepIterator Start; + pkgCache::DepIterator End; + D.GlobOr(Start,End); + // Check for dependanices that have not been unpacked, probably due to loops. bool Bad = true; while (End->Type == pkgCache::Dep::Depends) { PkgIterator DepPkg; + VerIterator InstallVer; SPtrArray VList = Start.AllTargets(); for (Version **I = VList; *I != 0; I++) { @@ -747,9 +840,35 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) DepPkg = Ver.ParentPkg(); if (!Bad) continue; + + InstallVer = VerIterator(Cache,Cache[DepPkg].InstallVer); + VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer); + + if (Debug && false) { + if (Ver==0) { + cout << " Checking if " << Ver << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; + } else { + cout << " Checking if " << Ver.VerStr() << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; + } + + if (DepPkg.CurrentVer()==0) { + cout << " CurrentVer " << DepPkg.CurrentVer() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; + } else { + cout << " CurrentVer " << DepPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; + } + + if (InstallVer==0) { + cout << " InstallVer " << InstallVer << endl; + } else { + cout << " InstallVer " << InstallVer.VerStr() << endl; + } + if (CandVer != 0) + cout << " CandVer " << CandVer.VerStr() << endl; - if (Debug) - cout << " Checking dep on " << DepPkg.Name() << endl; + cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << endl; + + } + // Check if it satisfies this dependancy if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true && DepPkg.State() == PkgIterator::NeedsNothing) @@ -762,16 +881,23 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) Bad = false; continue; } + + } + + if (InstallVer != 0 && Bad) { + Bad = false; + // FIXME Setting the flag here prevents a loop forming + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + // Found a break, so unpack the package + if (Debug) + cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; + SmartUnPack(DepPkg, false); } if (Start==End) { if (Bad) { - // FIXME Setting the flag here prevents a loop forming - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - // Found a break, so unpack the package - if (Debug) - cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - //SmartUnPack(DepPkg, false); + //return + _error->Error("Could not satisfy dependancies for %s",Pkg.Name()); } break; @@ -781,31 +907,6 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } } - // Check for reverse conflicts. - if (CheckRConflicts(Pkg,Pkg.RevDependsList(), - instVer.VerStr()) == false) - return false; - - for (PrvIterator P = instVer.ProvidesList(); - P.end() == false; P++) - CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); - - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - - if (instVer->MultiArch == pkgCache::Version::Same) - for (PkgIterator P = Pkg.Group().PackageList(); - P.end() == false; P = Pkg.Group().NextPkg(P)) - { - if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true || - Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && - (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) - continue; - SmartUnPack(P, false); - } - - if(Install(Pkg,FileNames[Pkg->ID]) == false) - return false; - // Perform immedate configuration of the package. if (Immediate == true && List->IsFlag(Pkg,pkgOrderList::Immediate) == true) @@ -900,7 +1001,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() PkgIterator(Cache,*I).Name()); return Failed; } - } + } return Completed; } -- cgit v1.2.3 From e2a5ff0c3398380b15a09d810effffc5eb96ea53 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 14 Jul 2011 13:26:19 +0100 Subject: More changes to make imediate configuration work for all packages, I have stolen the Loop flag from orderlist.cc as it didnt seem to use it anymore. --- apt-pkg/orderlist.cc | 4 +- apt-pkg/packagemanager.cc | 93 ++++++++++++++++++++++++++++++----------------- 2 files changed, 62 insertions(+), 35 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index a17a70112..eaa5ea20a 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -1021,8 +1021,8 @@ bool pkgOrderList::AddLoop(DepIterator D) Loops[LoopCount++] = D; // Mark the packages as being part of a loop. - Flag(D.TargetPkg(),Loop); - Flag(D.ParentPkg(),Loop); + //Flag(D.TargetPkg(),Loop); + //Flag(D.ParentPkg(),Loop); return true; } /*}}}*/ diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 38e0a0e1f..601fbb484 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -167,7 +167,7 @@ bool pkgPackageManager::CreateOrderList() List = new pkgOrderList(&Cache); static bool const NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); - ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",true); + ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false); if (Debug && ImmConfigureAll) clog << "CreateOrderList(): Adding Immediate flag for all packages because of APT::Immediate-Configure-All" << endl; @@ -189,11 +189,9 @@ bool pkgPackageManager::CreateOrderList() List->Flag(I,pkgOrderList::Immediate); if (!ImmConfigureAll) { - continue; - // Look for other install packages to make immediate configurea ImmediateAdd(I, true); - + // And again with the current version. ImmediateAdd(I, false); } @@ -705,8 +703,11 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) PkgIterator ConflictPkg = Ver.ParentPkg(); VerIterator InstallVer(Cache,Cache[ConflictPkg].InstallVer); - if (Debug) - cout << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; + // See if the current version is conflicting + if (ConflictPkg.CurrentVer() == Ver && !List->IsFlag(ConflictPkg,pkgOrderList::UnPacked)) + { + if (Debug && false) + cout << " " << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; if (Debug && false) { if (Ver==0) { @@ -727,23 +728,26 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) cout << " InstallVer " << InstallVer.VerStr() << endl; } - cout << " Keep " << Cache[ConflictPkg].Keep() << " Unpacked " << List->IsFlag(ConflictPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(ConflictPkg,pkgOrderList::Configured) << endl; + cout << " Keep " << Cache[ConflictPkg].Keep() << " Unpacked " << List->IsFlag(ConflictPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(ConflictPkg,pkgOrderList::Configured) << " Removed " << List->IsFlag(ConflictPkg,pkgOrderList::Removed) << " Loop " << List->IsFlag(ConflictPkg,pkgOrderList::Loop) << endl; cout << " Delete " << Cache[ConflictPkg].Delete() << endl; } - // See if the current version is conflicting - if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) - { - if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { - cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; - /* FIXME Setting the flag here prevents breakage loops, that can occur if BrokenPkg (or one of the - packages it breaks) breaks Pkg */ - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - SmartUnPack(ConflictPkg,false); - } else { - if (EarlyRemove(ConflictPkg) == false) - return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); - } + if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) { + if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { + cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; + List->Flag(Pkg,pkgOrderList::Loop); + SmartUnPack(ConflictPkg,false); + } else { + if (EarlyRemove(ConflictPkg) == false) + return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); + } + } else { + if (!List->IsFlag(ConflictPkg,pkgOrderList::Removed)) { + cout << "Because of conficts knot, removing " << ConflictPkg.Name() << " to conflict violation" << endl; + if (EarlyRemove(ConflictPkg) == false) + return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); + } + } } } } @@ -755,19 +759,42 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) { VerIterator Ver(Cache,*I); PkgIterator BrokenPkg = Ver.ParentPkg(); + VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer); + + cout << " " << Pkg.Name() << " breaks " << BrokenPkg.Name() << endl; + if (Debug && false) { + if (Ver==0) { + cout << " Checking if " << Ver << " of " << BrokenPkg.Name() << " satisfies this dependancy" << endl; + } else { + cout << " Checking if " << Ver.VerStr() << " of " << BrokenPkg.Name() << " satisfies this dependancy" << endl; + } + + if (BrokenPkg.CurrentVer()==0) { + cout << " CurrentVer " << BrokenPkg.CurrentVer() << " IsNow " << List->IsNow(BrokenPkg) << " NeedsNothing " << (BrokenPkg.State() == PkgIterator::NeedsNothing) << endl; + } else { + cout << " CurrentVer " << BrokenPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(BrokenPkg) << " NeedsNothing " << (BrokenPkg.State() == PkgIterator::NeedsNothing) << endl; + } + + if (InstallVer==0) { + cout << " InstallVer " << InstallVer << endl; + } else { + cout << " InstallVer " << InstallVer.VerStr() << endl; + } + + cout << " Keep " << Cache[BrokenPkg].Keep() << " Unpacked " << List->IsFlag(BrokenPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(BrokenPkg,pkgOrderList::Configured) << " Removed " << List->IsFlag(BrokenPkg,pkgOrderList::Removed) << " Loop " << List->IsFlag(BrokenPkg,pkgOrderList::Loop) << " InList " << List->IsFlag(BrokenPkg,pkgOrderList::InList) << endl; + cout << " Delete " << Cache[BrokenPkg].Delete() << endl; + } // Check if it needs to be unpacked if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && - !List->IsFlag(BrokenPkg,pkgOrderList::UnPacked)) { - /* FIXME Setting the flag here prevents breakage loops, that can occur if BrokenPkg (or one of the - packages it breaks) breaks Pkg */ - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + !List->IsFlag(BrokenPkg,pkgOrderList::Loop) && List->IsNow(BrokenPkg)) { + List->Flag(Pkg,pkgOrderList::Loop); // Found a break, so unpack the package if (Debug) cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; SmartUnPack(BrokenPkg, false); } // Check if a package needs to be removed - if (Cache[BrokenPkg].Delete() == true) { + if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) { if (Debug) cout << " Removing " << BrokenPkg.Name() << " to avoid break" << endl; SmartRemove(BrokenPkg); @@ -881,17 +908,17 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) Bad = false; continue; } - } if (InstallVer != 0 && Bad) { Bad = false; - // FIXME Setting the flag here prevents a loop forming - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); // Found a break, so unpack the package - if (Debug) - cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - SmartUnPack(DepPkg, false); + List->Flag(Pkg,pkgOrderList::Loop); + if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + if (Debug) + cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; + SmartUnPack(DepPkg, false); + } } if (Start==End) { @@ -906,7 +933,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } } } - + // Perform immedate configuration of the package. if (Immediate == true && List->IsFlag(Pkg,pkgOrderList::Immediate) == true) @@ -947,7 +974,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() for (pkgOrderList::iterator I = List->begin(); I != List->end(); I++) { PkgIterator Pkg(Cache,*I); - + if (List->IsNow(Pkg) == false) { if (Debug == true) -- cgit v1.2.3 From 634985f8138903d7fb1c883274be83fd2ccd64fe Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 14 Jul 2011 16:39:06 +0100 Subject: Inproved errors and warnings, will now warn if package configuration fails, but only error if the package is not configured at the end. --- apt-pkg/packagemanager.cc | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 601fbb484..874472a47 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -284,8 +284,10 @@ bool pkgPackageManager::ConfigureAll() { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && VerifyAndConfigure(Pkg,OList) == false) + if (ConfigurePkgs == true && VerifyAndConfigure(Pkg,OList) == false) { + _error->Error("Internal error, packages left unconfigured. %s",Pkg.Name()); return false; + } List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); } @@ -337,8 +339,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) } // Sanity Check - if (List->IsFlag(Pkg,pkgOrderList::Configured) == false) - return _error->Error(_("Could not perform immediate configuration on '%s'. " + if (List->IsFlag(Pkg,pkgOrderList::Configured) == false && Debug) + _error->Error(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); return true; @@ -494,8 +496,8 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) } else { cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer.VerStr() << endl; } - if (CandVer != 0) - cout << " CandVer " << CandVer.VerStr() << endl; + if (CandVer != 0) + cout << OutputInDepth(Depth ) << " CandVer " << CandVer.VerStr() << endl; cout << OutputInDepth(Depth) << " Keep " << Cache[Pkg].Keep() << " Unpacked " << List->IsFlag(Pkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(Pkg,pkgOrderList::Configured) << endl; @@ -619,7 +621,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) if (Immediate == true && List->IsFlag(Pkg,pkgOrderList::Immediate) == true) if (SmartConfigure(Pkg) == false) - return _error->Error(_("Could not perform immediate configuration on already unpacked '%s'. " + _error->Warning(_("Could not perform immediate configuration on already unpacked '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg.Name()); return true; } @@ -847,6 +849,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) /* Because of the ordered list, most dependancies should be unpacked, however if there is a loop this is not the case, so check for dependancies before configuring. This is done after the package installation as it makes it easier to deal with conflicts problems */ + bool Bad = true; for (DepIterator D = instVer.DependsList(); D.end() == false; ) { @@ -854,9 +857,11 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) pkgCache::DepIterator Start; pkgCache::DepIterator End; D.GlobOr(Start,End); + + if (End->Type == pkgCache::Dep::Depends) + Bad = true; // Check for dependanices that have not been unpacked, probably due to loops. - bool Bad = true; while (End->Type == pkgCache::Dep::Depends) { PkgIterator DepPkg; VerIterator InstallVer; @@ -922,9 +927,10 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } if (Start==End) { - if (Bad) { - //return - _error->Error("Could not satisfy dependancies for %s",Pkg.Name()); + if (Bad && Debug) { + if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + _error->Warning("Could not satisfy dependancies for %s",Pkg.Name()); + } } break; @@ -933,13 +939,12 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } } } - + // Perform immedate configuration of the package. if (Immediate == true && - List->IsFlag(Pkg,pkgOrderList::Immediate) == true) + List->IsFlag(Pkg,pkgOrderList::Immediate) == true && !Bad) if (SmartConfigure(Pkg) == false) - //return - _error->Error(_("Could not perform immediate configuration on '%s'. " + _error->Warning(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2); return true; @@ -977,9 +982,16 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() if (List->IsNow(Pkg) == false) { - if (Debug == true) - clog << "Skipping already done " << Pkg.Name() << endl; + if (!List->IsFlag(Pkg,pkgOrderList::Configured)) { + if (SmartConfigure(Pkg) == false && Debug) + _error->Warning("Internal Error, Could not configure %s",Pkg.Name()); + // FIXME: The above warning message might need changing + } else { + if (Debug == true) + clog << "Skipping already done " << Pkg.Name() << endl; + } continue; + } if (List->IsMissing(Pkg) == true) -- cgit v1.2.3 From b684d8c7b15fbbebb149afac4e374b025c1b335e Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 16 Jul 2011 22:10:52 +0100 Subject: Dont try to configure packages using SmartConfigure when not performing immediate configuration. --- apt-pkg/packagemanager.cc | 6 +++--- apt-pkg/packagemanager.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 874472a47..8112c7fa1 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -166,7 +166,7 @@ bool pkgPackageManager::CreateOrderList() delete List; List = new pkgOrderList(&Cache); - static bool const NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); + NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false); if (Debug && ImmConfigureAll) @@ -982,11 +982,11 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() if (List->IsNow(Pkg) == false) { - if (!List->IsFlag(Pkg,pkgOrderList::Configured)) { + if (!List->IsFlag(Pkg,pkgOrderList::Configured) && !NoImmConfigure) { if (SmartConfigure(Pkg) == false && Debug) _error->Warning("Internal Error, Could not configure %s",Pkg.Name()); // FIXME: The above warning message might need changing - } else { + } else { if (Debug == true) clog << "Skipping already done " << Pkg.Name() << endl; } diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index dcc9dc2a2..d4a25e982 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -48,6 +48,7 @@ class pkgPackageManager : protected pkgCache::Namespace pkgDepCache &Cache; pkgOrderList *List; bool Debug; + bool NoImmConfigure; bool ImmConfigureAll; /** \brief saves packages dpkg let disappear -- cgit v1.2.3 From 590f1923121815b36ef889033c1c416a23cbe9a2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 27 Jul 2011 15:20:35 +0100 Subject: SmartConfigure and SmartUnPack have got smarter! The full descriptions of what they now do is in the apt-pkg/packagemanager.cc file. The short version is that they will both put the system in a state where there operation can be achived, this involves calling themselves and each other recursively. Because SmartConfigure can now configure a package and all its dependancies itself, there is no current need for DepAdd (at least in packagemanager.cc), SmartConfigure also performs the function of the short lived VerifyConfigure as it checks through all the dependancies before performing configuration. Another change is to use the ConfigureAll method in OrderInstall to clean up any packages left unconfigured during ImmConfigureAll. This is necessary to inprove the safety of ImmConfiguration and because of the new SIGINT functionality of dpkgpm.cc relies on no packages being left unconfigured between pairs of dpkg calls. While writing this commit log, I have realised that the SIGINT stuff is a prototype and not ready to be used yet as I have only tested it twice. --- apt-pkg/deb/dpkgpm.cc | 15 +- apt-pkg/deb/dpkgpm.h | 2 + apt-pkg/packagemanager.cc | 434 ++++++++++++++-------------------------------- apt-pkg/packagemanager.h | 4 +- 4 files changed, 141 insertions(+), 314 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5fbd1801a..3dbbd7c97 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -888,7 +889,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) OpenLog(); // this loop is runs once per operation - for (vector::const_iterator I = List.begin(); I != List.end();) + for (vector::const_iterator I = List.begin(); I != List.end() && !pkgPackageManager::SigINTStop;) { // Do all actions with the same Op in one run vector::const_iterator J = I; @@ -920,7 +921,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // the argument list is split in a way that A depends on B // and they are in the same "--configure A B" run // - with the split they may now be configured in different - // runs + // runs if (J - I > (signed)MaxArgs) J = I + MaxArgs; @@ -1062,7 +1063,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) it to all processes in the group. Since dpkg ignores the signal it doesn't die but we do! So we must also ignore it */ sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); - sighandler_t old_SIGINT = signal(SIGINT,SIG_IGN); + sighandler_t old_SIGINT = signal(SIGINT,SigINT); // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1207,6 +1208,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGHUP,old_SIGHUP); return _error->Errno("waitpid","Couldn't wait for subprocess"); } @@ -1247,6 +1249,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // Restore sig int/quit signal(SIGQUIT,old_SIGQUIT); signal(SIGINT,old_SIGINT); + signal(SIGHUP,old_SIGHUP); if(master >= 0) @@ -1308,6 +1311,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) Cache.writeStateFile(NULL); return true; } + +void SigINT(int sig) { + cout << " -- SIGINT -- " << endl; + if (_config->FindB("APT::Immediate-Configure-All",false)) + pkgPackageManager::SigINTStop = true; +} /*}}}*/ // pkgDpkgPM::Reset - Dump the contents of the command list /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index b7b5a6def..fb92c58ea 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -113,4 +113,6 @@ class pkgDPkgPM : public pkgPackageManager virtual ~pkgDPkgPM(); }; +void SigINT(int sig); + #endif diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 8112c7fa1..8bcf3d884 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -29,6 +29,8 @@ /*}}}*/ using namespace std; +bool pkgPackageManager::SigINTStop = false; + // PM::PackageManager - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -262,7 +264,8 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D, // PM::ConfigureAll - Run the all out configuration /*{{{*/ // --------------------------------------------------------------------- /* This configures every package. It is assumed they are all unpacked and - that the final configuration is valid. */ + that the final configuration is valid. This is also used to catch packages + that have not been configured when using ImmConfigureAll */ bool pkgPackageManager::ConfigureAll() { pkgOrderList OList(&Cache); @@ -284,7 +287,7 @@ bool pkgPackageManager::ConfigureAll() { PkgIterator Pkg(Cache,*I); - if (ConfigurePkgs == true && VerifyAndConfigure(Pkg,OList) == false) { + if (ConfigurePkgs == true && SmartConfigure(Pkg) == false) { _error->Error("Internal error, packages left unconfigured. %s",Pkg.Name()); return false; } @@ -297,244 +300,142 @@ bool pkgPackageManager::ConfigureAll() /*}}}*/ // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/ // --------------------------------------------------------------------- -/* This routine scheduals the configuration of the given package and all - of it's dependents. */ +/* This routine trys to put the system in a state where Pkg can be configured, + this involves checking each of Pkg's dependanies and unpacking and + configuring packages where needed. */ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { if (Debug == true) clog << "SmartConfigure " << Pkg.Name() << endl; - - pkgOrderList OList(&Cache); - - if (DepAdd(OList,Pkg) == false) - return false; - - static std::string const conf = _config->Find("PackageManager::Configure","all"); - static bool const ConfigurePkgs = (conf == "all" || conf == "smart"); - - if (ConfigurePkgs == true) - if (OList.OrderConfigure() == false) - return false; - - // Perform the configuring - for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) - { - PkgIterator Pkg(Cache,*I); - - if (ConfigurePkgs == true && VerifyAndConfigure(Pkg,OList) == false) - return false; - List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); - } - - if (Cache[Pkg].InstVerIter(Cache)->MultiArch == pkgCache::Version::Same) - for (PkgIterator P = Pkg.Group().PackageList(); - P.end() == false; P = Pkg.Group().NextPkg(P)) - { - if (Pkg == P || List->IsFlag(P,pkgOrderList::Configured) == true || - Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && - (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) - continue; - SmartConfigure(P); - } - - // Sanity Check - if (List->IsFlag(Pkg,pkgOrderList::Configured) == false && Debug) - _error->Error(_("Could not perform immediate configuration on '%s'. " - "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); - - return true; -} - -// PM::VerifyConfigure - Check configuration of dependancies /*{{{*/ -// --------------------------------------------------------------------- -/* This routine checks that all a packages dependancies have been - configured, before it is going to be configured. If this gives a warning - on a virtual package, it means that the package thats providing it is not - configured*/ -bool pkgPackageManager::VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList) -{ - // If this is true at the end, then the package should not be configured - bool error=true; - // This holds the the OR status of the previous dependancy - bool previousOr=false; - - // First iterate through the dependancies of Pkg - for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); D.end() == false; D++) - { - - /* If the dependancy is of type Depends or PreDepends, we need to check it, but only if it is going to be - configured at some point */ - if (D->Type == pkgCache::Dep::Depends || D->Type == pkgCache::Dep::PreDepends) { - - /* If the previous package and this package are OR dependancies, and the previous package satisfied the dependancy - then skip this dependancy as it is not relevent, this will repeat for the next package if the situation is the - same */ - if (previousOr && !error) { // As error has not been reset, this refers to the previous dependancy - previousOr = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; - continue; - } - - // Reset error - error = true; - - // Check thorugh all possible versions of this dependancy (D) - SPtrArray VList = D.AllTargets(); - for (Version **I = VList; *I != 0; I++) - { - VerIterator DepVer(Cache,*I); - PkgIterator DepPkg = DepVer.ParentPkg(); - VerIterator DepInstallVer(Cache,Cache[DepPkg].InstallVer); - - if (DepPkg.CurrentVer() == DepVer && !List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { - error=false; - break; - } - - if (Cache[DepPkg].InstallVer == DepVer && - (List->IsFlag(DepPkg,pkgOrderList::Configured) || OList.IsFlag(DepPkg,pkgOrderList::InList))) { - error=false; - break; - } - } - - /* Only worry here if this package is a OR with the next, as even though this package does not satisfy the OR - the next one might */ - if (error && !((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)) { - _error->Error("Package %s should not be configured because package %s is not configured",Pkg.Name(),D.TargetPkg().Name()); - return false; - /* If the previous package is a OR but not this package, but there is still an error then fail as it will not - be satisfied */ - } else if (error && previousOr && !((D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or)) { - _error->Error("Package %s should not be configured because package %s (or any alternatives) are not configured",Pkg.Name(),D.TargetPkg().Name()); - return false; - } - - previousOr = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; - } else { - previousOr=false; - } - } - return true; -} - -// PM::VerifyAndConfigure - Check configuration of dependancies /*{{{*/ -// --------------------------------------------------------------------- -/* This routine verifies if a package can be configured and if so - configures it */ -bool pkgPackageManager::VerifyAndConfigure(PkgIterator Pkg, pkgOrderList &OList) -{ - if (VerifyConfigure(Pkg, OList)) - return Configure(Pkg); - else - return false; - -} - /*}}}*/ -// PM::DepAdd - Add all dependents to the oder list /*{{{*/ -// --------------------------------------------------------------------- -/* This recursively adds all dependents to the order list */ -bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) -{ - if (OList.IsFlag(Pkg,pkgOrderList::Added) == true) - return true; - if (List->IsFlag(Pkg,pkgOrderList::Configured) == true) - return true; - if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == false) - return false; - - if (Debug) - std::clog << OutputInDepth(Depth) << "DepAdd: " << Pkg.Name() << std::endl; + VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); - // Put the package on the list - OList.push_back(Pkg); - OList.Flag(Pkg,pkgOrderList::Added); - Depth++; - - // Check the dependencies to see if they are all satisfied. + /* Because of the ordered list, most dependancies should be unpacked, + however if there is a loop this is not the case, so check for dependancies before configuring. + This is done after the package installation as it makes it easier to deal with conflicts problems */ bool Bad = false; - for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); D.end() == false;) + for (DepIterator D = instVer.DependsList(); + D.end() == false; ) { - if (D->Type != pkgCache::Dep::Depends && D->Type != pkgCache::Dep::PreDepends) - { - D++; - continue; - } + // Compute a single dependency element (glob or) + pkgCache::DepIterator Start; + pkgCache::DepIterator End; + D.GlobOr(Start,End); - // Grok or groups - Bad = true; - for (bool LastOR = true; D.end() == false && LastOR == true; D++) - { - LastOR = (D->CompareOp & pkgCache::Dep::Or) == pkgCache::Dep::Or; - - if (Bad == false) - continue; + if (End->Type == pkgCache::Dep::Depends) + Bad = true; - SPtrArray VList = D.AllTargets(); - for (Version **I = VList; *I != 0 && Bad == true; I++) - { + // Check for dependanices that have not been unpacked, probably due to loops. + while (End->Type == pkgCache::Dep::Depends) { + PkgIterator DepPkg; + VerIterator InstallVer; + SPtrArray VList = Start.AllTargets(); + + for (Version **I = VList; *I != 0; I++) { VerIterator Ver(Cache,*I); - PkgIterator Pkg = Ver.ParentPkg(); - VerIterator InstallVer(Cache,Cache[Pkg].InstallVer); - VerIterator CandVer(Cache,Cache[Pkg].CandidateVer); + DepPkg = Ver.ParentPkg(); + + if (!Bad) continue; + + InstallVer = VerIterator(Cache,Cache[DepPkg].InstallVer); + //VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer); if (Debug && false) { if (Ver==0) { - cout << OutputInDepth(Depth) << "Checking if " << Ver << " of " << Pkg.Name() << " satisfies this dependancy" << endl; + cout << " Checking if " << Ver << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; } else { - cout << OutputInDepth(Depth) << "Checking if " << Ver.VerStr() << " of " << Pkg.Name() << " satisfies this dependancy" << endl; + cout << " Checking if " << Ver.VerStr() << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; } - - if (Pkg.CurrentVer()==0) { - cout << OutputInDepth(Depth) << " CurrentVer " << Pkg.CurrentVer() << " IsNow " << List->IsNow(Pkg) << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << endl; + + if (DepPkg.CurrentVer()==0) { + cout << " CurrentVer " << DepPkg.CurrentVer() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; } else { - cout << OutputInDepth(Depth) << " CurrentVer " << Pkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(Pkg) << " NeedsNothing " << (Pkg.State() == PkgIterator::NeedsNothing) << endl; + cout << " CurrentVer " << DepPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; } - + if (InstallVer==0) { - cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer << endl; + cout << " InstallVer " << InstallVer << endl; } else { - cout << OutputInDepth(Depth )<< " InstallVer " << InstallVer.VerStr() << endl; + cout << " InstallVer " << InstallVer.VerStr() << endl; } - if (CandVer != 0) - cout << OutputInDepth(Depth ) << " CandVer " << CandVer.VerStr() << endl; + //if (CandVer != 0) + // cout << " CandVer " << CandVer.VerStr() << endl; - cout << OutputInDepth(Depth) << " Keep " << Cache[Pkg].Keep() << " Unpacked " << List->IsFlag(Pkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(Pkg,pkgOrderList::Configured) << endl; + cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << endl; } - // See if the current version is ok - if (Pkg.CurrentVer() == Ver && List->IsNow(Pkg) == true && - Pkg.State() == PkgIterator::NeedsNothing) + + // Check if it satisfies this dependancy + if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true && + DepPkg.State() == PkgIterator::NeedsNothing) { Bad = false; continue; } - // Not the install version - if ((Cache[Pkg].InstallVer != *I && Cache[Pkg].CandidateVer != *I) || - (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing && - (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) + if (Cache[DepPkg].InstallVer == *I) { + if (List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { + if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + List->Flag(Pkg,pkgOrderList::Loop); + Bad = !SmartConfigure(DepPkg); + } else { + Bad = false; + } + } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) { + Bad = false; + } continue; - - if (List->IsFlag(Pkg,pkgOrderList::UnPacked) == true) - Bad = !DepAdd(OList,Pkg,Depth); - if (List->IsFlag(Pkg,pkgOrderList::Configured) == true) - Bad = false; + } } + + if (InstallVer != 0 && Bad) { + Bad = false; + List->Flag(Pkg,pkgOrderList::Loop); + if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + if (Debug) + cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; + SmartUnPack(DepPkg, true); + } + } + + if (Start==End) { + if (Bad && Debug) { + if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + _error->Warning("Could not satisfy dependancies for %s",Pkg.Name()); + } + } + break; + + } else { + Start++; + } } + } + + static std::string const conf = _config->Find("PackageManager::Configure","all"); + static bool const ConfigurePkgs = (conf == "all" || conf == "smart"); + + if (ConfigurePkgs == true && Configure(Pkg) == false) + return false; - if (Bad == true) + List->Flag(Pkg,pkgOrderList::Configured,pkgOrderList::States); + + if (Cache[Pkg].InstVerIter(Cache)->MultiArch == pkgCache::Version::Same) + for (PkgIterator P = Pkg.Group().PackageList(); + P.end() == false; P = Pkg.Group().NextPkg(P)) { - if (Debug) - std::clog << OutputInDepth(Depth) << "DepAdd FAILS on: " << Pkg.Name() << std::endl; - OList.Flag(Pkg,0,pkgOrderList::Added); - OList.pop_back(); - Depth--; - return false; + if (Pkg == P || List->IsFlag(P,pkgOrderList::Configured) == true || + Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && + (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) + continue; + SmartConfigure(P); } - } - - Depth--; + + // Sanity Check + if (List->IsFlag(Pkg,pkgOrderList::Configured) == false && Debug) + _error->Warning(_("Could not perform immediate configuration on '%s'. " + "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); + return true; } /*}}}*/ @@ -603,7 +504,8 @@ bool pkgPackageManager::SmartRemove(PkgIterator Pkg) /*}}}*/ // PM::SmartUnPack - Install helper /*{{{*/ // --------------------------------------------------------------------- -/* This performs the task of handling pre-depends. */ +/* This puts the system in a state where it can Unpack Pkg, if Pkg is allready + unpacked, or when it has been unpacked, if Immediate==true it configures it. */ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) { return SmartUnPack(Pkg, true); @@ -628,8 +530,11 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); - /* See if this packages install version has any predependencies - that are not met by 'now' packages. */ + /* PreUnpack Checks: This loop checks and attemps to rectify and problems that would prevent the package being unpacked. + It addresses: PreDepends, Conflicts, Obsoletes and DpkgBreaks. Any resolutions that do not require it should + avoid configuration (calling SmartUnpack with Immediate=true), this is because any loops before Pkg is unpacked + can cause problems. This will be either dealt with if the package is configured as a dependancy of + Pkg (if and when Pkg is configured), or by the ConfigureAll call at the end of the for loop in OrderInstall. */ for (DepIterator D = instVer.DependsList(); D.end() == false; ) { @@ -763,7 +668,6 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) PkgIterator BrokenPkg = Ver.ParentPkg(); VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer); - cout << " " << Pkg.Name() << " breaks " << BrokenPkg.Name() << endl; if (Debug && false) { if (Ver==0) { cout << " Checking if " << Ver << " of " << BrokenPkg.Name() << " satisfies this dependancy" << endl; @@ -793,6 +697,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) // Found a break, so unpack the package if (Debug) cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; + /* */ SmartUnPack(BrokenPkg, false); } // Check if a package needs to be removed @@ -846,106 +751,13 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) if(Install(Pkg,FileNames[Pkg->ID]) == false) return false; - /* Because of the ordered list, most dependancies should be unpacked, - however if there is a loop this is not the case, so check for dependancies before configuring. - This is done after the package installation as it makes it easier to deal with conflicts problems */ - bool Bad = true; - for (DepIterator D = instVer.DependsList(); - D.end() == false; ) - { - // Compute a single dependency element (glob or) - pkgCache::DepIterator Start; - pkgCache::DepIterator End; - D.GlobOr(Start,End); - - if (End->Type == pkgCache::Dep::Depends) - Bad = true; - - // Check for dependanices that have not been unpacked, probably due to loops. - while (End->Type == pkgCache::Dep::Depends) { - PkgIterator DepPkg; - VerIterator InstallVer; - SPtrArray VList = Start.AllTargets(); - - for (Version **I = VList; *I != 0; I++) { - VerIterator Ver(Cache,*I); - DepPkg = Ver.ParentPkg(); - - if (!Bad) continue; - - InstallVer = VerIterator(Cache,Cache[DepPkg].InstallVer); - VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer); - - if (Debug && false) { - if (Ver==0) { - cout << " Checking if " << Ver << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; - } else { - cout << " Checking if " << Ver.VerStr() << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; - } - - if (DepPkg.CurrentVer()==0) { - cout << " CurrentVer " << DepPkg.CurrentVer() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; - } else { - cout << " CurrentVer " << DepPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; - } - - if (InstallVer==0) { - cout << " InstallVer " << InstallVer << endl; - } else { - cout << " InstallVer " << InstallVer.VerStr() << endl; - } - if (CandVer != 0) - cout << " CandVer " << CandVer.VerStr() << endl; - - cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << endl; - - } - - // Check if it satisfies this dependancy - if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true && - DepPkg.State() == PkgIterator::NeedsNothing) - { - Bad = false; - continue; - } - - if (Cache[DepPkg].InstallVer == *I && !List->IsNow(DepPkg)) { - Bad = false; - continue; - } - } - - if (InstallVer != 0 && Bad) { - Bad = false; - // Found a break, so unpack the package - List->Flag(Pkg,pkgOrderList::Loop); - if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { - if (Debug) - cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - SmartUnPack(DepPkg, false); - } - } - - if (Start==End) { - if (Bad && Debug) { - if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { - _error->Warning("Could not satisfy dependancies for %s",Pkg.Name()); - } - } - break; - - } else { - Start++; - } - } - } + if (Immediate == true && List->IsFlag(Pkg,pkgOrderList::Immediate) == true) { - // Perform immedate configuration of the package. - if (Immediate == true && - List->IsFlag(Pkg,pkgOrderList::Immediate) == true && !Bad) - if (SmartConfigure(Pkg) == false) - _error->Warning(_("Could not perform immediate configuration on '%s'. " - "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2); + // Perform immedate configuration of the package. + if (SmartConfigure(Pkg) == false) + _error->Warning(_("Could not perform immediate configuration on '%s'. " + "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2); + } return true; } @@ -1025,6 +837,12 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() if (SmartUnPack(Pkg) == false) return Failed; DoneSomething = true; + + if (ImmConfigureAll) { + /* ConfigureAll here to pick up and packages left unconfigured becuase they were unpacked in the + "PreUnpack Checks" section */ + ConfigureAll(); + } } // Final run through the configure phase diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index d4a25e982..e1878ce46 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -42,6 +42,7 @@ class pkgPackageManager : protected pkgCache::Namespace public: enum OrderResult {Completed,Failed,Incomplete}; + static bool SigINTStop; protected: string *FileNames; @@ -59,7 +60,6 @@ class pkgPackageManager : protected pkgCache::Namespace */ std::set disappearedPkgs; - bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0); void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0); virtual OrderResult OrderInstall(); bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver); @@ -76,8 +76,6 @@ class pkgPackageManager : protected pkgCache::Namespace bool SmartUnPack(PkgIterator Pkg, bool const Immediate); bool SmartRemove(PkgIterator Pkg); bool EarlyRemove(PkgIterator Pkg); - bool VerifyAndConfigure(PkgIterator Pkg, pkgOrderList &OList); - bool VerifyConfigure(PkgIterator Pkg, pkgOrderList &OList); // The Actual installation implementation virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;}; -- cgit v1.2.3 From 1cecd4376cebdd0225ee91707b7630bc35959474 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 31 Jul 2011 16:26:39 +0100 Subject: Only allow interupts when using, Immediate-Configure-All. TODO for dpkgpm: Useful messages about the interupt, what was done to what packages and what was not done to what packages. Only fail when the system is in a clean state, at the moment it will fail either a configure or install run. --- apt-pkg/deb/dpkgpm.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 3dbbd7c97..479126658 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -889,7 +889,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) OpenLog(); // this loop is runs once per operation - for (vector::const_iterator I = List.begin(); I != List.end() && !pkgPackageManager::SigINTStop;) + for (vector::const_iterator I = List.begin(); I != List.end();) { // Do all actions with the same Op in one run vector::const_iterator J = I; @@ -921,7 +921,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // the argument list is split in a way that A depends on B // and they are in the same "--configure A B" run // - with the split they may now be configured in different - // runs + // runs, using Immediate-Configure-All can help prevent this. if (J - I > (signed)MaxArgs) J = I + MaxArgs; @@ -1064,6 +1064,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) it doesn't die but we do! So we must also ignore it */ sighandler_t old_SIGQUIT = signal(SIGQUIT,SIG_IGN); sighandler_t old_SIGINT = signal(SIGINT,SigINT); + + // Check here for any SIGINT + if (pkgPackageManager::SigINTStop) break; // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1102,7 +1105,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) sigprocmask(SIG_SETMASK, &original_sigmask, 0); } } - // Fork dpkg pid_t Child; _config->Set("APT::Keep-Fds::",fd[1]); -- cgit v1.2.3 From 17182c0c66630c2fcba938edb5b27668f7495854 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 1 Aug 2011 12:27:10 +0100 Subject: Only stop on SigInt if the system state is right (still needs more testing). More inprovements to the package manager to prevent packages from being configured twice. --- apt-pkg/deb/dpkgpm.cc | 4 ++-- apt-pkg/packagemanager.cc | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 479126658..68d9ca1de 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1066,7 +1066,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGINT = signal(SIGINT,SigINT); // Check here for any SIGINT - if (pkgPackageManager::SigINTStop) break; + if (pkgPackageManager::SigINTStop && + (I->Op == Item::Install || I->Op == Item::Remove || I->Op == Item::Purge)) break; // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1315,7 +1316,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) } void SigINT(int sig) { - cout << " -- SIGINT -- " << endl; if (_config->FindB("APT::Immediate-Configure-All",false)) pkgPackageManager::SigINTStop = true; } diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 8bcf3d884..324b7ffba 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -286,6 +286,10 @@ bool pkgPackageManager::ConfigureAll() for (pkgOrderList::iterator I = OList.begin(); I != OList.end(); I++) { PkgIterator Pkg(Cache,*I); + + /* Check if the package has been configured, this can happen if SmartConfigure + calls its self */ + if (List->IsFlag(Pkg,pkgOrderList::Configured)) continue; if (ConfigurePkgs == true && SmartConfigure(Pkg) == false) { _error->Error("Internal error, packages left unconfigured. %s",Pkg.Name()); @@ -415,6 +419,9 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) static std::string const conf = _config->Find("PackageManager::Configure","all"); static bool const ConfigurePkgs = (conf == "all" || conf == "smart"); + if (List->IsFlag(Pkg,pkgOrderList::Configured)) + return _error->Error("Internal configure error on '%s'. ",Pkg.Name(),1); + if (ConfigurePkgs == true && Configure(Pkg) == false) return false; @@ -577,6 +584,11 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) if (Cache[Pkg].InstallVer != *I || (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing)) continue; + + if (List->IsFlag(Pkg,pkgOrderList::Configured)) { + Bad = false; + continue; + } if (Debug) clog << "Trying to SmartConfigure " << Pkg.Name() << endl; -- cgit v1.2.3 From 11b87a08ee6952c5b66b14842283df3ea26b90ac Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 2 Aug 2011 10:29:11 +0100 Subject: Inproved the SIGINT stop in the dpkgpm, not perfect yet but it should work when using Immediate-Configure-All. --- apt-pkg/deb/dpkgpm.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 68d9ca1de..57361ccdc 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -954,6 +954,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]); Args[n++] = status_fd_buf; Size += strlen(Args[n-1]); + + unsigned long const Op = I->Op; switch (I->Op) { @@ -1066,9 +1068,10 @@ bool pkgDPkgPM::Go(int OutStatusFd) sighandler_t old_SIGINT = signal(SIGINT,SigINT); // Check here for any SIGINT - if (pkgPackageManager::SigINTStop && - (I->Op == Item::Install || I->Op == Item::Remove || I->Op == Item::Purge)) break; - + if (pkgPackageManager::SigINTStop && (Op == Item::Remove || Op == Item::Purge || Op == Item::Install)) + break; + + // ignore SIGHUP as well (debian #463030) sighandler_t old_SIGHUP = signal(SIGHUP,SIG_IGN); @@ -1290,6 +1293,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) } } CloseLog(); + + if (pkgPackageManager::SigINTStop) + _error->Warning(_("Operation was interrupted before it could finish")); if (RunScripts("DPkg::Post-Invoke") == false) return false; -- cgit v1.2.3 From b9f668796339b7581f49ee6d42c53dc10049e5c2 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 7 Aug 2011 16:35:36 +0100 Subject: Fixed a bug on line 623, I picked this up after seeing SmartUnpack trying to remove packages once they were confiured to solve Conflicts with the previous version! Luckily EarlyRemove is sane, and properly checks, so I think this was just cosmetic. Also fixed a bug on line 374 with SmartUnpack not checking if a dependancy has been removed, this bug was definately harmful. --- apt-pkg/packagemanager.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 324b7ffba..b3c3d2591 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -344,7 +344,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) InstallVer = VerIterator(Cache,Cache[DepPkg].InstallVer); //VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer); - if (Debug && false) { + if (Debug) { if (Ver==0) { cout << " Checking if " << Ver << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; } else { @@ -365,13 +365,13 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) //if (CandVer != 0) // cout << " CandVer " << CandVer.VerStr() << endl; - cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << endl; + cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << " Removed " << List->IsFlag(DepPkg,pkgOrderList::Removed) << endl; } // Check if it satisfies this dependancy if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true && - DepPkg.State() == PkgIterator::NeedsNothing) + !List->IsFlag(DepPkg,pkgOrderList::Removed) && DepPkg.State() == PkgIterator::NeedsNothing) { Bad = false; continue; @@ -623,7 +623,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) VerIterator InstallVer(Cache,Cache[ConflictPkg].InstallVer); // See if the current version is conflicting - if (ConflictPkg.CurrentVer() == Ver && !List->IsFlag(ConflictPkg,pkgOrderList::UnPacked)) + if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) { if (Debug && false) cout << " " << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; @@ -653,7 +653,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) { if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { - cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; + if (Debug) + cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; List->Flag(Pkg,pkgOrderList::Loop); SmartUnPack(ConflictPkg,false); } else { @@ -662,7 +663,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } } else { if (!List->IsFlag(ConflictPkg,pkgOrderList::Removed)) { - cout << "Because of conficts knot, removing " << ConflictPkg.Name() << " to conflict violation" << endl; + if (Debug) + cout << "Because of conficts knot, removing " << ConflictPkg.Name() << " to conflict violation" << endl; if (EarlyRemove(ConflictPkg) == false) return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); } -- cgit v1.2.3 From c7c7d3e8f12e68cd14470eec47db516c9b784cbe Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 7 Aug 2011 20:26:31 +0100 Subject: Improved errors and messages in general and improved the comments. Removed quite a bit of code I used while learning about how apt handles things. Added some extra checks and warnings relevent for Immediate Configuration. Removed a wierd section I put in to prevent a segfault at 724+, this appears no longer to be needed. --- apt-pkg/packagemanager.cc | 195 +++++++++++++++------------------------------- 1 file changed, 63 insertions(+), 132 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index b3c3d2591..d956c001e 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -292,7 +292,11 @@ bool pkgPackageManager::ConfigureAll() if (List->IsFlag(Pkg,pkgOrderList::Configured)) continue; if (ConfigurePkgs == true && SmartConfigure(Pkg) == false) { - _error->Error("Internal error, packages left unconfigured. %s",Pkg.Name()); + if (ImmConfigureAll) + _error->Error(_("Could not perform immediate configuration on '%s'. " + "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); + else + _error->Error("Internal error, packages left unconfigured. %s",Pkg.Name()); return false; } @@ -304,19 +308,26 @@ bool pkgPackageManager::ConfigureAll() /*}}}*/ // PM::SmartConfigure - Perform immediate configuration of the pkg /*{{{*/ // --------------------------------------------------------------------- -/* This routine trys to put the system in a state where Pkg can be configured, - this involves checking each of Pkg's dependanies and unpacking and - configuring packages where needed. */ +/* This function tries to put the system in a state where Pkg can be configured. + This involves checking each of Pkg's dependanies and unpacking and + configuring packages where needed. + + Note on failure: This method can fail, without causing any problems. + This can happen when using Immediate-Configure-All, SmartUnPack may call + SmartConfigure, it may fail because of a complex dependancy situation, but + a error will only be reported if ConfigureAll fails. This is why some of the + messages this function reports on failure (return false;) as just warnings + only shown when debuging*/ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { - if (Debug == true) + if (Debug) clog << "SmartConfigure " << Pkg.Name() << endl; VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* Because of the ordered list, most dependancies should be unpacked, - however if there is a loop this is not the case, so check for dependancies before configuring. - This is done after the package installation as it makes it easier to deal with conflicts problems */ + however if there is a loop (A depends on B, B depends on A) this will not + be the case, so check for dependancies before configuring. */ bool Bad = false; for (DepIterator D = instVer.DependsList(); D.end() == false; ) @@ -335,63 +346,39 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) VerIterator InstallVer; SPtrArray VList = Start.AllTargets(); + // Check through each version of each package that could satisfy this dependancy for (Version **I = VList; *I != 0; I++) { VerIterator Ver(Cache,*I); DepPkg = Ver.ParentPkg(); - - if (!Bad) continue; - InstallVer = VerIterator(Cache,Cache[DepPkg].InstallVer); - //VerIterator CandVer(Cache,Cache[DepPkg].CandidateVer); - - if (Debug) { - if (Ver==0) { - cout << " Checking if " << Ver << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; - } else { - cout << " Checking if " << Ver.VerStr() << " of " << DepPkg.Name() << " satisfies this dependancy" << endl; - } - - if (DepPkg.CurrentVer()==0) { - cout << " CurrentVer " << DepPkg.CurrentVer() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; - } else { - cout << " CurrentVer " << DepPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(DepPkg) << " NeedsNothing " << (DepPkg.State() == PkgIterator::NeedsNothing) << endl; - } - - if (InstallVer==0) { - cout << " InstallVer " << InstallVer << endl; - } else { - cout << " InstallVer " << InstallVer.VerStr() << endl; - } - //if (CandVer != 0) - // cout << " CandVer " << CandVer.VerStr() << endl; - - cout << " Keep " << Cache[DepPkg].Keep() << " Unpacked " << List->IsFlag(DepPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(DepPkg,pkgOrderList::Configured) << " Removed " << List->IsFlag(DepPkg,pkgOrderList::Removed) << endl; - - } - - // Check if it satisfies this dependancy + + // Check if the current version of the package is avalible and will satisfy this dependancy if (DepPkg.CurrentVer() == Ver && List->IsNow(DepPkg) == true && !List->IsFlag(DepPkg,pkgOrderList::Removed) && DepPkg.State() == PkgIterator::NeedsNothing) { Bad = false; - continue; + break; } + // Check if the version that is going to be installed will satisfy the dependancy if (Cache[DepPkg].InstallVer == *I) { if (List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { + /* Check for a loop to prevent one forming + If A depends on B and B depends on A, SmartConfigure will + just hop between them if this is not checked */ if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { List->Flag(Pkg,pkgOrderList::Loop); - Bad = !SmartConfigure(DepPkg); - } else { - Bad = false; + // If SmartConfigure was succesfull, Bad is false, so break + if (!(Bad = !SmartConfigure(DepPkg))) break; } } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) { Bad = false; + break; } - continue; } } + /* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */ if (InstallVer != 0 && Bad) { Bad = false; List->Flag(Pkg,pkgOrderList::Loop); @@ -409,12 +396,17 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) } } break; - } else { Start++; } } } + + if (Bad) { + if (Debug) + _error->Warning(_("Could not configure '%s'. "),Pkg.Name()); + return false; + } static std::string const conf = _config->Find("PackageManager::Configure","all"); static bool const ConfigurePkgs = (conf == "all" || conf == "smart"); @@ -439,9 +431,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) } // Sanity Check - if (List->IsFlag(Pkg,pkgOrderList::Configured) == false && Debug) - _error->Warning(_("Could not perform immediate configuration on '%s'. " - "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); + if (List->IsFlag(Pkg,pkgOrderList::Configured) == false) + return _error->Error(_("Could not configure '%s'. "),Pkg.Name()); return true; } @@ -519,7 +510,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) } bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) { - if (Debug == true) + if (Debug) clog << "SmartUnPack " << Pkg.Name() << endl; // Check if it is already unpacked @@ -537,11 +528,12 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); - /* PreUnpack Checks: This loop checks and attemps to rectify and problems that would prevent the package being unpacked. - It addresses: PreDepends, Conflicts, Obsoletes and DpkgBreaks. Any resolutions that do not require it should - avoid configuration (calling SmartUnpack with Immediate=true), this is because any loops before Pkg is unpacked - can cause problems. This will be either dealt with if the package is configured as a dependancy of - Pkg (if and when Pkg is configured), or by the ConfigureAll call at the end of the for loop in OrderInstall. */ + /* PreUnpack Checks: This loop checks and attempts to rectify and problems that would prevent the package being unpacked. + It addresses: PreDepends, Conflicts, Obsoletes and Breaks (DpkgBreaks). Any resolutions that do not require it should + avoid configuration (calling SmartUnpack with Immediate=true), this is because when unpacking some packages with + complex dependancy structures, trying to configure some packages while breaking the loops can complicate things . + This will be either dealt with if the package is configured as a dependency of Pkg (if and when Pkg is configured), + or by the ConfigureAll call at the end of the for loop in OrderInstall. */ for (DepIterator D = instVer.DependsList(); D.end() == false; ) { @@ -624,33 +616,9 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) // See if the current version is conflicting if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) - { - if (Debug && false) - cout << " " << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; - - if (Debug && false) { - if (Ver==0) { - cout << " Checking if " << Ver << " of " << ConflictPkg.Name() << " satisfies this dependancy" << endl; - } else { - cout << " Checking if " << Ver.VerStr() << " of " << ConflictPkg.Name() << " satisfies this dependancy" << endl; - } - - if (ConflictPkg.CurrentVer()==0) { - cout << " CurrentVer " << ConflictPkg.CurrentVer() << " IsNow " << List->IsNow(ConflictPkg) << " NeedsNothing " << (ConflictPkg.State() == PkgIterator::NeedsNothing) << endl; - } else { - cout << " CurrentVer " << ConflictPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(ConflictPkg) << " NeedsNothing " << (ConflictPkg.State() == PkgIterator::NeedsNothing) << endl; - } - - if (InstallVer==0) { - cout << " InstallVer " << InstallVer << endl; - } else { - cout << " InstallVer " << InstallVer.VerStr() << endl; - } - - cout << " Keep " << Cache[ConflictPkg].Keep() << " Unpacked " << List->IsFlag(ConflictPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(ConflictPkg,pkgOrderList::Configured) << " Removed " << List->IsFlag(ConflictPkg,pkgOrderList::Removed) << " Loop " << List->IsFlag(ConflictPkg,pkgOrderList::Loop) << endl; - cout << " Delete " << Cache[ConflictPkg].Delete() << endl; - } - + { + /* If a loop is not present or has not yet been detected, attempt to unpack packages + to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */ if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) { if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { if (Debug) @@ -682,28 +650,6 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) PkgIterator BrokenPkg = Ver.ParentPkg(); VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer); - if (Debug && false) { - if (Ver==0) { - cout << " Checking if " << Ver << " of " << BrokenPkg.Name() << " satisfies this dependancy" << endl; - } else { - cout << " Checking if " << Ver.VerStr() << " of " << BrokenPkg.Name() << " satisfies this dependancy" << endl; - } - - if (BrokenPkg.CurrentVer()==0) { - cout << " CurrentVer " << BrokenPkg.CurrentVer() << " IsNow " << List->IsNow(BrokenPkg) << " NeedsNothing " << (BrokenPkg.State() == PkgIterator::NeedsNothing) << endl; - } else { - cout << " CurrentVer " << BrokenPkg.CurrentVer().VerStr() << " IsNow " << List->IsNow(BrokenPkg) << " NeedsNothing " << (BrokenPkg.State() == PkgIterator::NeedsNothing) << endl; - } - - if (InstallVer==0) { - cout << " InstallVer " << InstallVer << endl; - } else { - cout << " InstallVer " << InstallVer.VerStr() << endl; - } - - cout << " Keep " << Cache[BrokenPkg].Keep() << " Unpacked " << List->IsFlag(BrokenPkg,pkgOrderList::UnPacked) << " Configured " << List->IsFlag(BrokenPkg,pkgOrderList::Configured) << " Removed " << List->IsFlag(BrokenPkg,pkgOrderList::Removed) << " Loop " << List->IsFlag(BrokenPkg,pkgOrderList::Loop) << " InList " << List->IsFlag(BrokenPkg,pkgOrderList::InList) << endl; - cout << " Delete " << Cache[BrokenPkg].Delete() << endl; - } // Check if it needs to be unpacked if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && !List->IsFlag(BrokenPkg,pkgOrderList::Loop) && List->IsNow(BrokenPkg)) { @@ -711,7 +657,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) // Found a break, so unpack the package if (Debug) cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; - /* */ + SmartUnPack(BrokenPkg, false); } // Check if a package needs to be removed @@ -724,43 +670,27 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } } - // FIXME: Crude but effective fix, allows the SmartUnPack method to be used for packages that new to the system - if (instVer != 0) { - //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << instVer.VerStr() << endl; - - // Check for reverse conflicts. - if (CheckRConflicts(Pkg,Pkg.RevDependsList(), + // Check for reverse conflicts. + if (CheckRConflicts(Pkg,Pkg.RevDependsList(), instVer.VerStr()) == false) - return false; + return false; - for (PrvIterator P = instVer.ProvidesList(); + for (PrvIterator P = instVer.ProvidesList(); P.end() == false; P++) CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - if (instVer->MultiArch == pkgCache::Version::Same) - for (PkgIterator P = Pkg.Group().PackageList(); - P.end() == false; P = Pkg.Group().NextPkg(P)) - { - if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true || + if (instVer->MultiArch == pkgCache::Version::Same) + for (PkgIterator P = Pkg.Group().PackageList(); + P.end() == false; P = Pkg.Group().NextPkg(P)) + { + if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true || Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) - continue; + continue; SmartUnPack(P, false); - } - - } else { - VerIterator InstallVer(Cache,Cache[Pkg].InstallVer); - //cout << "Check for reverse conflicts on " << Pkg.Name() << " " << InstallVer.VerStr() << endl; - - // Check for reverse conflicts. - if (CheckRConflicts(Pkg,Pkg.RevDependsList(), - InstallVer.VerStr()) == false) - return false; - - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - } + } if(Install(Pkg,FileNames[Pkg->ID]) == false) return false; @@ -855,7 +785,8 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() if (ImmConfigureAll) { /* ConfigureAll here to pick up and packages left unconfigured becuase they were unpacked in the "PreUnpack Checks" section */ - ConfigureAll(); + if (!ConfigureAll()) + return Failed; } } -- cgit v1.2.3 From e7ecc2183ced0503c4f9662339f5ab98dc1606ee Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 9 Aug 2011 17:10:09 +0100 Subject: More inproved comments about loops. --- apt-pkg/orderlist.cc | 2 ++ apt-pkg/orderlist.h | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index eaa5ea20a..1e412ead5 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -1023,6 +1023,8 @@ bool pkgOrderList::AddLoop(DepIterator D) // Mark the packages as being part of a loop. //Flag(D.TargetPkg(),Loop); //Flag(D.ParentPkg(),Loop); + /* This is currently disabled because the Loop flag is being used for + loop management in the package manager. Check the orderlist.h file for more info */ return true; } /*}}}*/ diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index bbceb3879..2f5c6d0d1 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -74,7 +74,12 @@ class pkgOrderList : protected pkgCache::Namespace typedef Package **iterator; - // State flags + /* State flags + The Loop flag can be set on a package that is currently being processed by either SmartConfigure or + SmartUnPack. This allows the package manager to tell when a loop has been formed as it will try to + SmartUnPack or SmartConfigure a package with the Loop flag set. It will then either stop (as it knows + that the operation is unnecessary as its already in process), or in the case of the conflicts resolution + in SmartUnPack, use EarlyRemove to resolve the situation. */ enum Flags {Added = (1 << 0), AddPending = (1 << 1), Immediate = (1 << 2), Loop = (1 << 3), UnPacked = (1 << 4), Configured = (1 << 5), @@ -89,6 +94,7 @@ class pkgOrderList : protected pkgCache::Namespace void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;}; inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; + // IsNow will return true if the Pkg has been not been either configured or unpacked inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;}; bool IsMissing(PkgIterator Pkg); void WipeFlags(unsigned long F); -- cgit v1.2.3 From cbea0578989754f70874bf49946b84bf4f7a567e Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 11 Aug 2011 15:35:54 +0100 Subject: Added a RmFlag function to remvoe the loop flag, this should prevent any errors or wierd behaviour because of the loop flag being used at mutiple stages in both SmartUnpack and SmartConfigure. --- apt-pkg/orderlist.h | 2 ++ apt-pkg/packagemanager.cc | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index 2f5c6d0d1..4e5ea1654 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -94,6 +94,8 @@ class pkgOrderList : protected pkgCache::Namespace void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;}; inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; + // RmFlag removes a flag from a package + inline void RmFlag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] &= ~F;}; // IsNow will return true if the Pkg has been not been either configured or unpacked inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;}; bool IsMissing(PkgIterator Pkg); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index d956c001e..722cbfa86 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -369,7 +369,9 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { List->Flag(Pkg,pkgOrderList::Loop); // If SmartConfigure was succesfull, Bad is false, so break - if (!(Bad = !SmartConfigure(DepPkg))) break; + Bad = !SmartConfigure(DepPkg); + List->RmFlag(Pkg,pkgOrderList::Loop); + if (!Bad) break; } } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) { Bad = false; @@ -381,11 +383,12 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) /* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */ if (InstallVer != 0 && Bad) { Bad = false; - List->Flag(Pkg,pkgOrderList::Loop); if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + List->Flag(Pkg,pkgOrderList::Loop); if (Debug) cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; SmartUnPack(DepPkg, true); + //List->Flag(Pkg,~pkgOrderList::Loop); } } @@ -616,15 +619,18 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) // See if the current version is conflicting if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) - { + { + cout << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; /* If a loop is not present or has not yet been detected, attempt to unpack packages to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */ if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) { if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { if (Debug) cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; - List->Flag(Pkg,pkgOrderList::Loop); + List->Flag(Pkg,pkgOrderList::Loop); SmartUnPack(ConflictPkg,false); + // Remove loop to allow it to be used later if needed + List->RmFlag(Pkg,pkgOrderList::Loop); } else { if (EarlyRemove(ConflictPkg) == false) return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); @@ -659,6 +665,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; SmartUnPack(BrokenPkg, false); + List->RmFlag(Pkg,pkgOrderList::Loop); } // Check if a package needs to be removed if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) { -- cgit v1.2.3 From b40b7c380acbdcd84338bdcd253df32f1ef79ed8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 18:42:19 +0200 Subject: cppcheck is right that the check for preventing null deference of Query is redundant in Redirect() as we can't reach the code with null anyway [apt-pkg/acquire-method.cc:433]: (error) Possible null pointer dereference: Queue - otherwise it is redundant to check if Queue is null at line 425 --- apt-pkg/acquire-method.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index e9e102488..79a7519a8 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -421,12 +421,8 @@ void pkgAcqMethod::Status(const char *Format,...) 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. -- cgit v1.2.3 From dd6882853b4555a6113740afca417acbaa060043 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 19:20:53 +0200 Subject: fix some cppcheck: (warning) Member variable is not initialized in the constructor. --- apt-pkg/aptconfiguration.h | 3 ++- apt-pkg/indexfile.cc | 3 ++- apt-pkg/tagfile.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.h b/apt-pkg/aptconfiguration.h index 1f0399dd2..e098d0fd6 100644 --- a/apt-pkg/aptconfiguration.h +++ b/apt-pkg/aptconfiguration.h @@ -13,6 +13,7 @@ // Include Files /*{{{*/ #include #include +#include /*}}}*/ namespace APT { class Configuration { /*{{{*/ @@ -94,7 +95,7 @@ public: /*{{{*/ Compressor(char const *name, char const *extension, char const *binary, char const *compressArg, char const *uncompressArg, unsigned short const cost); - Compressor() {}; + Compressor() : Cost(std::numeric_limits::max()) {}; }; /** \brief Return a vector of Compressors supported for data.tar's diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 37be87055..f18ddbfaa 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -27,7 +27,8 @@ unsigned long pkgIndexFile::Type::GlobalListLen = 0; pkgIndexFile::Type::Type() { ItmList[GlobalListLen] = this; - GlobalListLen++; + GlobalListLen++; + Label = NULL; } /*}}}*/ // Type::GetType - Locate the type by name /*{{{*/ diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 61491aa04..a101d7b1e 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -79,7 +79,7 @@ class pkgTagSection Stop = this->Stop; }; - pkgTagSection() : Section(0), Stop(0) {}; + pkgTagSection() : Section(0), TagCount(0), Stop(0) {}; }; class pkgTagFile -- cgit v1.2.3 From f7f0d6c7560a8f71707e7852a512469147aa9f84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 20:53:28 +0200 Subject: cppcheck complains about some possible speed improvements which could be done on the mirco-optimazation level, so lets fix them: (performance) Possible inefficient checking for emptiness. (performance) Prefer prefix ++/-- operators for non-primitive types. --- apt-pkg/acquire-item.cc | 22 +++++++------- apt-pkg/acquire-method.cc | 2 +- apt-pkg/acquire.cc | 20 ++++++------- apt-pkg/algorithms.cc | 62 ++++++++++++++++++++-------------------- apt-pkg/aptconfiguration.cc | 4 +-- apt-pkg/cdrom.cc | 26 ++++++++--------- apt-pkg/clean.cc | 4 +-- apt-pkg/contrib/configuration.cc | 6 ++-- apt-pkg/contrib/error.cc | 6 ++-- apt-pkg/contrib/strutl.cc | 30 +++++++++---------- apt-pkg/deb/debindexfile.cc | 6 ++-- apt-pkg/deb/deblistparser.cc | 2 +- apt-pkg/deb/debmetaindex.cc | 12 ++++---- apt-pkg/deb/debrecords.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 20 ++++++------- apt-pkg/depcache.cc | 28 +++++++++--------- apt-pkg/indexcopy.cc | 18 ++++++------ apt-pkg/orderlist.cc | 16 +++++------ apt-pkg/packagemanager.cc | 20 ++++++------- apt-pkg/pkgcache.cc | 26 ++++++++--------- apt-pkg/pkgcachegen.cc | 28 +++++++++--------- apt-pkg/pkgrecords.cc | 2 +- apt-pkg/policy.cc | 14 ++++----- apt-pkg/sourcelist.cc | 14 ++++----- apt-pkg/srcrecords.cc | 10 +++---- apt-pkg/vendorlist.cc | 6 ++-- apt-pkg/versionmatch.cc | 6 ++-- 27 files changed, 206 insertions(+), 206 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 7eb5920e0..2a514b088 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -681,17 +681,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; } @@ -756,7 +756,7 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash, /* 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(); @@ -1375,7 +1375,7 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ #endif for (vector ::const_iterator Target = IndexTargets->begin(); Target != IndexTargets->end(); - Target++) + ++Target) { HashString ExpectedIndexHash; if (verify) @@ -1672,7 +1672,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, // 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) @@ -1709,7 +1709,7 @@ pkgAcqArchive::pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, 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) @@ -1820,7 +1820,7 @@ bool pkgAcqArchive::QueueNext() Desc.ShortDesc = Version.ParentPkg().Name(); QueueURI(Desc); - Vf++; + ++Vf; return true; } return false; @@ -1894,7 +1894,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf) 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; diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 79a7519a8..7e9061e56 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -81,7 +81,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 = ' '; diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 9478cdfb4..a2da196be 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -116,7 +116,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; @@ -155,7 +155,7 @@ void pkgAcquire::Remove(Item *Itm) I = Items.begin(); } else - I++; + ++I; } } /*}}}*/ @@ -411,7 +411,7 @@ pkgAcquire::RunResult pkgAcquire::Run(int PulseIntervall) 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()) @@ -467,7 +467,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; @@ -488,7 +488,7 @@ bool pkgAcquire::Clean(string Dir) 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; } @@ -499,7 +499,7 @@ unsigned long long pkgAcquire::TotalNeeded() 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; @@ -511,7 +511,7 @@ unsigned long long pkgAcquire::FetchNeeded() 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; @@ -781,11 +781,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) 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) @@ -795,7 +795,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) if ((*I)->Complete == true) CurrentBytes += (*I)->FileSize; if ((*I)->FileSize == 0 && (*I)->Complete == false) - Unknown++; + ++Unknown; } // Compute the current completion diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 7c911b865..5fbcb47be 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -91,7 +91,7 @@ bool pkgSimulate::Install(PkgIterator iPkg,string /*File*/) 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; @@ -140,7 +140,7 @@ bool pkgSimulate::Configure(PkgIterator iPkg) 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) @@ -204,7 +204,7 @@ bool pkgSimulate::Remove(PkgIterator iPkg,bool Purge) 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) { @@ -226,7 +226,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; @@ -295,13 +295,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) @@ -338,19 +338,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); @@ -359,7 +359,7 @@ bool pkgDistUpgrade(pkgDepCache &Cache) // 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) { @@ -387,7 +387,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); @@ -421,7 +421,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) 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) @@ -438,7 +438,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) Change = true; } } - Count++; + ++Count; } while (Change == true && Count < 10); @@ -525,7 +525,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; @@ -552,12 +552,12 @@ void pkgProblemResolver::MakeScores() } // 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) @@ -574,12 +574,12 @@ void pkgProblemResolver::MakeScores() /* 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 || @@ -594,9 +594,9 @@ void pkgProblemResolver::MakeScores() /* 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) @@ -607,7 +607,7 @@ void pkgProblemResolver::MakeScores() /* 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; @@ -704,7 +704,7 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) if (Start == End) break; - Start++; + ++Start; } if (Fail == true) break; @@ -750,7 +750,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) 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; @@ -781,7 +781,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) 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); @@ -901,7 +901,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) } else { - Start++; + ++Start; // We only worry about critical deps. if (Start.IsCritical() != true) continue; @@ -1150,7 +1150,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) { // 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; @@ -1162,7 +1162,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // 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) @@ -1220,7 +1220,7 @@ bool pkgProblemResolver::ResolveByKeep() 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); @@ -1317,7 +1317,7 @@ bool pkgProblemResolver::ResolveByKeep() if (Start == End) break; - Start++; + ++Start; } if (InstOrNewPolicyBroken(I) == false) @@ -1344,7 +1344,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) { @@ -1424,7 +1424,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 --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 9ccbeecf1..6ec5fa03a 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -53,7 +53,7 @@ const Configuration::getCompressionTypes(bool const &Cached) { // 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 @@ -274,7 +274,7 @@ std::vector const Configuration::getLanguages(bool const &All, // 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) { diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2a914c665..b8acf0cbe 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -310,7 +310,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector &List) 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(' '); @@ -322,7 +322,7 @@ void pkgCdrom::ReduceSourcelist(string CD,vector &List) 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(' '); @@ -405,7 +405,7 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf) 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"); @@ -455,7 +455,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) 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) @@ -489,7 +489,7 @@ bool pkgCdrom::WriteSourceList(string Name,vector &List,bool Source) // 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) @@ -661,13 +661,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; } @@ -688,7 +688,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ 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); @@ -712,7 +712,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ { // Escape special characters string::iterator J = Name.begin(); - for (; J != Name.end(); J++) + for (; J != Name.end(); ++J) if (*J == '"' || *J == ']' || *J == '[') *J = '_'; @@ -757,7 +757,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ // Escape special characters string::iterator J = Name.begin(); - for (; J != Name.end(); J++) + for (; J != Name.end(); ++J) if (*J == '"' || *J == ']' || *J == '[') *J = '_'; @@ -804,7 +804,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ 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) @@ -823,7 +823,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log) /*{{{*/ } } - 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) diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 629afd7cf..9850b93b4 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -85,12 +85,12 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache) 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 --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 942ea9fbc..ece05e8f6 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -672,9 +672,9 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool const &AsSectio // 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 += ' '; @@ -850,7 +850,7 @@ bool ReadConfigDir(Configuration &Conf,const string &Dir, 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 --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index 18810d2a4..edb290f34 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -193,7 +193,7 @@ bool GlobalError::PopMessage(std::string &Text) { // 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; @@ -210,7 +210,7 @@ void GlobalError::DumpErrors(std::ostream &out, MsgType const &threshold, 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(); @@ -231,7 +231,7 @@ bool GlobalError::empty(MsgType const &trashhold) 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 --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index ab2da2d9a..867bb313b 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -271,7 +271,7 @@ bool ParseCWord(const char *&String,string &Res) 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 @@ string DeQuoteString(string::const_iterator const &begin, 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 @@ string LookupTag(const string &Message,const char *Tag,const char *Default) { // 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 @@ string LookupTag(const string &Message,const char *Tag,const char *Default) // 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 @@ -1224,7 +1224,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; @@ -1248,7 +1248,7 @@ 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++) + for (it = input.begin(); it != input.end(); ++it) { // just copy non-escape chars if (*it != '\\') @@ -1264,7 +1264,7 @@ string DeEscapeString(const string &input) // copy output += *it; // advance iterator one step further - it += 1; + ++it; continue; } @@ -1273,7 +1273,7 @@ string DeEscapeString(const string &input) continue; // read it - it++; + ++it; switch (*it) { case '0': @@ -1310,7 +1310,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 // @@ -1322,7 +1322,7 @@ void URI::CopyFrom(const string &U) /* 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; @@ -1355,11 +1355,11 @@ void URI::CopyFrom(const string &U) 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 --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index c9e7f1176..e3d4063dc 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -352,7 +352,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const { 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; @@ -540,7 +540,7 @@ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) con string FileName = IndexFile(Language); pkgCache::PkgFileIterator File = Cache.FileBegin(); - for (; File.end() == false; File++) + for (; File.end() == false; ++File) { if (FileName != File.FileName()) continue; @@ -620,7 +620,7 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const 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 --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 73628c741..8d3f6f0ba 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -203,7 +203,7 @@ string debListParser::DescriptionLanguage() 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; diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index a91cc34e9..f6c50742e 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -206,7 +206,7 @@ vector * debReleaseIndex::ComputeIndexTargets() const { 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; @@ -236,7 +236,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const // 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()); } @@ -279,7 +279,7 @@ vector *debReleaseIndex::GetIndexFiles() { 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())); } @@ -294,7 +294,7 @@ vector *debReleaseIndex::GetIndexFiles() { 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()); } @@ -303,7 +303,7 @@ vector *debReleaseIndex::GetIndexFiles() { 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())); } @@ -351,7 +351,7 @@ class debSLTypeDebian : public pkgSourceList::Type APT::Configuration::getArchitectures(); 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 --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index ec9e395ef..7f596ab0d 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -118,7 +118,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 --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 5fbd1801a..46f48777c 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -213,7 +213,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; @@ -335,7 +335,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) // 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) @@ -690,7 +690,7 @@ bool pkgDPkgPM::OpenLog() chmod(history_name.c_str(), 0644); fprintf(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; @@ -868,14 +868,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++; @@ -893,7 +893,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // 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; @@ -905,7 +905,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) 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 @@ -1011,7 +1011,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) // 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()); @@ -1023,7 +1023,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) { 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; @@ -1461,7 +1461,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) // 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 --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index eb3f4e598..580056687 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -129,7 +129,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); @@ -292,7 +292,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/ // 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()) { @@ -365,7 +365,7 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res) // 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. */ @@ -585,7 +585,7 @@ void pkgDepCache::BuildGroupOrs(VerIterator const &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]; @@ -625,7 +625,7 @@ unsigned char pkgDepCache::VersionState(DepIterator D,unsigned char Check, // 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; @@ -715,15 +715,15 @@ void pkgDepCache::Update(OpProgress *Prog) // 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]; @@ -760,7 +760,7 @@ void pkgDepCache::Update(OpProgress *Prog) 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); @@ -793,13 +793,13 @@ void pkgDepCache::Update(PkgIterator const &Pkg) // 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()); } /*}}}*/ @@ -1059,7 +1059,7 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, 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; @@ -1522,12 +1522,12 @@ pkgCache::VerIterator pkgDepCache::Policy::GetCandidateVer(PkgIterator const &Pk 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; diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 31c577705..b262e21c4 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -43,7 +43,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, pkgCdromStatus *log) { OpProgress *Progress = NULL; - if (List.size() == 0) + if (List.empty() == true) return true; if(log) @@ -54,7 +54,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, // Prepare the progress indicator unsigned long 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 && @@ -68,7 +68,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, 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; @@ -583,13 +583,13 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/ 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; @@ -633,7 +633,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector &SigList, // 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 @@ -776,7 +776,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ vector &List, pkgCdromStatus *log) { OpProgress *Progress = NULL; - if (List.size() == 0) + if (List.empty() == true) return true; if(log) @@ -786,7 +786,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ // Prepare the progress indicator unsigned long 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 && @@ -800,7 +800,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ 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; diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 19661fc2d..6034138cf 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -323,7 +323,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; @@ -488,7 +488,7 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver) 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; } @@ -615,7 +615,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg) Loops are preprocessed and logged. */ bool pkgOrderList::DepUnPackCrit(DepIterator D) { - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { if (D.Reverse() == true) { @@ -693,7 +693,7 @@ bool pkgOrderList::DepUnPackPreD(DepIterator D) if (D.Reverse() == true) return DepUnPackCrit(D); - for (; D.end() == false; D++) + for (; D.end() == false; ++D) { if (D.IsCritical() == false) continue; @@ -736,7 +736,7 @@ bool pkgOrderList::DepUnPackPre(DepIterator D) 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 @@ -791,7 +791,7 @@ bool pkgOrderList::DepUnPackPre(DepIterator D) bool pkgOrderList::DepUnPackDep(DepIterator D) { - for (; D.end() == false; D++) + for (; D.end() == false; ++D) if (D.IsCritical() == true) { if (D.Reverse() == true) @@ -846,7 +846,7 @@ bool pkgOrderList::DepConfigure(DepIterator D) 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; @@ -868,7 +868,7 @@ bool pkgOrderList::DepRemove(DepIterator D) { 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 --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index fe9f6eb68..999a7b0a0 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -99,7 +99,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; @@ -140,7 +140,7 @@ void pkgPackageManager::ImmediateAdd(PkgIterator I, bool UseInstallVer, unsigned 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)) @@ -169,7 +169,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) @@ -229,7 +229,7 @@ bool pkgPackageManager::DepAlwaysTrue(DepIterator 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) @@ -364,13 +364,13 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) { 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; @@ -378,7 +378,7 @@ bool pkgPackageManager::DepAdd(pkgOrderList &OList,PkgIterator Pkg,int Depth) 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(); @@ -444,7 +444,7 @@ bool pkgPackageManager::EarlyRemove(PkgIterator 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; @@ -564,7 +564,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) return _error->Error("Couldn't configure pre-depend %s for %s, " "probably a dependency cycle.", End.TargetPkg().Name(),Pkg.Name()); - Start++; + ++Start; } else break; @@ -597,7 +597,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) 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); diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 38e4e904e..ed24d9ea8 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -175,7 +175,7 @@ bool pkgCache::ReMap(bool const &Errorchecks) 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); } @@ -183,7 +183,7 @@ unsigned long pkgCache::sHash(const string &Str) const 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); } @@ -569,7 +569,7 @@ bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result) const 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) @@ -577,7 +577,7 @@ bool pkgCache::DepIterator::SmartTargetPkg(PkgIterator &Result) const // 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()) @@ -611,7 +611,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const 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; @@ -626,7 +626,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const } // 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; @@ -717,7 +717,7 @@ int pkgCache::VerIterator::CompareVer(const VerIterator &B) const /* 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; @@ -729,7 +729,7 @@ int pkgCache::VerIterator::CompareVer(const VerIterator &B) const 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; @@ -742,7 +742,7 @@ bool pkgCache::VerIterator::Downloadable() const 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; @@ -760,7 +760,7 @@ pkgCache::VerFileIterator pkgCache::VerIterator::NewestFile() const { 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; @@ -777,7 +777,7 @@ string pkgCache::VerIterator::RelStr() const { 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(); @@ -786,7 +786,7 @@ string pkgCache::VerIterator::RelStr() const // 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) @@ -887,7 +887,7 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const { 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 --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 2bfb77609..8a7c1e979 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -220,7 +220,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, // 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; @@ -229,7 +229,7 @@ bool pkgCacheGenerator::MergeList(ListParser &List, for (Desc = Ver.DescriptionList(); Desc.end() == false; - LastDesc = &Desc->NextDesc, Desc++) + LastDesc = &Desc->NextDesc, ++Desc) { if (MD5SumValue(Desc.md5()) == CurMd5) { @@ -395,7 +395,7 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) 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()) { @@ -511,7 +511,7 @@ bool pkgCacheGenerator::NewFileVer(pkgCache::VerIterator &Ver, // 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(); @@ -568,7 +568,7 @@ bool pkgCacheGenerator::NewFileDesc(pkgCache::DescIterator &Desc, // 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; @@ -623,7 +623,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress) // 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(); @@ -634,7 +634,7 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress) Dynamic DynallPkg(allPkg); pkgCache::VerIterator V = P.VersionList(); Dynamic DynV(V); - for (; V.end() != true; V++) + for (; V.end() != true; ++V) { // copy P.Arch() into a string here as a cache remap // in NewDepends() later may alter the pointer location @@ -728,7 +728,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg, 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; @@ -958,7 +958,7 @@ static bool CheckValidity(const string &CacheFile, 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() << ": "; @@ -1025,7 +1025,7 @@ static bool CheckValidity(const string &CacheFile, 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; @@ -1043,7 +1043,7 @@ static bool BuildCache(pkgCacheGenerator &Gen, FileIterator Start, FileIterator End) { FileIterator I; - for (I = Start; I != End; I++) + for (I = Start; I != End; ++I) { if ((*I)->HasPackages() == false) continue; @@ -1073,7 +1073,7 @@ static bool BuildCache(pkgCacheGenerator &Gen, 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) @@ -1120,12 +1120,12 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress 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); } diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index e506de73a..1a7585d8f 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -24,7 +24,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(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 --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index c5028d822..6a5130d48 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -81,7 +81,7 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner) 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) @@ -98,10 +98,10 @@ bool pkgPolicy::InitDefaults() 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) { @@ -122,7 +122,7 @@ bool pkgPolicy::InitDefaults() } 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; @@ -162,12 +162,12 @@ pkgCache::VerIterator pkgPolicy::GetCandidateVer(pkgCache::PkgIterator const &Pk 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) @@ -356,7 +356,7 @@ bool ReadPinDir(pkgPolicy &Plcy,string Dir) 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 --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index c96ccfd77..a25358bf2 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -173,7 +173,7 @@ pkgSourceList::pkgSourceList(string File) /* */ pkgSourceList::~pkgSourceList() { - for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I) delete *I; } /*}}}*/ @@ -218,7 +218,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()); } @@ -296,11 +296,11 @@ bool pkgSourceList::ReadAppend(string File) 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) { @@ -318,7 +318,7 @@ bool pkgSourceList::FindIndex(pkgCache::PkgFileIterator File, /* */ 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; @@ -334,7 +334,7 @@ bool pkgSourceList::ReadSourceDir(string Dir) 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; @@ -353,7 +353,7 @@ time_t pkgSourceList::GetLastModifiedTime() // calculate the time time_t mtime_sources = GetModificationTime(Main); - for (vector::const_iterator I = List.begin(); I != List.end(); I++) + for (vector::const_iterator I = List.begin(); I != List.end(); ++I) mtime_sources = std::max(mtime_sources, GetModificationTime(*I)); return mtime_sources; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 46a02b55c..946ac1a1a 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -24,11 +24,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) @@ -66,7 +66,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; @@ -89,7 +89,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn { if (_error->PendingError() == true) return 0; - Current++; + ++Current; if (Current == Files.end()) return 0; } @@ -107,7 +107,7 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn // 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 --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 48ac12cee..4cc500727 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -11,7 +11,7 @@ pkgVendorList::~pkgVendorList() { for (vector::const_iterator I = VendorList.begin(); - I != VendorList.end(); I++) + I != VendorList.end(); ++I) delete *I; } @@ -49,7 +49,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()); @@ -129,7 +129,7 @@ const Vendor* pkgVendorList::LookupFingerprint(string Fingerprint) /*{{{*/ /*}}}*/ 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 --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index c40b1fdbc..6d667acad 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -60,7 +60,7 @@ pkgVersionMatch::pkgVersionMatch(string Data,MatchType Type) : Type(Type) // 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 @@ bool pkgVersionMatch::MatchVer(const char *A,string B,bool Prefix) 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 @@ pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg) 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; } -- cgit v1.2.3 From 91c03d370d36b7a802b841394fb6afdccbd34893 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 23:01:15 +0200 Subject: fix a few more cppcheck performance and scope warnings --- apt-pkg/contrib/netrc.cc | 7 ++++--- apt-pkg/indexcopy.cc | 3 +-- apt-pkg/orderlist.cc | 10 +++++----- apt-pkg/packagemanager.cc | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 34f472ee1..9ff5796c5 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -47,10 +47,7 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) 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 */ @@ -81,6 +78,10 @@ int parsenetrc (char *host, char *login, char *password, char *netrcfile = NULL) 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 --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index b262e21c4..747e464be 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -885,7 +885,6 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ this->Section = &Section; string Prefix; unsigned long Hits = 0; - unsigned long Chop = 0; while (Parser.Step(Section) == true) { if(Progress) @@ -903,7 +902,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ 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 --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 6034138cf..a58efa987 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -145,13 +145,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; @@ -197,7 +197,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) @@ -222,7 +222,7 @@ bool pkgOrderList::OrderUnpack(string *FileList) 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) @@ -270,7 +270,7 @@ bool pkgOrderList::OrderUnpack(string *FileList) { 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) diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 999a7b0a0..060cd3248 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -63,7 +63,7 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources, 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(); @@ -262,7 +262,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); @@ -274,7 +274,7 @@ bool pkgPackageManager::ConfigureAll() 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); @@ -309,7 +309,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) 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); @@ -652,7 +652,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() 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); @@ -701,7 +701,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() 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) { -- cgit v1.2.3 From 1842a17db2ecebaf7b19de574cb4cd87c687202c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2011 23:06:46 +0200 Subject: rename the parameter name of MarkDelete from Purge to MarkPurge to fix a cosmetic warning from cppcheck: [apt-pkg/depcache.h:462] -> [apt-pkg/depcache.h:122]: (style) Variable 'Purge' hides enumerator with same name --- apt-pkg/depcache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 9efe110f5..760f0b589 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -390,7 +390,7 @@ class pkgDepCache : protected pkgCache::Namespace // @{ void MarkKeep(PkgIterator const &Pkg, bool Soft = false, bool FromUser = true, unsigned long Depth = 0); - void MarkDelete(PkgIterator const &Pkg, bool Purge = false, + void MarkDelete(PkgIterator const &Pkg, bool MarkPurge = false, unsigned long Depth = 0, bool FromUser = true); void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, unsigned long Depth = 0, bool FromUser = true, @@ -459,7 +459,7 @@ class pkgDepCache : protected pkgCache::Namespace * \param Depth recursive deep of this Marker call * \param FromUser was the remove requested by the user? */ - virtual bool IsDeleteOk(const PkgIterator &Pkg,bool Purge = false, + virtual bool IsDeleteOk(const PkgIterator &Pkg,bool MarkPurge = false, unsigned long Depth = 0, bool FromUser = true); // read persistent states -- cgit v1.2.3 From e844b947ab5c988fb6d6f8e5ebfa4e0eda856541 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 12 Aug 2011 10:38:19 +0100 Subject: Small fix for loop handeling. --- apt-pkg/packagemanager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 722cbfa86..2fe98b101 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -388,7 +388,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) if (Debug) cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; SmartUnPack(DepPkg, true); - //List->Flag(Pkg,~pkgOrderList::Loop); + List->RmFlag(Pkg,pkgOrderList::Loop); } } -- cgit v1.2.3 From 987d8d0315a315c74827ee2160671a30f5bc4e14 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 12 Aug 2011 12:22:17 +0100 Subject: Inproved debug with versioning --- apt-pkg/packagemanager.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 2fe98b101..8fc571f2f 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -320,9 +320,11 @@ bool pkgPackageManager::ConfigureAll() only shown when debuging*/ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { - if (Debug) - clog << "SmartConfigure " << Pkg.Name() << endl; - + if (Debug) { + VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); + clog << "SmartConfigure " << Pkg.Name() << InstallVer.VerStr() << endl; + } + VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* Because of the ordered list, most dependancies should be unpacked, @@ -513,8 +515,14 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) } bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) { - if (Debug) - clog << "SmartUnPack " << Pkg.Name() << endl; + if (Debug) { + clog << "SmartUnPack " << Pkg.Name(); + VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); + if (Pkg.CurrentVer() == 0) + cout << "(install version " << InstallVer.VerStr() << ")" << endl; + else + cout << "(replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")" << endl; + } // Check if it is already unpacked if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && -- cgit v1.2.3 From a99d02a86c5c25c4a36f06aa44c01709de8219c4 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 12 Aug 2011 16:36:25 +0100 Subject: Added code to allow SmartConfigure to be called mutiple times on the same package to ensure all dependancies are satisfied. --- apt-pkg/packagemanager.cc | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 8fc571f2f..7a0f11d85 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -324,7 +324,10 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); clog << "SmartConfigure " << Pkg.Name() << InstallVer.VerStr() << endl; } - + + // If this is true, only check and correct and dependancies without the Loop flag + bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop); + VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* Because of the ordered list, most dependancies should be unpacked, @@ -365,16 +368,19 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) // Check if the version that is going to be installed will satisfy the dependancy if (Cache[DepPkg].InstallVer == *I) { if (List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { + if (PkgLoop && List->IsFlag(DepPkg,pkgOrderList::Loop)) { + // This dependancy has already been dealt with by another SmartConfigure on Pkg + Bad = false; + break; + } /* Check for a loop to prevent one forming If A depends on B and B depends on A, SmartConfigure will just hop between them if this is not checked */ - if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { - List->Flag(Pkg,pkgOrderList::Loop); - // If SmartConfigure was succesfull, Bad is false, so break - Bad = !SmartConfigure(DepPkg); - List->RmFlag(Pkg,pkgOrderList::Loop); - if (!Bad) break; - } + List->Flag(Pkg,pkgOrderList::Loop); + // If SmartConfigure was succesfull, Bad is false, so break + Bad = !SmartConfigure(DepPkg); + List->RmFlag(Pkg,pkgOrderList::Loop); + if (!Bad) break; } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) { Bad = false; break; @@ -389,7 +395,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) List->Flag(Pkg,pkgOrderList::Loop); if (Debug) cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - SmartUnPack(DepPkg, true); + SmartUnPack(DepPkg, false); List->RmFlag(Pkg,pkgOrderList::Loop); } } @@ -412,6 +418,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) _error->Warning(_("Could not configure '%s'. "),Pkg.Name()); return false; } + + if (PkgLoop) return true; static std::string const conf = _config->Find("PackageManager::Configure","all"); static bool const ConfigurePkgs = (conf == "all" || conf == "smart"); -- cgit v1.2.3 From 165ff1df10fd5960b5f31ce4e3eaa8d41a8e7b67 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 13 Aug 2011 17:29:49 +0100 Subject: Fix a bug introduced in Rev.2159 on line 398, also fix another potential bug. --- apt-pkg/packagemanager.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 7a0f11d85..ee4798911 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -322,7 +322,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) { if (Debug) { VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); - clog << "SmartConfigure " << Pkg.Name() << InstallVer.VerStr() << endl; + clog << "SmartConfigure " << Pkg.Name() << " " << InstallVer.VerStr() << endl; } // If this is true, only check and correct and dependancies without the Loop flag @@ -391,11 +391,11 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) /* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */ if (InstallVer != 0 && Bad) { Bad = false; - if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { + if (List->IsNow(DepPkg) && !List->IsFlag(DepPkg,pkgOrderList::Loop)) { List->Flag(Pkg,pkgOrderList::Loop); if (Debug) cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - SmartUnPack(DepPkg, false); + SmartUnPack(DepPkg, true); List->RmFlag(Pkg,pkgOrderList::Loop); } } @@ -527,9 +527,9 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) clog << "SmartUnPack " << Pkg.Name(); VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); if (Pkg.CurrentVer() == 0) - cout << "(install version " << InstallVer.VerStr() << ")" << endl; + cout << " (install version " << InstallVer.VerStr() << ")" << endl; else - cout << "(replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")" << endl; + cout << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")" << endl; } // Check if it is already unpacked -- cgit v1.2.3 From 940f21606bc8d82366d554a9cfa025511a2b2bc4 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 14 Aug 2011 18:41:38 +0100 Subject: Applied DonKult (David)'s excellent fix for inproving the loop management. Now both SmartConfigure and SmartUnPack can be called mutiple times on the same package, this is to make sure that when loops are broken all packages that are required are kept in the same dpkg run. --- apt-pkg/packagemanager.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index ee4798911..4c827af6d 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -536,14 +536,11 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && Cache[Pkg].Keep() == true) { - List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - if (Immediate == true && - List->IsFlag(Pkg,pkgOrderList::Immediate) == true) - if (SmartConfigure(Pkg) == false) - _error->Warning(_("Could not perform immediate configuration on already unpacked '%s'. " - "Please see man 5 apt.conf under APT::Immediate-Configure for details."),Pkg.Name()); - return true; + cout << "SmartUnPack called on Package " << Pkg.Name() << " but its unpacked" << endl; + return false; } + + bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop); VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); @@ -674,7 +671,11 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) // Check if it needs to be unpacked if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && - !List->IsFlag(BrokenPkg,pkgOrderList::Loop) && List->IsNow(BrokenPkg)) { + List->IsNow(BrokenPkg)) { + if (PkgLoop && List->IsFlag(BrokenPkg,pkgOrderList::Loop)) { + // This dependancy has already been dealt with by another SmartUnPack on Pkg + break; + } List->Flag(Pkg,pkgOrderList::Loop); // Found a break, so unpack the package if (Debug) @@ -702,6 +703,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) P.end() == false; P++) CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); + if (PkgLoop) return true; + List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); if (instVer->MultiArch == pkgCache::Version::Same) -- cgit v1.2.3 From d41d0e0113208aa1752344a13e8a962a1ad4f76e Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Mon, 15 Aug 2011 22:31:09 +0100 Subject: Fixed a bug where SmartUnPack would be called with Immediate=true (to resolve dependancies in SmartConfigure) yet Pkg would not be immediately configured. This was because SmartUnPack still required the immediate flag to be set on Pkg. Also inproved the debuging adding indented output for SmartUnPack and SmartConfigure and specifying in the output if SmartConfigure or SmartUnPack was called just to Correct something (PkgLoop = true) or not. --- apt-pkg/packagemanager.cc | 75 +++++++++++++++++++++++++---------------------- apt-pkg/packagemanager.h | 4 +-- 2 files changed, 42 insertions(+), 37 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 4c827af6d..53bb507b6 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -291,7 +291,7 @@ bool pkgPackageManager::ConfigureAll() calls its self */ if (List->IsFlag(Pkg,pkgOrderList::Configured)) continue; - if (ConfigurePkgs == true && SmartConfigure(Pkg) == false) { + if (ConfigurePkgs == true && SmartConfigure(Pkg, 0) == false) { if (ImmConfigureAll) _error->Error(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),1); @@ -318,16 +318,19 @@ bool pkgPackageManager::ConfigureAll() a error will only be reported if ConfigureAll fails. This is why some of the messages this function reports on failure (return false;) as just warnings only shown when debuging*/ -bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) +bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth) { + // If this is true, only check and correct and dependancies without the Loop flag + bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop); + if (Debug) { VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); - clog << "SmartConfigure " << Pkg.Name() << " " << InstallVer.VerStr() << endl; + clog << OutputInDepth(Depth) << "SmartConfigure " << Pkg.Name() << " (" << InstallVer.VerStr() << ")"; + if (PkgLoop) + clog << " (Only Correct Dependancies)"; + clog << endl; } - // If this is true, only check and correct and dependancies without the Loop flag - bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop); - VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* Because of the ordered list, most dependancies should be unpacked, @@ -378,7 +381,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) just hop between them if this is not checked */ List->Flag(Pkg,pkgOrderList::Loop); // If SmartConfigure was succesfull, Bad is false, so break - Bad = !SmartConfigure(DepPkg); + Bad = !SmartConfigure(DepPkg, Depth + 1); List->RmFlag(Pkg,pkgOrderList::Loop); if (!Bad) break; } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) { @@ -394,8 +397,8 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) if (List->IsNow(DepPkg) && !List->IsFlag(DepPkg,pkgOrderList::Loop)) { List->Flag(Pkg,pkgOrderList::Loop); if (Debug) - cout << " Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - SmartUnPack(DepPkg, true); + cout << OutputInDepth(Depth) << "Unpacking " << DepPkg.Name() << " to avoid loop" << endl; + SmartUnPack(DepPkg, true, Depth + 1); List->RmFlag(Pkg,pkgOrderList::Loop); } } @@ -440,7 +443,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg) Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) continue; - SmartConfigure(P); + SmartConfigure(P, (Depth +1)); } // Sanity Check @@ -519,29 +522,32 @@ bool pkgPackageManager::SmartRemove(PkgIterator Pkg) unpacked, or when it has been unpacked, if Immediate==true it configures it. */ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) { - return SmartUnPack(Pkg, true); + return SmartUnPack(Pkg, true, 0); } -bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) +bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth) { + bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop); + if (Debug) { - clog << "SmartUnPack " << Pkg.Name(); + clog << OutputInDepth(Depth) << "SmartUnPack " << Pkg.Name(); VerIterator InstallVer = VerIterator(Cache,Cache[Pkg].InstallVer); if (Pkg.CurrentVer() == 0) - cout << " (install version " << InstallVer.VerStr() << ")" << endl; + cout << " (install version " << InstallVer.VerStr() << ")"; else - cout << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")" << endl; + cout << " (replace version " << Pkg.CurrentVer().VerStr() << " with " << InstallVer.VerStr() << ")"; + if (PkgLoop) + cout << " (Only Perform PreUnpack Checks)"; + cout << endl; } // Check if it is already unpacked if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && Cache[Pkg].Keep() == true) { - cout << "SmartUnPack called on Package " << Pkg.Name() << " but its unpacked" << endl; + cout << OutputInDepth(Depth) << "SmartUnPack called on Package " << Pkg.Name() << " but its unpacked" << endl; return false; } - bool PkgLoop = List->IsFlag(Pkg,pkgOrderList::Loop); - VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* PreUnpack Checks: This loop checks and attempts to rectify and problems that would prevent the package being unpacked. @@ -561,7 +567,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) while (End->Type == pkgCache::Dep::PreDepends) { if (Debug) - clog << "PreDepends order for " << Pkg.Name() << std::endl; + clog << OutputInDepth(Depth) << "PreDepends order for " << Pkg.Name() << std::endl; // Look for possible ok targets. SPtrArray VList = Start.AllTargets(); @@ -577,7 +583,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) { Bad = false; if (Debug) - clog << "Found ok package " << Pkg.Name() << endl; + clog << OutputInDepth(Depth) << "Found ok package " << Pkg.Name() << endl; continue; } } @@ -599,8 +605,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } if (Debug) - clog << "Trying to SmartConfigure " << Pkg.Name() << endl; - Bad = !SmartConfigure(Pkg); + clog << OutputInDepth(Depth) << "Trying to SmartConfigure " << Pkg.Name() << endl; + Bad = !SmartConfigure(Pkg, Depth + 1); } /* If this or element did not match then continue on to the @@ -633,15 +639,15 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) // See if the current version is conflicting if (ConflictPkg.CurrentVer() == Ver && List->IsNow(ConflictPkg)) { - cout << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; + cout << OutputInDepth(Depth) << Pkg.Name() << " conflicts with " << ConflictPkg.Name() << endl; /* If a loop is not present or has not yet been detected, attempt to unpack packages to resolve this conflict. If there is a loop present, remove packages to resolve this conflict */ if (!List->IsFlag(ConflictPkg,pkgOrderList::Loop)) { if (Cache[ConflictPkg].Keep() == 0 && Cache[ConflictPkg].InstallVer != 0) { if (Debug) - cout << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; + cout << OutputInDepth(Depth) << OutputInDepth(Depth) << "Unpacking " << ConflictPkg.Name() << " to prevent conflict" << endl; List->Flag(Pkg,pkgOrderList::Loop); - SmartUnPack(ConflictPkg,false); + SmartUnPack(ConflictPkg,false, Depth + 1); // Remove loop to allow it to be used later if needed List->RmFlag(Pkg,pkgOrderList::Loop); } else { @@ -651,7 +657,7 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) } else { if (!List->IsFlag(ConflictPkg,pkgOrderList::Removed)) { if (Debug) - cout << "Because of conficts knot, removing " << ConflictPkg.Name() << " to conflict violation" << endl; + cout << OutputInDepth(Depth) << "Because of conficts knot, removing " << ConflictPkg.Name() << " to conflict violation" << endl; if (EarlyRemove(ConflictPkg) == false) return _error->Error("Internal Error, Could not early remove %s",ConflictPkg.Name()); } @@ -679,15 +685,15 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) List->Flag(Pkg,pkgOrderList::Loop); // Found a break, so unpack the package if (Debug) - cout << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; + cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; - SmartUnPack(BrokenPkg, false); + SmartUnPack(BrokenPkg, false, Depth + 1); List->RmFlag(Pkg,pkgOrderList::Loop); } // Check if a package needs to be removed if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) { if (Debug) - cout << " Removing " << BrokenPkg.Name() << " to avoid break" << endl; + cout << OutputInDepth(Depth) << " Removing " << BrokenPkg.Name() << " to avoid break" << endl; SmartRemove(BrokenPkg); } } @@ -715,16 +721,15 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) continue; - SmartUnPack(P, false); + SmartUnPack(P, false, Depth + 1); } if(Install(Pkg,FileNames[Pkg->ID]) == false) return false; - if (Immediate == true && List->IsFlag(Pkg,pkgOrderList::Immediate) == true) { - + if (Immediate == true) { // Perform immedate configuration of the package. - if (SmartConfigure(Pkg) == false) + if (SmartConfigure(Pkg, Depth + 1) == false) _error->Warning(_("Could not perform immediate configuration on '%s'. " "Please see man 5 apt.conf under APT::Immediate-Configure for details. (%d)"),Pkg.Name(),2); } @@ -765,7 +770,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() if (List->IsNow(Pkg) == false) { if (!List->IsFlag(Pkg,pkgOrderList::Configured) && !NoImmConfigure) { - if (SmartConfigure(Pkg) == false && Debug) + if (SmartConfigure(Pkg, 0) == false && Debug) _error->Warning("Internal Error, Could not configure %s",Pkg.Name()); // FIXME: The above warning message might need changing } else { @@ -804,7 +809,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() return Failed; } else - if (SmartUnPack(Pkg) == false) + if (SmartUnPack(Pkg,List->IsFlag(Pkg,pkgOrderList::Immediate),0) == false) return Failed; DoneSomething = true; diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index e1878ce46..96dc5f236 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -70,10 +70,10 @@ class pkgPackageManager : protected pkgCache::Namespace // Install helpers bool ConfigureAll(); - bool SmartConfigure(PkgIterator Pkg); + bool SmartConfigure(PkgIterator Pkg, int const Depth); //FIXME: merge on abi break bool SmartUnPack(PkgIterator Pkg); - bool SmartUnPack(PkgIterator Pkg, bool const Immediate); + bool SmartUnPack(PkgIterator Pkg, bool const Immediate, int const Depth); bool SmartRemove(PkgIterator Pkg); bool EarlyRemove(PkgIterator Pkg); -- cgit v1.2.3 From b57257d2993aaf8c0cf9d6f0ea8ebd0208112bc5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 16 Aug 2011 18:00:01 +0100 Subject: Fixed a problem where the loop flag would be removed prematurely. SmartConfigure xserver-xorg-video-apm (1:1.2.3-0ubuntu1) SmartConfigure xserver-xorg-core (2:1.9.0-0ubuntu7.3) <- Loop flag set on xserver-xorg-core SmartConfigure xserver-xorg (1:7.5+6ubuntu3) SmartConfigure xserver-xorg-core (2:1.9.0-0ubuntu7.3) (Only Correct Dependancies) <- Loop flag removed prematurely SmartConfigure libpciaccess0 (0.12.0-1) SmartConfigure libpixman-1-0 (0.18.4-1) SmartConfigure xserver-xorg-video-all (1:7.5+6ubuntu3) SmartConfigure xserver-xorg-video-apm (1:1.2.3-0ubuntu1) (Only Correct Dependancies) SmartConfigure xserver-xorg-core (2:1.9.0-0ubuntu7.3) <- Incorrectly detects first run as no loop flag Also applied this fix to the SmartUnpack method. --- apt-pkg/packagemanager.cc | 49 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 53bb507b6..b5d353602 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -371,18 +371,27 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth) // Check if the version that is going to be installed will satisfy the dependancy if (Cache[DepPkg].InstallVer == *I) { if (List->IsFlag(DepPkg,pkgOrderList::UnPacked)) { - if (PkgLoop && List->IsFlag(DepPkg,pkgOrderList::Loop)) { + if (List->IsFlag(DepPkg,pkgOrderList::Loop) && PkgLoop) { // This dependancy has already been dealt with by another SmartConfigure on Pkg Bad = false; break; + } else if (List->IsFlag(Pkg,pkgOrderList::Loop)) { + /* Check for a loop to prevent one forming + If A depends on B and B depends on A, SmartConfigure will + just hop between them if this is not checked. Dont remove the + loop flag after finishing however as loop is already set. + This means that there is another SmartConfigure call for this + package and it will remove the loop flag */ + Bad = !SmartConfigure(DepPkg, Depth + 1); + } else { + /* Check for a loop to prevent one forming + If A depends on B and B depends on A, SmartConfigure will + just hop between them if this is not checked */ + List->Flag(Pkg,pkgOrderList::Loop); + Bad = !SmartConfigure(DepPkg, Depth + 1); + List->RmFlag(Pkg,pkgOrderList::Loop); } - /* Check for a loop to prevent one forming - If A depends on B and B depends on A, SmartConfigure will - just hop between them if this is not checked */ - List->Flag(Pkg,pkgOrderList::Loop); // If SmartConfigure was succesfull, Bad is false, so break - Bad = !SmartConfigure(DepPkg, Depth + 1); - List->RmFlag(Pkg,pkgOrderList::Loop); if (!Bad) break; } else if (List->IsFlag(DepPkg,pkgOrderList::Configured)) { Bad = false; @@ -678,18 +687,28 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c // Check if it needs to be unpacked if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && List->IsNow(BrokenPkg)) { - if (PkgLoop && List->IsFlag(BrokenPkg,pkgOrderList::Loop)) { + if (List->IsFlag(BrokenPkg,pkgOrderList::Loop) && PkgLoop) { // This dependancy has already been dealt with by another SmartUnPack on Pkg break; - } - List->Flag(Pkg,pkgOrderList::Loop); - // Found a break, so unpack the package - if (Debug) - cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; + } else if (List->IsFlag(Pkg,pkgOrderList::Loop)) { + /* Found a break, so unpack the package, but dont remove loop as already set. + This means that there is another SmartUnPack call for this + package and it will remove the loop flag. */ + if (Debug) + cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; + + SmartUnPack(BrokenPkg, false, Depth + 1); + } else { + List->Flag(Pkg,pkgOrderList::Loop); + // Found a break, so unpack the package + if (Debug) + cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; - SmartUnPack(BrokenPkg, false, Depth + 1); - List->RmFlag(Pkg,pkgOrderList::Loop); + SmartUnPack(BrokenPkg, false, Depth + 1); + List->RmFlag(Pkg,pkgOrderList::Loop); + } } + // Check if a package needs to be removed if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) { if (Debug) -- cgit v1.2.3 From 32d9baeab02d2399eb8bd2dfa53bb4f679eebd88 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 17 Aug 2011 11:13:50 +0200 Subject: * apt-pkg/packagemanager.cc, apt-pkg/pkgcache.cc: - ignore "self"-conflicts for all architectures of a package instead of just for the architecture of the package locked at in the ordering of installations too (Closes: #802901) --- apt-pkg/packagemanager.cc | 3 ++- apt-pkg/pkgcache.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 060cd3248..6601d9f6b 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -598,7 +598,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) for (PrvIterator P = instVer.ProvidesList(); P.end() == false; ++P) - CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); + if (Pkg->Group != P.OwnerPkg()->Group) + CheckRConflicts(Pkg,P.ParentPkg().RevDependsList(),P.ProvideVersion()); List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index ed24d9ea8..6db025bd0 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -632,7 +632,7 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const continue; if (IsNegative() == true && - ParentPkg() == I.OwnerPkg()) + ParentPkg()->Group == I.OwnerPkg()->Group) continue; Size++; -- cgit v1.2.3 From 1207cf3f9bd77664d6b7de9b8a7fdd33c0bed23a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 22:52:25 +0200 Subject: * apt-pkg/acquire-item.cc: - if no Release.gpg file is found try to verify with hashes, but do not fail if a hash can't be found --- apt-pkg/acquire-item.cc | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 566f51606..39ce90dda 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1258,9 +1258,9 @@ void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{* if (SigFile == "") { // There was no signature file, so we are finished. Download - // the indexes and do only hashsum verification + // the indexes and do only hashsum verification if possible MetaIndexParser->Load(DestFile); - QueueIndexes(true); + QueueIndexes(false); } else { @@ -1378,33 +1378,30 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ ++Target) { HashString ExpectedIndexHash; - if (verify) + const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey); + if (Record == NULL) { - const indexRecords::checkSum *Record = MetaIndexParser->Lookup((*Target)->MetaKey); - if (Record == NULL) + if (verify == true && (*Target)->IsOptional() == false) { - if ((*Target)->IsOptional() == false) - { - Status = StatAuthError; - strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str()); - return; - } + Status = StatAuthError; + strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str()); + return; } - else + } + else + { + ExpectedIndexHash = Record->Hash; + if (_config->FindB("Debug::pkgAcquire::Auth", false)) { - ExpectedIndexHash = Record->Hash; - if (_config->FindB("Debug::pkgAcquire::Auth", false)) - { - 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) - { - Status = StatAuthError; - strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str()); - return; - } + std::cerr << "Queueing: " << (*Target)->URI << std::endl; + std::cerr << "Expected Hash: " << ExpectedIndexHash.toStr() << std::endl; + std::cerr << "For: " << Record->MetaKeyFilename << std::endl; + } + if (verify == true && ExpectedIndexHash.empty() == true && (*Target)->IsOptional() == false) + { + Status = StatAuthError; + strprintf(ErrorText, _("Unable to find hash sum for '%s' in Release file"), (*Target)->MetaKey.c_str()); + return; } } -- cgit v1.2.3 From 95b5f6c19d361745c4e11b214f0f07ad10c9b5b3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 23:08:16 +0200 Subject: * apt-pkg/acquire.cc: - non-existing directories are by definition clean --- apt-pkg/acquire.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index a2da196be..ef120d8e9 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -445,6 +445,10 @@ pkgAcquire::Worker *pkgAcquire::WorkerStep(Worker *I) if it is part of the download set. */ bool pkgAcquire::Clean(string Dir) { + // non-existing directories are by definition clean… + if (DirectoryExists(Dir) == false) + return true; + DIR *D = opendir(Dir.c_str()); if (D == 0) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); -- cgit v1.2.3 From 8de79b68a834a6cc7abb8976e96ed19374fc02a2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 22 Aug 2011 23:10:15 +0200 Subject: remove the caches in 'apt-get update', too, as they will be invalid in most cases anyway --- apt-pkg/cachefile.cc | 14 ++++++++++++++ apt-pkg/cachefile.h | 1 + 2 files changed, 15 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 964c5bd8b..a76cfc08e 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -163,6 +163,20 @@ bool pkgCacheFile::Open(OpProgress *Progress, bool WithLock) return true; } /*}}}*/ +// CacheFile::RemoveCaches - remove all cache files from disk /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void pkgCacheFile::RemoveCaches() +{ + std::string const pkgcache = _config->FindFile("Dir::cache::pkgcache"); + std::string const srcpkgcache = _config->FindFile("Dir::cache::srcpkgcache"); + + if (pkgcache.empty() == false && RealFileExists(pkgcache) == true) + unlink(pkgcache.c_str()); + if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) + unlink(srcpkgcache.c_str()); +} + /*}}}*/ // CacheFile::Close - close the cache files /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h index 09d3ec267..b4f41c6f4 100644 --- a/apt-pkg/cachefile.h +++ b/apt-pkg/cachefile.h @@ -57,6 +57,7 @@ class pkgCacheFile bool Open(OpProgress *Progress = NULL, bool WithLock = true); inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; + static void RemoveCaches(); void Close(); inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; }; -- cgit v1.2.3 From 3b8d17737d840f48a60f1d4d1af3c285047ad61e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 23 Aug 2011 20:17:19 +0200 Subject: print from their the visit came from --- apt-pkg/orderlist.cc | 22 +++++++++++----------- apt-pkg/orderlist.h | 4 +++- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index a58efa987..2fc0b6927 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -152,7 +152,7 @@ bool pkgOrderList::DoRun() iterator OldEnd = End; End = NList; for (iterator I = List; I != OldEnd; ++I) - if (VisitNode(PkgIterator(Cache,*I)) == false) + if (VisitNode(PkgIterator(Cache,*I), "DoRun") == false) { End = OldEnd; return false; @@ -519,7 +519,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical) if (Critical == false && IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(Pkg) == false) + if (VisitNode(Pkg, "Provides") == false) return false; } return true; @@ -530,7 +530,7 @@ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical) /* This is the core ordering routine. It calls the set dependency consideration functions which then potentialy call this again. Finite depth is achived through the colouring mechinism. */ -bool pkgOrderList::VisitNode(PkgIterator Pkg) +bool pkgOrderList::VisitNode(PkgIterator Pkg, char const* from) { // Looping or irrelevent. // This should probably trancend not installed packages @@ -541,7 +541,7 @@ bool pkgOrderList::VisitNode(PkgIterator Pkg) if (Debug == true) { for (int j = 0; j != Depth; j++) clog << ' '; - clog << "Visit " << Pkg.FullName() << endl; + clog << "Visit " << Pkg.FullName() << " from " << from << endl; } Depth++; @@ -636,7 +636,7 @@ bool pkgOrderList::DepUnPackCrit(DepIterator D) if (CheckDep(D) == true) continue; - if (VisitNode(D.ParentPkg()) == false) + if (VisitNode(D.ParentPkg(), "UnPackCrit") == false) return false; } else @@ -811,7 +811,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D) if (IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(D.ParentPkg()) == false) + if (VisitNode(D.ParentPkg(), "UnPackDep-Parent") == false) return false; } else @@ -825,7 +825,7 @@ bool pkgOrderList::DepUnPackDep(DepIterator D) if (CheckDep(D) == true) continue; - if (VisitNode(D.TargetPkg()) == false) + if (VisitNode(D.TargetPkg(), "UnPackDep-Target") == false) return false; } } @@ -924,7 +924,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsFlag(P, InList) == true && IsFlag(P, AddPending) == false && Cache[P].InstallVer != 0 && - VisitNode(P) == true) + VisitNode(P, "Remove-P") == true) { Flag(P, Immediate); tryFixDeps = false; @@ -960,7 +960,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsFlag(F.TargetPkg(), InList) == true && IsFlag(F.TargetPkg(), AddPending) == false && Cache[F.TargetPkg()].InstallVer != 0 && - VisitNode(F.TargetPkg()) == true) + VisitNode(F.TargetPkg(), "Remove-Target") == true) { Flag(F.TargetPkg(), Immediate); tryFixDeps = false; @@ -974,7 +974,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsFlag(Prv.OwnerPkg(), InList) == true && IsFlag(Prv.OwnerPkg(), AddPending) == false && Cache[Prv.OwnerPkg()].InstallVer != 0 && - VisitNode(Prv.OwnerPkg()) == true) + VisitNode(Prv.OwnerPkg(), "Remove-Owner") == true) { Flag(Prv.OwnerPkg(), Immediate); tryFixDeps = false; @@ -994,7 +994,7 @@ bool pkgOrderList::DepRemove(DepIterator D) if (IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(D.ParentPkg()) == false) + if (VisitNode(D.ParentPkg(), "Remove-Parent") == false) return false; } diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index bbceb3879..264f7ba03 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -18,6 +18,7 @@ #include +#include class pkgDepCache; class pkgOrderList : protected pkgCache::Namespace @@ -45,7 +46,8 @@ class pkgOrderList : protected pkgCache::Namespace bool Debug; // Main visit function - bool VisitNode(PkgIterator Pkg); + __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); }; + bool VisitNode(PkgIterator Pkg, char const* from); bool VisitDeps(DepFunc F,PkgIterator Pkg); bool VisitRDeps(DepFunc F,PkgIterator Pkg); bool VisitRProvides(DepFunc F,VerIterator Ver); -- cgit v1.2.3 From 05b64a6f78e3bf39142808a3dae41a2c4618f6b0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 24 Aug 2011 00:41:30 +0200 Subject: * apt-pkg/orderlist.cc: - prefer visiting packages marked for deletion in VisitProvides if we are operating on a negative dependency so that we can deal early with the fallout of this remove --- apt-pkg/orderlist.cc | 50 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 2fc0b6927..cae5b0a48 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -495,33 +495,69 @@ bool pkgOrderList::VisitRProvides(DepFunc F,VerIterator Ver) /*}}}*/ // OrderList::VisitProvides - Visit all of the providing packages /*{{{*/ // --------------------------------------------------------------------- -/* This routine calls visit on all providing packages. */ +/* This routine calls visit on all providing packages. + + If the dependency is negative it first visits packages which are + intended to be removed and after that all other packages. + It does so to avoid situations in which this package is used to + satisfy a (or-group/provides) dependency of another package which + could have been satisfied also by upgrading another package - + otherwise we have more broken packages dpkg needs to auto- + deconfigure and in very complicated situations it even decides + against it! */ bool pkgOrderList::VisitProvides(DepIterator D,bool Critical) -{ +{ SPtrArray List = D.AllTargets(); - for (Version **I = List; *I != 0; I++) + for (Version **I = List; *I != 0; ++I) { VerIterator Ver(Cache,*I); PkgIterator Pkg = Ver.ParentPkg(); + if (D.IsNegative() == true && Cache[Pkg].Delete() == false) + continue; + if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing) continue; - + if (D.IsNegative() == false && Cache[Pkg].InstallVer != *I) continue; - + if (D.IsNegative() == true && (Version *)Pkg.CurrentVer() != *I) continue; - + + // Skip over missing files + if (Critical == false && IsMissing(D.ParentPkg()) == true) + continue; + + if (VisitNode(Pkg, "Provides-1") == false) + return false; + } + if (D.IsNegative() == false) + return true; + for (Version **I = List; *I != 0; ++I) + { + VerIterator Ver(Cache,*I); + PkgIterator Pkg = Ver.ParentPkg(); + + if (Cache[Pkg].Delete() == true) + continue; + + if (Cache[Pkg].Keep() == true && Pkg.State() == PkgIterator::NeedsNothing) + continue; + + if ((Version *)Pkg.CurrentVer() != *I) + continue; + // Skip over missing files if (Critical == false && IsMissing(D.ParentPkg()) == true) continue; - if (VisitNode(Pkg, "Provides") == false) + if (VisitNode(Pkg, "Provides-2") == false) return false; } + return true; } /*}}}*/ -- cgit v1.2.3 From 884a4c0a3a6cba654e77478a086f26539bc5bd32 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Sep 2011 14:50:30 +0200 Subject: * apt-pkg/indexrecords.cc: - fix Acquire::Max-ValidTime option by interpreting it really as seconds as specified in the manpage and not as days --- apt-pkg/indexrecords.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 10e154ad2..7852b99f0 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -113,7 +113,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/ } // get the user settings for this archive and use what expires earlier int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0); - if (Label.empty() == true) + if (Label.empty() == false) MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); if(MaxAge == 0) // No user settings, use the one from the Release file @@ -125,7 +125,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/ strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str()); return false; } - date += 24*60*60*MaxAge; + date += MaxAge; if (ValidUntil == 0 || ValidUntil > date) ValidUntil = date; -- cgit v1.2.3 From 89500a25b30d53ea0f5ae213c4207e13f35d1d61 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Sep 2011 15:58:19 +0200 Subject: - add an Acquire::Min-ValidTime option (Closes: #640122) * doc/apt.conf.5.xml: - reword Acquire::Max-ValidTime documentation to make clear that it doesn't provide the new Min-ValidTime functionality --- apt-pkg/indexrecords.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 7852b99f0..ba5b7c846 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -115,8 +115,12 @@ bool indexRecords::Load(const string Filename) /*{{{*/ int MaxAge = _config->FindI("Acquire::Max-ValidTime", 0); if (Label.empty() == false) MaxAge = _config->FindI(string("Acquire::Max-ValidTime::" + Label).c_str(), MaxAge); + int MinAge = _config->FindI("Acquire::Min-ValidTime", 0); + if (Label.empty() == false) + MinAge = _config->FindI(string("Acquire::Min-ValidTime::" + Label).c_str(), MinAge); - if(MaxAge == 0) // No user settings, use the one from the Release file + if(MaxAge == 0 && + (MinAge == 0 || ValidUntil == 0)) // No user settings, use the one from the Release file return true; time_t date; @@ -125,10 +129,17 @@ bool indexRecords::Load(const string Filename) /*{{{*/ strprintf(ErrorText, _("Invalid 'Date' entry in Release file %s"), Filename.c_str()); return false; } - date += MaxAge; - if (ValidUntil == 0 || ValidUntil > date) - ValidUntil = date; + if (MinAge != 0 && ValidUntil != 0) { + time_t const min_date = date + MinAge; + if (ValidUntil < min_date) + ValidUntil = min_date; + } + if (MaxAge != 0) { + time_t const max_date = date + MaxAge; + if (ValidUntil == 0 || ValidUntil > max_date) + ValidUntil = max_date; + } return true; } -- cgit v1.2.3 From 30426f4822516bdd26528aa2e6d8d69c1291c8d3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 9 Sep 2011 12:35:22 +0200 Subject: M-A:same lockstep unpack should operate on installed packages first (LP: #835625) --- apt-pkg/packagemanager.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 6601d9f6b..8b73b9980 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -603,18 +603,39 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate) List->Flag(Pkg,pkgOrderList::UnPacked,pkgOrderList::States); - if (instVer->MultiArch == pkgCache::Version::Same) + if (Immediate == true && instVer->MultiArch == pkgCache::Version::Same) + { + /* Do lockstep M-A:same unpacking in two phases: + First unpack all installed architectures, then the not installed. + This way we avoid that M-A: enabled packages are installed before + their older non-M-A enabled packages are replaced by newer versions */ + bool const installed = Pkg->CurrentVer != 0; + if (installed == true && Install(Pkg,FileNames[Pkg->ID]) == false) + return false; for (PkgIterator P = Pkg.Group().PackageList(); P.end() == false; P = Pkg.Group().NextPkg(P)) { - if (Pkg == P || List->IsFlag(P,pkgOrderList::UnPacked) == true || + if (P->CurrentVer == 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true || Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) continue; - SmartUnPack(P, false); + if (SmartUnPack(P, false) == false) + return false; } - - if(Install(Pkg,FileNames[Pkg->ID]) == false) + if (installed == false && Install(Pkg,FileNames[Pkg->ID]) == false) + return false; + for (PkgIterator P = Pkg.Group().PackageList(); + P.end() == false; P = Pkg.Group().NextPkg(P)) + { + if (P->CurrentVer != 0 || P == Pkg || List->IsFlag(P,pkgOrderList::UnPacked) == true || + Cache[P].InstallVer == 0 || (P.CurrentVer() == Cache[P].InstallVer && + (Cache[Pkg].iFlags & pkgDepCache::ReInstall) != pkgDepCache::ReInstall)) + continue; + if (SmartUnPack(P, false) == false) + return false; + } + } + else if (Install(Pkg,FileNames[Pkg->ID]) == false) return false; // Perform immedate configuration of the package. -- cgit v1.2.3 From ea54214002c09eeb4dd498d97a564471ec9993c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 10:09:00 +0200 Subject: reorder includes: add if needed and include it at first --- apt-pkg/acquire-item.cc | 6 ++++-- apt-pkg/acquire-method.cc | 2 ++ apt-pkg/acquire-worker.cc | 8 +++++--- apt-pkg/acquire.cc | 6 ++++-- apt-pkg/algorithms.cc | 6 ++++-- apt-pkg/aptconfiguration.cc | 2 ++ apt-pkg/cachefile.cc | 4 +++- apt-pkg/cachefilter.cc | 2 ++ apt-pkg/cacheset.cc | 6 ++++-- apt-pkg/cdrom.cc | 5 +++-- apt-pkg/clean.cc | 6 ++++-- apt-pkg/contrib/cdromutl.cc | 6 ++++-- apt-pkg/contrib/cmndline.cc | 4 +++- apt-pkg/contrib/configuration.cc | 5 ++++- apt-pkg/contrib/crc-16.cc | 2 ++ apt-pkg/contrib/error.cc | 5 +++-- apt-pkg/contrib/fileutl.cc | 7 ++++--- apt-pkg/contrib/hashes.cc | 4 +++- apt-pkg/contrib/hashsum.cc | 1 + apt-pkg/contrib/md5.cc | 3 ++- apt-pkg/contrib/mmap.cc | 9 +++++---- apt-pkg/contrib/netrc.cc | 1 + apt-pkg/contrib/progress.cc | 6 ++++-- apt-pkg/contrib/sha1.cc | 3 ++- apt-pkg/contrib/sha2_internal.cc | 1 + apt-pkg/contrib/strutl.cc | 6 +++--- apt-pkg/deb/debindexfile.cc | 2 ++ apt-pkg/deb/deblistparser.cc | 2 ++ apt-pkg/deb/debmetaindex.cc | 1 + apt-pkg/deb/debrecords.cc | 2 ++ apt-pkg/deb/debsrcrecords.cc | 2 ++ apt-pkg/deb/debsystem.cc | 5 ++++- apt-pkg/deb/debversion.cc | 1 + apt-pkg/deb/dpkgpm.cc | 3 ++- apt-pkg/depcache.cc | 6 ++++-- apt-pkg/edsp.cc | 6 ++++-- apt-pkg/edsp/edspindexfile.cc | 2 ++ apt-pkg/edsp/edsplistparser.cc | 2 ++ apt-pkg/edsp/edspsystem.cc | 5 ++++- apt-pkg/indexcopy.cc | 6 ++++-- apt-pkg/indexfile.cc | 2 ++ apt-pkg/indexrecords.cc | 4 +++- apt-pkg/init.cc | 6 ++++-- apt-pkg/orderlist.cc | 2 ++ apt-pkg/packagemanager.cc | 8 +++++--- apt-pkg/pkgcache.cc | 7 ++++--- apt-pkg/pkgcachegen.cc | 7 +++---- apt-pkg/pkgrecords.cc | 6 ++++-- apt-pkg/pkgsystem.cc | 2 ++ apt-pkg/policy.cc | 6 ++++-- apt-pkg/sourcelist.cc | 6 ++++-- apt-pkg/srcrecords.cc | 6 ++++-- apt-pkg/tagfile.cc | 6 ++++-- apt-pkg/vendor.cc | 2 ++ apt-pkg/vendorlist.cc | 2 ++ apt-pkg/version.cc | 2 ++ apt-pkg/versionmatch.cc | 4 ++-- 57 files changed, 168 insertions(+), 71 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index aa77824f8..d798c7107 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -24,8 +26,6 @@ #include #include -#include - #include #include #include @@ -33,6 +33,8 @@ #include #include #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 8c353beb2..69f7b1c57 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -15,6 +15,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 3e1fd98db..366879a57 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -12,6 +12,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -19,18 +21,18 @@ #include #include -#include - #include #include #include - + #include #include #include #include #include #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 2064abc50..e33dbb5d5 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -21,8 +23,6 @@ #include #include -#include - #include #include #include @@ -30,6 +30,8 @@ #include #include #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 8737c5334..d5652791c 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -14,6 +14,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -22,13 +24,13 @@ #include #include -#include #include #include #include #include - #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index e8c8e73d0..71e0b8e73 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 964c5bd8b..b60b1cc0f 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -12,6 +12,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -21,7 +23,7 @@ #include #include #include - + #include /*}}}*/ // CacheFile::CacheFile - Constructor /*{{{*/ diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc index 8f0725ea3..210a9a9ab 100644 --- a/apt-pkg/cachefilter.cc +++ b/apt-pkg/cachefilter.cc @@ -4,6 +4,8 @@ Collection of functor classes */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index a1de613e2..386ecfb5f 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -9,6 +9,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -16,11 +18,11 @@ #include #include -#include - #include #include + +#include /*}}}*/ namespace APT { // FromTask - Return all packages in the cache from a specific task /*{{{*/ diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 2a914c665..c432cf509 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -1,5 +1,6 @@ /* */ +#include #include #include @@ -10,8 +11,6 @@ #include #include -#include -#include #include #include #include @@ -22,6 +21,8 @@ #include "indexcopy.h" +#include + using namespace std; // FindPackages - Find the package files on the CDROM /*{{{*/ diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 629afd7cf..2e5fd675a 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -8,17 +8,19 @@ ##################################################################### */ /*}}}*/ // Includes /*{{{*/ +#include + #include #include #include #include #include -#include - #include #include #include + +#include /*}}}*/ // ArchiveCleaner::Go - Perform smart cleanup of the archive /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 821e6d688..7f30f132d 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -10,6 +10,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -17,8 +19,6 @@ #include #include -#include - #include #include #include @@ -26,6 +26,8 @@ #include #include #include + +#include /*}}}*/ // IsMounted - Returns true if the mount point is mounted /*{{{*/ diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 5a9944096..34e90da20 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -11,11 +11,13 @@ ##################################################################### */ /*}}}*/ // Include files /*{{{*/ +#include + #include #include #include -#include +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 0664e3704..b3e9d8863 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -15,16 +15,19 @@ ##################################################################### */ /*}}}*/ // Include files /*{{{*/ +#include + #include #include #include #include -#include #include #include #include +#include + using namespace std; /*}}}*/ diff --git a/apt-pkg/contrib/crc-16.cc b/apt-pkg/contrib/crc-16.cc index b300ed67e..26ea1ba28 100644 --- a/apt-pkg/contrib/crc-16.cc +++ b/apt-pkg/contrib/crc-16.cc @@ -15,6 +15,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include /*}}}*/ diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc index 18810d2a4..56bbd1c60 100644 --- a/apt-pkg/contrib/error.cc +++ b/apt-pkg/contrib/error.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include @@ -24,8 +26,7 @@ #include #include -#include "config.h" - /*}}}*/ + /*}}}*/ // Global Error Object /*{{{*/ /* If the implementation supports posix threads then the accessor function diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 50019872e..690e2403c 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -18,14 +18,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include -#include - #include #include #include @@ -43,10 +43,11 @@ #include #include -#include #ifdef WORDS_BIGENDIAN #include #endif + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 4407574fa..9c251e89f 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -11,12 +11,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include -#include +#include #include #include /*}}}*/ diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index 728747d7a..28f711176 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -1,4 +1,5 @@ // Cryptographic API Base +#include #include #include "hashsum_template.h" diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc index 65e20e9bb..b53c4fbd2 100644 --- a/apt-pkg/contrib/md5.cc +++ b/apt-pkg/contrib/md5.cc @@ -35,6 +35,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -43,7 +45,6 @@ #include #include // For htonl #include -#include /*}}}*/ // byteSwap - Swap bytes in a buffer /*{{{*/ diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 19381ae47..3cd87eda4 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -17,20 +17,21 @@ /*}}}*/ // Include Files /*{{{*/ #define _BSD_SOURCE +#include + #include #include -#include - #include #include #include #include #include #include - #include - /*}}}*/ + +#include + /*}}}*/ // MMap::MMap - Constructor /*{{{*/ // --------------------------------------------------------------------- diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 34f472ee1..456ada950 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -11,6 +11,7 @@ ##################################################################### */ /*}}}*/ +#include #include #include diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 84ee4c124..6cd6134d3 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -8,15 +8,17 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include -#include - #include #include #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc index 4b0552102..9416895ac 100644 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@ -29,6 +29,8 @@ */ /*}}} */ // Include Files /*{{{*/ +#include + #include #include #include @@ -36,7 +38,6 @@ #include #include #include -#include /*}}}*/ // SHA1Transform - Alters an existing SHA-1 hash /*{{{*/ diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index 565db2f91..ff995cdf2 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -31,6 +31,7 @@ * * $Id: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $ */ +#include #include /* memcpy()/memset() or bcopy()/bzero() */ #include /* assert() */ diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 072dda3ac..6586ef17b 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -15,12 +15,12 @@ ##################################################################### */ /*}}}*/ // Includes /*{{{*/ +#include + #include #include #include -#include - #include #include #include @@ -31,7 +31,7 @@ #include #include -#include "config.h" +#include using namespace std; /*}}}*/ diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index c9e7f1176..303dab796 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -9,6 +9,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index b708296d3..6b8fbce99 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -10,6 +10,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 81afb22b6..aaae906dd 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -1,4 +1,5 @@ // ijones, walters +#include #include #include diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 1ca9ae1d2..db62d6c45 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 749305005..c9c20267b 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -9,6 +9,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 7644bc66b..080af5659 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -10,6 +10,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -17,11 +19,12 @@ #include #include #include -#include #include #include #include #include + +#include /*}}}*/ debSystem debSys; diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index 755ffbe96..ba32b2dd4 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -11,6 +11,7 @@ /*}}}*/ // Include Files /*{{{*/ #define APT_COMPATIBILITY 986 +#include #include #include diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 019b72bb8..7733390c0 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Includes /*{{{*/ +#include + #include #include #include @@ -40,7 +42,6 @@ #include #include -#include #include /*}}}*/ diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 72a0bb542..0fbd77fd8 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -23,12 +25,12 @@ #include #include -#include +#include #include #include -#include +#include /*}}}*/ // helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/ static bool diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 4d2230613..44f7dbfd6 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -5,6 +5,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -12,10 +14,10 @@ #include #include -#include #include - #include + +#include /*}}}*/ // we could use pkgCache::DepType and ::Priority, but these would be localized strings… diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index f5881e663..b417a7562 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -6,6 +6,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 3349e8cce..e00abdbcc 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -9,6 +9,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index ac0bb8beb..10d75771a 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -9,17 +9,20 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include #include -#include #include #include #include #include + +#include /*}}}*/ edspSystem edspSys; diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index 31c577705..dcba78dce 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -10,7 +10,7 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include "indexcopy.h" +#include #include #include @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -30,6 +29,9 @@ #include #include #include + +#include "indexcopy.h" +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 37be87055..b56d9dc6c 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 10e154ad2..00f520c4f 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -3,15 +3,17 @@ // $Id: indexrecords.cc,v 1.1.2.4 2003/12/30 02:11:43 mdz Exp $ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include -#include #include #include +#include /*}}}*/ string indexRecords::GetDist() const { diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 8f20c31df..97a39e96e 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -8,14 +8,16 @@ ##################################################################### */ /*}}}*/ // Include files /*{{{*/ +#include + #include #include #include -#include -#include #include #include + +#include /*}}}*/ #define Stringfy_(x) # x diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 19661fc2d..4dcb31b7e 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -63,6 +63,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 1ae09347a..6f9f4748f 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -13,6 +13,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -22,10 +24,10 @@ #include #include #include - -#include + +#include #include -#include +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 951caeb78..0a81cb791 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -20,6 +20,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -29,13 +31,12 @@ #include #include -#include - #include #include #include - #include + +#include /*}}}*/ using std::string; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index b89c8c0d3..1cae23134 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -11,6 +11,7 @@ /*}}}*/ // Include Files /*{{{*/ #define APT_COMPATIBILITY 986 +#include #include #include @@ -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; diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index e506de73a..9459f7def 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -9,12 +9,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include - -#include + +#include /*}}}*/ // Records::pkgRecords - Constructor /*{{{*/ diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc index 6dd2d3ee4..f61c140fa 100644 --- a/apt-pkg/pkgsystem.cc +++ b/apt-pkg/pkgsystem.cc @@ -10,6 +10,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index be96d4c84..372b58a7c 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -23,6 +23,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include @@ -31,10 +33,10 @@ #include #include -#include - #include #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 851eefdfe..d4eec5c8d 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -8,15 +8,17 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include -#include - #include + +#include /*}}}*/ using namespace std; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 46a02b55c..b368322f5 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -11,12 +11,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include - -#include + +#include /*}}}*/ // SrcRecords::pkgSrcRecords - Constructor /*{{{*/ diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index a8f04b23a..3b491fcd2 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -11,15 +11,17 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include -#include - #include #include #include + +#include /*}}}*/ using std::string; diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc index 2350afe69..eab6d448f 100644 --- a/apt-pkg/vendor.cc +++ b/apt-pkg/vendor.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 48ac12cee..8432091e8 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc index 42e449d36..a9d4fb763 100644 --- a/apt-pkg/version.cc +++ b/apt-pkg/version.cc @@ -8,6 +8,8 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index c40b1fdbc..c23b4c3bf 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -11,8 +11,9 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#include +#include +#include #include #include @@ -21,7 +22,6 @@ #include #include #include - /*}}}*/ // VersionMatch::pkgVersionMatch - Constructor /*{{{*/ -- cgit v1.2.3 From 650faab01603caac04494d54cf6b10a65c00ea13 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 17:46:48 +0200 Subject: 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) --- apt-pkg/acquire-worker.cc | 8 ++++---- apt-pkg/contrib/crc-16.cc | 2 +- apt-pkg/contrib/crc-16.h | 2 +- apt-pkg/contrib/fileutl.cc | 33 +++++++++++++++++---------------- apt-pkg/contrib/fileutl.h | 35 +++++++++++++++++++++++++---------- apt-pkg/contrib/hashes.cc | 10 +++++----- apt-pkg/contrib/hashes.h | 6 +++--- apt-pkg/contrib/hashsum.cc | 10 +++++----- apt-pkg/contrib/hashsum_template.h | 6 +++--- apt-pkg/contrib/md5.cc | 2 +- apt-pkg/contrib/md5.h | 2 +- apt-pkg/contrib/mmap.cc | 16 ++++++++-------- apt-pkg/contrib/mmap.h | 8 ++++---- apt-pkg/contrib/progress.cc | 8 ++++---- apt-pkg/contrib/progress.h | 16 ++++++++-------- apt-pkg/contrib/sha1.cc | 2 +- apt-pkg/contrib/sha1.h | 2 +- apt-pkg/contrib/sha2.h | 6 +++--- apt-pkg/contrib/strutl.cc | 28 ++++++++++++++++++++++++++++ apt-pkg/contrib/strutl.h | 1 + apt-pkg/depcache.cc | 4 ++-- apt-pkg/indexcopy.cc | 23 ++++++++++++----------- apt-pkg/indexcopy.h | 6 +++--- apt-pkg/indexrecords.cc | 6 +++--- apt-pkg/indexrecords.h | 4 ++-- apt-pkg/pkgrecords.h | 1 - apt-pkg/tagfile.cc | 18 +++++++++--------- apt-pkg/tagfile.h | 4 ++-- 28 files changed, 157 insertions(+), 112 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 366879a57..3bb977e14 100644 --- a/apt-pkg/acquire-worker.cc +++ b/apt-pkg/acquire-worker.cc @@ -258,9 +258,9 @@ bool pkgAcquire::Worker::RunMessages() CurrentItem = Itm; CurrentSize = 0; - TotalSize = atoi(LookupTag(Message,"Size","0").c_str()); - ResumePoint = atoi(LookupTag(Message,"Resume-Point","0").c_str()); - Itm->Owner->Start(Message,atoi(LookupTag(Message,"Size","0").c_str())); + TotalSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10); + ResumePoint = strtoull(LookupTag(Message,"Resume-Point","0").c_str(), NULL, 10); + Itm->Owner->Start(Message,strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10)); // Display update before completion if (Log != 0 && Log->MorePulses == true) @@ -289,7 +289,7 @@ bool pkgAcquire::Worker::RunMessages() Log->Pulse(Owner->GetOwner()); OwnerQ->ItemDone(Itm); - unsigned long long const ServerSize = atoll(LookupTag(Message,"Size","0").c_str()); + unsigned long long const ServerSize = strtoull(LookupTag(Message,"Size","0").c_str(), NULL, 10); if (TotalSize != 0 && ServerSize != TotalSize) _error->Warning("Size of file %s is not what the server reported %s %llu", Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize); diff --git a/apt-pkg/contrib/crc-16.cc b/apt-pkg/contrib/crc-16.cc index 26ea1ba28..4058821f9 100644 --- a/apt-pkg/contrib/crc-16.cc +++ b/apt-pkg/contrib/crc-16.cc @@ -65,7 +65,7 @@ static unsigned short const crc16_table[256] = /* Recompute the FCS with one more character appended. */ #define CalcFCS(fcs, c) (((fcs) >> 8) ^ crc16_table[((fcs) ^ (c)) & 0xff]) unsigned short AddCRC16(unsigned short fcs, void const *Buf, - unsigned long len) + unsigned long long len) { unsigned char const *buf = (unsigned char const *)Buf; while (len--) diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h index f30678bac..702de40b2 100644 --- a/apt-pkg/contrib/crc-16.h +++ b/apt-pkg/contrib/crc-16.h @@ -12,6 +12,6 @@ #define INIT_FCS 0xffff unsigned short AddCRC16(unsigned short fcs, void const *buf, - unsigned long len); + unsigned long long len); #endif diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 690e2403c..2e62846d9 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -133,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; @@ -800,7 +800,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 +839,13 @@ bool FileFd::Read(void *To,unsigned long Size,unsigned long *Actual) } 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 +872,13 @@ bool FileFd::Write(const void *From,unsigned long Size) 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 +888,7 @@ bool FileFd::Seek(unsigned long To) 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 +897,7 @@ bool FileFd::Seek(unsigned long To) // 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 +907,7 @@ bool FileFd::Skip(unsigned long Over) 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 +916,7 @@ bool FileFd::Skip(unsigned long Over) // FileFd::Truncate - Truncate the file /*{{{*/ // --------------------------------------------------------------------- /* */ -bool FileFd::Truncate(unsigned long To) +bool FileFd::Truncate(unsigned long long To) { if (gz) { @@ -926,7 +926,7 @@ bool FileFd::Truncate(unsigned long To) 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 +935,7 @@ bool FileFd::Truncate(unsigned long To) // FileFd::Tell - Current seek position /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long FileFd::Tell() +unsigned long long FileFd::Tell() { off_t Res; if (gz) @@ -950,7 +950,7 @@ unsigned long FileFd::Tell() // FileFd::FileSize - Return the size of the file /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned long FileFd::FileSize() +unsigned long long FileFd::FileSize() { struct stat Buf; @@ -962,9 +962,9 @@ unsigned long FileFd::FileSize() // 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,6 +974,7 @@ unsigned long FileFd::Size() /* 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 --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index cde288ad2..0f2dd4194 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -49,21 +49,36 @@ class FileFd 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(); diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 9c251e89f..fd76bf229 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -108,18 +108,18 @@ string HashString::toStr() const // Hashes::AddFD - Add the contents of the FD /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5, +bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5, bool const addSHA1, bool const addSHA256, bool const addSHA512) { unsigned char Buf[64*64]; - int Res = 0; + ssize_t Res = 0; int ToEOF = (Size == 0); while (Size != 0 || ToEOF) { - unsigned n = sizeof(Buf); - if (!ToEOF) n = min(Size,(unsigned long)n); + unsigned long long n = sizeof(Buf); + if (!ToEOF) n = min(Size, n); Res = read(Fd,Buf,n); - if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read + if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; if (ToEOF && Res == 0) // EOF break; diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index e702fcca2..40c2ad064 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -62,14 +62,14 @@ class Hashes SHA256Summation SHA256; SHA512Summation SHA512; - inline bool Add(const unsigned char *Data,unsigned long Size) + inline bool Add(const unsigned char *Data,unsigned long long Size) { return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size); }; inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));}; - inline bool AddFD(int const Fd,unsigned long Size = 0) + inline bool AddFD(int const Fd,unsigned long long Size = 0) { return AddFD(Fd, Size, true, true, true, true); }; - bool AddFD(int const Fd, unsigned long Size, bool const addMD5, + bool AddFD(int const Fd, unsigned long long Size, bool const addMD5, bool const addSHA1, bool const addSHA256, bool const addSHA512); inline bool Add(const unsigned char *Beg,const unsigned char *End) {return Add(Beg,End-Beg);}; diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index 28f711176..0edcbb364 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -7,16 +7,16 @@ // Summation::AddFD - Add content of file into the checksum /*{{{*/ // --------------------------------------------------------------------- /* */ -bool SummationImplementation::AddFD(int const Fd, unsigned long Size) { +bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) { unsigned char Buf[64 * 64]; - int Res = 0; + ssize_t Res = 0; int ToEOF = (Size == 0); while (Size != 0 || ToEOF) { - unsigned n = sizeof(Buf); - if (!ToEOF) n = min(Size,(unsigned long)n); + unsigned long long n = sizeof(Buf); + if (!ToEOF) n = min(Size, n); Res = read(Fd, Buf, n); - if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read + if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; if (ToEOF && Res == 0) // EOF break; diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 85d94c2af..9157754e3 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -87,8 +87,8 @@ class HashSumValue class SummationImplementation { public: - virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0; - inline bool Add(const char *inbuf, unsigned long const inlen) + virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0; + inline bool Add(const char *inbuf, unsigned long long const inlen) { return Add((unsigned char *)inbuf, inlen); }; inline bool Add(const unsigned char *Data) @@ -101,7 +101,7 @@ class SummationImplementation inline bool Add(const char *Beg, const char *End) { return Add((const unsigned char *)Beg, End - Beg); }; - bool AddFD(int Fd, unsigned long Size = 0); + bool AddFD(int Fd, unsigned long long Size = 0); }; #endif diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc index b53c4fbd2..4351aeb22 100644 --- a/apt-pkg/contrib/md5.cc +++ b/apt-pkg/contrib/md5.cc @@ -187,7 +187,7 @@ MD5Summation::MD5Summation() // MD5Summation::Add - 'Add' a data set to the hash /*{{{*/ // --------------------------------------------------------------------- /* */ -bool MD5Summation::Add(const unsigned char *data,unsigned long len) +bool MD5Summation::Add(const unsigned char *data,unsigned long long len) { if (Done == true) return false; diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h index e76428325..305cdb20d 100644 --- a/apt-pkg/contrib/md5.h +++ b/apt-pkg/contrib/md5.h @@ -45,7 +45,7 @@ class MD5Summation : public SummationImplementation public: - bool Add(const unsigned char *inbuf, unsigned long inlen); + bool Add(const unsigned char *inbuf, unsigned long long inlen); using SummationImplementation::Add; MD5SumValue Result(); diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index 3cd87eda4..a110a7019 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -95,7 +95,7 @@ bool MMap::Map(FileFd &Fd) return false; } else - return _error->Errno("mmap",_("Couldn't make mmap of %lu bytes"), + return _error->Errno("mmap",_("Couldn't make mmap of %llu bytes"), iSize); } @@ -166,7 +166,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) return true; #ifdef _POSIX_SYNCHRONIZED_IO - unsigned long PSize = sysconf(_SC_PAGESIZE); + unsigned long long PSize = sysconf(_SC_PAGESIZE); if ((Flags & ReadOnly) != ReadOnly) { if (SyncToFd != 0) @@ -177,7 +177,7 @@ bool MMap::Sync(unsigned long Start,unsigned long Stop) } else { - if (msync((char *)Base+(int)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0) + if (msync((char *)Base+(unsigned long long)(Start/PSize)*PSize,Stop - Start,MS_SYNC) < 0) return _error->Errno("msync", _("Unable to synchronize mmap")); } } @@ -197,7 +197,7 @@ DynamicMMap::DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &Work if (_error->PendingError() == true) return; - unsigned long EndOfFile = Fd->Size(); + unsigned long long EndOfFile = Fd->Size(); if (EndOfFile > WorkSpace) WorkSpace = EndOfFile; else if(WorkSpace > 0) @@ -285,7 +285,7 @@ DynamicMMap::~DynamicMMap() return; } - unsigned long EndOfFile = iSize; + unsigned long long EndOfFile = iSize; iSize = WorkSpace; Close(false); if(ftruncate(Fd->Fd(),EndOfFile) < 0) @@ -295,9 +295,9 @@ DynamicMMap::~DynamicMMap() // DynamicMMap::RawAllocate - Allocate a raw chunk of unaligned space /*{{{*/ // --------------------------------------------------------------------- /* This allocates a block of memory aligned to the given size */ -unsigned long DynamicMMap::RawAllocate(unsigned long Size,unsigned long Aln) +unsigned long DynamicMMap::RawAllocate(unsigned long long Size,unsigned long Aln) { - unsigned long Result = iSize; + unsigned long long Result = iSize; if (Aln != 0) Result += Aln - (iSize%Aln); @@ -412,7 +412,7 @@ bool DynamicMMap::Grow() { if (GrowFactor <= 0) return _error->Error(_("Unable to increase size of the MMap as automatic growing is disabled by user.")); - unsigned long const newSize = WorkSpace + GrowFactor; + unsigned long long const newSize = WorkSpace + GrowFactor; if(Fd != 0) { Fd->Seek(newSize - 1); diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index 2bf2c1540..e0ff8db95 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -41,7 +41,7 @@ class MMap protected: unsigned long Flags; - unsigned long iSize; + unsigned long long iSize; void *Base; // In case mmap can not be used, we keep a dup of the file @@ -60,8 +60,8 @@ class MMap // Simple accessors inline operator void *() {return Base;}; inline void *Data() {return Base;}; - inline unsigned long Size() {return iSize;}; - inline void AddSize(unsigned long const size) {iSize += size;}; + inline unsigned long long Size() {return iSize;}; + inline void AddSize(unsigned long long const size) {iSize += size;}; inline bool validData() const { return Base != (void *)-1 && Base != 0; }; // File manipulators @@ -99,7 +99,7 @@ class DynamicMMap : public MMap public: // Allocation - unsigned long RawAllocate(unsigned long Size,unsigned long Aln = 0); + unsigned long RawAllocate(unsigned long long Size,unsigned long Aln = 0); unsigned long Allocate(unsigned long ItemSize); unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1); inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());}; diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index 6cd6134d3..317048845 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -37,7 +37,7 @@ OpProgress::OpProgress() : Current(0), Total(0), Size(0), SubTotal(1), /* Current is the Base Overall progress in units of Total. Cur is the sub progress in units of SubTotal. Size is a scaling factor that says what percent of Total SubTotal is. */ -void OpProgress::Progress(unsigned long Cur) +void OpProgress::Progress(unsigned long long Cur) { if (Total == 0 || Size == 0 || SubTotal == 0) Percent = 0; @@ -49,8 +49,8 @@ void OpProgress::Progress(unsigned long Cur) // OpProgress::OverallProgress - Set the overall progress /*{{{*/ // --------------------------------------------------------------------- /* */ -void OpProgress::OverallProgress(unsigned long Current, unsigned long Total, - unsigned long Size,const string &Op) +void OpProgress::OverallProgress(unsigned long long Current, unsigned long long Total, + unsigned long long Size,const string &Op) { this->Current = Current; this->Total = Total; @@ -67,7 +67,7 @@ void OpProgress::OverallProgress(unsigned long Current, unsigned long Total, // OpProgress::SubProgress - Set the sub progress state /*{{{*/ // --------------------------------------------------------------------- /* */ -void OpProgress::SubProgress(unsigned long SubTotal,const string &Op, +void OpProgress::SubProgress(unsigned long long SubTotal,const string &Op, float const Percent) { this->SubTotal = SubTotal; diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h index 3a914d17f..5344323f6 100644 --- a/apt-pkg/contrib/progress.h +++ b/apt-pkg/contrib/progress.h @@ -30,10 +30,10 @@ using std::string; class Configuration; class OpProgress { - unsigned long Current; - unsigned long Total; - unsigned long Size; - unsigned long SubTotal; + unsigned long long Current; + unsigned long long Total; + unsigned long long Size; + unsigned long long SubTotal; float LastPercent; // Change reduction code @@ -54,10 +54,10 @@ class OpProgress public: - void Progress(unsigned long Current); - void SubProgress(unsigned long SubTotal, const string &Op = "", float const Percent = -1); - void OverallProgress(unsigned long Current,unsigned long Total, - unsigned long Size,const string &Op); + void Progress(unsigned long long Current); + void SubProgress(unsigned long long SubTotal, const string &Op = "", float const Percent = -1); + void OverallProgress(unsigned long long Current,unsigned long long Total, + unsigned long long Size,const string &Op); virtual void Done() {}; OpProgress(); diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc index 9416895ac..31c576611 100644 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@ -243,7 +243,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 --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h index 2701fc67e..916faec1b 100644 --- a/apt-pkg/contrib/sha1.h +++ b/apt-pkg/contrib/sha1.h @@ -34,7 +34,7 @@ class SHA1Summation : public SummationImplementation bool Done; public: - bool Add(const unsigned char *inbuf, unsigned long inlen); + bool Add(const unsigned char *inbuf, unsigned long long inlen); using SummationImplementation::Add; SHA1SumValue Result(); diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h index 386225889..51c921dbd 100644 --- a/apt-pkg/contrib/sha2.h +++ b/apt-pkg/contrib/sha2.h @@ -30,7 +30,7 @@ class SHA2SummationBase : public SummationImplementation protected: bool Done; public: - bool Add(const unsigned char *inbuf, unsigned long len) = 0; + bool Add(const unsigned char *inbuf, unsigned long long len) = 0; void Result(); }; @@ -41,7 +41,7 @@ class SHA256Summation : public SHA2SummationBase unsigned char Sum[32]; public: - bool Add(const unsigned char *inbuf, unsigned long len) + bool Add(const unsigned char *inbuf, unsigned long long len) { if (Done) return false; @@ -73,7 +73,7 @@ class SHA512Summation : public SHA2SummationBase unsigned char Sum[64]; public: - bool Add(const unsigned char *inbuf, unsigned long len) + bool Add(const unsigned char *inbuf, unsigned long long len) { if (Done) return false; diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 6586ef17b..04226f1b4 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -970,6 +970,34 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base) 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 diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 89cbf0370..b32198f25 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -52,6 +52,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default = 0); 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 --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 0fbd77fd8..8dde7c173 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -171,14 +171,14 @@ bool pkgDepCache::readStateFile(OpProgress *Prog) /*{{{*/ 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"); diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc index dcba78dce..f52ecbbcb 100644 --- a/apt-pkg/indexcopy.cc +++ b/apt-pkg/indexcopy.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include "indexcopy.h" #include @@ -55,7 +56,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, 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++) { struct stat Buf; @@ -66,14 +67,14 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, 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++) { string OrigPath = string(*I,CDROM.length()); - unsigned long FileSize = 0; + off_t FileSize = 0; // Open the package file FileFd Pkg; @@ -166,7 +167,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, if(Progress) Progress->Progress(Parser.Offset()); string File; - unsigned long Size; + unsigned long long Size; if (GetFile(File,Size) == false) { fclose(TargetFl); @@ -221,7 +222,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector &List, } // Size match - if ((unsigned)Buf.st_size != Size) + if ((unsigned long long)Buf.st_size != Size) { if (Debug == true) clog << "Wrong Size: " << File << endl; @@ -455,7 +456,7 @@ bool IndexCopy::GrabFirst(string Path,string &To,unsigned int Depth) // 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"); @@ -481,7 +482,7 @@ bool PackageCopy::RewriteEntry(FILE *Target,string File) // 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) @@ -504,7 +505,7 @@ bool SourceCopy::GetFile(string &File,unsigned long &Size) 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; } @@ -787,7 +788,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ 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++) { struct stat Buf; @@ -798,14 +799,14 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/ 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++) { string OrigPath = string(*I,CDROM.length()); - unsigned long FileSize = 0; + off_t FileSize = 0; // Open the package file FileFd Pkg; diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h index 277fb561c..60c90dd4a 100644 --- a/apt-pkg/indexcopy.h +++ b/apt-pkg/indexcopy.h @@ -37,7 +37,7 @@ class IndexCopy /*{{{*/ bool ReconstructChop(unsigned long &Chop,string Dir,string File); void ConvertToSourceList(string CD,string &Path); bool GrabFirst(string Path,string &To,unsigned int Depth); - virtual bool GetFile(string &Filename,unsigned long &Size) = 0; + virtual bool GetFile(string &Filename,unsigned long long &Size) = 0; virtual bool RewriteEntry(FILE *Target,string File) = 0; virtual const char *GetFileName() = 0; virtual const char *Type() = 0; @@ -53,7 +53,7 @@ class PackageCopy : public IndexCopy /*{{{*/ { protected: - virtual bool GetFile(string &Filename,unsigned long &Size); + virtual bool GetFile(string &Filename,unsigned long long &Size); virtual bool RewriteEntry(FILE *Target,string File); virtual const char *GetFileName() {return "Packages";}; virtual const char *Type() {return "Package";}; @@ -64,7 +64,7 @@ class SourceCopy : public IndexCopy /*{{{*/ { protected: - virtual bool GetFile(string &Filename,unsigned long &Size); + virtual bool GetFile(string &Filename,unsigned long long &Size); virtual bool RewriteEntry(FILE *Target,string File); virtual const char *GetFileName() {return "Sources";}; virtual const char *Type() {return "Source";}; diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 00f520c4f..932640764 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -80,7 +80,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/ string Name; string Hash; - size_t Size; + unsigned long long Size; while (Start < End) { if (!parseSumData(Start, End, Name, Hash, Size)) @@ -147,7 +147,7 @@ vector indexRecords::MetaKeys() /*{{{*/ } /*}}}*/ bool indexRecords::parseSumData(const char *&Start, const char *End, /*{{{*/ - string &Name, string &Hash, size_t &Size) + string &Name, string &Hash, unsigned long long &Size) { Name = ""; Hash = ""; @@ -184,7 +184,7 @@ bool indexRecords::parseSumData(const char *&Start, const char *End, /*{{{*/ if (EntryEnd == End) return false; - Size = strtol (Start, NULL, 10); + Size = strtoull (Start, NULL, 10); /* Skip over intermediate blanks */ Start = EntryEnd; diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index 5b532c1a5..0f933b93c 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -17,7 +17,7 @@ class indexRecords { bool parseSumData(const char *&Start, const char *End, string &Name, - string &Hash, size_t &Size); + string &Hash, unsigned long long &Size); public: struct checkSum; string ErrorText; @@ -53,7 +53,7 @@ struct indexRecords::checkSum { string MetaKeyFilename; HashString Hash; - size_t Size; + unsigned long long Size; }; #endif diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index 78e39e577..840454e18 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -19,7 +19,6 @@ #include -#include #include class pkgRecords /*{{{*/ diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 3b491fcd2..418e6bed8 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -29,7 +29,7 @@ using std::string; class pkgTagFilePrivate { public: - pkgTagFilePrivate(FileFd *pFd, unsigned long Size) : Fd(*pFd), Size(Size) + pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Size(Size) { } FileFd &Fd; @@ -37,14 +37,14 @@ public: char *Start; char *End; bool Done; - unsigned long iOffset; - unsigned long Size; + unsigned long long iOffset; + unsigned long long Size; }; // TagFile::pkgTagFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) +pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long long Size) { d = new pkgTagFilePrivate(pFd, Size); @@ -86,7 +86,7 @@ unsigned long pkgTagFile::Offset() bool pkgTagFile::Resize() { char *tmp; - unsigned long EndSize = d->End - d->Start; + unsigned long long EndSize = d->End - d->Start; // fail is the buffer grows too big if(d->Size > 1024*1024+1) @@ -138,8 +138,8 @@ bool pkgTagFile::Step(pkgTagSection &Tag) then fills the rest from the file */ bool pkgTagFile::Fill() { - unsigned long EndSize = d->End - d->Start; - unsigned long Actual = 0; + unsigned long long EndSize = d->End - d->Start; + unsigned long long Actual = 0; memmove(d->Buffer,d->Start,EndSize); d->Start = d->Buffer; @@ -180,12 +180,12 @@ bool pkgTagFile::Fill() // --------------------------------------------------------------------- /* This jumps to a pre-recorded file location and reads the record that is there */ -bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset) +bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long long Offset) { // We are within a buffer space of the next hit.. if (Offset >= d->iOffset && d->iOffset + (d->End - d->Start) > Offset) { - unsigned long Dist = Offset - d->iOffset; + unsigned long long Dist = Offset - d->iOffset; d->Start += Dist; d->iOffset += Dist; return Step(Tag); diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 23f5c57e6..87d070d28 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -94,9 +94,9 @@ class pkgTagFile 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(); }; -- cgit v1.2.3 From fd4d895b208937ef84a3c367f5b55e3c46375130 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Sep 2011 10:17:37 +0200 Subject: * apt-pkg/contrib/configuration.cc: - fix double delete (LP: #848907) - ignore only the invalid regexp instead of all options --- apt-pkg/contrib/configuration.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index ece05e8f6..2db191ba2 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -870,10 +870,10 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config) { regfree(p); delete p; - clearPatterns(); - _error->Warning("Regex compilation error for '%s' in configuration option '%s'", - s->c_str(), Config); - return; + _error->Warning("Invalid regular expression '%s' in configuration " + "option '%s' will be ignored.", + s->c_str(), Config); + continue; } } if (strings.size() == 0) @@ -894,6 +894,7 @@ void Configuration::MatchAgainstConfig::clearPatterns() regfree(*p); delete *p; } + patterns.clear(); } /*}}}*/ // MatchAgainstConfig::Match - returns true if a pattern matches /*{{{*/ -- cgit v1.2.3 From 7427781db6d1ca8b14167145d7884ad2f40bab5d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 14 Sep 2011 13:24:23 +0200 Subject: * [abi-break] Support large files in the complete toolset. Indexes of this * bump ABI version --- apt-pkg/init.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 6b92dd200..4cee1001a 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -22,7 +22,7 @@ // Non-ABI-Breaks should only increase RELEASE number. // See also buildlib/libversion.mak #define APT_PKG_MAJOR 4 -#define APT_PKG_MINOR 11 +#define APT_PKG_MINOR 12 #define APT_PKG_RELEASE 0 extern const char *pkgVersion; -- cgit v1.2.3 From c333ea435b67d7d7d7d10e867298ecac4da0f7b8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 12:26:56 +0200 Subject: remove an extra argument for the error mesage format --- apt-pkg/packagemanager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 3cd9f6f00..b9ef0f5d7 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -439,7 +439,7 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth) static bool const ConfigurePkgs = (conf == "all" || conf == "smart"); if (List->IsFlag(Pkg,pkgOrderList::Configured)) - return _error->Error("Internal configure error on '%s'. ",Pkg.Name(),1); + return _error->Error("Internal configure error on '%s'.", Pkg.Name()); if (ConfigurePkgs == true && Configure(Pkg) == false) return false; -- cgit v1.2.3 From 8f3ba4e8708cb72be19dacc2af4f601ee5fea292 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 13:31:29 +0200 Subject: do not pollute namespace in the headers with using (Closes: #500198) --- apt-pkg/acquire-method.h | 38 ++++++------- apt-pkg/acquire-worker.h | 12 ++--- apt-pkg/acquire.h | 36 ++++++------- apt-pkg/algorithms.h | 6 +-- apt-pkg/aptconfiguration.cc | 10 ++-- apt-pkg/cacheiterators.h | 6 +-- apt-pkg/cdrom.h | 38 +++++++------ apt-pkg/clean.cc | 10 ++-- apt-pkg/clean.h | 4 +- apt-pkg/contrib/cdromutl.cc | 2 + apt-pkg/contrib/cdromutl.h | 12 ++--- apt-pkg/contrib/configuration.h | 46 ++++++++-------- apt-pkg/contrib/fileutl.h | 42 +++++++-------- apt-pkg/contrib/hashes.cc | 26 ++++----- apt-pkg/contrib/hashes.h | 17 +++--- apt-pkg/contrib/hashsum.cc | 2 +- apt-pkg/contrib/hashsum_template.h | 13 ++--- apt-pkg/contrib/md5.h | 3 -- apt-pkg/contrib/mmap.h | 4 +- apt-pkg/contrib/netrc.cc | 1 + apt-pkg/contrib/netrc.h | 2 +- apt-pkg/contrib/progress.h | 18 +++---- apt-pkg/contrib/sha1.h | 3 -- apt-pkg/contrib/strutl.h | 108 ++++++++++++++++++------------------- apt-pkg/deb/debindexfile.h | 68 +++++++++++------------ apt-pkg/deb/deblistparser.cc | 2 + apt-pkg/deb/deblistparser.h | 24 ++++----- apt-pkg/deb/debrecords.cc | 6 ++- apt-pkg/deb/debrecords.h | 28 +++++----- apt-pkg/deb/debsrcrecords.cc | 6 ++- apt-pkg/deb/debsrcrecords.h | 18 +++---- apt-pkg/deb/debsystem.cc | 4 +- apt-pkg/deb/debversion.cc | 4 +- apt-pkg/deb/debversion.h | 6 +-- apt-pkg/deb/dpkgpm.h | 19 +++---- apt-pkg/depcache.cc | 3 ++ apt-pkg/depcache.h | 6 +-- apt-pkg/edsp/edspindexfile.h | 2 +- apt-pkg/edsp/edsplistparser.cc | 8 +-- apt-pkg/edsp/edsplistparser.h | 8 +-- apt-pkg/edsp/edspsystem.cc | 2 +- apt-pkg/indexcopy.h | 41 +++++++------- apt-pkg/indexfile.cc | 10 ++-- apt-pkg/indexfile.h | 12 ++--- apt-pkg/indexrecords.cc | 5 +- apt-pkg/indexrecords.h | 30 +++++------ apt-pkg/init.cc | 6 +-- apt-pkg/metaindex.h | 20 ++++--- apt-pkg/orderlist.h | 6 +-- apt-pkg/packagemanager.h | 6 +-- apt-pkg/pkgcache.cc | 4 +- apt-pkg/pkgcache.h | 16 +++--- apt-pkg/pkgcachegen.h | 38 ++++++------- apt-pkg/pkgrecords.cc | 2 +- apt-pkg/pkgrecords.h | 26 ++++----- apt-pkg/policy.h | 20 ++++--- apt-pkg/srcrecords.h | 33 ++++++------ apt-pkg/tagfile.h | 2 +- apt-pkg/vendor.cc | 6 +-- apt-pkg/vendor.h | 22 ++++---- apt-pkg/vendorlist.cc | 3 ++ apt-pkg/vendorlist.h | 14 ++--- apt-pkg/version.h | 4 +- apt-pkg/versionmatch.cc | 2 + apt-pkg/versionmatch.h | 26 +++++---- 65 files changed, 493 insertions(+), 534 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 6551170c4..8acec82ed 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -34,8 +34,8 @@ class pkgAcqMethod { FetchItem *Next; - string Uri; - string DestFile; + std::string Uri; + std::string DestFile; time_t LastModified; bool IndexFile; bool FailIgnore; @@ -43,14 +43,14 @@ class pkgAcqMethod struct FetchResult { - string MD5Sum; - string SHA1Sum; - string SHA256Sum; - string SHA512Sum; - vector GPGVOutput; + std::string MD5Sum; + std::string SHA1Sum; + std::string SHA256Sum; + std::string SHA512Sum; + std::vector GPGVOutput; time_t LastModified; bool IMSHit; - string Filename; + std::string Filename; unsigned long long Size; unsigned long long ResumePoint; @@ -59,25 +59,25 @@ class pkgAcqMethod }; // State - vector Messages; + std::vector Messages; FetchItem *Queue; FetchItem *QueueBack; - string FailReason; - string UsedMirror; - string IP; + std::string FailReason; + std::string UsedMirror; + std::string IP; // Handlers for messages - virtual bool Configuration(string Message); + virtual bool Configuration(std::string Message); virtual bool Fetch(FetchItem * /*Item*/) {return true;}; // Outgoing messages void Fail(bool Transient = false); - inline void Fail(const char *Why, bool Transient = false) {Fail(string(Why),Transient);}; - virtual void Fail(string Why, bool Transient = false); + inline void Fail(const char *Why, bool Transient = false) {Fail(std::string(Why),Transient);}; + virtual void Fail(std::string Why, bool Transient = false); virtual void URIStart(FetchResult &Res); virtual void URIDone(FetchResult &Res,FetchResult *Alt = 0); - bool MediaFail(string Required,string Drive); + bool MediaFail(std::string Required,std::string Drive); virtual void Exit() {}; void PrintStatus(char const * const header, const char* Format, va_list &args) const; @@ -91,11 +91,11 @@ class pkgAcqMethod void Log(const char *Format,...); void Status(const char *Format,...); - void Redirect(const string &NewURI); + void Redirect(const std::string &NewURI); int Run(bool Single = false); - inline void SetFailReason(string Msg) {FailReason = Msg;}; - inline void SetIP(string aIP) {IP = aIP;}; + inline void SetFailReason(std::string Msg) {FailReason = Msg;}; + inline void SetIP(std::string aIP) {IP = aIP;}; pkgAcqMethod(const char *Ver,unsigned long Flags = 0); virtual ~pkgAcqMethod() {}; diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index ce19091e4..848a6bad7 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -79,7 +79,7 @@ class pkgAcquire::Worker : public WeakPointable * * \todo Doesn't this duplicate Config->Access? */ - string Access; + std::string Access; /** \brief The PID of the subprocess. */ pid_t Process; @@ -118,13 +118,13 @@ class pkgAcquire::Worker : public WeakPointable /** \brief The raw text values of messages received from the * worker, in sequence. */ - vector MessageQueue; + std::vector MessageQueue; /** \brief Buffers pending writes to the subprocess. * * \todo Wouldn't a std::dequeue be more appropriate? */ - string OutQueue; + std::string OutQueue; /** \brief Common code for the constructor. * @@ -183,7 +183,7 @@ class pkgAcquire::Worker : public WeakPointable * * \return \b true. */ - bool Capabilities(string Message); + bool Capabilities(std::string Message); /** \brief Send a 601 Configuration message (containing the APT * configuration) to the subprocess. @@ -214,7 +214,7 @@ class pkgAcquire::Worker : public WeakPointable * 603 Media Changed, with the Failed field set to \b true if the * user cancelled the media change). */ - bool MediaChange(string Message); + bool MediaChange(std::string Message); /** \brief Invoked when the worked process dies unexpectedly. * @@ -242,7 +242,7 @@ class pkgAcquire::Worker : public WeakPointable /** \brief The most recent status string received from the * subprocess. */ - string Status; + std::string Status; /** \brief How many bytes of the file have been downloaded. Zero * if the current progress of the file cannot be determined. diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index ae555df22..93772403d 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -72,10 +72,6 @@ #include #include -using std::vector; -using std::string; - - #include #include @@ -107,8 +103,8 @@ class pkgAcquire friend class Item; friend class Queue; - typedef vector::iterator ItemIterator; - typedef vector::const_iterator ItemCIterator; + typedef std::vector::iterator ItemIterator; + typedef std::vector::const_iterator ItemCIterator; protected: @@ -117,7 +113,7 @@ class pkgAcquire * This is built monotonically as items are created and only * emptied when the download shuts down. */ - vector Items; + std::vector Items; /** \brief The head of the list of active queues. * @@ -202,7 +198,7 @@ class pkgAcquire * \return the string-name of the queue in which a fetch request * for the given URI should be placed. */ - string QueueName(string URI,MethodConfig const *&Config); + std::string QueueName(std::string URI,MethodConfig const *&Config); /** \brief Build up the set of file descriptors upon which select() should * block. @@ -248,7 +244,7 @@ class pkgAcquire * * \return the method whose name is Access, or \b NULL if no such method exists. */ - MethodConfig *GetConfig(string Access); + MethodConfig *GetConfig(std::string Access); /** \brief Provides information on how a download terminated. */ enum RunResult { @@ -319,7 +315,7 @@ class pkgAcquire * * \return \b true if the directory exists and is readable. */ - bool Clean(string Dir); + bool Clean(std::string Dir); /** \return the total size in bytes of all the items included in * this download. @@ -347,7 +343,7 @@ class pkgAcquire * only one Acquire class is in action at the time or an empty string * if no lock file should be used. */ - bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = ""); + bool Setup(pkgAcquireStatus *Progress = NULL, std::string const &Lock = ""); void SetLog(pkgAcquireStatus *Progress) { Log = Progress; } @@ -372,11 +368,11 @@ class pkgAcquire struct pkgAcquire::ItemDesc : public WeakPointable { /** \brief The URI from which to download this item. */ - string URI; + std::string URI; /** brief A description of this item. */ - string Description; + std::string Description; /** brief A shorter description of this item. */ - string ShortDesc; + std::string ShortDesc; /** brief The underlying item which is to be downloaded. */ Item *Owner; }; @@ -420,7 +416,7 @@ class pkgAcquire::Queue }; /** \brief The name of this queue. */ - string Name; + std::string Name; /** \brief The head of the list of items contained in this queue. * @@ -475,7 +471,7 @@ class pkgAcquire::Queue * \return the first item in the queue whose URI is #URI and that * is being downloaded by #Owner. */ - QItem *FindItem(string URI,pkgAcquire::Worker *Owner); + QItem *FindItem(std::string URI,pkgAcquire::Worker *Owner); /** Presumably this should start downloading an item? * @@ -538,7 +534,7 @@ class pkgAcquire::Queue * \param Name The name of the new queue. * \param Owner The download process that owns the new queue. */ - Queue(string Name,pkgAcquire *Owner); + Queue(std::string Name,pkgAcquire *Owner); /** Shut down all the worker processes associated with this queue * and empty the queue. @@ -603,10 +599,10 @@ struct pkgAcquire::MethodConfig MethodConfig *Next; /** \brief The name of this acquire method (e.g., http). */ - string Access; + std::string Access; /** \brief The implementation version of this acquire method. */ - string Version; + std::string Version; /** \brief If \b true, only one download queue should be created for this * method. @@ -748,7 +744,7 @@ class pkgAcquireStatus * \todo This is a horrible blocking monster; it should be CPSed * with prejudice. */ - virtual bool MediaChange(string Media,string Drive) = 0; + virtual bool MediaChange(std::string Media,std::string Drive) = 0; /** \brief Invoked when an item is confirmed to be up-to-date. diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index 86d5fbd53..f299f8189 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -37,8 +37,6 @@ #include -using std::ostream; - class pkgSimulate : public pkgPackageManager /*{{{*/ { protected: @@ -63,13 +61,13 @@ class pkgSimulate : public pkgPackageManager /*{{{*/ pkgDepCache::ActionGroup group; // The Actuall installation implementation - virtual bool Install(PkgIterator Pkg,string File); + virtual bool Install(PkgIterator Pkg,std::string File); virtual bool Configure(PkgIterator Pkg); virtual bool Remove(PkgIterator Pkg,bool Purge); private: void ShortBreaks(); - void Describe(PkgIterator iPkg,ostream &out,bool Current,bool Candidate); + void Describe(PkgIterator iPkg,std::ostream &out,bool Current,bool Candidate); public: diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index e1bc94f31..a0566e05e 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -59,10 +59,10 @@ const Configuration::getCompressionTypes(bool const &Cached) { if ((*o).empty() == true) continue; // ignore types we have no method ready to use - if (_config->Exists(string("Acquire::CompressionTypes::").append(*o)) == false) + if (_config->Exists(std::string("Acquire::CompressionTypes::").append(*o)) == false) continue; // ignore types we have no app ready to use - string const appsetting = string("Dir::Bin::").append(*o); + std::string const appsetting = std::string("Dir::Bin::").append(*o); if (_config->Exists(appsetting) == true) { std::string const app = _config->FindFile(appsetting.c_str(), ""); if (app.empty() == false && FileExists(app) == false) @@ -83,7 +83,7 @@ const Configuration::getCompressionTypes(bool const &Cached) { if (std::find(types.begin(),types.end(),Types->Tag) != types.end()) continue; // ignore types we have no app ready to use - string const appsetting = string("Dir::Bin::").append(Types->Value); + std::string const appsetting = std::string("Dir::Bin::").append(Types->Value); if (appsetting.empty() == false && _config->Exists(appsetting) == true) { std::string const app = _config->FindFile(appsetting.c_str(), ""); if (app.empty() == false && FileExists(app) == false) @@ -95,7 +95,7 @@ const Configuration::getCompressionTypes(bool const &Cached) { // add the special "uncompressed" type if (std::find(types.begin(), types.end(), "uncompressed") == types.end()) { - string const uncompr = _config->FindFile("Dir::Bin::uncompressed", ""); + std::string const uncompr = _config->FindFile("Dir::Bin::uncompressed", ""); if (uncompr.empty() == true || FileExists(uncompr) == true) types.push_back("uncompressed"); } @@ -441,7 +441,7 @@ Configuration::Compressor::Compressor(char const *name, char const *extension, char const *binary, char const *compressArg, char const *uncompressArg, unsigned short const cost) { - std::string const config = string("APT:Compressor::").append(name).append("::"); + std::string const config = std::string("APT:Compressor::").append(name).append("::"); Name = _config->Find(std::string(config).append("Name"), name); Extension = _config->Find(std::string(config).append("Extension"), extension); Binary = _config->Find(std::string(config).append("Binary"), binary); diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index b97a1a589..464b2fdd8 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -111,7 +111,7 @@ class pkgCache::GrpIterator: public Iterator { inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}; inline PkgIterator PackageList() const; - PkgIterator FindPkg(string Arch = "any") const; + PkgIterator FindPkg(std::string Arch = "any") const; /** \brief find the package with the "best" architecture The best architecture is either the "native" or the first @@ -219,7 +219,7 @@ class pkgCache::VerIterator : public Iterator { inline VerFileIterator FileList() const; bool Downloadable() const; inline const char *PriorityType() const {return Owner->Priority(S->Priority);}; - string RelStr() const; + std::string RelStr() const; bool Automatic() const; VerFileIterator NewestFile() const; @@ -365,7 +365,7 @@ class pkgCache::PkgFileIterator : public Iterator inline const char *IndexType() const {return S->IndexType == 0?0:Owner->StrP + S->IndexType;}; bool IsOk(); - string RelStr(); + std::string RelStr(); // Constructors inline PkgFileIterator() : Iterator() {}; diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 614062cbb..2241f1eba 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -6,8 +6,6 @@ #include -using namespace std; - class pkgCdromStatus /*{{{*/ { protected: @@ -20,12 +18,12 @@ class pkgCdromStatus /*{{{*/ // total steps virtual void SetTotal(int total) { totalSteps = total; }; // update steps, will be called regularly as a "pulse" - virtual void Update(string text="", int current=0) = 0; + virtual void Update(std::string text="", int current=0) = 0; // ask for cdrom insert virtual bool ChangeCdrom() = 0; // ask for cdrom name - virtual bool AskCdromName(string &Name) = 0; + virtual bool AskCdromName(std::string &Name) = 0; // Progress indicator for the Index rewriter virtual OpProgress* GetOpProgress() {return NULL; }; }; @@ -47,22 +45,22 @@ class pkgCdrom /*{{{*/ }; - bool FindPackages(string CD, - vector &List, - vector &SList, - vector &SigList, - vector &TransList, - string &InfoDir, pkgCdromStatus *log, + bool FindPackages(std::string CD, + std::vector &List, + std::vector &SList, + std::vector &SigList, + std::vector &TransList, + std::string &InfoDir, pkgCdromStatus *log, unsigned int Depth = 0); - bool DropBinaryArch(vector &List); - bool DropRepeats(vector &List,const char *Name); - void ReduceSourcelist(string CD,vector &List); + bool DropBinaryArch(std::vector &List); + bool DropRepeats(std::vector &List,const char *Name); + void ReduceSourcelist(std::string CD,std::vector &List); bool WriteDatabase(Configuration &Cnf); - bool WriteSourceList(string Name,vector &List,bool Source); - int Score(string Path); + bool WriteSourceList(std::string Name,std::vector &List,bool Source); + int Score(std::string Path); public: - bool Ident(string &ident, pkgCdromStatus *log); + bool Ident(std::string &ident, pkgCdromStatus *log); bool Add(pkgCdromStatus *log); }; /*}}}*/ @@ -71,9 +69,9 @@ class pkgCdrom /*{{{*/ // class that uses libudev to find cdrom/removable devices dynamically struct CdromDevice /*{{{*/ { - string DeviceName; + std::string DeviceName; bool Mounted; - string MountPath; + std::string MountPath; }; /*}}}*/ class pkgUdevCdromDevices /*{{{*/ @@ -104,9 +102,9 @@ class pkgUdevCdromDevices /*{{{*/ // convenience interface, this will just call ScanForRemovable // with "APT::cdrom::CdromOnly" - vector Scan(); + std::vector Scan(); - vector ScanForRemovable(bool CdromOnly); + std::vector ScanForRemovable(bool CdromOnly); }; /*}}}*/ diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index 1f96e941b..f5a939968 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -26,7 +26,7 @@ // --------------------------------------------------------------------- /* Scan the directory for files to erase, we check the version information against our database to see if it is interesting */ -bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache) +bool pkgArchiveCleaner::Go(std::string Dir,pkgCache &Cache) { bool CleanInstalled = _config->FindB("APT::Clean-Installed",true); @@ -34,7 +34,7 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache) if (D == 0) return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); - string StartDir = SafeGetCWD(); + std::string StartDir = SafeGetCWD(); if (chdir(Dir.c_str()) != 0) { closedir(D); @@ -63,21 +63,21 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache) for (; *I != 0 && *I != '_';I++); if (*I != '_') continue; - string Pkg = DeQuoteString(string(Dir->d_name,I-Dir->d_name)); + std::string Pkg = DeQuoteString(std::string(Dir->d_name,I-Dir->d_name)); // Grab the version const char *Start = I + 1; for (I = Start; *I != 0 && *I != '_';I++); if (*I != '_') continue; - string Ver = DeQuoteString(string(Start,I-Start)); + std::string Ver = DeQuoteString(std::string(Start,I-Start)); // Grab the arch Start = I + 1; for (I = Start; *I != 0 && *I != '.' ;I++); if (*I != '.') continue; - string const Arch = DeQuoteString(string(Start,I-Start)); + std::string const Arch = DeQuoteString(std::string(Start,I-Start)); if (APT::Configuration::checkArchitecture(Arch) == false) continue; diff --git a/apt-pkg/clean.h b/apt-pkg/clean.h index 1ebf68dc9..ad4049e83 100644 --- a/apt-pkg/clean.h +++ b/apt-pkg/clean.h @@ -20,11 +20,11 @@ class pkgArchiveCleaner protected: - virtual void Erase(const char * /*File*/,string /*Pkg*/,string /*Ver*/,struct stat & /*St*/) {}; + virtual void Erase(const char * /*File*/,std::string /*Pkg*/,std::string /*Ver*/,struct stat & /*St*/) {}; public: - bool Go(string Dir,pkgCache &Cache); + bool Go(std::string Dir,pkgCache &Cache); virtual ~pkgArchiveCleaner() {}; }; diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 9de795b60..187f6bd59 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -30,6 +30,8 @@ #include /*}}}*/ +using std::string; + // IsMounted - Returns true if the mount point is mounted /*{{{*/ // --------------------------------------------------------------------- /* This is a simple algorithm that should always work, we stat the mount point diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h index 38ed2996e..2c6afac0f 100644 --- a/apt-pkg/contrib/cdromutl.h +++ b/apt-pkg/contrib/cdromutl.h @@ -12,13 +12,11 @@ #include -using std::string; - // mount cdrom, DeviceName (e.g. /dev/sr0) is optional -bool MountCdrom(string Path, string DeviceName=""); -bool UnmountCdrom(string Path); -bool IdentCdrom(string CD,string &Res,unsigned int Version = 2); -bool IsMounted(string &Path); -string FindMountPointForDevice(const char *device); +bool MountCdrom(std::string Path, std::string DeviceName=""); +bool UnmountCdrom(std::string Path); +bool IdentCdrom(std::string CD,std::string &Res,unsigned int Version = 2); +bool IsMounted(std::string &Path); +std::string FindMountPointForDevice(const char *device); #endif diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 2844ec097..f6f2a3c1d 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -34,21 +34,19 @@ #include #include -using std::string; - class Configuration { public: struct Item { - string Value; - string Tag; + std::string Value; + std::string Tag; Item *Parent; Item *Child; Item *Next; - string FullTag(const Item *Stop = 0) const; + std::string FullTag(const Item *Stop = 0) const; Item() : Parent(0), Child(0), Next(0) {}; }; @@ -67,35 +65,35 @@ class Configuration public: - string Find(const char *Name,const char *Default = 0) const; - string Find(string const &Name,const char *Default = 0) const {return Find(Name.c_str(),Default);}; - string Find(string const &Name, string const &Default) const {return Find(Name.c_str(),Default.c_str());}; - string FindFile(const char *Name,const char *Default = 0) const; - string FindDir(const char *Name,const char *Default = 0) const; - std::vector FindVector(const char *Name) const; - std::vector FindVector(string const &Name) const { return FindVector(Name.c_str()); }; + std::string Find(const char *Name,const char *Default = 0) const; + std::string Find(std::string const &Name,const char *Default = 0) const {return Find(Name.c_str(),Default);}; + std::string Find(std::string const &Name, std::string const &Default) const {return Find(Name.c_str(),Default.c_str());}; + std::string FindFile(const char *Name,const char *Default = 0) const; + std::string FindDir(const char *Name,const char *Default = 0) const; + std::vector FindVector(const char *Name) const; + std::vector FindVector(std::string const &Name) const { return FindVector(Name.c_str()); }; int FindI(const char *Name,int const &Default = 0) const; - int FindI(string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);}; + int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);}; bool FindB(const char *Name,bool const &Default = false) const; - bool FindB(string const &Name,bool const &Default = false) const {return FindB(Name.c_str(),Default);}; - string FindAny(const char *Name,const char *Default = 0) const; + bool FindB(std::string const &Name,bool const &Default = false) const {return FindB(Name.c_str(),Default);}; + std::string FindAny(const char *Name,const char *Default = 0) const; - inline void Set(const string &Name,const string &Value) {Set(Name.c_str(),Value);}; - void CndSet(const char *Name,const string &Value); + inline void Set(const std::string &Name,const std::string &Value) {Set(Name.c_str(),Value);}; + void CndSet(const char *Name,const std::string &Value); void CndSet(const char *Name,const int Value); - void Set(const char *Name,const string &Value); + void Set(const char *Name,const std::string &Value); void Set(const char *Name,const int &Value); - inline bool Exists(const string &Name) const {return Exists(Name.c_str());}; + inline bool Exists(const std::string &Name) const {return Exists(Name.c_str());}; bool Exists(const char *Name) const; bool ExistsAny(const char *Name) const; // clear a whole tree - void Clear(const string &Name); + void Clear(const std::string &Name); // remove a certain value from a list (e.g. the list of "APT::Keep-Fds") - void Clear(string const &List, string const &Value); - void Clear(string const &List, int const &Value); + void Clear(std::string const &List, std::string const &Value); + void Clear(std::string const &List, int const &Value); inline const Item *Tree(const char *Name) const {return Lookup(Name);}; @@ -127,11 +125,11 @@ class Configuration extern Configuration *_config; -bool ReadConfigFile(Configuration &Conf,const string &FName, +bool ReadConfigFile(Configuration &Conf,const std::string &FName, bool const &AsSectional = false, unsigned const &Depth = 0); -bool ReadConfigDir(Configuration &Conf,const string &Dir, +bool ReadConfigDir(Configuration &Conf,const std::string &Dir, bool const &AsSectional = false, unsigned const &Depth = 0); diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 973a38cff..0d0451a46 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -31,8 +31,6 @@ /* Define this for python-apt */ #define APT_HAS_GZIP 1 -using std::string; - class FileFd { protected: @@ -41,8 +39,8 @@ class FileFd enum LocalFlags {AutoClose = (1<<0),Fail = (1<<1),DelOnFail = (1<<2), HitEof = (1<<3), Replace = (1<<4) }; unsigned long Flags; - string FileName; - string TemporaryFileName; + std::string FileName; + std::string TemporaryFileName; gzFile gz; public: @@ -79,7 +77,7 @@ class FileFd return T; } - bool Open(string FileName,OpenMode Mode,unsigned long Perms = 0666); + bool Open(std::string FileName,OpenMode Mode,unsigned long Perms = 0666); bool OpenDescriptor(int Fd, OpenMode Mode, bool AutoClose=false); bool Close(); bool Sync(); @@ -93,9 +91,9 @@ class FileFd inline void EraseOnFailure() {Flags |= DelOnFail;}; inline void OpFail() {Flags |= Fail;}; inline bool Eof() {return (Flags & HitEof) == HitEof;}; - inline string &Name() {return FileName;}; + inline std::string &Name() {return FileName;}; - FileFd(string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1), + FileFd(std::string FileName,OpenMode Mode,unsigned long Perms = 0666) : iFd(-1), Flags(0), gz(NULL) { Open(FileName,Mode,Perms); @@ -107,12 +105,12 @@ class FileFd bool RunScripts(const char *Cnf); bool CopyFile(FileFd &From,FileFd &To); -int GetLock(string File,bool Errors = true); -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); +int GetLock(std::string File,bool Errors = true); +bool FileExists(std::string File); +bool RealFileExists(std::string File); +bool DirectoryExists(std::string const &Path) __attrib_const; +bool CreateDirectory(std::string const &Parent, std::string const &Path); +time_t GetModificationTime(std::string const &Path); /** \brief Ensure the existence of the given Path * @@ -120,13 +118,13 @@ time_t GetModificationTime(string const &Path); * /apt/ will be removed before CreateDirectory call. * \param Path which should exist after (successful) call */ -bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path); +bool CreateAPTDirectoryIfNeeded(std::string const &Parent, std::string const &Path); -std::vector GetListOfFilesInDir(string const &Dir, string const &Ext, +std::vector GetListOfFilesInDir(std::string const &Dir, std::string const &Ext, bool const &SortList, bool const &AllowNoExt=false); -std::vector GetListOfFilesInDir(string const &Dir, std::vector const &Ext, +std::vector GetListOfFilesInDir(std::string const &Dir, std::vector const &Ext, bool const &SortList); -string SafeGetCWD(); +std::string SafeGetCWD(); void SetCloseExec(int Fd,bool Close); void SetNonBlock(int Fd,bool Block); bool WaitFd(int Fd,bool write = false,unsigned long timeout = 0); @@ -134,10 +132,10 @@ pid_t ExecFork(); bool ExecWait(pid_t Pid,const char *Name,bool Reap = false); // File string manipulators -string flNotDir(string File); -string flNotFile(string File); -string flNoLink(string File); -string flExtension(string File); -string flCombine(string Dir,string File); +std::string flNotDir(std::string File); +std::string flNotFile(std::string File); +std::string flNoLink(std::string File); +std::string flExtension(std::string File); +std::string flCombine(std::string Dir,std::string File); #endif diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index fd76bf229..05001f042 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -32,20 +32,20 @@ HashString::HashString() { } -HashString::HashString(string Type, string Hash) : Type(Type), Hash(Hash) +HashString::HashString(std::string Type, std::string Hash) : Type(Type), Hash(Hash) { } -HashString::HashString(string StringedHash) /*{{{*/ +HashString::HashString(std::string StringedHash) /*{{{*/ { // legacy: md5sum without "MD5Sum:" prefix - if (StringedHash.find(":") == string::npos && StringedHash.size() == 32) + if (StringedHash.find(":") == std::string::npos && StringedHash.size() == 32) { Type = "MD5Sum"; Hash = StringedHash; return; } - string::size_type pos = StringedHash.find(":"); + std::string::size_type pos = StringedHash.find(":"); Type = StringedHash.substr(0,pos); Hash = StringedHash.substr(pos+1, StringedHash.size() - pos); @@ -53,34 +53,34 @@ HashString::HashString(string StringedHash) /*{{{*/ std::clog << "HashString(string): " << Type << " : " << Hash << std::endl; } /*}}}*/ -bool HashString::VerifyFile(string filename) const /*{{{*/ +bool HashString::VerifyFile(std::string filename) const /*{{{*/ { - string fileHash; + std::string fileHash; FileFd Fd(filename, FileFd::ReadOnly); if(Type == "MD5Sum") { MD5Summation MD5; MD5.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)MD5.Result(); + fileHash = (std::string)MD5.Result(); } else if (Type == "SHA1") { SHA1Summation SHA1; SHA1.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA1.Result(); + fileHash = (std::string)SHA1.Result(); } else if (Type == "SHA256") { SHA256Summation SHA256; SHA256.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA256.Result(); + fileHash = (std::string)SHA256.Result(); } else if (Type == "SHA512") { SHA512Summation SHA512; SHA512.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA512.Result(); + fileHash = (std::string)SHA512.Result(); } Fd.Close(); @@ -100,9 +100,9 @@ bool HashString::empty() const return (Type.empty() || Hash.empty()); } -string HashString::toStr() const +std::string HashString::toStr() const { - return Type+string(":")+Hash; + return Type + std::string(":") + Hash; } // Hashes::AddFD - Add the contents of the FD /*{{{*/ @@ -117,7 +117,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5, while (Size != 0 || ToEOF) { unsigned long long n = sizeof(Buf); - if (!ToEOF) n = min(Size, n); + if (!ToEOF) n = std::min(Size, n); Res = read(Fd,Buf,n); if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 40c2ad064..81851dede 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -22,31 +22,28 @@ #include #include -using std::min; -using std::vector; - // helper class that contains hash function name // and hash class HashString { protected: - string Type; - string Hash; + std::string Type; + std::string Hash; static const char * _SupportedHashes[10]; public: - HashString(string Type, string Hash); - HashString(string StringedHashString); // init from str as "type:hash" + HashString(std::string Type, std::string Hash); + HashString(std::string StringedHashString); // init from str as "type:hash" HashString(); // get hash type used - string HashType() { return Type; }; + std::string HashType() { return Type; }; // verify the given filename against the currently loaded hash - bool VerifyFile(string filename) const; + bool VerifyFile(std::string filename) const; // helper - string toStr() const; // convert to str as "type:hash" + std::string toStr() const; // convert to str as "type:hash" bool empty() const; // return the list of hashes we support diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc index 0edcbb364..ff3b112bb 100644 --- a/apt-pkg/contrib/hashsum.cc +++ b/apt-pkg/contrib/hashsum.cc @@ -14,7 +14,7 @@ bool SummationImplementation::AddFD(int const Fd, unsigned long long Size) { while (Size != 0 || ToEOF) { unsigned long long n = sizeof(Buf); - if (!ToEOF) n = min(Size, n); + if (!ToEOF) n = std::min(Size, n); Res = read(Fd, Buf, n); if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 9157754e3..c109a8212 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -15,9 +15,6 @@ #include #include -using std::string; -using std::min; - template class HashSumValue { @@ -31,7 +28,7 @@ class HashSumValue return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0; }; - string Value() const + std::string Value() const { char Conv[16] = { '0','1','2','3','4','5','6','7','8','9','a','b', @@ -48,7 +45,7 @@ class HashSumValue Result[I] = Conv[Sum[J] >> 4]; Result[I + 1] = Conv[Sum[J] & 0xF]; } - return string(Result); + return std::string(Result); }; inline void Value(unsigned char S[N/8]) @@ -57,12 +54,12 @@ class HashSumValue S[I] = Sum[I]; }; - inline operator string() const + inline operator std::string() const { return Value(); }; - bool Set(string Str) + bool Set(std::string Str) { return Hex2Num(Str,Sum,sizeof(Sum)); }; @@ -73,7 +70,7 @@ class HashSumValue Sum[I] = S[I]; }; - HashSumValue(string Str) + HashSumValue(std::string Str) { memset(Sum,0,sizeof(Sum)); Set(Str); diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h index 305cdb20d..a207da4e4 100644 --- a/apt-pkg/contrib/md5.h +++ b/apt-pkg/contrib/md5.h @@ -29,9 +29,6 @@ #include #include -using std::string; -using std::min; - #include "hashsum_template.h" typedef HashSumValue<128> MD5SumValue; diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index e0ff8db95..387e9a170 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -29,8 +29,6 @@ #include #include -using std::string; - /* This should be a 32 bit type, larger tyes use too much ram and smaller types are too small. Where ever possible 'unsigned long' should be used instead of this internal type */ @@ -102,7 +100,7 @@ class DynamicMMap : public MMap unsigned long RawAllocate(unsigned long long Size,unsigned long Aln = 0); unsigned long Allocate(unsigned long ItemSize); unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1); - inline unsigned long WriteString(const string &S) {return WriteString(S.c_str(),S.length());}; + inline unsigned long WriteString(const std::string &S) {return WriteString(S.c_str(),S.length());}; void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;}; DynamicMMap(FileFd &F,unsigned long Flags,unsigned long const &WorkSpace = 2*1024*1024, diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index b9d0749e2..9aa1376dc 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -24,6 +24,7 @@ #include "netrc.h" +using std::string; /* Get user and password from .netrc when given a machine name */ diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 02a5eb09f..86afa43d1 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -25,5 +25,5 @@ // If login[0] != 0, search for password within machine and login. int parsenetrc (char *host, char *login, char *password, char *filename); -void maybe_add_auth (URI &Uri, string NetRCFile); +void maybe_add_auth (URI &Uri, std::string NetRCFile); #endif diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h index 5344323f6..7635719bc 100644 --- a/apt-pkg/contrib/progress.h +++ b/apt-pkg/contrib/progress.h @@ -25,8 +25,6 @@ #include #include -using std::string; - class Configuration; class OpProgress { @@ -38,13 +36,13 @@ class OpProgress // Change reduction code struct timeval LastTime; - string LastOp; - string LastSubOp; + std::string LastOp; + std::string LastSubOp; protected: - string Op; - string SubOp; + std::string Op; + std::string SubOp; float Percent; bool MajorChange; @@ -55,9 +53,9 @@ class OpProgress public: void Progress(unsigned long long Current); - void SubProgress(unsigned long long SubTotal, const string &Op = "", float const Percent = -1); + void SubProgress(unsigned long long SubTotal, const std::string &Op = "", float const Percent = -1); void OverallProgress(unsigned long long Current,unsigned long long Total, - unsigned long long Size,const string &Op); + unsigned long long Size,const std::string &Op); virtual void Done() {}; OpProgress(); @@ -67,8 +65,8 @@ class OpProgress class OpTextProgress : public OpProgress { protected: - - string OldOp; + + std::string OldOp; bool NoUpdate; bool NoDisplay; unsigned long LastLen; diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h index 916faec1b..b4b139a22 100644 --- a/apt-pkg/contrib/sha1.h +++ b/apt-pkg/contrib/sha1.h @@ -18,9 +18,6 @@ #include #include -using std::string; -using std::min; - #include "hashsum_template.h" typedef HashSumValue<160> SHA1SumValue; diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index ab4b54722..93f4bef4f 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -27,60 +27,56 @@ #include "macros.h" -using std::string; -using std::vector; -using std::ostream; - -bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest); +bool UTF8ToCodeset(const char *codeset, const std::string &orig, std::string *dest); char *_strstrip(char *String); char *_strtabexpand(char *String,size_t Len); -bool ParseQuoteWord(const char *&String,string &Res); -bool ParseCWord(const char *&String,string &Res); -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); +bool ParseQuoteWord(const char *&String,std::string &Res); +bool ParseCWord(const char *&String,std::string &Res); +std::string QuoteString(const std::string &Str,const char *Bad); +std::string DeQuoteString(const std::string &Str); +std::string DeQuoteString(std::string::const_iterator const &begin, std::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); -string OutputInDepth(const unsigned long Depth, const char* Separator=" "); -string URItoFileName(const string &URI); -string TimeRFC1123(time_t Date); +std::string DeEscapeString(const std::string &input); + +std::string SizeToStr(double Bytes); +std::string TimeToStr(unsigned long Sec); +std::string Base64Encode(const std::string &Str); +std::string OutputInDepth(const unsigned long Depth, const char* Separator=" "); +std::string URItoFileName(const std::string &URI); +std::string TimeRFC1123(time_t Date); bool RFC1123StrToTime(const char* const str,time_t &time) __must_check; bool FTPMDTMStrToTime(const char* const str,time_t &time) __must_check; -__deprecated bool StrToTime(const string &Val,time_t &Result); -string LookupTag(const string &Message,const char *Tag,const char *Default = 0); -int StringToBool(const string &Text,int Default = -1); -bool ReadMessages(int Fd, vector &List); +__deprecated bool StrToTime(const std::string &Val,time_t &Result); +std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0); +int StringToBool(const std::string &Text,int Default = -1); +bool ReadMessages(int Fd, std::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 Hex2Num(const std::string &Str,unsigned char *Num,unsigned int Length); bool TokSplitString(char Tok,char *Input,char **List, unsigned long ListMax); -vector VectorizeString(string const &haystack, char const &split) __attrib_const; -void ioprintf(ostream &out,const char *format,...) __like_printf(2); -void strprintf(string &out,const char *format,...) __like_printf(2); +std::vector VectorizeString(std::string const &haystack, char const &split) __attrib_const; +void ioprintf(std::ostream &out,const char *format,...) __like_printf(2); +void strprintf(std::string &out,const char *format,...) __like_printf(2); char *safe_snprintf(char *Buffer,char *End,const char *Format,...) __like_printf(3); -bool CheckDomainList(const string &Host, const string &List); +bool CheckDomainList(const std::string &Host, const std::string &List); int tolower_ascii(int const c) __attrib_const __hot; -string StripEpoch(const string &VerStr); +std::string StripEpoch(const std::string &VerStr); #define APT_MKSTRCMP(name,func) \ inline int name(const char *A,const char *B) {return func(A,A+strlen(A),B,B+strlen(B));}; \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ -inline int name(const string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ -inline int name(const string& A,const string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ -inline int name(const string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; +inline int name(const std::string& A,const char *B) {return func(A.c_str(),A.c_str()+A.length(),B,B+strlen(B));}; \ +inline int name(const std::string& A,const std::string& B) {return func(A.c_str(),A.c_str()+A.length(),B.c_str(),B.c_str()+B.length());}; \ +inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.c_str(),A.c_str()+A.length(),B,BEnd);}; #define APT_MKSTRCMP2(name,func) \ inline int name(const char *A,const char *AEnd,const char *B) {return func(A,AEnd,B,B+strlen(B));}; \ -inline int name(const string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \ -inline int name(const string& A,const string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \ -inline int name(const string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}; +inline int name(const std::string& A,const char *B) {return func(A.begin(),A.end(),B,B+strlen(B));}; \ +inline int name(const std::string& A,const std::string& B) {return func(A.begin(),A.end(),B.begin(),B.end());}; \ +inline int name(const std::string& A,const char *B,const char *BEnd) {return func(A.begin(),A.end(),B,BEnd);}; int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); @@ -89,17 +85,17 @@ int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd) case the definition of string::const_iterator is not the same as const char * and we need these extra functions */ #if __GNUC__ >= 3 -int stringcmp(string::const_iterator A,string::const_iterator AEnd, +int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, const char *B,const char *BEnd); -int stringcmp(string::const_iterator A,string::const_iterator AEnd, - string::const_iterator B,string::const_iterator BEnd); -int stringcasecmp(string::const_iterator A,string::const_iterator AEnd, +int stringcmp(std::string::const_iterator A,std::string::const_iterator AEnd, + std::string::const_iterator B,std::string::const_iterator BEnd); +int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, const char *B,const char *BEnd); -int stringcasecmp(string::const_iterator A,string::const_iterator AEnd, - string::const_iterator B,string::const_iterator BEnd); +int stringcasecmp(std::string::const_iterator A,std::string::const_iterator AEnd, + std::string::const_iterator B,std::string::const_iterator BEnd); -inline int stringcmp(string::const_iterator A,string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}; -inline int stringcasecmp(string::const_iterator A,string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}; +inline int stringcmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcmp(A,Aend,B,B+strlen(B));}; +inline int stringcasecmp(std::string::const_iterator A,std::string::const_iterator Aend,const char *B) {return stringcasecmp(A,Aend,B,B+strlen(B));}; #endif APT_MKSTRCMP2(stringcmp,stringcmp); @@ -109,34 +105,34 @@ inline const char *DeNull(const char *s) {return (s == 0?"(null)":s);}; class URI { - void CopyFrom(const string &From); + void CopyFrom(const std::string &From); public: - string Access; - string User; - string Password; - string Host; - string Path; + std::string Access; + std::string User; + std::string Password; + std::string Host; + std::string Path; unsigned int Port; - operator string(); - inline void operator =(const string &From) {CopyFrom(From);}; + operator std::string(); + inline void operator =(const std::string &From) {CopyFrom(From);}; inline bool empty() {return Access.empty();}; - static string SiteOnly(const string &URI); - static string NoUserPassword(const string &URI); + static std::string SiteOnly(const std::string &URI); + static std::string NoUserPassword(const std::string &URI); - URI(string Path) {CopyFrom(Path);}; + URI(std::string Path) {CopyFrom(Path);}; URI() : Port(0) {}; }; struct SubstVar { const char *Subst; - const string *Contents; + const std::string *Contents; }; -string SubstVar(string Str,const struct SubstVar *Vars); -string SubstVar(const string &Str,const string &Subst,const string &Contents); +std::string SubstVar(std::string Str,const struct SubstVar *Vars); +std::string SubstVar(const std::string &Str,const std::string &Subst,const std::string &Contents); struct RxChoiceList { diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index 678c22473..9e64d4476 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -26,14 +26,14 @@ class debStatusIndex : public pkgIndexFile void *d; protected: - string File; + std::string File; public: virtual const Type *GetType() const; // Interface for acquire - virtual string Describe(bool Short) const {return File;}; + virtual std::string Describe(bool Short) const {return File;}; // Interface for the Cache Generator virtual bool Exists() const; @@ -43,7 +43,7 @@ class debStatusIndex : public pkgIndexFile bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog, unsigned long const Flag) const; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; - debStatusIndex(string File); + debStatusIndex(std::string File); virtual ~debStatusIndex() {}; }; @@ -52,25 +52,25 @@ class debPackagesIndex : public pkgIndexFile /** \brief dpointer placeholder (for later in case we need it) */ void *d; - string URI; - string Dist; - string Section; - string Architecture; + std::string URI; + std::string Dist; + std::string Section; + std::string Architecture; - string Info(const char *Type) const; - string IndexFile(const char *Type) const; - string IndexURI(const char *Type) const; + std::string Info(const char *Type) const; + std::string IndexFile(const char *Type) const; + std::string IndexURI(const char *Type) const; public: virtual const Type *GetType() const; // Stuff for accessing files on remote items - virtual string ArchiveInfo(pkgCache::VerIterator Ver) const; - virtual string ArchiveURI(string File) const {return URI + File;}; + virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const; + virtual std::string ArchiveURI(std::string File) const {return URI + File;}; // Interface for acquire - virtual string Describe(bool Short) const; + virtual std::string Describe(bool Short) const; // Interface for the Cache Generator virtual bool Exists() const; @@ -79,8 +79,8 @@ class debPackagesIndex : public pkgIndexFile virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; - debPackagesIndex(string const &URI, string const &Dist, string const &Section, - bool const &Trusted, string const &Arch = "native"); + debPackagesIndex(std::string const &URI, std::string const &Dist, std::string const &Section, + bool const &Trusted, std::string const &Arch = "native"); virtual ~debPackagesIndex() {}; }; @@ -89,23 +89,23 @@ class debTranslationsIndex : public pkgIndexFile /** \brief dpointer placeholder (for later in case we need it) */ void *d; - string URI; - string Dist; - string Section; + std::string URI; + std::string Dist; + std::string Section; const char * const Language; - string Info(const char *Type) const; - string IndexFile(const char *Type) const; - string IndexURI(const char *Type) const; + std::string Info(const char *Type) const; + std::string IndexFile(const char *Type) const; + std::string IndexURI(const char *Type) const; - inline string TranslationFile() const {return string("Translation-").append(Language);}; + inline std::string TranslationFile() const {return std::string("Translation-").append(Language);}; public: virtual const Type *GetType() const; // Interface for acquire - virtual string Describe(bool Short) const; + virtual std::string Describe(bool Short) const; virtual bool GetIndexes(pkgAcquire *Owner) const; // Interface for the Cache Generator @@ -115,7 +115,7 @@ class debTranslationsIndex : public pkgIndexFile virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; - debTranslationsIndex(string URI,string Dist,string Section, char const * const Language); + debTranslationsIndex(std::string URI,std::string Dist,std::string Section, char const * const Language); virtual ~debTranslationsIndex() {}; }; @@ -124,25 +124,25 @@ class debSourcesIndex : public pkgIndexFile /** \brief dpointer placeholder (for later in case we need it) */ void *d; - string URI; - string Dist; - string Section; + std::string URI; + std::string Dist; + std::string Section; - string Info(const char *Type) const; - string IndexFile(const char *Type) const; - string IndexURI(const char *Type) const; + std::string Info(const char *Type) const; + std::string IndexFile(const char *Type) const; + std::string IndexURI(const char *Type) const; public: virtual const Type *GetType() const; // Stuff for accessing files on remote items - virtual string SourceInfo(pkgSrcRecords::Parser const &Record, + virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record, pkgSrcRecords::File const &File) const; - virtual string ArchiveURI(string File) const {return URI + File;}; + virtual std::string ArchiveURI(std::string File) const {return URI + File;}; // Interface for acquire - virtual string Describe(bool Short) const; + virtual std::string Describe(bool Short) const; // Interface for the record parsers virtual pkgSrcRecords::Parser *CreateSrcParser() const; @@ -152,7 +152,7 @@ class debSourcesIndex : public pkgIndexFile virtual bool HasPackages() const {return false;}; virtual unsigned long Size() const; - debSourcesIndex(string URI,string Dist,string Section,bool Trusted); + debSourcesIndex(std::string URI,std::string Dist,std::string Section,bool Trusted); virtual ~debSourcesIndex() {}; }; diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index a4a974897..95a2e6d47 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -25,6 +25,8 @@ #include /*}}}*/ +using std::string; + static debListParser::WordList PrioList[] = {{"important",pkgCache::State::Important}, {"required",pkgCache::State::Required}, {"standard",pkgCache::State::Standard}, diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 41d712fbf..09858d991 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -34,7 +34,7 @@ class debListParser : public pkgCacheGenerator::ListParser pkgTagFile Tags; pkgTagSection Section; unsigned long iOffset; - string Arch; + std::string Arch; std::vector Architectures; bool MultiArchEnabled; @@ -43,21 +43,21 @@ class debListParser : public pkgCacheGenerator::ListParser bool ParseDepends(pkgCache::VerIterator &Ver,const char *Tag, unsigned int Type); bool ParseProvides(pkgCache::VerIterator &Ver); - bool NewProvidesAllArch(pkgCache::VerIterator &Ver, string const &Package, string const &Version); - static bool GrabWord(string Word,WordList *List,unsigned char &Out); + bool NewProvidesAllArch(pkgCache::VerIterator &Ver, std::string const &Package, std::string const &Version); + static bool GrabWord(std::string Word,WordList *List,unsigned char &Out); public: - static unsigned char GetPrio(string Str); + static unsigned char GetPrio(std::string Str); // These all operate against the current section - virtual string Package(); - virtual string Architecture(); + virtual std::string Package(); + virtual std::string Architecture(); virtual bool ArchitectureAll(); - virtual string Version(); + virtual std::string Version(); virtual bool NewVersion(pkgCache::VerIterator &Ver); - virtual string Description(); - virtual string DescriptionLanguage(); + virtual std::string Description(); + virtual std::string DescriptionLanguage(); virtual MD5SumValue Description_md5(); virtual unsigned short VersionHash(); virtual bool UsePackage(pkgCache::PkgIterator &Pkg, @@ -68,15 +68,15 @@ class debListParser : public pkgCacheGenerator::ListParser virtual bool Step(); bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File, - string section); + std::string section); static const char *ParseDepends(const char *Start,const char *Stop, - string &Package,string &Ver,unsigned int &Op, + std::string &Package,std::string &Ver,unsigned int &Op, bool const &ParseArchFlags = false, bool const &StripMultiArch = true); static const char *ConvertRelation(const char *I,unsigned int &Op); - debListParser(FileFd *File, string const &Arch = ""); + debListParser(FileFd *File, std::string const &Arch = ""); virtual ~debListParser() {}; }; diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 4dfc8b56a..ef6a7ca9d 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -17,6 +17,8 @@ #include /*}}}*/ +using std::string; + // RecordParser::debRecordParser - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -135,8 +137,8 @@ string debRecordParser::LongDesc() orig = Section.FindS("Description").c_str(); else { - vector const lang = APT::Configuration::getLanguages(); - for (vector::const_iterator l = lang.begin(); + std::vector const lang = APT::Configuration::getLanguages(); + for (std::vector::const_iterator l = lang.begin(); orig.empty() && l != lang.end(); ++l) orig = Section.FindS(string("Description-").append(*l).c_str()); } diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index 7868bfa3d..b75726859 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -35,27 +35,27 @@ class debRecordParser : public pkgRecords::Parser public: // These refer to the archive file for the Version - virtual string FileName(); - virtual string MD5Hash(); - virtual string SHA1Hash(); - virtual string SHA256Hash(); - virtual string SHA512Hash(); - virtual string SourcePkg(); - virtual string SourceVer(); + virtual std::string FileName(); + virtual std::string MD5Hash(); + virtual std::string SHA1Hash(); + virtual std::string SHA256Hash(); + virtual std::string SHA512Hash(); + virtual std::string SourcePkg(); + virtual std::string SourceVer(); // These are some general stats about the package - virtual string Maintainer(); - virtual string ShortDesc(); - virtual string LongDesc(); - virtual string Name(); - virtual string Homepage(); + virtual std::string Maintainer(); + virtual std::string ShortDesc(); + virtual std::string LongDesc(); + virtual std::string Name(); + virtual std::string Homepage(); // An arbitrary custom field - virtual string RecordField(const char *fieldName); + virtual std::string RecordField(const char *fieldName); virtual void GetRec(const char *&Start,const char *&Stop); - debRecordParser(string FileName,pkgCache &Cache); + debRecordParser(std::string FileName,pkgCache &Cache); virtual ~debRecordParser() {}; }; diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index c9c20267b..38389e624 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -21,6 +21,8 @@ using std::max; /*}}}*/ +using std::string; + // SrcRecordParser::Binaries - Return the binaries field /*{{{*/ // --------------------------------------------------------------------- /* This member parses the binaries field into a pair of class arrays and @@ -57,7 +59,7 @@ const char **debSrcRecordParser::Binaries() package/version records representing the build dependency. The returned array need not be freed and will be reused by the next call to this function */ -bool debSrcRecordParser::BuildDepends(vector &BuildDeps, +bool debSrcRecordParser::BuildDepends(std::vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch) { unsigned int I; @@ -102,7 +104,7 @@ bool debSrcRecordParser::BuildDepends(vector // --------------------------------------------------------------------- /* This parses the list of files and returns it, each file is required to have a complete source package */ -bool debSrcRecordParser::Files(vector &List) +bool debSrcRecordParser::Files(std::vector &List) { List.erase(List.begin(),List.end()); diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index aa859b0e6..bb588e3d9 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -35,22 +35,22 @@ class debSrcRecordParser : public pkgSrcRecords::Parser virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);}; virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);}; - virtual string Package() const {return Sect.FindS("Package");}; - virtual string Version() const {return Sect.FindS("Version");}; - virtual string Maintainer() const {return Sect.FindS("Maintainer");}; - virtual string Section() const {return Sect.FindS("Section");}; + virtual std::string Package() const {return Sect.FindS("Package");}; + virtual std::string Version() const {return Sect.FindS("Version");}; + virtual std::string Maintainer() const {return Sect.FindS("Maintainer");}; + virtual std::string Section() const {return Sect.FindS("Section");}; virtual const char **Binaries(); - virtual bool BuildDepends(vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true); + virtual bool BuildDepends(std::vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true); virtual unsigned long Offset() {return iOffset;}; - virtual string AsStr() + virtual std::string AsStr() { const char *Start=0,*Stop=0; Sect.GetSection(Start,Stop); - return string(Start,Stop); + return std::string(Start,Stop); }; - virtual bool Files(vector &F); + virtual bool Files(std::vector &F); - debSrcRecordParser(string const &File,pkgIndexFile const *Index) + debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400), Buffer(0), BufSize(0) {} virtual ~debSrcRecordParser(); diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc index 080af5659..7ed6936c3 100644 --- a/apt-pkg/deb/debsystem.cc +++ b/apt-pkg/deb/debsystem.cc @@ -27,6 +27,8 @@ #include /*}}}*/ +using std::string; + debSystem debSys; class debSystemPrivate { @@ -219,7 +221,7 @@ signed debSystem::Score(Configuration const &Cnf) // System::AddStatusFiles - Register the status files /*{{{*/ // --------------------------------------------------------------------- /* */ -bool debSystem::AddStatusFiles(vector &List) +bool debSystem::AddStatusFiles(std::vector &List) { if (d->StatusFile == 0) d->StatusFile = new debStatusIndex(_config->FindFile("Dir::State::status")); diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index ba32b2dd4..859ff6b6d 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -263,7 +263,7 @@ bool debVersioningSystem::CheckDep(const char *PkgVer, // debVS::UpstreamVersion - Return the upstream version string /*{{{*/ // --------------------------------------------------------------------- /* This strips all the debian specific information from the version number */ -string debVersioningSystem::UpstreamVersion(const char *Ver) +std::string debVersioningSystem::UpstreamVersion(const char *Ver) { // Strip off the bit before the first colon const char *I = Ver; @@ -278,6 +278,6 @@ string debVersioningSystem::UpstreamVersion(const char *Ver) if (*I == '-') Last = I - Ver; - return string(Ver,Last); + return std::string(Ver,Last); } /*}}}*/ diff --git a/apt-pkg/deb/debversion.h b/apt-pkg/deb/debversion.h index 56fb67887..24ad73149 100644 --- a/apt-pkg/deb/debversion.h +++ b/apt-pkg/deb/debversion.h @@ -32,7 +32,7 @@ class debVersioningSystem : public pkgVersioningSystem { return DoCmpVersion(A,Aend,B,Bend); } - virtual string UpstreamVersion(const char *A); + virtual std::string UpstreamVersion(const char *A); debVersioningSystem(); }; @@ -53,7 +53,7 @@ inline int pkgVersionCompare(const char *A, const char *AEnd, { return debVS.DoCmpVersion(A,AEnd,B,BEnd); } -inline int pkgVersionCompare(string A,string B) +inline int pkgVersionCompare(std::string A,std::string B) { return debVS.CmpVersion(A,B); } @@ -61,7 +61,7 @@ inline bool pkgCheckDep(const char *DepVer,const char *PkgVer,int Op) { return debVS.CheckDep(PkgVer,Op,DepVer); } -inline string pkgBaseVersion(const char *Ver) +inline std::string pkgBaseVersion(const char *Ver) { return debVS.UpstreamVersion(Ver); } diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 3f95c51dc..6b62360b7 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -15,9 +15,6 @@ #include #include -using std::vector; -using std::map; - class pkgDPkgPMPrivate; class pkgDPkgPM : public pkgPackageManager @@ -38,7 +35,7 @@ class pkgDPkgPM : public pkgPackageManager needs to declare a Replaces on the disappeared package. \param pkgname Name of the package that disappeared */ - void handleDisappearAction(string const &pkgname); + void handleDisappearAction(std::string const &pkgname); protected: int pkgFailures; @@ -53,11 +50,11 @@ class pkgDPkgPM : public pkgPackageManager // the dpkg states that the pkg will run through, the string is // the package, the vector contains the dpkg states that the package // will go through - map > PackageOps; + std::map > PackageOps; // the dpkg states that are already done; the string is the package // the int is the state that is already done (e.g. a package that is // going to be install is already in state "half-installed") - map PackageOpsDone; + std::map PackageOpsDone; // progress reporting unsigned int PackagesDone; @@ -66,19 +63,19 @@ class pkgDPkgPM : public pkgPackageManager struct Item { enum Ops {Install, Configure, Remove, Purge, ConfigurePending, TriggersPending} Op; - string File; + std::string File; PkgIterator Pkg; - Item(Ops Op,PkgIterator Pkg,string File = "") : Op(Op), + Item(Ops Op,PkgIterator Pkg,std::string File = "") : Op(Op), File(File), Pkg(Pkg) {}; Item() {}; }; - vector List; + std::vector List; // Helpers bool RunScriptsWithPkgs(const char *Cnf); bool SendV2Pkgs(FILE *F); - void WriteHistoryTag(string const &tag, string value); + void WriteHistoryTag(std::string const &tag, std::string value); // apport integration void WriteApportReport(const char *pkgpath, const char *errormsg); @@ -94,7 +91,7 @@ class pkgDPkgPM : public pkgPackageManager void ProcessDpkgStatusLine(int OutStatusFd, char *line); // The Actuall installation implementation - virtual bool Install(PkgIterator Pkg,string File); + virtual bool Install(PkgIterator Pkg,std::string File); virtual bool Configure(PkgIterator Pkg); virtual bool Remove(PkgIterator Pkg,bool Purge = false); virtual bool Go(int StatusFd=-1); diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index f816630ae..529085b4a 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -32,6 +32,9 @@ #include /*}}}*/ + +using std::string; + // helper for Install-Recommends-Sections and Never-MarkAuto-Sections /*{{{*/ static bool ConfigValueInSubTree(const char* SubTree, const char *needle) diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 66cb7dbab..5798f0362 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -338,9 +338,9 @@ class pkgDepCache : protected pkgCache::Namespace inline Header &Head() {return *Cache->HeaderP;}; inline GrpIterator GrpBegin() {return Cache->GrpBegin();}; inline PkgIterator PkgBegin() {return Cache->PkgBegin();}; - inline GrpIterator FindGrp(string const &Name) {return Cache->FindGrp(Name);}; - inline PkgIterator FindPkg(string const &Name) {return Cache->FindPkg(Name);}; - inline PkgIterator FindPkg(string const &Name, string const &Arch) {return Cache->FindPkg(Name, Arch);}; + inline GrpIterator FindGrp(std::string const &Name) {return Cache->FindGrp(Name);}; + inline PkgIterator FindPkg(std::string const &Name) {return Cache->FindPkg(Name);}; + inline PkgIterator FindPkg(std::string const &Name, std::string const &Arch) {return Cache->FindPkg(Name, Arch);}; inline pkgCache &GetCache() {return *Cache;}; inline pkgVersioningSystem &VS() {return *Cache->VS;}; diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h index 0053388eb..58a7f62a9 100644 --- a/apt-pkg/edsp/edspindexfile.h +++ b/apt-pkg/edsp/edspindexfile.h @@ -22,7 +22,7 @@ class edspIndex : public debStatusIndex virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const; - edspIndex(string File); + edspIndex(std::string File); }; #endif diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index e00abdbcc..bcfdb1017 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -20,7 +20,7 @@ /*}}}*/ // ListParser::edspListParser - Constructor /*{{{*/ -edspListParser::edspListParser(FileFd *File, string const &Arch) : debListParser(File, Arch) +edspListParser::edspListParser(FileFd *File, std::string const &Arch) : debListParser(File, Arch) {} /*}}}*/ // ListParser::NewVersion - Fill in the version structure /*{{{*/ @@ -33,11 +33,11 @@ bool edspListParser::NewVersion(pkgCache::VerIterator &Ver) // ListParser::Description - Return the description string /*{{{*/ // --------------------------------------------------------------------- /* Sorry, no description for the resolvers… */ -string edspListParser::Description() +std::string edspListParser::Description() { return ""; } -string edspListParser::DescriptionLanguage() +std::string edspListParser::DescriptionLanguage() { return ""; } @@ -85,7 +85,7 @@ bool edspListParser::ParseStatus(pkgCache::PkgIterator &Pkg, /*}}}*/ // ListParser::LoadReleaseInfo - Load the release information /*{{{*/ bool edspListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, - FileFd &File, string component) + FileFd &File, std::string component) { return true; } diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h index ec9f09905..3e196cb9a 100644 --- a/apt-pkg/edsp/edsplistparser.h +++ b/apt-pkg/edsp/edsplistparser.h @@ -20,15 +20,15 @@ class edspListParser : public debListParser { public: virtual bool NewVersion(pkgCache::VerIterator &Ver); - virtual string Description(); - virtual string DescriptionLanguage(); + virtual std::string Description(); + virtual std::string DescriptionLanguage(); virtual MD5SumValue Description_md5(); virtual unsigned short VersionHash(); bool LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,FileFd &File, - string section); + std::string section); - edspListParser(FileFd *File, string const &Arch = ""); + edspListParser(FileFd *File, std::string const &Arch = ""); protected: virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver); diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index 10d75771a..6b9207451 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -97,7 +97,7 @@ signed edspSystem::Score(Configuration const &Cnf) } /*}}}*/ // System::AddStatusFiles - Register the status files /*{{{*/ -bool edspSystem::AddStatusFiles(vector &List) +bool edspSystem::AddStatusFiles(std::vector &List) { if (StatusFile == 0) { diff --git a/apt-pkg/indexcopy.h b/apt-pkg/indexcopy.h index 60c90dd4a..21294ae7e 100644 --- a/apt-pkg/indexcopy.h +++ b/apt-pkg/indexcopy.h @@ -14,9 +14,6 @@ #include #include -using std::string; -using std::vector; - class pkgTagSection; class FileFd; class indexRecords; @@ -31,20 +28,20 @@ class IndexCopy /*{{{*/ pkgTagSection *Section; - string ChopDirs(string Path,unsigned int Depth); - bool ReconstructPrefix(string &Prefix,string OrigPath,string CD, - string File); - bool ReconstructChop(unsigned long &Chop,string Dir,string File); - void ConvertToSourceList(string CD,string &Path); - bool GrabFirst(string Path,string &To,unsigned int Depth); - virtual bool GetFile(string &Filename,unsigned long long &Size) = 0; - virtual bool RewriteEntry(FILE *Target,string File) = 0; + std::string ChopDirs(std::string Path,unsigned int Depth); + bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD, + std::string File); + bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File); + void ConvertToSourceList(std::string CD,std::string &Path); + bool GrabFirst(std::string Path,std::string &To,unsigned int Depth); + virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0; + virtual bool RewriteEntry(FILE *Target,std::string File) = 0; virtual const char *GetFileName() = 0; virtual const char *Type() = 0; public: - bool CopyPackages(string CDROM,string Name,vector &List, + bool CopyPackages(std::string CDROM,std::string Name,std::vector &List, pkgCdromStatus *log); virtual ~IndexCopy() {}; }; @@ -53,8 +50,8 @@ class PackageCopy : public IndexCopy /*{{{*/ { protected: - virtual bool GetFile(string &Filename,unsigned long long &Size); - virtual bool RewriteEntry(FILE *Target,string File); + virtual bool GetFile(std::string &Filename,unsigned long long &Size); + virtual bool RewriteEntry(FILE *Target,std::string File); virtual const char *GetFileName() {return "Packages";}; virtual const char *Type() {return "Package";}; @@ -64,8 +61,8 @@ class SourceCopy : public IndexCopy /*{{{*/ { protected: - virtual bool GetFile(string &Filename,unsigned long long &Size); - virtual bool RewriteEntry(FILE *Target,string File); + virtual bool GetFile(std::string &Filename,unsigned long long &Size); + virtual bool RewriteEntry(FILE *Target,std::string File); virtual const char *GetFileName() {return "Sources";}; virtual const char *Type() {return "Source";}; @@ -77,7 +74,7 @@ class TranslationsCopy /*{{{*/ pkgTagSection *Section; public: - bool CopyTranslations(string CDROM,string Name,vector &List, + bool CopyTranslations(std::string CDROM,std::string Name,std::vector &List, pkgCdromStatus *log); }; /*}}}*/ @@ -86,13 +83,13 @@ class SigVerify /*{{{*/ /** \brief dpointer placeholder (for later in case we need it) */ void *d; - bool Verify(string prefix,string file, indexRecords *records); - bool CopyMetaIndex(string CDROM, string CDName, - string prefix, string file); + bool Verify(std::string prefix,std::string file, indexRecords *records); + bool CopyMetaIndex(std::string CDROM, std::string CDName, + std::string prefix, std::string file); public: - bool CopyAndVerify(string CDROM,string Name,vector &SigList, - vector PkgList,vector SrcList); + bool CopyAndVerify(std::string CDROM,std::string Name,std::vector &SigList, + std::vector PkgList,std::vector SrcList); /** \brief generates and run the command to verify a file with gpgv */ static bool RunGPGV(std::string const &File, std::string const &FileOut, diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 68e9df4c8..642a750d4 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -47,9 +47,9 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type) // IndexFile::ArchiveInfo - Stub /*{{{*/ // --------------------------------------------------------------------- /* */ -string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const +std::string pkgIndexFile::ArchiveInfo(pkgCache::VerIterator Ver) const { - return string(); + return std::string(); } /*}}}*/ // IndexFile::FindInCache - Stub /*{{{*/ @@ -63,10 +63,10 @@ pkgCache::PkgFileIterator pkgIndexFile::FindInCache(pkgCache &Cache) const // IndexFile::SourceIndex - Stub /*{{{*/ // --------------------------------------------------------------------- /* */ -string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record, +std::string pkgIndexFile::SourceInfo(pkgSrcRecords::Parser const &Record, pkgSrcRecords::File const &File) const { - return string(); + return std::string(); } /*}}}*/ // IndexFile::TranslationsAvailable - Check if will use Translation /*{{{*/ @@ -98,7 +98,7 @@ __attribute__ ((deprecated)) bool pkgIndexFile::CheckLanguageCode(const char *La /* As we have now possibly more than one LanguageCode this method is supersided by a) private classmembers or b) getLanguages(). TODO: Remove method with next API break */ -__attribute__ ((deprecated)) string pkgIndexFile::LanguageCode() { +__attribute__ ((deprecated)) std::string pkgIndexFile::LanguageCode() { if (TranslationsAvailable() == false) return ""; return APT::Configuration::getLanguages()[0]; diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index 2b5ae6342..68d53ad7e 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -27,8 +27,6 @@ #include #include #include - -using std::string; class pkgAcquire; class pkgCacheGenerator; @@ -59,13 +57,13 @@ class pkgIndexFile virtual const Type *GetType() const = 0; // Return descriptive strings of various sorts - virtual string ArchiveInfo(pkgCache::VerIterator Ver) const; - virtual string SourceInfo(pkgSrcRecords::Parser const &Record, + virtual std::string ArchiveInfo(pkgCache::VerIterator Ver) const; + virtual std::string SourceInfo(pkgSrcRecords::Parser const &Record, pkgSrcRecords::File const &File) const; - virtual string Describe(bool Short = false) const = 0; + virtual std::string Describe(bool Short = false) const = 0; // Interface for acquire - virtual string ArchiveURI(string /*File*/) const {return string();}; + virtual std::string ArchiveURI(std::string /*File*/) const {return std::string();}; // Interface for the record parsers virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;}; @@ -84,7 +82,7 @@ class pkgIndexFile static bool TranslationsAvailable(); static bool CheckLanguageCode(const char *Lang); - static string LanguageCode(); + static std::string LanguageCode(); bool IsTrusted() const { return Trusted; }; diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 448a76c27..7b48d659e 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -15,6 +15,9 @@ #include /*}}}*/ + +using std::string; + string indexRecords::GetDist() const { return this->Dist; @@ -146,7 +149,7 @@ bool indexRecords::Load(const string Filename) /*{{{*/ return true; } /*}}}*/ -vector indexRecords::MetaKeys() /*{{{*/ +std::vector indexRecords::MetaKeys() /*{{{*/ { std::vector keys; std::map::iterator I = Entries.begin(); diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index 0f933b93c..66b84f8bb 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -16,42 +16,42 @@ class indexRecords { - bool parseSumData(const char *&Start, const char *End, string &Name, - string &Hash, unsigned long long &Size); + bool parseSumData(const char *&Start, const char *End, std::string &Name, + std::string &Hash, unsigned long long &Size); public: struct checkSum; - string ErrorText; + std::string ErrorText; protected: - string Dist; - string Suite; - string ExpectedDist; + std::string Dist; + std::string Suite; + std::string ExpectedDist; time_t ValidUntil; - std::map Entries; + std::map Entries; public: indexRecords(); - indexRecords(const string ExpectedDist); + indexRecords(const std::string ExpectedDist); // Lookup function - virtual const checkSum *Lookup(const string MetaKey); + virtual const checkSum *Lookup(const std::string MetaKey); /** \brief tests if a checksum for this file is available */ - bool Exists(string const &MetaKey) const; + bool Exists(std::string const &MetaKey) const; std::vector MetaKeys(); - virtual bool Load(string Filename); - string GetDist() const; + virtual bool Load(std::string Filename); + std::string GetDist() const; time_t GetValidUntil() const; - virtual bool CheckDist(const string MaybeDist) const; - string GetExpectedDist() const; + virtual bool CheckDist(const std::string MaybeDist) const; + std::string GetExpectedDist() const; virtual ~indexRecords(){}; }; struct indexRecords::checkSum { - string MetaKeyFilename; + std::string MetaKeyFilename; HashString Hash; unsigned long long Size; }; diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 97a39e96e..a1cb05e38 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -108,14 +108,14 @@ bool pkgInitConfig(Configuration &Cnf) } // Read the configuration parts dir - string Parts = Cnf.FindDir("Dir::Etc::parts"); + std::string Parts = Cnf.FindDir("Dir::Etc::parts"); if (DirectoryExists(Parts) == true) Res &= ReadConfigDir(Cnf,Parts); else _error->WarningE("DirectoryExists",_("Unable to read %s"),Parts.c_str()); // Read the main config file - string FName = Cnf.FindFile("Dir::Etc::main"); + std::string FName = Cnf.FindFile("Dir::Etc::main"); if (RealFileExists(FName) == true) Res &= ReadConfigFile(Cnf,FName); @@ -142,7 +142,7 @@ bool pkgInitConfig(Configuration &Cnf) bool pkgInitSystem(Configuration &Cnf,pkgSystem *&Sys) { Sys = 0; - string Label = Cnf.Find("Apt::System",""); + std::string Label = Cnf.Find("Apt::System",""); if (Label.empty() == false) { Sys = pkgSystem::GetSystem(Label.c_str()); diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index f60235a5d..66c287c30 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -8,8 +8,6 @@ #include #include #include - -using std::string; class pkgAcquire; class pkgCacheGenerator; @@ -18,35 +16,35 @@ class OpProgress; class metaIndex { protected: - vector *Indexes; + std::vector *Indexes; const char *Type; - string URI; - string Dist; + std::string URI; + std::string Dist; bool Trusted; public: // Various accessors - virtual string GetURI() const {return URI;} - virtual string GetDist() const {return Dist;} + virtual std::string GetURI() const {return URI;} + virtual std::string GetDist() const {return Dist;} virtual const char* GetType() const {return Type;} // Interface for acquire - virtual string ArchiveURI(string const& /*File*/) const = 0; + virtual std::string ArchiveURI(std::string const& /*File*/) const = 0; virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0; - virtual vector *GetIndexFiles() = 0; + virtual std::vector *GetIndexFiles() = 0; virtual bool IsTrusted() const = 0; - metaIndex(string const &URI, string const &Dist, char const * const Type) : + metaIndex(std::string const &URI, std::string const &Dist, char const * const Type) : Indexes(NULL), Type(Type), URI(URI), Dist(Dist) { } virtual ~metaIndex() { if (Indexes == 0) return; - for (vector::iterator I = (*Indexes).begin(); I != (*Indexes).end(); ++I) + for (std::vector::iterator I = (*Indexes).begin(); I != (*Indexes).end(); ++I) delete *I; delete Indexes; } diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h index 9588d30a5..a2d7b321b 100644 --- a/apt-pkg/orderlist.h +++ b/apt-pkg/orderlist.h @@ -38,7 +38,7 @@ class pkgOrderList : protected pkgCache::Namespace Package **End; Package **List; Package **AfterEnd; - string *FileList; + std::string *FileList; DepIterator Loops[20]; int LoopCount; int Depth; @@ -102,7 +102,7 @@ class pkgOrderList : protected pkgCache::Namespace inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;}; bool IsMissing(PkgIterator Pkg); void WipeFlags(unsigned long F); - void SetFileList(string *FileList) {this->FileList = FileList;}; + void SetFileList(std::string *FileList) {this->FileList = FileList;}; // Accessors inline iterator begin() {return List;}; @@ -115,7 +115,7 @@ class pkgOrderList : protected pkgCache::Namespace // Ordering modes bool OrderCritical(); - bool OrderUnpack(string *FileList = 0); + bool OrderUnpack(std::string *FileList = 0); bool OrderConfigure(); int Score(PkgIterator Pkg); diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 96dc5f236..7ee17942c 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -30,8 +30,6 @@ #include #include -using std::string; - class pkgAcquire; class pkgDepCache; class pkgSourceList; @@ -45,7 +43,7 @@ class pkgPackageManager : protected pkgCache::Namespace static bool SigINTStop; protected: - string *FileNames; + std::string *FileNames; pkgDepCache &Cache; pkgOrderList *List; bool Debug; @@ -78,7 +76,7 @@ class pkgPackageManager : protected pkgCache::Namespace bool EarlyRemove(PkgIterator Pkg); // The Actual installation implementation - virtual bool Install(PkgIterator /*Pkg*/,string /*File*/) {return false;}; + virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;}; virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; virtual bool Go(int statusFd=-1) {return true;}; diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 089648271..40b99891a 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -490,7 +490,7 @@ pkgCache::PkgIterator::CurVersion() const if they provide no new information (e.g. there is no newer version than candidate) If no version and/or section can be found "none" is used. */ std::ostream& -operator<<(ostream& out, pkgCache::PkgIterator Pkg) +operator<<(std::ostream& out, pkgCache::PkgIterator Pkg) { if (Pkg.end() == true) return out << "invalid package"; @@ -685,7 +685,7 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End) // ostream operator to handle string representation of a dependecy /*{{{*/ // --------------------------------------------------------------------- /* */ -std::ostream& operator<<(ostream& out, pkgCache::DepIterator D) +std::ostream& operator<<(std::ostream& out, pkgCache::DepIterator D) { if (D.end() == true) return out << "invalid dependency"; diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h index 87912aead..7e32a3a96 100644 --- a/apt-pkg/pkgcache.h +++ b/apt-pkg/pkgcache.h @@ -79,8 +79,6 @@ #include #include -using std::string; - class pkgVersioningSystem; class pkgCache /*{{{*/ { @@ -152,10 +150,10 @@ class pkgCache /*{{{*/ protected: // Memory mapped cache file - string CacheFile; + std::string CacheFile; MMap ⤅ - unsigned long sHash(const string &S) const; + unsigned long sHash(const std::string &S) const; unsigned long sHash(const char *S) const; public: @@ -180,16 +178,16 @@ class pkgCache /*{{{*/ inline void *DataEnd() {return ((unsigned char *)Map.Data()) + Map.Size();}; // String hashing function (512 range) - inline unsigned long Hash(const string &S) const {return sHash(S);}; + inline unsigned long Hash(const std::string &S) const {return sHash(S);}; inline unsigned long Hash(const char *S) const {return sHash(S);}; // Useful transformation things const char *Priority(unsigned char Priority); // Accessors - GrpIterator FindGrp(const string &Name); - PkgIterator FindPkg(const string &Name); - PkgIterator FindPkg(const string &Name, const string &Arch); + GrpIterator FindGrp(const std::string &Name); + PkgIterator FindPkg(const std::string &Name); + PkgIterator FindPkg(const std::string &Name, const std::string &Arch); Header &Head() {return *HeaderP;}; inline GrpIterator GrpBegin(); @@ -214,7 +212,7 @@ class pkgCache /*{{{*/ private: bool MultiArchEnabled; - PkgIterator SingleArchFindPkg(const string &Name); + PkgIterator SingleArchFindPkg(const std::string &Name); inline char const * const NativeArch() const; }; /*}}}*/ diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index c26051182..af9c2bcb0 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -63,29 +63,29 @@ class pkgCacheGenerator /*{{{*/ pkgCache Cache; OpProgress *Progress; - string PkgFileName; + std::string PkgFileName; pkgCache::PackageFile *CurrentFile; // Flag file dependencies bool FoundFileDeps; - bool NewGroup(pkgCache::GrpIterator &Grp,const string &Name); - bool NewPackage(pkgCache::PkgIterator &Pkg,const string &Name, const string &Arch); + bool NewGroup(pkgCache::GrpIterator &Grp,const std::string &Name); + bool NewPackage(pkgCache::PkgIterator &Pkg,const std::string &Name, const std::string &Arch); bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); bool NewDepends(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver, - string const &Version, unsigned int const &Op, + std::string const &Version, unsigned int const &Op, unsigned int const &Type, map_ptrloc* &OldDepLast); - unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next); - map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next); + unsigned long NewVersion(pkgCache::VerIterator &Ver,const std::string &VerStr,unsigned long Next); + map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const std::string &Lang,const MD5SumValue &md5sum,map_ptrloc Next); public: unsigned long WriteUniqString(const char *S,unsigned int Size); - inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());}; + inline unsigned long WriteUniqString(const std::string &S) {return WriteUniqString(S.c_str(),S.length());}; void DropProgress() {Progress = 0;}; - bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index, + bool SelectFile(const std::string &File,const std::string &Site,pkgIndexFile const &Index, unsigned long Flags = 0); bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0); inline pkgCache &GetCache() {return Cache;}; @@ -122,26 +122,26 @@ class pkgCacheGenerator::ListParser protected: - inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; + inline unsigned long WriteUniqString(std::string S) {return Owner->WriteUniqString(S);}; inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; - inline unsigned long WriteString(const string &S) {return Owner->WriteStringInMap(S);}; + inline unsigned long WriteString(const std::string &S) {return Owner->WriteStringInMap(S);}; inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->WriteStringInMap(S,Size);}; - bool NewDepends(pkgCache::VerIterator &Ver,const string &Package, const string &Arch, - const string &Version,unsigned int Op, + bool NewDepends(pkgCache::VerIterator &Ver,const std::string &Package, const std::string &Arch, + const std::string &Version,unsigned int Op, unsigned int Type); - bool NewProvides(pkgCache::VerIterator &Ver,const string &PkgName, - const string &PkgArch, const string &Version); + bool NewProvides(pkgCache::VerIterator &Ver,const std::string &PkgName, + const std::string &PkgArch, const std::string &Version); public: // These all operate against the current section - virtual string Package() = 0; - virtual string Architecture() = 0; + virtual std::string Package() = 0; + virtual std::string Architecture() = 0; virtual bool ArchitectureAll() = 0; - virtual string Version() = 0; + virtual std::string Version() = 0; virtual bool NewVersion(pkgCache::VerIterator &Ver) = 0; - virtual string Description() = 0; - virtual string DescriptionLanguage() = 0; + virtual std::string Description() = 0; + virtual std::string DescriptionLanguage() = 0; virtual MD5SumValue Description_md5() = 0; virtual unsigned short VersionHash() = 0; virtual bool UsePackage(pkgCache::PkgIterator &Pkg, diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index 7709f133a..c5b3bebd7 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -46,7 +46,7 @@ pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), /* */ pkgRecords::~pkgRecords() { - for ( vector::iterator it = Files.begin(); + for ( std::vector::iterator it = Files.begin(); it != Files.end(); ++it) { diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h index 8741533b9..3658435e8 100644 --- a/apt-pkg/pkgrecords.h +++ b/apt-pkg/pkgrecords.h @@ -54,23 +54,23 @@ class pkgRecords::Parser /*{{{*/ friend class pkgRecords; // These refer to the archive file for the Version - virtual string FileName() {return string();}; - virtual string MD5Hash() {return string();}; - virtual string SHA1Hash() {return string();}; - virtual string SHA256Hash() {return string();}; - virtual string SHA512Hash() {return string();}; - virtual string SourcePkg() {return string();}; - virtual string SourceVer() {return string();}; + virtual std::string FileName() {return std::string();}; + virtual std::string MD5Hash() {return std::string();}; + virtual std::string SHA1Hash() {return std::string();}; + virtual std::string SHA256Hash() {return std::string();}; + virtual std::string SHA512Hash() {return std::string();}; + virtual std::string SourcePkg() {return std::string();}; + virtual std::string SourceVer() {return std::string();}; // These are some general stats about the package - virtual string Maintainer() {return string();}; - virtual string ShortDesc() {return string();}; - virtual string LongDesc() {return string();}; - virtual string Name() {return string();}; - virtual string Homepage() {return string();} + virtual std::string Maintainer() {return std::string();}; + virtual std::string ShortDesc() {return std::string();}; + virtual std::string LongDesc() {return std::string();}; + virtual std::string Name() {return std::string();}; + virtual std::string Homepage() {return std::string();} // An arbitrary custom field - virtual string RecordField(const char *fieldName) { return string();}; + virtual std::string RecordField(const char *fieldName) { return std::string();}; // The record in binary form virtual void GetRec(const char *&Start,const char *&Stop) {Start = Stop = 0;}; diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h index 92d32728f..3c8246e3b 100644 --- a/apt-pkg/policy.h +++ b/apt-pkg/policy.h @@ -38,8 +38,6 @@ #include #include -using std::vector; - class pkgPolicy : public pkgDepCache::Policy { protected: @@ -47,29 +45,29 @@ class pkgPolicy : public pkgDepCache::Policy struct Pin { pkgVersionMatch::MatchType Type; - string Data; + std::string Data; signed short Priority; Pin() : Type(pkgVersionMatch::None), Priority(0) {}; }; struct PkgPin : Pin { - string Pkg; - PkgPin(string const &Pkg) : Pin(), Pkg(Pkg) {}; + std::string Pkg; + PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {}; }; Pin *Pins; signed short *PFPriority; - vector Defaults; - vector Unmatched; + std::vector Defaults; + std::vector Unmatched; pkgCache *Cache; bool StatusOverride; public: // Things for manipulating pins - void CreatePin(pkgVersionMatch::MatchType Type,string Pkg, - string Data,signed short Priority); + void CreatePin(pkgVersionMatch::MatchType Type,std::string Pkg, + std::string Data,signed short Priority); pkgCache::VerIterator GetMatch(pkgCache::PkgIterator const &Pkg); // Things for the cache interface. @@ -83,7 +81,7 @@ class pkgPolicy : public pkgDepCache::Policy virtual ~pkgPolicy() {delete [] PFPriority; delete [] Pins;}; }; -bool ReadPinFile(pkgPolicy &Plcy,string File = ""); -bool ReadPinDir(pkgPolicy &Plcy,string Dir = ""); +bool ReadPinFile(pkgPolicy &Plcy, std::string File = ""); +bool ReadPinDir(pkgPolicy &Plcy, std::string Dir = ""); #endif diff --git a/apt-pkg/srcrecords.h b/apt-pkg/srcrecords.h index 8a78d7711..a55bc74fa 100644 --- a/apt-pkg/srcrecords.h +++ b/apt-pkg/srcrecords.h @@ -15,10 +15,7 @@ #include -#include - -using std::string; -using std::vector; +#include class pkgSourceList; class pkgIndexFile; @@ -29,10 +26,10 @@ class pkgSrcRecords // Describes a single file struct File { - string MD5Hash; + std::string MD5Hash; unsigned long Size; - string Path; - string Type; + std::string Path; + std::string Type; }; // Abstract parser for each source record @@ -49,8 +46,8 @@ class pkgSrcRecords struct BuildDepRec { - string Package; - string Version; + std::string Package; + std::string Version; unsigned int Op; unsigned char Type; }; @@ -61,18 +58,18 @@ class pkgSrcRecords virtual bool Step() = 0; virtual bool Jump(unsigned long const &Off) = 0; virtual unsigned long Offset() = 0; - virtual string AsStr() = 0; + virtual std::string AsStr() = 0; - virtual string Package() const = 0; - virtual string Version() const = 0; - virtual string Maintainer() const = 0; - virtual string Section() const = 0; + virtual std::string Package() const = 0; + virtual std::string Version() const = 0; + virtual std::string Maintainer() const = 0; + virtual std::string Section() const = 0; virtual const char **Binaries() = 0; // Ownership does not transfer - virtual bool BuildDepends(vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0; + virtual bool BuildDepends(std::vector &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) = 0; static const char *BuildDepType(unsigned char const &Type); - virtual bool Files(vector &F) = 0; + virtual bool Files(std::vector &F) = 0; Parser(const pkgIndexFile *Index) : iIndex(Index) {}; virtual ~Parser() {}; @@ -83,8 +80,8 @@ class pkgSrcRecords void *d; // The list of files and the current parser pointer - vector Files; - vector::iterator Current; + std::vector Files; + std::vector::iterator Current; public: diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index 28f7fcc24..e3034b628 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -54,7 +54,7 @@ class pkgTagSection bool Find(const char *Tag,const char *&Start, const char *&End) const; bool Find(const char *Tag,unsigned &Pos) const; - string FindS(const char *Tag) const; + std::string FindS(const char *Tag) const; signed int FindI(const char *Tag,signed long Default = 0) const ; unsigned long long FindULL(const char *Tag, unsigned long long const &Default = 0) const; bool FindFlag(const char *Tag,unsigned long &Flags, diff --git a/apt-pkg/vendor.cc b/apt-pkg/vendor.cc index eab6d448f..36fc25957 100644 --- a/apt-pkg/vendor.cc +++ b/apt-pkg/vendor.cc @@ -22,16 +22,16 @@ Vendor::Vendor(std::string VendorID, delete FingerprintList; } -const string Vendor::LookupFingerprint(string Print) const +const std::string Vendor::LookupFingerprint(std::string Print) const { - std::map::const_iterator Elt = Fingerprints.find(Print); + std::map::const_iterator Elt = Fingerprints.find(Print); if (Elt == Fingerprints.end()) return ""; else return (*Elt).second; } -bool Vendor::CheckDist(string Dist) +bool Vendor::CheckDist(std::string Dist) { return true; } diff --git a/apt-pkg/vendor.h b/apt-pkg/vendor.h index df229737a..9b157378c 100644 --- a/apt-pkg/vendor.h +++ b/apt-pkg/vendor.h @@ -6,29 +6,27 @@ #include -using std::string; - -// A class representing a particular software provider. +// A class representing a particular software provider. class __deprecated Vendor { public: struct Fingerprint { - string Print; - string Description; + std::string Print; + std::string Description; }; protected: - string VendorID; - string Origin; - std::map Fingerprints; + std::string VendorID; + std::string Origin; + std::map Fingerprints; public: - Vendor(string VendorID, string Origin, + Vendor(std::string VendorID, std::string Origin, std::vector *FingerprintList); - virtual const string& GetVendorID() const { return VendorID; }; - virtual const string LookupFingerprint(string Print) const; - virtual bool CheckDist(string Dist); + virtual const std::string& GetVendorID() const { return VendorID; }; + virtual const std::string LookupFingerprint(std::string Print) const; + virtual bool CheckDist(std::string Dist); virtual ~Vendor(){}; }; diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 731f11acf..2ccb556ab 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -10,6 +10,9 @@ #include +using std::string; +using std::vector; + pkgVendorList::~pkgVendorList() { for (vector::const_iterator I = VendorList.begin(); diff --git a/apt-pkg/vendorlist.h b/apt-pkg/vendorlist.h index eaeecb173..62ab78a33 100644 --- a/apt-pkg/vendorlist.h +++ b/apt-pkg/vendorlist.h @@ -19,22 +19,18 @@ #include #include -using std::string; -using std::vector; - - class __deprecated pkgVendorList { protected: - vector VendorList; + std::vector VendorList; bool CreateList(Configuration& Cnf); - const Vendor* LookupFingerprint(string Fingerprint); + const Vendor* LookupFingerprint(std::string Fingerprint); public: - typedef vector::const_iterator const_iterator; + typedef std::vector::const_iterator const_iterator; bool ReadMainList(); - bool Read(string File); + bool Read(std::string File); // List accessors inline const_iterator begin() const {return VendorList.begin();}; @@ -42,7 +38,7 @@ class __deprecated pkgVendorList inline unsigned int size() const {return VendorList.size();}; inline bool empty() const {return VendorList.empty();}; - const Vendor* FindVendor(const vector GPGVOutput); + const Vendor* FindVendor(const std::vector GPGVOutput); ~pkgVendorList(); }; diff --git a/apt-pkg/version.h b/apt-pkg/version.h index 49c53a93a..c9257d116 100644 --- a/apt-pkg/version.h +++ b/apt-pkg/version.h @@ -24,8 +24,6 @@ #include #include -using std::string; - class pkgVersioningSystem { public: @@ -43,7 +41,7 @@ class pkgVersioningSystem virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer) = 0; virtual int DoCmpReleaseVer(const char *A,const char *Aend, const char *B,const char *Bend) = 0; - virtual string UpstreamVersion(const char *A) = 0; + virtual std::string UpstreamVersion(const char *A) = 0; // See if the given VS is compatible with this one.. virtual bool TestCompatibility(pkgVersioningSystem const &Against) diff --git a/apt-pkg/versionmatch.cc b/apt-pkg/versionmatch.cc index f336b3c35..e4fa0ea65 100644 --- a/apt-pkg/versionmatch.cc +++ b/apt-pkg/versionmatch.cc @@ -24,6 +24,8 @@ #include /*}}}*/ +using std::string; + // VersionMatch::pkgVersionMatch - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Break up the data string according to the selected type */ diff --git a/apt-pkg/versionmatch.h b/apt-pkg/versionmatch.h index 39639a23d..da103fc5b 100644 --- a/apt-pkg/versionmatch.h +++ b/apt-pkg/versionmatch.h @@ -39,40 +39,38 @@ #include #include -using std::string; - class pkgVersionMatch { // Version Matching - string VerStr; + std::string VerStr; bool VerPrefixMatch; // Release Matching - string RelVerStr; + std::string RelVerStr; bool RelVerPrefixMatch; - string RelOrigin; - string RelRelease; - string RelCodename; - string RelArchive; - string RelLabel; - string RelComponent; - string RelArchitecture; + std::string RelOrigin; + std::string RelRelease; + std::string RelCodename; + std::string RelArchive; + std::string RelLabel; + std::string RelComponent; + std::string RelArchitecture; bool MatchAll; // Origin Matching - string OrSite; + std::string OrSite; public: enum MatchType {None = 0,Version,Release,Origin} Type; - bool MatchVer(const char *A,string B,bool Prefix); + bool MatchVer(const char *A,std::string B,bool Prefix); bool ExpressionMatches(const char *pattern, const char *string); bool ExpressionMatches(const std::string& pattern, const char *string); bool FileMatch(pkgCache::PkgFileIterator File); pkgCache::VerIterator Find(pkgCache::PkgIterator Pkg); - pkgVersionMatch(string Data,MatchType Type); + pkgVersionMatch(std::string Data,MatchType Type); }; #endif -- cgit v1.2.3 From 472ff00ef2e48383805d281c6364ec27839e3f4d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 19:14:19 +0200 Subject: use forward declaration in headers if possible instead of includes --- apt-pkg/acquire-item.cc | 2 + apt-pkg/acquire-item.h | 238 +++++++++++++++++++++--------------------- apt-pkg/acquire-method.h | 6 +- apt-pkg/algorithms.cc | 3 + apt-pkg/algorithms.h | 3 +- apt-pkg/cachefile.cc | 1 + apt-pkg/cachefile.h | 9 +- apt-pkg/cacheiterators.h | 1 + apt-pkg/cacheset.cc | 7 +- apt-pkg/cacheset.h | 13 ++- apt-pkg/cdrom.cc | 2 + apt-pkg/cdrom.h | 3 +- apt-pkg/clean.cc | 1 + apt-pkg/contrib/cmndline.cc | 1 + apt-pkg/contrib/cmndline.h | 4 +- apt-pkg/contrib/mmap.cc | 1 + apt-pkg/contrib/mmap.h | 3 +- apt-pkg/contrib/netrc.cc | 2 + apt-pkg/contrib/netrc.h | 4 +- apt-pkg/deb/deblistparser.cc | 1 + apt-pkg/deb/deblistparser.h | 1 - apt-pkg/deb/debmetaindex.cc | 3 + apt-pkg/deb/debmetaindex.h | 43 ++++---- apt-pkg/deb/debrecords.cc | 2 + apt-pkg/deb/debrecords.h | 2 +- apt-pkg/deb/debsystem.h | 4 +- apt-pkg/depcache.cc | 2 +- apt-pkg/depcache.h | 5 +- apt-pkg/edsp.cc | 7 ++ apt-pkg/edsp.h | 11 +- apt-pkg/edsp/edspindexfile.cc | 1 + apt-pkg/edsp/edspindexfile.h | 1 - apt-pkg/edsp/edsplistparser.h | 5 +- apt-pkg/indexfile.h | 2 + apt-pkg/indexrecords.cc | 3 + apt-pkg/indexrecords.h | 1 - apt-pkg/init.cc | 2 + apt-pkg/init.h | 4 +- apt-pkg/metaindex.h | 3 - apt-pkg/packagemanager.h | 3 +- apt-pkg/pkgcachegen.cc | 2 + apt-pkg/pkgsystem.h | 6 +- apt-pkg/sourcelist.cc | 2 + apt-pkg/sourcelist.h | 6 +- apt-pkg/srcrecords.cc | 1 + apt-pkg/tagfile.cc | 1 + apt-pkg/tagfile.h | 6 +- apt-pkg/vendorlist.cc | 2 + apt-pkg/vendorlist.h | 5 +- apt-pkg/version.h | 3 +- 50 files changed, 252 insertions(+), 192 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index b46489f87..453fce109 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index 13be17a01..24f848f27 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -21,13 +21,9 @@ #define PKGLIB_ACQUIRE_ITEM_H #include -#include -#include -#include -#include -#include #include #include +#include /** \addtogroup acquire * @{ @@ -35,6 +31,10 @@ * \file acquire-item.h */ +class indexRecords; +class pkgRecords; +class pkgSourceList; + /** \brief Represents the process by which a pkgAcquire object should {{{ * retrieve a file or a collection of files. * @@ -74,7 +74,7 @@ class pkgAcquire::Item : public WeakPointable * \param To The new name of #From. If #To exists it will be * overwritten. */ - void Rename(string From,string To); + void Rename(std::string From,std::string To); public: @@ -109,7 +109,7 @@ class pkgAcquire::Item : public WeakPointable /** \brief Contains a textual description of the error encountered * if #Status is #StatError or #StatAuthError. */ - string ErrorText; + std::string ErrorText; /** \brief The size of the object to fetch. */ unsigned long long FileSize; @@ -143,7 +143,7 @@ class pkgAcquire::Item : public WeakPointable * download progress indicator's overall statistics. */ bool Local; - string UsedMirror; + std::string UsedMirror; /** \brief The number of fetch queues into which this item has been * inserted. @@ -158,7 +158,7 @@ class pkgAcquire::Item : public WeakPointable /** \brief The name of the file into which the retrieved object * will be written. */ - string DestFile; + std::string DestFile; /** \brief Invoked by the acquire worker when the object couldn't * be fetched. @@ -173,7 +173,7 @@ class pkgAcquire::Item : public WeakPointable * * \sa pkgAcqMethod */ - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); /** \brief Invoked by the acquire worker when the object was * fetched successfully. @@ -194,7 +194,7 @@ class pkgAcquire::Item : public WeakPointable * * \sa pkgAcqMethod */ - virtual void Done(string Message,unsigned long long Size,string Hash, + virtual void Done(std::string Message,unsigned long long Size,std::string Hash, pkgAcquire::MethodConfig *Cnf); /** \brief Invoked when the worker starts to fetch this object. @@ -206,7 +206,7 @@ class pkgAcquire::Item : public WeakPointable * * \sa pkgAcqMethod */ - virtual void Start(string Message,unsigned long long Size); + virtual void Start(std::string Message,unsigned long long Size); /** \brief Custom headers to be sent to the fetch process. * @@ -216,18 +216,18 @@ class pkgAcquire::Item : public WeakPointable * line, so they should (if nonempty) have a leading newline and * no trailing newline. */ - virtual string Custom600Headers() {return string();}; + virtual std::string Custom600Headers() {return std::string();}; /** \brief A "descriptive" URI-like string. * * \return a URI that should be used to describe what is being fetched. */ - virtual string DescURI() = 0; + virtual std::string DescURI() = 0; /** \brief Short item description. * * \return a brief description of the object being fetched. */ - virtual string ShortDesc() {return DescURI();} + virtual std::string ShortDesc() {return DescURI();} /** \brief Invoked by the worker when the download is completely done. */ virtual void Finished() {}; @@ -237,7 +237,7 @@ class pkgAcquire::Item : public WeakPointable * \return the HashSum of this object, if applicable; otherwise, an * empty string. */ - virtual string HashSum() {return string();}; + virtual std::string HashSum() {return std::string();}; /** \return the acquire process with which this item is associated. */ pkgAcquire *GetOwner() {return Owner;}; @@ -253,7 +253,7 @@ class pkgAcquire::Item : public WeakPointable * * \param FailCode A short failure string that is send */ - void ReportMirrorFailure(string FailCode); + void ReportMirrorFailure(std::string FailCode); /** \brief Initialize an item. @@ -278,10 +278,10 @@ class pkgAcquire::Item : public WeakPointable /** \brief Information about an index patch (aka diff). */ /*{{{*/ struct DiffInfo { /** The filename of the diff. */ - string file; + std::string file; /** The sha1 hash of the diff. */ - string sha1; + std::string sha1; /** The size of the diff. */ unsigned long size; @@ -308,12 +308,12 @@ class pkgAcqSubIndex : public pkgAcquire::Item public: // Specialized action members - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string Md5Hash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash, pkgAcquire::MethodConfig *Cnf); - virtual string DescURI() {return Desc.URI;}; - virtual string Custom600Headers(); - virtual bool ParseIndex(string const &IndexFile); + virtual std::string DescURI() {return Desc.URI;}; + virtual std::string Custom600Headers(); + virtual bool ParseIndex(std::string const &IndexFile); /** \brief Create a new pkgAcqSubIndex. * @@ -327,8 +327,8 @@ class pkgAcqSubIndex : public pkgAcquire::Item * * \param ExpectedHash The list file's MD5 signature. */ - pkgAcqSubIndex(pkgAcquire *Owner, string const &URI,string const &URIDesc, - string const &ShortDesc, HashString const &ExpectedHash); + pkgAcqSubIndex(pkgAcquire *Owner, std::string const &URI,std::string const &URIDesc, + std::string const &ShortDesc, HashString const &ExpectedHash); }; /*}}}*/ /** \brief An item that is responsible for fetching an index file of {{{ @@ -352,7 +352,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item /** \brief The URI of the index file to recreate at our end (either * by downloading it or by applying partial patches). */ - string RealURI; + std::string RealURI; /** \brief The Hash that the real index file should have after * all patches have been applied. @@ -362,20 +362,20 @@ class pkgAcqDiffIndex : public pkgAcquire::Item /** \brief The index file which will be patched to generate the new * file. */ - string CurrentPackagesFile; + std::string CurrentPackagesFile; /** \brief A description of the Packages file (stored in * pkgAcquire::ItemDesc::Description). */ - string Description; + std::string Description; public: // Specialized action members - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string Md5Hash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash, pkgAcquire::MethodConfig *Cnf); - virtual string DescURI() {return RealURI + "Index";}; - virtual string Custom600Headers(); + virtual std::string DescURI() {return RealURI + "Index";}; + virtual std::string Custom600Headers(); /** \brief Parse the Index file for a set of Packages diffs. * @@ -387,7 +387,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item * \return \b true if the Index file was successfully parsed, \b * false otherwise. */ - bool ParseDiffIndex(string IndexDiffFile); + bool ParseDiffIndex(std::string IndexDiffFile); /** \brief Create a new pkgAcqDiffIndex. @@ -402,8 +402,8 @@ class pkgAcqDiffIndex : public pkgAcquire::Item * * \param ExpectedHash The list file's MD5 signature. */ - pkgAcqDiffIndex(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc, HashString ExpectedHash); + pkgAcqDiffIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, + std::string ShortDesc, HashString ExpectedHash); }; /*}}}*/ /** \brief An item that is responsible for fetching all the patches {{{ @@ -460,7 +460,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item /** \brief The URI of the package index file that is being * reconstructed. */ - string RealURI; + std::string RealURI; /** \brief The HashSum of the package index file that is being * reconstructed. @@ -468,7 +468,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item HashString ExpectedHash; /** A description of the file being downloaded. */ - string Description; + std::string Description; /** The patches that remain to be downloaded, including the patch * being downloaded right now. This list should be ordered so @@ -478,10 +478,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * dictionary instead of relying on ordering and stripping them * off the front? */ - vector available_patches; + std::vector available_patches; /** Stop applying patches when reaching that sha1 */ - string ServerSha1; + std::string ServerSha1; /** The current status of this patch. */ enum DiffState @@ -506,11 +506,11 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * This method will fall back to downloading the whole index file * outright; its arguments are ignored. */ - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string Md5Hash, + virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash, pkgAcquire::MethodConfig *Cnf); - virtual string DescURI() {return RealURI + "Index";}; + virtual std::string DescURI() {return RealURI + "Index";}; /** \brief Create an index diff item. * @@ -534,10 +534,10 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item * should be ordered so that each diff appears before any diff * that depends on it. */ - pkgAcqIndexDiffs(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc, HashString ExpectedHash, - string ServerSha1, - vector diffs=vector()); + pkgAcqIndexDiffs(pkgAcquire *Owner,std::string URI,std::string URIDesc, + std::string ShortDesc, HashString ExpectedHash, + std::string ServerSha1, + std::vector diffs=std::vector()); }; /*}}}*/ /** \brief An acquire item that is responsible for fetching an index {{{ @@ -577,7 +577,7 @@ class pkgAcqIndex : public pkgAcquire::Item /** \brief The object that is actually being fetched (minus any * compression-related extensions). */ - string RealURI; + std::string RealURI; /** \brief The expected hashsum of the decompressed index file. */ HashString ExpectedHash; @@ -585,17 +585,17 @@ class pkgAcqIndex : public pkgAcquire::Item /** \brief The compression-related file extensions that are being * added to the downloaded file one by one if first fails (e.g., "gz bz2"). */ - string CompressionExtension; + std::string CompressionExtension; public: // Specialized action members - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string Md5Hash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash, pkgAcquire::MethodConfig *Cnf); - virtual string Custom600Headers(); - virtual string DescURI() {return Desc.URI;}; - virtual string HashSum() {return ExpectedHash.toStr(); }; + virtual std::string Custom600Headers(); + virtual std::string DescURI() {return Desc.URI;}; + virtual std::string HashSum() {return ExpectedHash.toStr(); }; /** \brief Create a pkgAcqIndex. * @@ -616,12 +616,12 @@ class pkgAcqIndex : public pkgAcquire::Item * default is ".lzma" or ".bz2" (if the needed binaries are present) * fallback is ".gz" or none. */ - pkgAcqIndex(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc, HashString ExpectedHash, - string compressExt=""); + pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc, + std::string ShortDesc, HashString ExpectedHash, + std::string compressExt=""); pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target, HashString const &ExpectedHash, indexRecords const *MetaIndexParser); - void Init(string const &URI, string const &URIDesc, string const &ShortDesc); + void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc); }; /*}}}*/ /** \brief An acquire item that is responsible for fetching a {{{ @@ -635,8 +635,8 @@ class pkgAcqIndexTrans : public pkgAcqIndex { public: - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual string Custom600Headers(); + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual std::string Custom600Headers(); /** \brief Create a pkgAcqIndexTrans. * @@ -649,8 +649,8 @@ class pkgAcqIndexTrans : public pkgAcqIndex * * \param ShortDesc A brief description of this index file. */ - pkgAcqIndexTrans(pkgAcquire *Owner,string URI,string URIDesc, - string ShortDesc); + pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc, + std::string ShortDesc); pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target, HashString const &ExpectedHash, indexRecords const *MetaIndexParser); }; @@ -660,18 +660,18 @@ class IndexTarget { public: /** \brief A URI from which the index file can be downloaded. */ - string URI; + std::string URI; /** \brief A description of the index file. */ - string Description; + std::string Description; /** \brief A shorter description of the index file. */ - string ShortDesc; + std::string ShortDesc; /** \brief The key by which this index file should be * looked up within the meta signature file. */ - string MetaKey; + std::string MetaKey; virtual bool IsOptional() const { return false; @@ -710,7 +710,7 @@ class pkgAcqMetaSig : public pkgAcquire::Item { protected: /** \brief The last good signature file */ - string LastGoodSig; + std::string LastGoodSig; /** \brief The fetch request that is currently being processed. */ pkgAcquire::ItemDesc Desc; @@ -719,20 +719,20 @@ class pkgAcqMetaSig : public pkgAcquire::Item * never modified; it is used to determine the file that is being * downloaded. */ - string RealURI; + std::string RealURI; /** \brief The URI of the meta-index file to be fetched after the signature. */ - string MetaIndexURI; + std::string MetaIndexURI; /** \brief A "URI-style" description of the meta-index file to be * fetched after the signature. */ - string MetaIndexURIDesc; + std::string MetaIndexURIDesc; /** \brief A brief description of the meta-index file to be fetched * after the signature. */ - string MetaIndexShortDesc; + std::string MetaIndexShortDesc; /** \brief A package-system-specific parser for the meta-index file. */ indexRecords* MetaIndexParser; @@ -742,21 +742,21 @@ class pkgAcqMetaSig : public pkgAcquire::Item * * \todo Why a list of pointers instead of a list of structs? */ - const vector* IndexTargets; + const std::vector* IndexTargets; public: // Specialized action members - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string Md5Hash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash, pkgAcquire::MethodConfig *Cnf); - virtual string Custom600Headers(); - virtual string DescURI() {return RealURI; }; + virtual std::string Custom600Headers(); + virtual std::string DescURI() {return RealURI; }; /** \brief Create a new pkgAcqMetaSig. */ - pkgAcqMetaSig(pkgAcquire *Owner,string URI,string URIDesc, string ShortDesc, - string MetaIndexURI, string MetaIndexURIDesc, string MetaIndexShortDesc, - const vector* IndexTargets, + pkgAcqMetaSig(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc, + std::string MetaIndexURI, std::string MetaIndexURIDesc, std::string MetaIndexShortDesc, + const std::vector* IndexTargets, indexRecords* MetaIndexParser); }; /*}}}*/ @@ -779,17 +779,17 @@ class pkgAcqMetaIndex : public pkgAcquire::Item /** \brief The URI that is actually being downloaded; never * modified by pkgAcqMetaIndex. */ - string RealURI; + std::string RealURI; /** \brief The file in which the signature for this index was stored. * * If empty, the signature and the md5sums of the individual * indices will not be checked. */ - string SigFile; + std::string SigFile; /** \brief The index files to download. */ - const vector* IndexTargets; + const std::vector* IndexTargets; /** \brief The parser for the meta-index file. */ indexRecords* MetaIndexParser; @@ -805,7 +805,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item * * \return \b true if no fatal errors were encountered. */ - bool VerifyVendor(string Message); + bool VerifyVendor(std::string Message); /** \brief Called when a file is finished being retrieved. * @@ -816,7 +816,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item * \param Message The message block received from the fetch * subprocess. */ - void RetrievalDone(string Message); + void RetrievalDone(std::string Message); /** \brief Called when authentication succeeded. * @@ -827,7 +827,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item * \param Message The message block received from the fetch * subprocess. */ - void AuthDone(string Message); + void AuthDone(std::string Message); /** \brief Starts downloading the individual index files. * @@ -842,17 +842,17 @@ class pkgAcqMetaIndex : public pkgAcquire::Item public: // Specialized action members - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size, string Hash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size, std::string Hash, pkgAcquire::MethodConfig *Cnf); - virtual string Custom600Headers(); - virtual string DescURI() {return RealURI; }; + virtual std::string Custom600Headers(); + virtual std::string DescURI() {return RealURI; }; /** \brief Create a new pkgAcqMetaIndex. */ pkgAcqMetaIndex(pkgAcquire *Owner, - string URI,string URIDesc, string ShortDesc, - string SigFile, - const vector* IndexTargets, + std::string URI,std::string URIDesc, std::string ShortDesc, + std::string SigFile, + const std::vector* IndexTargets, indexRecords* MetaIndexParser); }; /*}}}*/ @@ -860,33 +860,33 @@ class pkgAcqMetaIndex : public pkgAcquire::Item class pkgAcqMetaClearSig : public pkgAcqMetaIndex { /** \brief The URI of the meta-index file for the detached signature */ - string MetaIndexURI; + std::string MetaIndexURI; /** \brief A "URI-style" description of the meta-index file */ - string MetaIndexURIDesc; + std::string MetaIndexURIDesc; /** \brief A brief description of the meta-index file */ - string MetaIndexShortDesc; + std::string MetaIndexShortDesc; /** \brief The URI of the detached meta-signature file if the clearsigned one failed. */ - string MetaSigURI; + std::string MetaSigURI; /** \brief A "URI-style" description of the meta-signature file */ - string MetaSigURIDesc; + std::string MetaSigURIDesc; /** \brief A brief description of the meta-signature file */ - string MetaSigShortDesc; + std::string MetaSigShortDesc; public: - void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual string Custom600Headers(); + void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual std::string Custom600Headers(); /** \brief Create a new pkgAcqMetaClearSig. */ pkgAcqMetaClearSig(pkgAcquire *Owner, - string const &URI, string const &URIDesc, string const &ShortDesc, - string const &MetaIndexURI, string const &MetaIndexURIDesc, string const &MetaIndexShortDesc, - string const &MetaSigURI, string const &MetaSigURIDesc, string const &MetaSigShortDesc, - const vector* IndexTargets, + std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc, + std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc, + std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc, + const std::vector* IndexTargets, indexRecords* MetaIndexParser); }; /*}}}*/ @@ -920,7 +920,7 @@ class pkgAcqArchive : public pkgAcquire::Item /** \brief A location in which the actual filename of the package * should be stored. */ - string &StoreFilename; + std::string &StoreFilename; /** \brief The next file for this version to try to download. */ pkgCache::VerFileIterator Vf; @@ -942,13 +942,13 @@ class pkgAcqArchive : public pkgAcquire::Item public: - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string Hash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size,std::string Hash, pkgAcquire::MethodConfig *Cnf); - virtual string DescURI() {return Desc.URI;}; - virtual string ShortDesc() {return Desc.ShortDesc;}; + virtual std::string DescURI() {return Desc.URI;}; + virtual std::string ShortDesc() {return Desc.ShortDesc;}; virtual void Finished(); - virtual string HashSum() {return ExpectedHash.toStr(); }; + virtual std::string HashSum() {return ExpectedHash.toStr(); }; virtual bool IsTrusted(); /** \brief Create a new pkgAcqArchive. @@ -971,7 +971,7 @@ class pkgAcqArchive : public pkgAcquire::Item */ pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources, pkgRecords *Recs,pkgCache::VerIterator const &Version, - string &StoreFilename); + std::string &StoreFilename); }; /*}}}*/ /** \brief Retrieve an arbitrary file to the current directory. {{{ @@ -999,12 +999,12 @@ class pkgAcqFile : public pkgAcquire::Item public: // Specialized action members - virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf); - virtual void Done(string Message,unsigned long long Size,string CalcHash, + virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf); + virtual void Done(std::string Message,unsigned long long Size,std::string CalcHash, pkgAcquire::MethodConfig *Cnf); - virtual string DescURI() {return Desc.URI;}; - virtual string HashSum() {return ExpectedHash.toStr(); }; - virtual string Custom600Headers(); + virtual std::string DescURI() {return Desc.URI;}; + virtual std::string HashSum() {return ExpectedHash.toStr(); }; + virtual std::string Custom600Headers(); /** \brief Create a new pkgAcqFile object. * @@ -1037,9 +1037,9 @@ class pkgAcqFile : public pkgAcquire::Item * is the absolute name to which the file should be downloaded. */ - pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long long Size, - string Desc, string ShortDesc, - const string &DestDir="", const string &DestFilename="", + pkgAcqFile(pkgAcquire *Owner, std::string URI, std::string Hash, unsigned long long Size, + std::string Desc, std::string ShortDesc, + const std::string &DestDir="", const std::string &DestFilename="", bool IsIndexFile=false); }; /*}}}*/ diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 8acec82ed..c3f042ee0 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -20,11 +20,11 @@ #ifndef PKGLIB_ACQUIRE_METHOD_H #define PKGLIB_ACQUIRE_METHOD_H -#include -#include - #include +#include +#include + class Hashes; class pkgAcqMethod { diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 40368c91f..919daefef 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include #include #include diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index f299f8189..948fe1103 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -33,10 +33,11 @@ #include #include -#include #include +class pkgAcquireStatus; + class pkgSimulate : public pkgPackageManager /*{{{*/ { protected: diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index f38dfc581..1b8d91a44 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include /*}}}*/ diff --git a/apt-pkg/cachefile.h b/apt-pkg/cachefile.h index 243061f0f..b56e42855 100644 --- a/apt-pkg/cachefile.h +++ b/apt-pkg/cachefile.h @@ -17,11 +17,12 @@ #ifndef PKGLIB_CACHEFILE_H #define PKGLIB_CACHEFILE_H - #include -#include -#include -#include +#include + +class pkgPolicy; +class pkgSourceList; +class OpProgress; class pkgCacheFile { diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 464b2fdd8..5382f3838 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -32,6 +32,7 @@ #include #include + // abstract Iterator template /*{{{*/ /* This template provides the very basic iterator methods we need to have for doing some walk-over-the-cache magic */ diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 386ecfb5f..6b95eab70 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -12,11 +12,14 @@ #include #include +#include #include #include #include #include #include +#include +#include #include @@ -298,7 +301,7 @@ APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg, std::string ver; bool verIsRel = false; size_t const vertag = pkg.find_last_of("/="); - if (vertag != string::npos) { + if (vertag != std::string::npos) { ver = pkg.substr(vertag+1); verIsRel = (pkg[vertag] == '/'); pkg.erase(vertag); @@ -316,7 +319,7 @@ APT::VersionSet VersionSet::FromString(pkgCacheFile &Cache, std::string pkg, errors = helper.showErrors(false); for (PackageSet::const_iterator P = pkgset.begin(); P != pkgset.end(); ++P) { - if (vertag == string::npos) { + if (vertag == std::string::npos) { verset.insert(VersionSet::FromPackage(Cache, P, fallback, helper)); continue; } diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 061d0a2f4..3b1118bdc 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -16,9 +16,12 @@ #include #include -#include +#include #include /*}}}*/ + +class pkgCacheFile; + namespace APT { class PackageSet; class VersionSet; @@ -37,10 +40,10 @@ public: /*{{{*/ ShowError(ShowError), ErrorType(ErrorType) {}; virtual ~CacheSetHelper() {}; - virtual void showTaskSelection(PackageSet const &pkgset, string const &pattern) {}; - virtual void showRegExSelection(PackageSet const &pkgset, string const &pattern) {}; + virtual void showTaskSelection(PackageSet const &pkgset, std::string const &pattern) {}; + virtual void showRegExSelection(PackageSet const &pkgset, std::string const &pattern) {}; virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver, - string const &ver, bool const &verIsRel) {}; + std::string const &ver, bool const &verIsRel) {}; virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str); virtual PackageSet canNotFindTask(pkgCacheFile &Cache, std::string pattern); @@ -265,7 +268,7 @@ public: /*{{{*/ inline pkgCache::VerFileIterator FileList() const { return (**this).FileList(); }; inline bool Downloadable() const { return (**this).Downloadable(); }; inline const char *PriorityType() const { return (**this).PriorityType(); }; - inline string RelStr() const { return (**this).RelStr(); }; + inline std::string RelStr() const { return (**this).RelStr(); }; inline bool Automatic() const { return (**this).Automatic(); }; inline pkgCache::VerFileIterator NewestFile() const { return (**this).NewestFile(); }; }; diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc index 392cd890e..a9c63fd21 100644 --- a/apt-pkg/cdrom.cc +++ b/apt-pkg/cdrom.cc @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include diff --git a/apt-pkg/cdrom.h b/apt-pkg/cdrom.h index 2241f1eba..319254fd0 100644 --- a/apt-pkg/cdrom.h +++ b/apt-pkg/cdrom.h @@ -1,10 +1,11 @@ #ifndef PKGLIB_CDROM_H #define PKGLIB_CDROM_H -#include #include #include +class Configuration; +class OpProgress; class pkgCdromStatus /*{{{*/ { diff --git a/apt-pkg/clean.cc b/apt-pkg/clean.cc index f5a939968..ed8fa1aa9 100644 --- a/apt-pkg/clean.cc +++ b/apt-pkg/clean.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 34e90da20..997f26bc7 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -13,6 +13,7 @@ // Include files /*{{{*/ #include +#include #include #include #include diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h index 7c0c71aa7..b201d9855 100644 --- a/apt-pkg/contrib/cmndline.h +++ b/apt-pkg/contrib/cmndline.h @@ -44,9 +44,7 @@ #ifndef PKGLIB_CMNDLINE_H #define PKGLIB_CMNDLINE_H - - -#include +class Configuration; class CommandLine { diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc index a110a7019..f76169a92 100644 --- a/apt-pkg/contrib/mmap.cc +++ b/apt-pkg/contrib/mmap.cc @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h index 387e9a170..2ed4a95f8 100644 --- a/apt-pkg/contrib/mmap.h +++ b/apt-pkg/contrib/mmap.h @@ -27,7 +27,8 @@ #include -#include + +class FileFd; /* This should be a 32 bit type, larger tyes use too much ram and smaller types are too small. Where ever possible 'unsigned long' should be used diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 9aa1376dc..cb7d36088 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -14,7 +14,9 @@ #include #include +#include #include + #include #include #include diff --git a/apt-pkg/contrib/netrc.h b/apt-pkg/contrib/netrc.h index 86afa43d1..7b94eba88 100644 --- a/apt-pkg/contrib/netrc.h +++ b/apt-pkg/contrib/netrc.h @@ -14,11 +14,13 @@ #ifndef NETRC_H #define NETRC_H -#include +#include #define DOT_CHAR "." #define DIR_CHAR "/" +class URI; + // Assume: password[0]=0, host[0] != 0. // If login[0] = 0, search for login and password within a machine section // in the netrc. diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 95a2e6d47..3652f9e8b 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 09858d991..9519d9711 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -12,7 +12,6 @@ #define PKGLIB_DEBLISTPARSER_H #include -#include #include class debListParser : public pkgCacheGenerator::ListParser diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 1d3754b00..0d07725eb 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -4,9 +4,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index 695cfa7cc..0cba2d8a8 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -3,9 +3,10 @@ #define PKGLIB_DEBMETAINDEX_H #include -#include #include +#include +#include class debReleaseIndex : public metaIndex { public: @@ -13,43 +14,43 @@ class debReleaseIndex : public metaIndex { class debSectionEntry { public: - debSectionEntry (string const &Section, bool const &IsSrc); - string const Section; + debSectionEntry (std::string const &Section, bool const &IsSrc); + std::string const Section; bool const IsSrc; }; private: /** \brief dpointer placeholder (for later in case we need it) */ void *d; - std::map > ArchEntries; + std::map > ArchEntries; enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted; public: - debReleaseIndex(string const &URI, string const &Dist); - debReleaseIndex(string const &URI, string const &Dist, bool const Trusted); + debReleaseIndex(std::string const &URI, std::string const &Dist); + debReleaseIndex(std::string const &URI, std::string const &Dist, bool const Trusted); virtual ~debReleaseIndex(); - virtual string ArchiveURI(string const &File) const {return URI + File;}; + virtual std::string ArchiveURI(std::string const &File) const {return URI + File;}; virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const; - vector * ComputeIndexTargets() const; - string Info(const char *Type, string const &Section, string const &Arch="") const; - string MetaIndexInfo(const char *Type) const; - string MetaIndexFile(const char *Types) const; - string MetaIndexURI(const char *Type) const; - string IndexURI(const char *Type, string const &Section, string const &Arch="native") const; - string IndexURISuffix(const char *Type, string const &Section, string const &Arch="native") const; - string SourceIndexURI(const char *Type, const string &Section) const; - string SourceIndexURISuffix(const char *Type, const string &Section) const; - string TranslationIndexURI(const char *Type, const string &Section) const; - string TranslationIndexURISuffix(const char *Type, const string &Section) const; - virtual vector *GetIndexFiles(); + std::vector * ComputeIndexTargets() const; + std::string Info(const char *Type, std::string const &Section, std::string const &Arch="") const; + std::string MetaIndexInfo(const char *Type) const; + std::string MetaIndexFile(const char *Types) const; + std::string MetaIndexURI(const char *Type) const; + std::string IndexURI(const char *Type, std::string const &Section, std::string const &Arch="native") const; + std::string IndexURISuffix(const char *Type, std::string const &Section, std::string const &Arch="native") const; + std::string SourceIndexURI(const char *Type, const std::string &Section) const; + std::string SourceIndexURISuffix(const char *Type, const std::string &Section) const; + std::string TranslationIndexURI(const char *Type, const std::string &Section) const; + std::string TranslationIndexURISuffix(const char *Type, const std::string &Section) const; + virtual std::vector *GetIndexFiles(); void SetTrusted(bool const Trusted); virtual bool IsTrusted() const; - void PushSectionEntry(vector const &Archs, const debSectionEntry *Entry); - void PushSectionEntry(string const &Arch, const debSectionEntry *Entry); + void PushSectionEntry(std::vector const &Archs, const debSectionEntry *Entry); + void PushSectionEntry(std::string const &Arch, const debSectionEntry *Entry); void PushSectionEntry(const debSectionEntry *Entry); }; diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index ef6a7ca9d..1afa7b74d 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -14,6 +14,8 @@ #include #include #include +#include + #include /*}}}*/ diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h index b75726859..9c7ea6b48 100644 --- a/apt-pkg/deb/debrecords.h +++ b/apt-pkg/deb/debrecords.h @@ -15,8 +15,8 @@ #define PKGLIB_DEBRECORDS_H #include -#include #include +#include class debRecordParser : public pkgRecords::Parser { diff --git a/apt-pkg/deb/debsystem.h b/apt-pkg/deb/debsystem.h index 232155256..855123516 100644 --- a/apt-pkg/deb/debsystem.h +++ b/apt-pkg/deb/debsystem.h @@ -11,10 +11,12 @@ #define PKGLIB_DEBSYSTEM_H #include +#include class debSystemPrivate; - class debStatusIndex; +class pkgDepCache; + class debSystem : public pkgSystem { // private d-pointer diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 529085b4a..529e9240d 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -16,13 +16,13 @@ #include #include #include - #include #include #include #include #include #include +#include #include #include diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 5798f0362..f6e6c0afc 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -40,12 +40,13 @@ #include #include -#include -#include #include #include #include +#include + +class OpProgress; class pkgDepCache : protected pkgCache::Namespace { diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 44f7dbfd6..137398100 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -9,17 +9,24 @@ #include #include +#include #include #include #include #include +#include +#include #include #include +#include + #include /*}}}*/ +using std::string; + // we could use pkgCache::DepType and ::Priority, but these would be localized strings… const char * const EDSP::PrioMap[] = {0, "important", "required", "standard", "optional", "extra"}; diff --git a/apt-pkg/edsp.h b/apt-pkg/edsp.h index 743c3f5d1..c14309422 100644 --- a/apt-pkg/edsp.h +++ b/apt-pkg/edsp.h @@ -9,12 +9,17 @@ #ifndef PKGLIB_EDSP_H #define PKGLIB_EDSP_H -#include -#include -#include +#include +#include #include +namespace APT { + class PackageSet; +}; +class pkgDepCache; +class OpProgress; + class EDSP /*{{{*/ { // we could use pkgCache::DepType and ::Priority, but these would be localized strings… diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc index b417a7562..058cef636 100644 --- a/apt-pkg/edsp/edspindexfile.cc +++ b/apt-pkg/edsp/edspindexfile.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include diff --git a/apt-pkg/edsp/edspindexfile.h b/apt-pkg/edsp/edspindexfile.h index 58a7f62a9..9670c4837 100644 --- a/apt-pkg/edsp/edspindexfile.h +++ b/apt-pkg/edsp/edspindexfile.h @@ -8,7 +8,6 @@ #ifndef PKGLIB_EDSPINDEXFILE_H #define PKGLIB_EDSPINDEXFILE_H -#include #include class edspIndex : public debStatusIndex diff --git a/apt-pkg/edsp/edsplistparser.h b/apt-pkg/edsp/edsplistparser.h index 3e196cb9a..5d82716c7 100644 --- a/apt-pkg/edsp/edsplistparser.h +++ b/apt-pkg/edsp/edsplistparser.h @@ -12,9 +12,8 @@ #define PKGLIB_EDSPLISTPARSER_H #include -#include -#include -#include + +class FileFd; class edspListParser : public debListParser { diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h index 68d53ad7e..5e162a846 100644 --- a/apt-pkg/indexfile.h +++ b/apt-pkg/indexfile.h @@ -27,10 +27,12 @@ #include #include #include +#include class pkgAcquire; class pkgCacheGenerator; class OpProgress; + class pkgIndexFile { protected: diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index 7b48d659e..cdb9250e8 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -10,6 +10,9 @@ #include #include #include +#include +#include + #include #include diff --git a/apt-pkg/indexrecords.h b/apt-pkg/indexrecords.h index 66b84f8bb..fa60a0847 100644 --- a/apt-pkg/indexrecords.h +++ b/apt-pkg/indexrecords.h @@ -7,7 +7,6 @@ #include -#include #include #include diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index a1cb05e38..2a709dd36 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 4cee1001a..85ad0df7e 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -13,8 +13,8 @@ #ifndef PKGLIB_INIT_H #define PKGLIB_INIT_H -#include -#include +class pkgSystem; +class Configuration; // These lines are extracted by the makefiles and the buildsystem // Increasing MAJOR or MINOR results in the need of recompiling all diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index 66c287c30..9cc79a7a6 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -4,10 +4,7 @@ #include #include -#include -#include #include -#include class pkgAcquire; class pkgCacheGenerator; diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 7ee17942c..d4989a6e0 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -23,11 +23,10 @@ #ifndef PKGLIB_PACKAGEMANAGER_H #define PKGLIB_PACKAGEMANAGER_H +#include #include #include -#include -#include #include class pkgAcquire; diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index a39aa9f59..1356054b5 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include diff --git a/apt-pkg/pkgsystem.h b/apt-pkg/pkgsystem.h index 246762e0b..211fd0d56 100644 --- a/apt-pkg/pkgsystem.h +++ b/apt-pkg/pkgsystem.h @@ -37,14 +37,16 @@ #ifndef PKGLIB_PKGSYSTEM_H #define PKGLIB_PKGSYSTEM_H +#include -#include #include - + +class pkgDepCache; class pkgPackageManager; class pkgVersioningSystem; class Configuration; class pkgIndexFile; +class PkgFileIterator; class pkgSystem { diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index e20ec4704..46025fc74 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index 7b473ee64..4509e54b9 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -31,13 +31,15 @@ #include #include #include -#include using std::string; using std::vector; -class pkgAquire; +class pkgAcquire; +class pkgIndexFile; +class metaIndex; + class pkgSourceList { public: diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 8c1de2ea5..f6d2d5158 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include /*}}}*/ diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 418e6bed8..ec86173df 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h index e3034b628..a5bf5ac90 100644 --- a/apt-pkg/tagfile.h +++ b/apt-pkg/tagfile.h @@ -20,10 +20,12 @@ #ifndef PKGLIB_TAGFILE_H #define PKGLIB_TAGFILE_H - -#include #include +#include + +class FileFd; + class pkgTagSection { const char *Section; diff --git a/apt-pkg/vendorlist.cc b/apt-pkg/vendorlist.cc index 2ccb556ab..ecfc7db87 100644 --- a/apt-pkg/vendorlist.cc +++ b/apt-pkg/vendorlist.cc @@ -2,12 +2,14 @@ #include #include +#include #include #if __GNUC__ >= 4 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif +#include #include using std::string; diff --git a/apt-pkg/vendorlist.h b/apt-pkg/vendorlist.h index 62ab78a33..733d23a32 100644 --- a/apt-pkg/vendorlist.h +++ b/apt-pkg/vendorlist.h @@ -15,10 +15,11 @@ #include #include -#include -#include #include +class Vendor; +class Configuration; + class __deprecated pkgVendorList { protected: diff --git a/apt-pkg/version.h b/apt-pkg/version.h index c9257d116..47e1919bb 100644 --- a/apt-pkg/version.h +++ b/apt-pkg/version.h @@ -20,8 +20,7 @@ #ifndef PKGLIB_VERSION_H #define PKGLIB_VERSION_H - -#include +#include #include class pkgVersioningSystem -- cgit v1.2.3 From 1bc6873583b01469f4981d738f4d0d4132ccfdbf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 19:27:07 +0200 Subject: remove old APT_COMPATIBILITY ifdef's --- apt-pkg/deb/debversion.cc | 1 - apt-pkg/deb/debversion.h | 28 ---------------------------- apt-pkg/init.h | 11 ----------- apt-pkg/pkgcachegen.cc | 1 - apt-pkg/pkgcachegen.h | 14 -------------- apt-pkg/version.h | 4 ---- 6 files changed, 59 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index 859ff6b6d..bc9e13d92 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -10,7 +10,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#define APT_COMPATIBILITY 986 #include #include diff --git a/apt-pkg/deb/debversion.h b/apt-pkg/deb/debversion.h index 24ad73149..f1d6f3cc5 100644 --- a/apt-pkg/deb/debversion.h +++ b/apt-pkg/deb/debversion.h @@ -39,32 +39,4 @@ class debVersioningSystem : public pkgVersioningSystem extern debVersioningSystem debVS; -#ifdef APT_COMPATIBILITY -#if APT_COMPATIBILITY != 986 -#warning "Using APT_COMPATIBILITY" -#endif - -inline int pkgVersionCompare(const char *A, const char *B) -{ - return debVS.CmpVersion(A,B); -} -inline int pkgVersionCompare(const char *A, const char *AEnd, - const char *B, const char *BEnd) -{ - return debVS.DoCmpVersion(A,AEnd,B,BEnd); -} -inline int pkgVersionCompare(std::string A,std::string B) -{ - return debVS.CmpVersion(A,B); -} -inline bool pkgCheckDep(const char *DepVer,const char *PkgVer,int Op) -{ - return debVS.CheckDep(PkgVer,Op,DepVer); -} -inline std::string pkgBaseVersion(const char *Ver) -{ - return debVS.UpstreamVersion(Ver); -} -#endif - #endif diff --git a/apt-pkg/init.h b/apt-pkg/init.h index 85ad0df7e..0c1c7ae5a 100644 --- a/apt-pkg/init.h +++ b/apt-pkg/init.h @@ -31,15 +31,4 @@ extern const char *pkgLibVersion; bool pkgInitConfig(Configuration &Cnf); bool pkgInitSystem(Configuration &Cnf,pkgSystem *&Sys); -#ifdef APT_COMPATIBILITY -#if APT_COMPATIBILITY != 986 -#warning "Using APT_COMPATIBILITY" -#endif - -inline bool pkgInitialize(Configuration &Cnf) -{ - return pkgInitConfig(Cnf) && pkgInitSystem(Cnf,_system); -}; -#endif - #endif diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 1356054b5..f7e01f60b 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -10,7 +10,6 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ -#define APT_COMPATIBILITY 986 #include #include diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index af9c2bcb0..b381fa9a3 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -164,18 +164,4 @@ bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, MMap **OutMap = 0,bool AllowMem = false); bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); - -#ifdef APT_COMPATIBILITY -#if APT_COMPATIBILITY != 986 -#warning "Using APT_COMPATIBILITY" -#endif -MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) -{ - MMap *Map = 0; - if (pkgCacheGenerator::MakeStatusCache(List,&Progress,&Map,true) == false) - return 0; - return Map; -} -#endif - #endif diff --git a/apt-pkg/version.h b/apt-pkg/version.h index 47e1919bb..92dbc2576 100644 --- a/apt-pkg/version.h +++ b/apt-pkg/version.h @@ -54,8 +54,4 @@ class pkgVersioningSystem virtual ~pkgVersioningSystem() {}; }; -#ifdef APT_COMPATIBILITY -#include -#endif - #endif -- cgit v1.2.3 From 36a171e1e5b3e6a3baa4be6cfb52dbcd47324abb Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 21:05:00 +0200 Subject: fix foldmarker in algorithms.h --- apt-pkg/algorithms.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 919daefef..2fca0f6af 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1209,7 +1209,6 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) return true; } /*}}}*/ - // ProblemResolver::BreaksInstOrPolicy - Check if the given pkg is broken/*{{{*/ // --------------------------------------------------------------------- /* This checks if the given package is broken either by a hard dependency @@ -1233,7 +1232,7 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I) return false; } - + /*}}}*/ // ProblemResolver::ResolveByKeep - Resolve problems using keep /*{{{*/ // --------------------------------------------------------------------- /* This is the work horse of the soft upgrade routine. It is very gental @@ -1439,7 +1438,7 @@ void pkgPrioSortList(pkgCache &Cache,pkgCache::Version **List) qsort(List,Count,sizeof(*List),PrioComp); } /*}}}*/ -// CacheFile::ListUpdate - update the cache files /*{{{*/ +// ListUpdate - update the cache files /*{{{*/ // --------------------------------------------------------------------- /* This is a simple wrapper to update the cache. it will fetch stuff * from the network (or any other sources defined in sources.list) -- cgit v1.2.3 From edca7af056e5f4e09dd0df235743c512ddfe83e7 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 11:34:37 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - use std::vector instead of fixed size arrays to store args and multiarch-packagename strings --- apt-pkg/deb/dpkgpm.cc | 122 +++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 0cc21f322..c17419819 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -927,10 +927,9 @@ bool pkgDPkgPM::Go(int OutStatusFd) /* nothing */; // Generate the argument list - const char *Args[MaxArgs + 50]; + std::vector Args; // keep track of allocated strings for multiarch package names - char *Packages[MaxArgs + 50]; - unsigned int pkgcount = 0; + std::vector Packages; // Now check if we are within the MaxArgs limit // @@ -940,13 +939,19 @@ bool pkgDPkgPM::Go(int OutStatusFd) // - with the split they may now be configured in different // runs, using Immediate-Configure-All can help prevent this. if (J - I > (signed)MaxArgs) + { J = I + MaxArgs; - - unsigned int n = 0; + Args.reserve(MaxArgs + 10); + } + else + { + Args.reserve((J - I) + 10); + } + unsigned long Size = 0; string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); - Args[n++] = Tmp.c_str(); - Size += strlen(Args[n-1]); + Args.push_back(Tmp.c_str()); + Size += Tmp.length(); // Stick in any custom dpkg options Configuration::Item const *Opts = _config->Tree("DPkg::Options"); @@ -957,76 +962,64 @@ bool pkgDPkgPM::Go(int OutStatusFd) { if (Opts->Value.empty() == true) continue; - Args[n++] = Opts->Value.c_str(); + Args.push_back(Opts->Value.c_str()); Size += Opts->Value.length(); } } - char status_fd_buf[20]; int fd[2]; pipe(fd); - - Args[n++] = "--status-fd"; - Size += strlen(Args[n-1]); + +#define ADDARG(X) Args.push_back(X); Size += strlen(X) +#define ADDARGC(X) Args.push_back(X); Size += sizeof(X) - 1 + + ADDARGC("--status-fd"); + char status_fd_buf[20]; snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]); - Args[n++] = status_fd_buf; - Size += strlen(Args[n-1]); - + ADDARG(status_fd_buf); + unsigned long const Op = I->Op; switch (I->Op) { case Item::Remove: - Args[n++] = "--force-depends"; - Size += strlen(Args[n-1]); - Args[n++] = "--force-remove-essential"; - Size += strlen(Args[n-1]); - Args[n++] = "--remove"; - Size += strlen(Args[n-1]); + ADDARGC("--force-depends"); + ADDARGC("--force-remove-essential"); + ADDARGC("--remove"); break; case Item::Purge: - Args[n++] = "--force-depends"; - Size += strlen(Args[n-1]); - Args[n++] = "--force-remove-essential"; - Size += strlen(Args[n-1]); - Args[n++] = "--purge"; - Size += strlen(Args[n-1]); + ADDARGC("--force-depends"); + ADDARGC("--force-remove-essential"); + ADDARGC("--purge"); break; case Item::Configure: - Args[n++] = "--configure"; - Size += strlen(Args[n-1]); + ADDARGC("--configure"); break; case Item::ConfigurePending: - Args[n++] = "--configure"; - Size += strlen(Args[n-1]); - Args[n++] = "--pending"; - Size += strlen(Args[n-1]); + ADDARGC("--configure"); + ADDARGC("--pending"); break; case Item::TriggersPending: - Args[n++] = "--triggers-only"; - Size += strlen(Args[n-1]); - Args[n++] = "--pending"; - Size += strlen(Args[n-1]); + ADDARGC("--triggers-only"); + ADDARGC("--pending"); break; case Item::Install: - Args[n++] = "--unpack"; - Size += strlen(Args[n-1]); - Args[n++] = "--auto-deconfigure"; - Size += strlen(Args[n-1]); + ADDARGC("--unpack"); + ADDARGC("--auto-deconfigure"); break; } if (NoTriggers == true && I->Op != Item::TriggersPending && I->Op != Item::ConfigurePending) { - Args[n++] = "--no-triggers"; - Size += strlen(Args[n-1]); + ADDARGC("--no-triggers"); } +#undef ADDARGC // Write in the file or package names if (I->Op == Item::Install) @@ -1035,10 +1028,10 @@ bool pkgDPkgPM::Go(int OutStatusFd) { if (I->File[0] != '/') return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str()); - Args[n++] = I->File.c_str(); - Size += strlen(Args[n-1]); + Args.push_back(I->File.c_str()); + Size += I->File.length(); } - } + } else { string const nativeArch = _config->Find("APT::Architecture"); @@ -1049,30 +1042,36 @@ bool pkgDPkgPM::Go(int OutStatusFd) continue; if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end()) continue; - if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all")) - Args[n++] = I->Pkg.Name(); + if (false && (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))) + { + char const * const name = I->Pkg.Name(); + ADDARG(name); + } else { - Packages[pkgcount] = strdup(I->Pkg.FullName(false).c_str()); - Args[n++] = Packages[pkgcount++]; + char * const fullname = strdup(I->Pkg.FullName(false).c_str()); + Packages.push_back(fullname); + ADDARG(fullname); } - Size += strlen(Args[n-1]); } // skip configure action if all sheduled packages disappeared if (oldSize == Size) continue; } - Args[n] = 0; +#undef ADDARG + J = I; if (_config->FindB("Debug::pkgDPkgPM",false) == true) { - for (unsigned int k = 0; k != n; k++) - clog << Args[k] << ' '; - clog << endl; + for (std::vector::const_iterator a = Args.begin(); + a != Args.end(); ++a) + clog << *a << ' '; + clog << "size=" << Size << endl; continue; } - + Args.push_back(NULL); + cout << flush; clog << flush; cerr << flush; @@ -1186,7 +1185,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) /* No Job Control Stop Env is a magic dpkg var that prevents it from using sigstop */ putenv((char *)"DPKG_NO_TSTP=yes"); - execvp(Args[0],(char **)Args); + execvp(Args[0], (char**) &Args[0]); cerr << "Could not exec dpkg!" << endl; _exit(100); } @@ -1212,10 +1211,11 @@ bool pkgDPkgPM::Go(int OutStatusFd) sigemptyset(&sigmask); sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); - /* clean up the temporary allocation for multiarch package names in - the parent, so we don't leak memory when we return. */ - for (unsigned int i = 0; i < pkgcount; i++) - free(Packages[i]); + /* free vectors (and therefore memory) as we don't need the included data anymore */ + for (std::vector::const_iterator p = Packages.begin(); + p != Packages.end(); ++p) + free(*p); + Packages.clear(); // the result of the waitpid call int res; -- cgit v1.2.3 From 11bcbdb93e13e0b2c1625fc0f926378bce43fead Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 11:54:15 +0200 Subject: load the dpkg base arguments only one time and reuse them later --- apt-pkg/deb/dpkgpm.cc | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index c17419819..5eb6406c6 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -905,6 +905,28 @@ bool pkgDPkgPM::Go(int OutStatusFd) // create log OpenLog(); + // Generate the base argument list for dpkg + std::vector Args; + unsigned long StartSize = 0; + string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); + Args.push_back(Tmp.c_str()); + StartSize += Tmp.length(); + + // Stick in any custom dpkg options + Configuration::Item const *Opts = _config->Tree("DPkg::Options"); + if (Opts != 0) + { + Opts = Opts->Child; + for (; Opts != 0; Opts = Opts->Next) + { + if (Opts->Value.empty() == true) + continue; + Args.push_back(Opts->Value.c_str()); + StartSize += Opts->Value.length(); + } + } + size_t const BaseArgs = Args.size(); + // this loop is runs once per operation for (vector::const_iterator I = List.begin(); I != List.end();) { @@ -926,11 +948,13 @@ bool pkgDPkgPM::Go(int OutStatusFd) for (; J != List.end() && J->Op == I->Op; ++J) /* nothing */; - // Generate the argument list - std::vector Args; // keep track of allocated strings for multiarch package names std::vector Packages; + // start with the baseset of arguments + unsigned long Size = StartSize; + Args.erase(Args.begin() + BaseArgs, Args.end()); + // Now check if we are within the MaxArgs limit // // this code below is problematic, because it may happen that @@ -948,24 +972,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) Args.reserve((J - I) + 10); } - unsigned long Size = 0; - string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); - Args.push_back(Tmp.c_str()); - Size += Tmp.length(); - - // Stick in any custom dpkg options - Configuration::Item const *Opts = _config->Tree("DPkg::Options"); - if (Opts != 0) - { - Opts = Opts->Child; - for (; Opts != 0; Opts = Opts->Next) - { - if (Opts->Value.empty() == true) - continue; - Args.push_back(Opts->Value.c_str()); - Size += Opts->Value.length(); - } - } int fd[2]; pipe(fd); @@ -1042,7 +1048,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) continue; if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end()) continue; - if (false && (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))) + if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all")) { char const * const name = I->Pkg.Name(); ADDARG(name); @@ -1067,7 +1073,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) for (std::vector::const_iterator a = Args.begin(); a != Args.end(); ++a) clog << *a << ' '; - clog << "size=" << Size << endl; + clog << endl; continue; } Args.push_back(NULL); -- cgit v1.2.3 From 87da74517a0defa3450d0f3d8c3275f6963d0f5e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 14:21:23 +0200 Subject: * apt-pkg/algorithms.cc: - if a package is garbage, don't try to save it with FixByInstall --- apt-pkg/algorithms.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 2fca0f6af..4c2ea0f2d 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1035,7 +1035,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) if (BrokenFix == false || DoUpgrade(I) == false) { // Consider other options - if (InOr == false) + if (InOr == false || Cache[I].Garbage == true) { if (Debug == true) clog << " Removing " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl; -- cgit v1.2.3 From 778559db797ce61611e2b761b24dcb49c49f2652 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 20 Sep 2011 14:30:31 +0200 Subject: * apt-pkg/deb/dpkgpm.cc: - use std::vector instead of fixed size arrays to store args and multiarch-packagename strings - load the dpkg base arguments only one time and reuse them later * cmdline/apt-get.cc: - follow Provides in the evaluation of saving candidates, too, for statisfying garbage package dependencies (Closes: #640590) * apt-pkg/algorithms.cc: - if a package is garbage, don't try to save it with FixByInstall --- apt-pkg/algorithms.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 150 ++++++++++++++++++++++++++------------------------ 2 files changed, 79 insertions(+), 73 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 5fbcb47be..6ac69032b 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1002,7 +1002,7 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) if (BrokenFix == false || DoUpgrade(I) == false) { // Consider other options - if (InOr == false) + if (InOr == false || Cache[I].Garbage == true) { if (Debug == true) clog << " Removing " << I.FullName(false) << " rather than change " << Start.TargetPkg().FullName(false) << endl; diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 46f48777c..b6c92fc23 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -887,6 +887,28 @@ bool pkgDPkgPM::Go(int OutStatusFd) // create log OpenLog(); + // Generate the base argument list for dpkg + std::vector Args; + unsigned long StartSize = 0; + string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); + Args.push_back(Tmp.c_str()); + StartSize += Tmp.length(); + + // Stick in any custom dpkg options + Configuration::Item const *Opts = _config->Tree("DPkg::Options"); + if (Opts != 0) + { + Opts = Opts->Child; + for (; Opts != 0; Opts = Opts->Next) + { + if (Opts->Value.empty() == true) + continue; + Args.push_back(Opts->Value.c_str()); + StartSize += Opts->Value.length(); + } + } + size_t const BaseArgs = Args.size(); + // this loop is runs once per operation for (vector::const_iterator I = List.begin(); I != List.end();) { @@ -908,11 +930,12 @@ bool pkgDPkgPM::Go(int OutStatusFd) for (; J != List.end() && J->Op == I->Op; ++J) /* nothing */; - // Generate the argument list - const char *Args[MaxArgs + 50]; // keep track of allocated strings for multiarch package names - char *Packages[MaxArgs + 50]; - unsigned int pkgcount = 0; + std::vector Packages; + + // start with the baseset of arguments + unsigned long Size = StartSize; + Args.erase(Args.begin() + BaseArgs, Args.end()); // Now check if we are within the MaxArgs limit // @@ -922,91 +945,67 @@ bool pkgDPkgPM::Go(int OutStatusFd) // - with the split they may now be configured in different // runs if (J - I > (signed)MaxArgs) + { J = I + MaxArgs; - - unsigned int n = 0; - unsigned long Size = 0; - string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg"); - Args[n++] = Tmp.c_str(); - Size += strlen(Args[n-1]); - - // Stick in any custom dpkg options - Configuration::Item const *Opts = _config->Tree("DPkg::Options"); - if (Opts != 0) + Args.reserve(MaxArgs + 10); + } + else { - Opts = Opts->Child; - for (; Opts != 0; Opts = Opts->Next) - { - if (Opts->Value.empty() == true) - continue; - Args[n++] = Opts->Value.c_str(); - Size += Opts->Value.length(); - } + Args.reserve((J - I) + 10); } + - char status_fd_buf[20]; int fd[2]; pipe(fd); - - Args[n++] = "--status-fd"; - Size += strlen(Args[n-1]); + +#define ADDARG(X) Args.push_back(X); Size += strlen(X) +#define ADDARGC(X) Args.push_back(X); Size += sizeof(X) - 1 + + ADDARGC("--status-fd"); + char status_fd_buf[20]; snprintf(status_fd_buf,sizeof(status_fd_buf),"%i", fd[1]); - Args[n++] = status_fd_buf; - Size += strlen(Args[n-1]); + ADDARG(status_fd_buf); switch (I->Op) { case Item::Remove: - Args[n++] = "--force-depends"; - Size += strlen(Args[n-1]); - Args[n++] = "--force-remove-essential"; - Size += strlen(Args[n-1]); - Args[n++] = "--remove"; - Size += strlen(Args[n-1]); + ADDARGC("--force-depends"); + ADDARGC("--force-remove-essential"); + ADDARGC("--remove"); break; case Item::Purge: - Args[n++] = "--force-depends"; - Size += strlen(Args[n-1]); - Args[n++] = "--force-remove-essential"; - Size += strlen(Args[n-1]); - Args[n++] = "--purge"; - Size += strlen(Args[n-1]); + ADDARGC("--force-depends"); + ADDARGC("--force-remove-essential"); + ADDARGC("--purge"); break; case Item::Configure: - Args[n++] = "--configure"; - Size += strlen(Args[n-1]); + ADDARGC("--configure"); break; case Item::ConfigurePending: - Args[n++] = "--configure"; - Size += strlen(Args[n-1]); - Args[n++] = "--pending"; - Size += strlen(Args[n-1]); + ADDARGC("--configure"); + ADDARGC("--pending"); break; case Item::TriggersPending: - Args[n++] = "--triggers-only"; - Size += strlen(Args[n-1]); - Args[n++] = "--pending"; - Size += strlen(Args[n-1]); + ADDARGC("--triggers-only"); + ADDARGC("--pending"); break; case Item::Install: - Args[n++] = "--unpack"; - Size += strlen(Args[n-1]); - Args[n++] = "--auto-deconfigure"; - Size += strlen(Args[n-1]); + ADDARGC("--unpack"); + ADDARGC("--auto-deconfigure"); break; } if (NoTriggers == true && I->Op != Item::TriggersPending && I->Op != Item::ConfigurePending) { - Args[n++] = "--no-triggers"; - Size += strlen(Args[n-1]); + ADDARGC("--no-triggers"); } +#undef ADDARGC // Write in the file or package names if (I->Op == Item::Install) @@ -1015,10 +1014,10 @@ bool pkgDPkgPM::Go(int OutStatusFd) { if (I->File[0] != '/') return _error->Error("Internal Error, Pathname to install is not absolute '%s'",I->File.c_str()); - Args[n++] = I->File.c_str(); - Size += strlen(Args[n-1]); + Args.push_back(I->File.c_str()); + Size += I->File.length(); } - } + } else { string const nativeArch = _config->Find("APT::Architecture"); @@ -1030,29 +1029,35 @@ bool pkgDPkgPM::Go(int OutStatusFd) if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end()) continue; if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all")) - Args[n++] = I->Pkg.Name(); + { + char const * const name = I->Pkg.Name(); + ADDARG(name); + } else { - Packages[pkgcount] = strdup(I->Pkg.FullName(false).c_str()); - Args[n++] = Packages[pkgcount++]; + char * const fullname = strdup(I->Pkg.FullName(false).c_str()); + Packages.push_back(fullname); + ADDARG(fullname); } - Size += strlen(Args[n-1]); } // skip configure action if all sheduled packages disappeared if (oldSize == Size) continue; } - Args[n] = 0; +#undef ADDARG + J = I; if (_config->FindB("Debug::pkgDPkgPM",false) == true) { - for (unsigned int k = 0; k != n; k++) - clog << Args[k] << ' '; + for (std::vector::const_iterator a = Args.begin(); + a != Args.end(); ++a) + clog << *a << ' '; clog << endl; continue; } - + Args.push_back(NULL); + cout << flush; clog << flush; cerr << flush; @@ -1162,7 +1167,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) /* No Job Control Stop Env is a magic dpkg var that prevents it from using sigstop */ putenv((char *)"DPKG_NO_TSTP=yes"); - execvp(Args[0],(char **)Args); + execvp(Args[0], (char**) &Args[0]); cerr << "Could not exec dpkg!" << endl; _exit(100); } @@ -1188,10 +1193,11 @@ bool pkgDPkgPM::Go(int OutStatusFd) sigemptyset(&sigmask); sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); - /* clean up the temporary allocation for multiarch package names in - the parent, so we don't leak memory when we return. */ - for (unsigned int i = 0; i < pkgcount; i++) - free(Packages[i]); + /* free vectors (and therefore memory) as we don't need the included data anymore */ + for (std::vector::const_iterator p = Packages.begin(); + p != Packages.end(); ++p) + free(*p); + Packages.clear(); // the result of the waitpid call int res; -- cgit v1.2.3 From 404528bd581a4d2fa3bae1834d6fde48c6153434 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 21 Sep 2011 18:42:08 +0200 Subject: convert a few for-loop char finds to proper strchr and memchr --- apt-pkg/acquire-method.cc | 10 +++++----- apt-pkg/contrib/cmndline.cc | 28 +++++++++++----------------- apt-pkg/contrib/strutl.cc | 15 +++++++-------- apt-pkg/deb/deblistparser.cc | 21 ++++++++------------- apt-pkg/deb/debversion.cc | 25 ++++++++++--------------- apt-pkg/sourcelist.cc | 2 +- 6 files changed, 42 insertions(+), 59 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 7e9061e56..294d78f86 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -285,12 +285,12 @@ bool pkgAcqMethod::Configuration(string Message) I += Length + 1; for (; I < MsgEnd && *I == ' '; I++); - const char *Equals = I; - for (; Equals < MsgEnd && *Equals != '='; Equals++); - const char *End = Equals; - for (; End < MsgEnd && *End != '\n'; End++); - if (End == Equals) + const char *Equals = (const char*) memchr(I, '=', MsgEnd - I); + if (Equals == NULL) return false; + const char *End = (const char*) memchr(Equals, '\n', MsgEnd - Equals); + if (End == NULL) + End = MsgEnd; Cnf.Set(DeQuoteString(string(I,Equals-I)), DeQuoteString(string(Equals+1,End-Equals-1))); diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc index 5a9944096..f7359c36e 100644 --- a/apt-pkg/contrib/cmndline.cc +++ b/apt-pkg/contrib/cmndline.cc @@ -87,9 +87,8 @@ bool CommandLine::Parse(int argc,const char **argv) Opt++; // Match up to a = against the list - const char *OptEnd = Opt; Args *A; - for (; *OptEnd != 0 && *OptEnd != '='; OptEnd++); + const char *OptEnd = strchrnul(Opt, '='); for (A = ArgList; A->end() == false && stringcasecmp(Opt,OptEnd,A->LongOpt) != 0; A++); @@ -97,9 +96,8 @@ bool CommandLine::Parse(int argc,const char **argv) bool PreceedMatch = false; if (A->end() == true) { - for (; Opt != OptEnd && *Opt != '-'; Opt++); - - if (Opt == OptEnd) + Opt = (const char*) memchr(Opt, '-', OptEnd - Opt); + if (Opt == NULL) return _error->Error(_("Command line option %s is not understood"),argv[I]); Opt++; @@ -194,9 +192,8 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[], // Arbitrary item specification if ((A->Flags & ArbItem) == ArbItem) { - const char *J; - for (J = Argument; *J != 0 && *J != '='; J++); - if (*J == 0) + const char *J = strchr(Argument, '='); + if (J == NULL) return _error->Error(_("Option %s: Configuration item specification must have an =."),argv[I]); // = is trailing @@ -212,8 +209,7 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[], return true; } - const char *I = A->ConfName; - for (; *I != 0 && *I != ' '; I++); + const char *I = strchrnul(A->ConfName, ' '); if (*I == ' ') Conf->Set(string(A->ConfName,0,I-A->ConfName),string(I+1) + Argument); else @@ -269,10 +265,9 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[], // Skip the leading dash const char *J = argv[I]; for (; *J != 0 && *J == '-'; J++); - - const char *JEnd = J; - for (; *JEnd != 0 && *JEnd != '-'; JEnd++); - if (*JEnd != 0) + + const char *JEnd = strchr(J, '-'); + if (JEnd != NULL) { strncpy(Buffer,J,JEnd - J); Buffer[JEnd - J] = 0; @@ -373,9 +368,8 @@ void CommandLine::SaveInConfig(unsigned int const &argc, char const * const * co { // That is possibly an option: Quote it if it includes spaces, // the benefit is that this will eliminate also most false positives - const char* c = &argv[i][j+1]; - for (; *c != '\0' && *c != ' '; ++c); - if (*c == '\0') continue; + const char* c = strchr(&argv[i][j+1], ' '); + if (c == NULL) continue; cmdline[++length] = '"'; closeQuote = true; } diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 867bb313b..8dd05b9c0 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -179,14 +179,14 @@ bool ParseQuoteWord(const char *&String,string &Res) { if (*C == '"') { - for (C++; *C != 0 && *C != '"'; C++); - if (*C == 0) + C = strchr(C + 1, '"'); + if (C == NULL) return false; } if (*C == '[') { - for (C++; *C != 0 && *C != ']'; C++); - if (*C == 0) + C = strchr(C + 1, ']'); + if (C == NULL) return false; } } @@ -904,11 +904,10 @@ bool StrToTime(const string &Val,time_t &Result) { struct tm Tm; char Month[10]; - const char *I = Val.c_str(); - + // Skip the day of the week - for (;*I != 0 && *I != ' '; I++); - + const char *I = strchr(Val.c_str(), ' '); + // Handle RFC 1123 time Month[0] = 0; if (sscanf(I," %d %3s %d %d:%d:%d GMT",&Tm.tm_mday,Month,&Tm.tm_year, diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 8d3f6f0ba..0562be44c 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -525,9 +525,9 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, // Skip whitespace for (;I != Stop && isspace(*I) != 0; I++); Start = I; - for (;I != Stop && *I != ')'; I++); - if (I == Stop || Start == I) - return 0; + I = (const char*) memchr(I, ')', Stop - I); + if (I == NULL || Start == I) + return 0; // Skip trailing whitespace const char *End = I; @@ -800,21 +800,16 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI, } // seperate the tag from the data - for (; buffer[len] != ':' && buffer[len] != '\0'; ++len) - /* nothing */ - ; - if (buffer[len] == '\0') + const char* dataStart = strchr(buffer + len, ':'); + if (dataStart == NULL) continue; - char* dataStart = buffer + len; + len = dataStart - buffer; for (++dataStart; *dataStart == ' '; ++dataStart) /* nothing */ ; - char* dataEnd = dataStart; - for (++dataEnd; *dataEnd != '\0'; ++dataEnd) - /* nothing */ - ; + const char* dataEnd = (const char*)rawmemchr(dataStart, '\0'); // The last char should be a newline, but we can never be sure: #633350 - char* lineEnd = dataEnd; + const char* lineEnd = dataEnd; for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd) /* nothing */ ; diff --git a/apt-pkg/deb/debversion.cc b/apt-pkg/deb/debversion.cc index 755ffbe96..340403721 100644 --- a/apt-pkg/deb/debversion.cc +++ b/apt-pkg/deb/debversion.cc @@ -127,14 +127,12 @@ int debVersioningSystem::CmpFragment(const char *A,const char *AEnd, int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd, const char *B,const char *BEnd) { - // Strip off the epoch and compare it - const char *lhs = A; - const char *rhs = B; - for (;lhs != AEnd && *lhs != ':'; lhs++); - for (;rhs != BEnd && *rhs != ':'; rhs++); - if (lhs == AEnd) + // Strip off the epoch and compare it + const char *lhs = (const char*) memchr(A, ':', AEnd - A); + const char *rhs = (const char*) memchr(B, ':', BEnd - B); + if (lhs == NULL) lhs = A; - if (rhs == BEnd) + if (rhs == NULL) rhs = B; // Special case: a zero epoch is the same as no epoch, @@ -169,15 +167,12 @@ int debVersioningSystem::DoCmpVersion(const char *A,const char *AEnd, if (rhs != B) rhs++; - // Find the last - - const char *dlhs = AEnd-1; - const char *drhs = BEnd-1; - for (;dlhs > lhs && *dlhs != '-'; dlhs--); - for (;drhs > rhs && *drhs != '-'; drhs--); - - if (dlhs == lhs) + // Find the last - + const char *dlhs = (const char*) memrchr(lhs, '-', AEnd - lhs); + const char *drhs = (const char*) memrchr(rhs, '-', BEnd - rhs); + if (dlhs == NULL) dlhs = AEnd; - if (drhs == rhs) + if (drhs == NULL) drhs = BEnd; // Compare the main version diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index a25358bf2..ebfb5289e 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -266,7 +266,7 @@ bool pkgSourceList::ReadAppend(string File) // CNC:2003-02-20 - Do not break if '#' is inside []. for (I = Buffer; *I != 0 && *I != '#'; I++) if (*I == '[') - for (I++; *I != 0 && *I != ']'; I++); + I = strchr(I + 1, ']'); *I = 0; const char *C = _strstrip(Buffer); -- cgit v1.2.3 From 39fb1e241ebb76c7e51c8d8f2f76ce5f1e680859 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 21 Sep 2011 19:31:03 +0200 Subject: * apt-pkg/deb/debsrcrecords.cc: - remove the limit of 400 Binaries for a source package (Closes: #622110) --- apt-pkg/deb/debsrcrecords.cc | 41 ++++++++++++++++++++++++----------------- apt-pkg/deb/debsrcrecords.h | 5 ++--- 2 files changed, 26 insertions(+), 20 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 38389e624..ce55ccd1f 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -32,25 +32,32 @@ using std::string; used during scanning to find the right package */ const char **debSrcRecordParser::Binaries() { - // This should use Start/Stop too, it is supposed to be efficient after all. - string Bins = Sect.FindS("Binary"); - if (Bins.empty() == true || Bins.length() >= 102400) - return 0; - - if (Bins.length() >= BufSize) - { - delete [] Buffer; - // allocate new size based on buffer (but never smaller than 4000) - BufSize = max((unsigned int)4000, max((unsigned int)Bins.length()+1,2*BufSize)); - Buffer = new char[BufSize]; - } + const char *Start, *End; + if (Sect.Find("Binary", Start, End) == false) + return NULL; + for (; isspace(*Start) != 0; ++Start); + if (Start >= End) + return NULL; - strcpy(Buffer,Bins.c_str()); - if (TokSplitString(',',Buffer,StaticBinList, - sizeof(StaticBinList)/sizeof(StaticBinList[0])) == false) - return 0; + StaticBinList.clear(); + free(Buffer); + Buffer = strndup(Start, End - Start); + + char* bin = Buffer; + do { + char* binStartNext = strchrnul(bin, ','); + char* binEnd = binStartNext - 1; + for (; isspace(*binEnd) != 0; --binEnd) + binEnd = '\0'; + StaticBinList.push_back(bin); + if (*binStartNext != ',') + break; + *binStartNext = '\0'; + for (bin = binStartNext + 1; isspace(*bin) != 0; ++bin); + } while (*bin != '\0'); + StaticBinList.push_back(NULL); - return (const char **)StaticBinList; + return (const char **) &StaticBinList[0]; } /*}}}*/ // SrcRecordParser::BuildDepends - Return the Build-Depends information /*{{{*/ diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index bb588e3d9..4c8d03224 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -24,10 +24,9 @@ class debSrcRecordParser : public pkgSrcRecords::Parser FileFd Fd; pkgTagFile Tags; pkgTagSection Sect; - char *StaticBinList[400]; + std::vector StaticBinList; unsigned long iOffset; char *Buffer; - unsigned int BufSize; public: @@ -52,7 +51,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) : Parser(Index), Fd(File,FileFd::ReadOnlyGzip), Tags(&Fd,102400), - Buffer(0), BufSize(0) {} + Buffer(NULL) {} virtual ~debSrcRecordParser(); }; -- cgit v1.2.3 From a91cb9542572fe5aa279db5ac5d28465bec1905f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 21 Sep 2011 19:37:31 +0200 Subject: * apt-pkg/init.cc: - silently ignore *.orig and *.save files by default --- apt-pkg/init.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc index 38a0814e5..b283e2dd9 100644 --- a/apt-pkg/init.cc +++ b/apt-pkg/init.cc @@ -81,13 +81,12 @@ bool pkgInitConfig(Configuration &Cnf) Cnf.CndSet("Dir::Log::Terminal","term.log"); Cnf.CndSet("Dir::Log::History","history.log"); - if (Cnf.Exists("Dir::Ignore-Files-Silently") == false) - { - Cnf.Set("Dir::Ignore-Files-Silently::", "~$"); - Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$"); - Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$"); - Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$"); - } + Cnf.Set("Dir::Ignore-Files-Silently::", "~$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.disabled$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.bak$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.dpkg-[a-z]+$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.save$"); + Cnf.Set("Dir::Ignore-Files-Silently::", "\\.orig$"); // Default cdrom mount point Cnf.CndSet("Acquire::cdrom::mount", "/media/cdrom/"); -- cgit v1.2.3 From 061c58b61ab5aae4689386bd2ab1e36e71470dfc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 4 Oct 2011 00:14:38 +0200 Subject: * apt-pkg/policy.cc: - accept generic release pin expressions again in -t (Closes: #644166) --- apt-pkg/policy.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index 6a5130d48..a369bea83 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -64,7 +64,8 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner) { 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)) + (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true) || + (DefRel.length() > 2 && DefRel[1] == '=')) found = true; } if (found == false) -- cgit v1.2.3 From 7cb28948317e0d326c8663ec3c9ce995d5bf65e8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Oct 2011 22:45:22 +0200 Subject: * apt-pkg/deb/debmetaindex.cc: - none is a separator, not a language: no need for Index (Closes: #624218) * apt-pkg/aptconfiguration.cc: - do not builtin languages only if none is forced (Closes: #643787) --- apt-pkg/aptconfiguration.cc | 6 ++++-- apt-pkg/deb/debmetaindex.cc | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index a0566e05e..7441b452c 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -142,7 +142,7 @@ std::vector const Configuration::getLanguages(bool const &All, for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) { string const name = Ent->d_name; size_t const foundDash = name.rfind("-"); - size_t const foundUnderscore = name.rfind("_"); + size_t const foundUnderscore = name.rfind("_", foundDash); if (foundDash == string::npos || foundUnderscore == string::npos || foundDash <= foundUnderscore || name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation") @@ -153,7 +153,7 @@ std::vector const Configuration::getLanguages(bool const &All, // Skip unusual files, like backups or that alike string::const_iterator s = c.begin(); for (;s != c.end(); ++s) { - if (isalpha(*s) == 0) + if (isalpha(*s) == 0 && *s != '_') break; } if (s != c.end()) @@ -234,6 +234,8 @@ std::vector const Configuration::getLanguages(bool const &All, codes = environment; } else if (forceLang != "none") codes.push_back(forceLang); + else //if (forceLang == "none") + builtin.clear(); allCodes = codes; for (std::vector::const_iterator b = builtin.begin(); b != builtin.end(); ++b) diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index c509c29c7..5d3a80aa5 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -13,6 +13,7 @@ #include #include +#include using namespace std; @@ -201,7 +202,11 @@ vector * debReleaseIndex::ComputeIndexTargets() const { } } - std::vector const lang = APT::Configuration::getLanguages(true); + std::vector lang = APT::Configuration::getLanguages(true); + std::vector::iterator lend = std::remove(lang.begin(), lang.end(), "none"); + if (lend != lang.end()) + lang.erase(lend); + if (lang.empty() == true) return IndexTargets; @@ -213,7 +218,6 @@ vector * debReleaseIndex::ComputeIndexTargets() const { s != sections.end(); ++s) { for (std::vector::const_iterator l = lang.begin(); l != lang.end(); ++l) { - if (*l == "none") continue; IndexTarget * Target = new OptionalIndexTarget(); Target->ShortDesc = "Translation-" + *l; Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s); -- cgit v1.2.3 From d073d7db69eddd2d9c22e8ded7c6b871bca1716a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Oct 2011 23:00:47 +0200 Subject: cherrypick from my apt/experimental branch * apt-pkg/deb/debmetaindex.cc: - none is a separator, not a language: no need for Index (Closes: #624218) * apt-pkg/aptconfiguration.cc: - do not builtin languages only if none is forced (Closes: #643787) --- apt-pkg/aptconfiguration.cc | 6 ++++-- apt-pkg/deb/debmetaindex.cc | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 6ec5fa03a..bc385b2dc 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -140,7 +140,7 @@ std::vector const Configuration::getLanguages(bool const &All, for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) { string const name = Ent->d_name; size_t const foundDash = name.rfind("-"); - size_t const foundUnderscore = name.rfind("_"); + size_t const foundUnderscore = name.rfind("_", foundDash); if (foundDash == string::npos || foundUnderscore == string::npos || foundDash <= foundUnderscore || name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation") @@ -151,7 +151,7 @@ std::vector const Configuration::getLanguages(bool const &All, // Skip unusual files, like backups or that alike string::const_iterator s = c.begin(); for (;s != c.end(); ++s) { - if (isalpha(*s) == 0) + if (isalpha(*s) == 0 && *s != '_') break; } if (s != c.end()) @@ -232,6 +232,8 @@ std::vector const Configuration::getLanguages(bool const &All, codes = environment; } else if (forceLang != "none") codes.push_back(forceLang); + else //if (forceLang == "none") + builtin.clear(); allCodes = codes; for (std::vector::const_iterator b = builtin.begin(); b != builtin.end(); ++b) diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index f6c50742e..22effdc8f 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -9,6 +9,7 @@ #include #include +#include using namespace std; @@ -195,7 +196,11 @@ vector * debReleaseIndex::ComputeIndexTargets() const { } } - std::vector const lang = APT::Configuration::getLanguages(true); + std::vector lang = APT::Configuration::getLanguages(true); + std::vector::iterator lend = std::remove(lang.begin(), lang.end(), "none"); + if (lend != lang.end()) + lang.erase(lend); + if (lang.empty() == true) return IndexTargets; @@ -207,7 +212,6 @@ vector * debReleaseIndex::ComputeIndexTargets() const { s != sections.end(); ++s) { for (std::vector::const_iterator l = lang.begin(); l != lang.end(); ++l) { - if (*l == "none") continue; IndexTarget * Target = new OptionalIndexTarget(); Target->ShortDesc = "Translation-" + *l; Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s); -- cgit v1.2.3 From 99a2ea5a2737ba6bf346e15a609d927dc03a02ea Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 11 Oct 2011 18:34:21 +0200 Subject: * apt-pkg/pkgcachegen.cc: - refactor MergeList by creating -Group, -Package and -Version specialist --- apt-pkg/contrib/hashsum_template.h | 6 +- apt-pkg/deb/deblistparser.cc | 5 +- apt-pkg/pkgcachegen.cc | 304 ++++++++++++++++++++++--------------- apt-pkg/pkgcachegen.h | 6 + 4 files changed, 190 insertions(+), 131 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index c109a8212..27d192b82 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -26,7 +26,11 @@ class HashSumValue bool operator ==(const HashSumValue &rhs) const { return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0; - }; + }; + bool operator !=(const HashSumValue &rhs) const + { + return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0; + }; std::string Value() const { diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index f6fb2789c..a36857cb5 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -74,10 +74,7 @@ string debListParser::Package() { // --------------------------------------------------------------------- /* This will return the Architecture of the package this section describes */ string debListParser::Architecture() { - std::string const Arch = Section.FindS("Architecture"); - if (Arch.empty() == true) - return _config->Find("APT::Architecture"); - return Arch; + return Section.FindS("Architecture"); } /*}}}*/ // ListParser::ArchitectureAll /*{{{*/ diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index f7e01f60b..5147d7547 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -182,82 +182,149 @@ bool pkgCacheGenerator::MergeList(ListParser &List, if (PackageName.empty() == true) return false; - string const Arch = List.Architecture(); - + Counter++; + if (Counter % 100 == 0 && Progress != 0) + Progress->Progress(List.Offset()); + + string Arch = List.Architecture(); + string const Version = List.Version(); + if (Version.empty() == true && Arch.empty() == true) + { + if (MergeListGroup(List, PackageName) == false) + return false; + } + + if (Arch.empty() == true) + Arch = _config->Find("APT::Architecture"); + // Get a pointer to the package structure pkgCache::PkgIterator Pkg; Dynamic DynPkg(Pkg); if (NewPackage(Pkg, PackageName, Arch) == false) return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str()); - Counter++; - if (Counter % 100 == 0 && Progress != 0) - Progress->Progress(List.Offset()); - /* Get a pointer to the version structure. We know the list is sorted - so we use that fact in the search. Insertion of new versions is - done with correct sorting */ - string Version = List.Version(); + if (Version.empty() == true) { - // we first process the package, then the descriptions - // (this has the bonus that we get MMap error when we run out - // of MMap space) - pkgCache::VerIterator Ver(Cache); - Dynamic DynVer(Ver); - if (List.UsePackage(Pkg, Ver) == false) - return _error->Error(_("Error occurred while processing %s (UsePackage1)"), - PackageName.c_str()); - - // Find the right version to write the description - MD5SumValue CurMd5 = List.Description_md5(); - Ver = Pkg.VersionList(); - - for (; Ver.end() == false; ++Ver) - { - pkgCache::DescIterator Desc = Ver.DescriptionList(); - Dynamic DynDesc(Desc); - map_ptrloc *LastDesc = &Ver->DescriptionList; - bool duplicate=false; - - // don't add a new description if we have one for the given - // md5 && language - for ( ; Desc.end() == false; ++Desc) - if (MD5SumValue(Desc.md5()) == CurMd5 && - Desc.LanguageCode() == List.DescriptionLanguage()) - duplicate=true; - if(duplicate) - continue; - - for (Desc = Ver.DescriptionList(); - Desc.end() == false; - LastDesc = &Desc->NextDesc, ++Desc) - { - if (MD5SumValue(Desc.md5()) == CurMd5) - { - // Add new description - void const * const oldMap = Map.Data(); - map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc); - if (oldMap != Map.Data()) - LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - *LastDesc = descindex; - Desc->ParentPkg = Pkg.Index(); - - if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"),PackageName.c_str()); - break; - } - } - } + if (MergeListPackage(List, Pkg) == false) + return false; + } + else + { + if (MergeListVersion(List, Pkg, Version, OutVer) == false) + return false; + } - continue; + if (OutVer != 0) + { + FoundFileDeps |= List.HasFileDeps(); + return true; } + } - pkgCache::VerIterator Ver = Pkg.VersionList(); - Dynamic DynVer(Ver); - map_ptrloc *LastVer = &Pkg->VersionList; - void const * oldMap = Map.Data(); + if (Cache.HeaderP->PackageCount >= (1ULL<ID)*8)-1) + return _error->Error(_("Wow, you exceeded the number of package " + "names this APT is capable of.")); + if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID)*8))-1) + return _error->Error(_("Wow, you exceeded the number of versions " + "this APT is capable of.")); + if (Cache.HeaderP->DescriptionCount >= (1ULL<<(sizeof(Cache.DescP->ID)*8))-1) + return _error->Error(_("Wow, you exceeded the number of descriptions " + "this APT is capable of.")); + if (Cache.HeaderP->DependsCount >= (1ULL<<(sizeof(Cache.DepP->ID)*8))-1ULL) + return _error->Error(_("Wow, you exceeded the number of dependencies " + "this APT is capable of.")); + + FoundFileDeps |= List.HasFileDeps(); + return true; +} +// CacheGenerator::MergeListGroup /*{{{*/ +bool pkgCacheGenerator::MergeListGroup(ListParser &List, std::string const &GrpName) +{ + pkgCache::GrpIterator Grp = Cache.FindGrp(GrpName); + if (Grp.end() == true) + return _error->Error("Information merge for non-existent group %s requested", GrpName.c_str()); + Dynamic DynGrp(Grp); + + pkgCache::PkgIterator Pkg; + Dynamic DynPkg(Pkg); + for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg)) + if (MergeListPackage(List, Pkg) == false) + return false; + + return true; +} + /*}}}*/ +// CacheGenerator::MergeListPackage /*{{{*/ +bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg) +{ + // we first process the package, then the descriptions + // (for deb this package processing is in fact a no-op) + pkgCache::VerIterator Ver(Cache); + Dynamic DynVer(Ver); + if (List.UsePackage(Pkg, Ver) == false) + return _error->Error(_("Error occurred while processing %s (UsePackage1)"), + Pkg.Name()); + + // Find the right version to write the description + MD5SumValue CurMd5 = List.Description_md5(); + + for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) + { + pkgCache::DescIterator Desc = Ver.DescriptionList(); + Dynamic DynDesc(Desc); + map_ptrloc *LastDesc = &Ver->DescriptionList; + + + // don't add a new description if we have one for the given + // md5 && language + bool duplicate = false; + for ( ; Desc.end() == false; ++Desc) + if (MD5SumValue(Desc.md5()) == CurMd5 && + Desc.LanguageCode() == List.DescriptionLanguage()) + duplicate=true; + if (duplicate == true) + continue; + + for (Desc = Ver.DescriptionList(); + Desc.end() == false; + LastDesc = &Desc->NextDesc, ++Desc) + { + if (MD5SumValue(Desc.md5()) != CurMd5) + continue; + + // Add new description + void const * const oldMap = Map.Data(); + map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc); + if (oldMap != Map.Data()) + LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + *LastDesc = descindex; + Desc->ParentPkg = Pkg.Index(); + + if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) + return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"), Pkg.Name()); + break; + } + } + + return true; +} + /*}}}*/ +// CacheGenerator::MergeListVersion /*{{{*/ +bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, + std::string const &Version, pkgCache::VerIterator* &OutVer) +{ + pkgCache::VerIterator Ver = Pkg.VersionList(); + Dynamic DynVer(Ver); + map_ptrloc *LastVer = &Pkg->VersionList; + void const * oldMap = Map.Data(); + + unsigned long const Hash = List.VersionHash(); + if (Ver.end() == false) + { + /* We know the list is sorted so we use that fact in the search. + Insertion of new versions is done with correct sorting */ int Res = 1; - unsigned long const Hash = List.VersionHash(); for (; Ver.end() == false; LastVer = &Ver->NextVer, Ver++) { Res = Cache.VS->CmpVersion(Version,Ver.VerStr()); @@ -276,93 +343,78 @@ bool pkgCacheGenerator::MergeList(ListParser &List, { if (List.UsePackage(Pkg,Ver) == false) return _error->Error(_("Error occurred while processing %s (UsePackage2)"), - PackageName.c_str()); + Pkg.Name()); if (NewFileVer(Ver,List) == false) return _error->Error(_("Error occurred while processing %s (NewFileVer1)"), - PackageName.c_str()); - + Pkg.Name()); + // Read only a single record and return if (OutVer != 0) { *OutVer = Ver; - FoundFileDeps |= List.HasFileDeps(); return true; } - - continue; + + return true; } + } - // Add a new version - map_ptrloc const verindex = NewVersion(Ver,Version,*LastVer); - if (verindex == 0 && _error->PendingError()) - return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), - PackageName.c_str(), 1); + // Add a new version + map_ptrloc const verindex = NewVersion(Ver,Version,*LastVer); + if (verindex == 0 && _error->PendingError()) + return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), + Pkg.Name(), 1); - if (oldMap != Map.Data()) + if (oldMap != Map.Data()) LastVer += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - *LastVer = verindex; - Ver->ParentPkg = Pkg.Index(); - Ver->Hash = Hash; + *LastVer = verindex; + Ver->ParentPkg = Pkg.Index(); + Ver->Hash = Hash; - if (List.NewVersion(Ver) == false) - return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), - PackageName.c_str(), 2); + if (List.NewVersion(Ver) == false) + return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), + Pkg.Name(), 2); - if (List.UsePackage(Pkg,Ver) == false) - return _error->Error(_("Error occurred while processing %s (UsePackage3)"), - PackageName.c_str()); - - if (NewFileVer(Ver,List) == false) - return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), - PackageName.c_str(), 3); + if (List.UsePackage(Pkg,Ver) == false) + return _error->Error(_("Error occurred while processing %s (UsePackage3)"), + Pkg.Name()); - // Read only a single record and return - if (OutVer != 0) - { - *OutVer = Ver; - FoundFileDeps |= List.HasFileDeps(); - return true; - } + if (NewFileVer(Ver,List) == false) + return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), + Pkg.Name(), 3); - /* Record the Description data. Description data always exist in - Packages and Translation-* files. */ - pkgCache::DescIterator Desc = Ver.DescriptionList(); - Dynamic DynDesc(Desc); - map_ptrloc *LastDesc = &Ver->DescriptionList; + // Read only a single record and return + if (OutVer != 0) + { + *OutVer = Ver; + return true; + } - // Skip to the end of description set - for (; Desc.end() == false; LastDesc = &Desc->NextDesc, Desc++); + /* Record the Description data. Description data always exist in + Packages and Translation-* files. */ + pkgCache::DescIterator Desc = Ver.DescriptionList(); + Dynamic DynDesc(Desc); + map_ptrloc *LastDesc = &Ver->DescriptionList; - // Add new description - oldMap = Map.Data(); - map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc); - if (oldMap != Map.Data()) - LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - *LastDesc = descindex; - Desc->ParentPkg = Pkg.Index(); + // Skip to the end of description set + for (; Desc.end() == false; LastDesc = &Desc->NextDesc, ++Desc); - if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),PackageName.c_str()); - } + // Add new description + oldMap = Map.Data(); + map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc); + if (oldMap != Map.Data()) + LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + *LastDesc = descindex; + Desc->ParentPkg = Pkg.Index(); - FoundFileDeps |= List.HasFileDeps(); + if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) + return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),Pkg.Name()); - if (Cache.HeaderP->PackageCount >= (1ULL<ID)*8)-1) - return _error->Error(_("Wow, you exceeded the number of package " - "names this APT is capable of.")); - if (Cache.HeaderP->VersionCount >= (1ULL<<(sizeof(Cache.VerP->ID)*8))-1) - return _error->Error(_("Wow, you exceeded the number of versions " - "this APT is capable of.")); - if (Cache.HeaderP->DescriptionCount >= (1ULL<<(sizeof(Cache.DescP->ID)*8))-1) - return _error->Error(_("Wow, you exceeded the number of descriptions " - "this APT is capable of.")); - if (Cache.HeaderP->DependsCount >= (1ULL<<(sizeof(Cache.DepP->ID)*8))-1ULL) - return _error->Error(_("Wow, you exceeded the number of dependencies " - "this APT is capable of.")); return true; } /*}}}*/ + /*}}}*/ // CacheGenerator::MergeFileProvides - Merge file provides /*{{{*/ // --------------------------------------------------------------------- /* If we found any file depends while parsing the main list we need to diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index b381fa9a3..99795bb1c 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -105,6 +105,12 @@ class pkgCacheGenerator /*{{{*/ pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); ~pkgCacheGenerator(); + + private: + bool MergeListGroup(ListParser &List, std::string const &GrpName); + bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg); + bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, + std::string const &Version, pkgCache::VerIterator* &OutVer); }; /*}}}*/ // This is the abstract package list parser class. /*{{{*/ -- cgit v1.2.3 From 5f4db009e50a254f1dd3edaac7b77fe31e1c5f6b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 11 Oct 2011 21:10:31 +0200 Subject: share description list between "same" versions (LP: #868977) --- apt-pkg/pkgcachegen.cc | 60 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 15 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 5147d7547..3545517fe 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -38,6 +38,9 @@ typedef vector::iterator FileIterator; template std::vector pkgCacheGenerator::Dynamic::toReMap; +bool IsDuplicateDescription(pkgCache::DescIterator Desc, + MD5SumValue const &CurMd5, std::string const &CurLang); + // CacheGenerator::pkgCacheGenerator - Constructor /*{{{*/ // --------------------------------------------------------------------- /* We set the dirty flag and make sure that is written to the disk */ @@ -242,8 +245,11 @@ bool pkgCacheGenerator::MergeList(ListParser &List, bool pkgCacheGenerator::MergeListGroup(ListParser &List, std::string const &GrpName) { pkgCache::GrpIterator Grp = Cache.FindGrp(GrpName); + // a group has no data on it's own, only packages have it but these + // stanzas like this come from Translation- files to add descriptions, + // but without a version we don't need a description for it… if (Grp.end() == true) - return _error->Error("Information merge for non-existent group %s requested", GrpName.c_str()); + return true; Dynamic DynGrp(Grp); pkgCache::PkgIterator Pkg; @@ -268,6 +274,7 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator // Find the right version to write the description MD5SumValue CurMd5 = List.Description_md5(); + std::string CurLang = List.DescriptionLanguage(); for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { @@ -275,15 +282,9 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator Dynamic DynDesc(Desc); map_ptrloc *LastDesc = &Ver->DescriptionList; - // don't add a new description if we have one for the given // md5 && language - bool duplicate = false; - for ( ; Desc.end() == false; ++Desc) - if (MD5SumValue(Desc.md5()) == CurMd5 && - Desc.LanguageCode() == List.DescriptionLanguage()) - duplicate=true; - if (duplicate == true) + if (IsDuplicateDescription(Desc, CurMd5, CurLang) == true) continue; for (Desc = Ver.DescriptionList(); @@ -295,7 +296,7 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator // Add new description void const * const oldMap = Map.Data(); - map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), CurMd5, *LastDesc); + map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc); if (oldMap != Map.Data()) LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; *LastDesc = descindex; @@ -391,16 +392,34 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator return true; } - /* Record the Description data. Description data always exist in - Packages and Translation-* files. */ + /* Record the Description (it is not translated) */ + MD5SumValue CurMd5 = List.Description_md5(); + if (CurMd5.Value().empty() == true) + return true; + std::string CurLang = List.DescriptionLanguage(); + + /* Before we add a new description we first search in the group for + a version with a description of the same MD5 - if so we reuse this + description group instead of creating our own for this version */ + pkgCache::GrpIterator Grp = Pkg.Group(); + for (pkgCache::PkgIterator P = Grp.PackageList(); + P.end() == false; P = Grp.NextPkg(P)) + { + for (pkgCache::VerIterator V = P.VersionList(); + V.end() == false; ++V) + { + if (IsDuplicateDescription(V.DescriptionList(), CurMd5, "") == false) + continue; + Ver->DescriptionList = V->DescriptionList; + return true; + } + } + + // We haven't found reusable descriptions, so add the first description pkgCache::DescIterator Desc = Ver.DescriptionList(); Dynamic DynDesc(Desc); map_ptrloc *LastDesc = &Ver->DescriptionList; - // Skip to the end of description set - for (; Desc.end() == false; LastDesc = &Desc->NextDesc, ++Desc); - - // Add new description oldMap = Map.Data(); map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc); if (oldMap != Map.Data()) @@ -1403,3 +1422,14 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O return true; } /*}}}*/ +// IsDuplicateDescription /*{{{*/ +bool IsDuplicateDescription(pkgCache::DescIterator Desc, + MD5SumValue const &CurMd5, std::string const &CurLang) +{ + for ( ; Desc.end() == false; ++Desc) + if (MD5SumValue(Desc.md5()) == CurMd5 && Desc.LanguageCode() == CurLang) + return true; + return false; +} + /*}}}*/ + -- cgit v1.2.3 From 22f07fc5e77bcedbc774a4b60d305da847fab287 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Oct 2011 15:47:56 +0200 Subject: a version can have only a single md5 for descriptions, so we can optimize the merging with this knowledge a bit and by correctly sharing the lists we only need to have a single description list for possibly many different versions. This also means that description translations are shared between different sources --- apt-pkg/pkgcachegen.cc | 54 ++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 3545517fe..3b2c08e34 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -279,33 +279,36 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator for (Ver = Pkg.VersionList(); Ver.end() == false; ++Ver) { pkgCache::DescIterator Desc = Ver.DescriptionList(); - Dynamic DynDesc(Desc); - map_ptrloc *LastDesc = &Ver->DescriptionList; + + // a version can only have one md5 describing it + if (MD5SumValue(Desc.md5()) != CurMd5) + continue; // don't add a new description if we have one for the given // md5 && language if (IsDuplicateDescription(Desc, CurMd5, CurLang) == true) continue; - for (Desc = Ver.DescriptionList(); - Desc.end() == false; - LastDesc = &Desc->NextDesc, ++Desc) - { - if (MD5SumValue(Desc.md5()) != CurMd5) - continue; - - // Add new description - void const * const oldMap = Map.Data(); - map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc); - if (oldMap != Map.Data()) - LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; - *LastDesc = descindex; - Desc->ParentPkg = Pkg.Index(); - - if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"), Pkg.Name()); - break; - } + Dynamic DynDesc(Desc); + // we add at the end, so that the start is constant as we need + // that to be able to efficiently share these lists + map_ptrloc *LastDesc = &Ver->DescriptionList; + for (;Desc.end() == false && Desc->NextDesc != 0; ++Desc); + if (Desc.end() == false) + LastDesc = &Desc->NextDesc; + + void const * const oldMap = Map.Data(); + map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc); + if (oldMap != Map.Data()) + LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; + *LastDesc = descindex; + Desc->ParentPkg = Pkg.Index(); + + if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) + return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"), Pkg.Name()); + + // we can stop here as all "same" versions will share the description + break; } return true; @@ -421,7 +424,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator map_ptrloc *LastDesc = &Ver->DescriptionList; oldMap = Map.Data(); - map_ptrloc const descindex = NewDescription(Desc, List.DescriptionLanguage(), List.Description_md5(), *LastDesc); + map_ptrloc const descindex = NewDescription(Desc, CurLang, CurMd5, *LastDesc); if (oldMap != Map.Data()) LastDesc += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; *LastDesc = descindex; @@ -1426,8 +1429,11 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O bool IsDuplicateDescription(pkgCache::DescIterator Desc, MD5SumValue const &CurMd5, std::string const &CurLang) { - for ( ; Desc.end() == false; ++Desc) - if (MD5SumValue(Desc.md5()) == CurMd5 && Desc.LanguageCode() == CurLang) + // Descriptions in the same link-list have all the same md5 + if (MD5SumValue(Desc.md5()) != CurMd5) + return false; + for (; Desc.end() == false; ++Desc) + if (Desc.LanguageCode() == CurLang) return true; return false; } -- cgit v1.2.3 From 79e9003cd2d895936634da7d810eec389f7b97c2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Oct 2011 19:34:06 +0200 Subject: use one string to construct the error message instead of using multiple just with different debugging information at the end --- apt-pkg/pkgcachegen.cc | 53 ++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 3b2c08e34..47441d65c 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -204,7 +204,10 @@ bool pkgCacheGenerator::MergeList(ListParser &List, pkgCache::PkgIterator Pkg; Dynamic DynPkg(Pkg); if (NewPackage(Pkg, PackageName, Arch) == false) - return _error->Error(_("Error occurred while processing %s (NewPackage)"),PackageName.c_str()); + // TRANSLATOR: The first placeholder is a package name, + // the other two should be copied verbatim as they include debug info + return _error->Error(_("Error occurred while processing %s (%s%d)"), + PackageName.c_str(), "NewPackage", 1); if (Version.empty() == true) @@ -269,8 +272,8 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator pkgCache::VerIterator Ver(Cache); Dynamic DynVer(Ver); if (List.UsePackage(Pkg, Ver) == false) - return _error->Error(_("Error occurred while processing %s (UsePackage1)"), - Pkg.Name()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "UsePackage", 1); // Find the right version to write the description MD5SumValue CurMd5 = List.Description_md5(); @@ -305,7 +308,8 @@ bool pkgCacheGenerator::MergeListPackage(ListParser &List, pkgCache::PkgIterator Desc->ParentPkg = Pkg.Index(); if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc1)"), Pkg.Name()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "NewFileDesc", 1); // we can stop here as all "same" versions will share the description break; @@ -346,12 +350,12 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator if (Res == 0 && Ver.end() == false && Ver->Hash == Hash) { if (List.UsePackage(Pkg,Ver) == false) - return _error->Error(_("Error occurred while processing %s (UsePackage2)"), - Pkg.Name()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "UsePackage", 2); if (NewFileVer(Ver,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileVer1)"), - Pkg.Name()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "NewFileVer", 1); // Read only a single record and return if (OutVer != 0) @@ -367,8 +371,8 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator // Add a new version map_ptrloc const verindex = NewVersion(Ver,Version,*LastVer); if (verindex == 0 && _error->PendingError()) - return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), - Pkg.Name(), 1); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "NewVersion", 1); if (oldMap != Map.Data()) LastVer += (map_ptrloc*) Map.Data() - (map_ptrloc*) oldMap; @@ -376,17 +380,18 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator Ver->ParentPkg = Pkg.Index(); Ver->Hash = Hash; - if (List.NewVersion(Ver) == false) - return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), - Pkg.Name(), 2); + if (unlikely(List.NewVersion(Ver) == false)) + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "NewVersion", 2); - if (List.UsePackage(Pkg,Ver) == false) - return _error->Error(_("Error occurred while processing %s (UsePackage3)"), - Pkg.Name()); + if (unlikely(List.UsePackage(Pkg,Ver) == false)) + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "UsePackage", 3); + + if (unlikely(NewFileVer(Ver,List) == false)) + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "NewFileVer", 2); - if (NewFileVer(Ver,List) == false) - return _error->Error(_("Error occurred while processing %s (NewVersion%d)"), - Pkg.Name(), 3); // Read only a single record and return if (OutVer != 0) @@ -431,7 +436,8 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator Desc->ParentPkg = Pkg.Index(); if ((*LastDesc == 0 && _error->PendingError()) || NewFileDesc(Desc,List) == false) - return _error->Error(_("Error occurred while processing %s (NewFileDesc2)"),Pkg.Name()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "NewFileDesc", 2); return true; } @@ -461,8 +467,8 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) pkgCache::PkgIterator Pkg = Cache.FindPkg(PackageName); Dynamic DynPkg(Pkg); if (Pkg.end() == true) - return _error->Error(_("Error occurred while processing %s (FindPkg)"), - PackageName.c_str()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + PackageName.c_str(), "FindPkg", 1); Counter++; if (Counter % 100 == 0 && Progress != 0) Progress->Progress(List.Offset()); @@ -475,7 +481,8 @@ bool pkgCacheGenerator::MergeFileProvides(ListParser &List) if (Ver->Hash == Hash && Version.c_str() == Ver.VerStr()) { if (List.CollectFileProvides(Cache,Ver) == false) - return _error->Error(_("Error occurred while processing %s (CollectFileProvides)"),PackageName.c_str()); + return _error->Error(_("Error occurred while processing %s (%s%d)"), + PackageName.c_str(), "CollectFileProvides", 1); break; } } -- cgit v1.2.3 From 5a8e963bbbbc689d7b1a1ebfa4ab5c6ec1f716bb Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Oct 2011 20:16:02 +0200 Subject: add implicit dependencies needed for Multi-Arch at the time a Version struct is created and not at the end of the cache generation This allows us to be independent from the configured architectures for these kind of conflicts, we get natural progress for free and only the needed dependencies are in th respective binary cache. --- apt-pkg/pkgcachegen.cc | 181 +++++++++++++++++++++++++++---------------------- apt-pkg/pkgcachegen.h | 7 +- 2 files changed, 106 insertions(+), 82 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 47441d65c..9f999c41b 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -392,6 +392,31 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator return _error->Error(_("Error occurred while processing %s (%s%d)"), Pkg.Name(), "NewFileVer", 2); + pkgCache::GrpIterator Grp = Pkg.Group(); + Dynamic DynGrp(Grp); + + /* If it is the first version of this package we need to add implicit + Multi-Arch dependencies to all other package versions in the group now - + otherwise we just add them for this new version */ + if (Pkg.VersionList()->NextVer == 0) + { + pkgCache::PkgIterator P = Grp.PackageList(); + Dynamic DynP(P); + for (; P.end() != true; P = Grp.NextPkg(P)) + { + if (P->ID == Pkg->ID) + continue; + pkgCache::VerIterator V = P.VersionList(); + Dynamic DynV(V); + for (; V.end() != true; ++V) + if (unlikely(AddImplicitDepends(V, Pkg) == false)) + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "AddImplicitDepends", 1); + } + } + if (unlikely(AddImplicitDepends(Grp, Pkg, Ver) == false)) + return _error->Error(_("Error occurred while processing %s (%s%d)"), + Pkg.Name(), "AddImplicitDepends", 2); // Read only a single record and return if (OutVer != 0) @@ -409,7 +434,6 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator /* Before we add a new description we first search in the group for a version with a description of the same MD5 - if so we reuse this description group instead of creating our own for this version */ - pkgCache::GrpIterator Grp = Pkg.Group(); for (pkgCache::PkgIterator P = Grp.PackageList(); P.end() == false; P = Grp.NextPkg(P)) { @@ -573,6 +597,75 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg,const string &Name return true; } + /*}}}*/ +// CacheGenerator::AddImplicitDepends /*{{{*/ +bool pkgCacheGenerator::AddImplicitDepends(pkgCache::GrpIterator &G, + pkgCache::PkgIterator &P, + pkgCache::VerIterator &V) +{ + // 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 + - All others conflict with all other group members */ + bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same); + pkgCache::PkgIterator D = G.PackageList(); + Dynamic DynD(D); + for (; D.end() != true; D = G.NextPkg(D)) + { + if (Arch == D.Arch() || D->VersionList == 0) + continue; + /* We allow only one installed arch at the time + per group, therefore each group member conflicts + with all other group members */ + if (coInstall == true) + { + // Replaces: ${self}:other ( << ${binary:Version}) + NewDepends(D, V, V.VerStr(), + pkgCache::Dep::Less, pkgCache::Dep::Replaces, + OldDepLast); + // Breaks: ${self}:other (!= ${binary:Version}) + NewDepends(D, V, V.VerStr(), + pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks, + OldDepLast); + } else { + // Conflicts: ${self}:other + NewDepends(D, V, "", + pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts, + OldDepLast); + } + } + return true; +} +bool pkgCacheGenerator::AddImplicitDepends(pkgCache::VerIterator &V, + pkgCache::PkgIterator &D) +{ + /* MultiArch handling introduces a lot of implicit Dependencies: + - MultiArch: same → Co-Installable if they have the same version + - All others conflict with all other group members */ + map_ptrloc *OldDepLast = NULL; + bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same); + if (coInstall == true) + { + // Replaces: ${self}:other ( << ${binary:Version}) + NewDepends(D, V, V.VerStr(), + pkgCache::Dep::Less, pkgCache::Dep::Replaces, + OldDepLast); + // Breaks: ${self}:other (!= ${binary:Version}) + NewDepends(D, V, V.VerStr(), + pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks, + OldDepLast); + } else { + // Conflicts: ${self}:other + NewDepends(D, V, "", + pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts, + OldDepLast); + } + return true; +} + /*}}}*/ // CacheGenerator::NewFileVer - Create a new File<->Version association /*{{{*/ // --------------------------------------------------------------------- @@ -692,76 +785,6 @@ map_ptrloc pkgCacheGenerator::NewDescription(pkgCache::DescIterator &Desc, return Description; } /*}}}*/ -// CacheGenerator::FinishCache - do various finish operations /*{{{*/ -// --------------------------------------------------------------------- -/* This prepares the Cache for delivery */ -bool pkgCacheGenerator::FinishCache(OpProgress *Progress) -{ - // FIXME: add progress reporting for this operation - // Do we have different architectures in your groups ? - vector archs = APT::Configuration::getArchitectures(); - if (archs.size() > 1) - { - // Create Conflicts in between the group - pkgCache::GrpIterator G = GetCache().GrpBegin(); - Dynamic DynG(G); - for (; G.end() != true; ++G) - { - string const PkgName = G.Name(); - pkgCache::PkgIterator P = G.PackageList(); - Dynamic DynP(P); - for (; P.end() != true; P = G.NextPkg(P)) - { - pkgCache::PkgIterator allPkg; - Dynamic DynallPkg(allPkg); - pkgCache::VerIterator V = P.VersionList(); - Dynamic DynV(V); - for (; V.end() != true; ++V) - { - // 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 - - Architecture: all → Need to be Co-Installable for internal reasons - - All others conflict with all other group members */ - bool const coInstall = ((V->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same); - for (vector::const_iterator A = archs.begin(); A != archs.end(); ++A) - { - if (*A == Arch) - continue; - /* We allow only one installed arch at the time - per group, therefore each group member conflicts - with all other group members */ - pkgCache::PkgIterator D = G.FindPkg(*A); - Dynamic DynD(D); - if (D.end() == true) - continue; - if (coInstall == true) - { - // Replaces: ${self}:other ( << ${binary:Version}) - NewDepends(D, V, V.VerStr(), - pkgCache::Dep::Less, pkgCache::Dep::Replaces, - OldDepLast); - // Breaks: ${self}:other (!= ${binary:Version}) - NewDepends(D, V, V.VerStr(), - pkgCache::Dep::NotEquals, pkgCache::Dep::DpkgBreaks, - OldDepLast); - } else { - // Conflicts: ${self}:other - NewDepends(D, V, "", - pkgCache::Dep::NoOp, pkgCache::Dep::Conflicts, - OldDepLast); - } - } - } - } - } - } - return true; -} - /*}}}*/ // CacheGenerator::NewDepends - Create a dependency element /*{{{*/ // --------------------------------------------------------------------- /* This creates a dependency element in the tree. It is linked to the @@ -1324,9 +1347,6 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress if (BuildCache(Gen,Progress,CurrentSize,TotalSize, Files.begin()+EndOfSource,Files.end()) == false) return false; - - // FIXME: move me to a better place - Gen.FinishCache(Progress); } else { @@ -1369,9 +1389,6 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress if (BuildCache(Gen,Progress,CurrentSize,TotalSize, Files.begin()+EndOfSource,Files.end()) == false) return false; - - // FIXME: move me to a better place - Gen.FinishCache(Progress); } if (Debug == true) std::clog << "Caches are ready for shipping" << std::endl; @@ -1422,9 +1439,6 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O Files.begin()+EndOfSource,Files.end()) == false) return false; - // FIXME: move me to a better place - Gen.FinishCache(Progress); - if (_error->PendingError() == true) return false; *OutMap = Map.UnGuard(); @@ -1445,4 +1459,9 @@ bool IsDuplicateDescription(pkgCache::DescIterator Desc, return false; } /*}}}*/ - +// CacheGenerator::FinishCache /*{{{*/ +bool pkgCacheGenerator::FinishCache(OpProgress *Progress) +{ + return true; +} + /*}}}*/ diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 99795bb1c..b6259b433 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -22,6 +22,7 @@ #include #include +#include #include @@ -94,7 +95,7 @@ class pkgCacheGenerator /*{{{*/ bool HasFileDeps() {return FoundFileDeps;}; bool MergeFileProvides(ListParser &List); - bool FinishCache(OpProgress *Progress); + __deprecated bool FinishCache(OpProgress *Progress); static bool MakeStatusCache(pkgSourceList &List,OpProgress *Progress, MMap **OutMap = 0,bool AllowMem = false); @@ -111,6 +112,10 @@ class pkgCacheGenerator /*{{{*/ bool MergeListPackage(ListParser &List, pkgCache::PkgIterator &Pkg); bool MergeListVersion(ListParser &List, pkgCache::PkgIterator &Pkg, std::string const &Version, pkgCache::VerIterator* &OutVer); + + bool AddImplicitDepends(pkgCache::GrpIterator &G, pkgCache::PkgIterator &P, + pkgCache::VerIterator &V); + bool AddImplicitDepends(pkgCache::VerIterator &V, pkgCache::PkgIterator &D); }; /*}}}*/ // This is the abstract package list parser class. /*{{{*/ -- cgit v1.2.3 From 0e7c33134cd32410eb8b344c6b6577826238bbbc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Oct 2011 22:28:46 +0200 Subject: * apt-pkg/pkgcache.cc: - always prefer "en" over "" for "en"-language regardless of cache-order --- apt-pkg/pkgcache.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index 40b99891a..c854249e4 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -894,11 +894,22 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const { pkgCache::DescIterator Desc = DescriptionList(); for (; Desc.end() == false; ++Desc) - if (*l == Desc.LanguageCode() || - (*l == "en" && strcmp(Desc.LanguageCode(),"") == 0)) + if (*l == Desc.LanguageCode()) break; if (Desc.end() == true) - continue; + { + if (*l == "en") + { + Desc = DescriptionList(); + for (; Desc.end() == false; ++Desc) + if (strcmp(Desc.LanguageCode(), "") == 0) + break; + if (Desc.end() == true) + continue; + } + else + continue; + } return Desc; } for (pkgCache::DescIterator Desc = DescriptionList(); -- cgit v1.2.3 From cd5e84440a9bb75a9cc2c142ac8bc214ba57685a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 17 Oct 2011 11:22:45 +0200 Subject: * apt-pkg/packagemanager.cc: - do not fail on unpacked packages in SmartUnPack, just don't shedule them for unpack, but do all checks and configure them --- apt-pkg/packagemanager.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index b9ef0f5d7..a97ce4833 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -551,14 +551,6 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c cout << endl; } - // Check if it is already unpacked - if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure && - Cache[Pkg].Keep() == true) - { - cout << OutputInDepth(Depth) << "SmartUnPack called on Package " << Pkg.Name() << " but its unpacked" << endl; - return false; - } - VerIterator const instVer = Cache[Pkg].InstVerIter(Cache); /* PreUnpack Checks: This loop checks and attempts to rectify and problems that would prevent the package being unpacked. @@ -768,7 +760,8 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c return false; } } - else if (Install(Pkg,FileNames[Pkg->ID]) == false) + // packages which are already unpacked don't need to be unpacked again + else if (Pkg.State() != pkgCache::PkgIterator::NeedsConfigure && Install(Pkg,FileNames[Pkg->ID]) == false) return false; if (Immediate == true) { -- cgit v1.2.3 From deec647438c6394d8d8398cba35412992f1babd5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 17 Oct 2011 16:41:54 +0200 Subject: * algorithms.cc: - show a debug why a package was kept by ResolveByKeep() --- apt-pkg/algorithms.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 6ac69032b..44cba8d92 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1188,16 +1188,23 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) */ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I) { - // a broken install is always a problem if (Cache[I].InstBroken() == true) + { + if (Debug == true) + std::clog << " Dependencies are not satisfied for " << I << std::endl; return true; + } // a newly broken policy (recommends/suggests) is a problem if (Cache[I].NowPolicyBroken() == false && Cache[I].InstPolicyBroken() == true) + { + if (Debug == true) + std::clog << " Policy breaks with upgrade of " << I << std::endl; return true; - + } + return false; } -- cgit v1.2.3 From 1f8fe502967c41a811c50c9f07454239665047f8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 30 Oct 2011 14:17:09 -0500 Subject: * apt-pkg/contrib/sha2_internal.cc: - use a pointer-union to peace gcc strict-aliasing warning --- apt-pkg/contrib/sha2_internal.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc index ff995cdf2..6d27e8f2b 100644 --- a/apt-pkg/contrib/sha2_internal.cc +++ b/apt-pkg/contrib/sha2_internal.cc @@ -605,7 +605,12 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) { *context->buffer = 0x80; } /* Set the bit count: */ - *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; + union { + sha2_byte* c; + sha2_word64* l; + } bitcount; + bitcount.c = &context->buffer[SHA256_SHORT_BLOCK_LENGTH]; + *(bitcount.l) = context->bitcount; /* Final transform: */ SHA256_Transform(context, (sha2_word32*)context->buffer); @@ -922,8 +927,13 @@ static void SHA512_Last(SHA512_CTX* context) { *context->buffer = 0x80; } /* Store the length of input data (in bits): */ - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; - *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; + union { + sha2_byte* c; + sha2_word64* l; + } bitcount; + bitcount.c = &context->buffer[SHA512_SHORT_BLOCK_LENGTH]; + bitcount.l[0] = context->bitcount[1]; + bitcount.l[1] = context->bitcount[0]; /* Final transform: */ SHA512_Transform(context, (sha2_word64*)context->buffer); -- cgit v1.2.3 From d9f6c79566a94cf4da20d55edececcaa11ffaa1b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 31 Oct 2011 14:36:05 -0500 Subject: do not enter an endless loop for (essential) pre-dependency loops --- apt-pkg/packagemanager.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index a97ce4833..4f9762701 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -404,22 +404,27 @@ bool pkgPackageManager::SmartConfigure(PkgIterator Pkg, int const Depth) /* If the dependany is still not satisfied, try, if possible, unpacking a package to satisfy it */ if (InstallVer != 0 && Bad) { - Bad = false; - if (List->IsNow(DepPkg) && !List->IsFlag(DepPkg,pkgOrderList::Loop)) { - List->Flag(Pkg,pkgOrderList::Loop); - if (Debug) - cout << OutputInDepth(Depth) << "Unpacking " << DepPkg.Name() << " to avoid loop" << endl; - SmartUnPack(DepPkg, true, Depth + 1); - List->RmFlag(Pkg,pkgOrderList::Loop); + if (List->IsNow(DepPkg)) { + Bad = false; + if (List->IsFlag(Pkg,pkgOrderList::Loop)) + { + if (Debug) + std::clog << OutputInDepth(Depth) << "Package " << Pkg << " loops in SmartConfigure" << std::endl; + } + else + { + List->Flag(Pkg,pkgOrderList::Loop); + if (Debug) + cout << OutputInDepth(Depth) << "Unpacking " << DepPkg.Name() << " to avoid loop" << endl; + SmartUnPack(DepPkg, true, Depth + 1); + List->RmFlag(Pkg,pkgOrderList::Loop); + } } } if (Start==End) { - if (Bad && Debug) { - if (!List->IsFlag(DepPkg,pkgOrderList::Loop)) { - _error->Warning("Could not satisfy dependancies for %s",Pkg.Name()); - } - } + if (Bad && Debug && List->IsFlag(DepPkg,pkgOrderList::Loop) == false) + std::clog << OutputInDepth(Depth) << "Could not satisfy dependancies for " << Pkg.Name() << std::endl; break; } else { Start++; -- cgit v1.2.3 From 04340db392f14e2610189db6f8787e10fbf3c6d0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 3 Nov 2011 09:41:14 -0500 Subject: * apt-pkg/deb/deblistparser.cc: - M-A: foreign packages provide for other archs, too --- apt-pkg/deb/deblistparser.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index fd3e4808d..28568d5e3 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -675,6 +675,9 @@ bool debListParser::ParseProvides(pkgCache::VerIterator &Ver) return _error->Error("Problem parsing Provides line"); if (Op != pkgCache::Dep::NoOp) { _error->Warning("Ignoring Provides line with DepCompareOp for package %s", Package.c_str()); + } else if ((Ver->MultiArch & pkgCache::Version::Foreign) == pkgCache::Version::Foreign) { + if (NewProvidesAllArch(Ver, Package, Version) == false) + return false; } else { if (NewProvides(Ver, Package, Arch, Version) == false) return false; -- cgit v1.2.3