From 285feb3cedca3cccff971155099adef8d902223d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 16 Jul 2011 14:21:51 +0200 Subject: * cmdline/apt-key: - use a tmpfile instead of /etc/apt/secring.gpg (Closes: #632596) * debian/apt.postinst: - remove /etc/apt/secring.gpg if it is an empty file --- cmdline/apt-key | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index 843163f82..8a995dadd 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -5,9 +5,12 @@ unset GREP_OPTIONS # We don't use a secret keyring, of course, but gpg panics and # implodes if there isn't one available -GPG_CMD='gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg' +SECRETKEYRING="$(mktemp)" +trap "rm -f '${SECRETKEYRING}'" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM +GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring '${SECRETKEYRING}'" if [ "$(id -u)" -eq 0 ]; then + # we could use a tmpfile here too, but creation of this tends to be time-consuming GPG_CMD="$GPG_CMD --trustdb-name /etc/apt/trustdb.gpg" fi -- cgit v1.2.3 From 4a53151acad0c4ccfbcf4ce11c5c2d7cffd05de3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 16 Jul 2011 14:57:37 +0200 Subject: do not require unused partial dirs in 'source' (Closes: #633510) --- cmdline/apt-get.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 3292ae745..748ebe6ab 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2366,8 +2366,7 @@ bool DoSource(CommandLine &CmdL) // Create the download object AcqTextStatus Stat(ScreenWidth,_config->FindI("quiet",0)); pkgAcquire Fetcher; - if (Fetcher.Setup(&Stat) == false) - return false; + Fetcher.SetLog(&Stat); DscFile *Dsc = new DscFile[CmdL.FileSize()]; -- cgit v1.2.3 From fd8b88d6ece1382cf3441efe721ec84d43a19bbe Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 22 Jul 2011 11:12:14 +0200 Subject: * cmdline/apt-get.cc: - fix missing download progress in apt-get download --- cmdline/apt-get.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 845c92026..3f818ffc3 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2273,7 +2273,7 @@ bool DoDownload(CommandLine &CmdL) pkgAcquire Fetcher; AcqTextStatus Stat(ScreenWidth, _config->FindI("quiet",0)); - if (_config->FindB("APT::Get::Print-URIs") == true) + if (_config->FindB("APT::Get::Print-URIs") == false) Fetcher.Setup(&Stat); pkgRecords Recs(Cache); -- cgit v1.2.3 From 331eea386e2bb57af6dbb9f1c86f176b2d55c6a1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 23 Jul 2011 11:50:49 +0200 Subject: =?UTF-8?q?you=20want=20to=20be=20nice=20and=20quote=20a=20filenam?= =?UTF-8?q?e=20just=20to=20be=20reminded=20by=20gpg=20that=20it=20doesn't?= =?UTF-8?q?=20like=20that=E2=80=A6=20remove=20superficial=20quoting=20to?= =?UTF-8?q?=20fix=20apt-key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmdline/apt-key | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-key b/cmdline/apt-key index 8a995dadd..e632be706 100755 --- a/cmdline/apt-key +++ b/cmdline/apt-key @@ -7,7 +7,7 @@ unset GREP_OPTIONS # implodes if there isn't one available SECRETKEYRING="$(mktemp)" trap "rm -f '${SECRETKEYRING}'" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM -GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring '${SECRETKEYRING}'" +GPG_CMD="gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring ${SECRETKEYRING}" if [ "$(id -u)" -eq 0 ]; then # we could use a tmpfile here too, but creation of this tends to be time-consuming -- cgit v1.2.3 From e3a86238d2fac37c5573079d70dbf3d31a638cfd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Jul 2011 19:03:15 +0200 Subject: buildconflicts effect all architectures --- cmdline/apt-get.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 748ebe6ab..1df3b520e 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2733,20 +2733,22 @@ bool DoBuildDep(CommandLine &CmdL) if ((*D).Type == pkgSrcRecords::Parser::BuildConflict || (*D).Type == pkgSrcRecords::Parser::BuildConflictIndep) { - pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package); + pkgCache::GrpIterator Grp = Cache->FindGrp((*D).Package); // Build-conflicts on unknown packages are silently ignored - if (Pkg.end() == true) + if (Grp.end() == true) continue; - pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); - - /* - * Remove if we have an installed version that satisfies the - * version criteria - */ - if (IV.end() == false && - Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - TryToInstallBuildDep(Pkg,Cache,Fix,true,false); + for (pkgCache::PkgIterator Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg)) + { + pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); + /* + * Remove if we have an installed version that satisfies the + * version criteria + */ + if (IV.end() == false && + Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) + TryToInstallBuildDep(Pkg,Cache,Fix,true,false); + } } else // BuildDep || BuildDepIndep { -- cgit v1.2.3 From 3fdb6f8315de03819a82bcf9fc5ac5d15389fcb0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Jul 2011 19:04:18 +0200 Subject: first round of reorder code without changing result --- cmdline/apt-get.cc | 56 ++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 1df3b520e..721ce9dc7 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2725,6 +2725,16 @@ bool DoBuildDep(CommandLine &CmdL) if (skipAlternatives == true) { + /* + * if there are alternatives, we've already picked one, so skip + * the rest + * + * TODO: this means that if there's a build-dep on A|B and B is + * installed, we'll still try to install A; more importantly, + * if A is currently broken, we cannot go back and try B. To fix + * this would require we do a Resolve cycle for each package we + * add to the install list. Ugh + */ if (!hasAlternatives) skipAlternatives = false; // end of or group continue; @@ -2752,10 +2762,10 @@ bool DoBuildDep(CommandLine &CmdL) } else // BuildDep || BuildDepIndep { - pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package); if (_config->FindB("Debug::BuildDeps",false) == true) cout << "Looking for " << (*D).Package << "...\n"; + pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package); if (Pkg.end() == true) { if (_config->FindB("Debug::BuildDeps",false) == true) @@ -2770,34 +2780,6 @@ bool DoBuildDep(CommandLine &CmdL) (*D).Package.c_str()); } - /* - * if there are alternatives, we've already picked one, so skip - * the rest - * - * TODO: this means that if there's a build-dep on A|B and B is - * installed, we'll still try to install A; more importantly, - * if A is currently broken, we cannot go back and try B. To fix - * this would require we do a Resolve cycle for each package we - * add to the install list. Ugh - */ - - /* - * If this is a virtual package, we need to check the list of - * packages that provide it and see if any of those are - * installed - */ - pkgCache::PrvIterator Prv = Pkg.ProvidesList(); - for (; Prv.end() != true; Prv++) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; - - if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) - break; - } - - // Get installed version and version we are going to install - pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); if ((*D).Version[0] != '\0') { // Versioned dependency @@ -2827,6 +2809,21 @@ bool DoBuildDep(CommandLine &CmdL) } else { + /* + * If this is a virtual package, we need to check the list of + * packages that provide it and see if any of those are + * installed + */ + pkgCache::PrvIterator Prv = Pkg.ProvidesList(); + for (; Prv.end() != true; Prv++) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; + + if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) + break; + } + // Only consider virtual packages if there is no versioned dependency if (Prv.end() == false) { @@ -2837,6 +2834,7 @@ bool DoBuildDep(CommandLine &CmdL) } } + pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); if (IV.end() == false) { if (_config->FindB("Debug::BuildDeps",false) == true) -- cgit v1.2.3 From 91bee655abd9091eee0687dc3689744217c6cdb4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Jul 2011 19:06:01 +0200 Subject: move the detection for installed versions up as it is the easiest case --- cmdline/apt-get.cc | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 721ce9dc7..9f9a9e589 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2780,6 +2780,26 @@ bool DoBuildDep(CommandLine &CmdL) (*D).Package.c_str()); } + pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); + if (IV.end() == false) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Is installed\n"; + + if (D->Version.empty() == true || + Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) + { + skipAlternatives = hasAlternatives; + continue; + } + + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " ...but the installed version doesn't meet the version requirement\n"; + + if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq) + return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"), + Last->BuildDepType((*D).Type), Src.c_str(), Pkg.FullName(true).c_str()); + } if ((*D).Version[0] != '\0') { // Versioned dependency @@ -2834,31 +2854,6 @@ bool DoBuildDep(CommandLine &CmdL) } } - pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache); - if (IV.end() == false) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Is installed\n"; - - if (Cache->VS().CheckDep(IV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - { - skipAlternatives = hasAlternatives; - continue; - } - - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " ...but the installed version doesn't meet the version requirement\n"; - - if (((*D).Op & pkgCache::Dep::LessEq) == pkgCache::Dep::LessEq) - { - return _error->Error(_("Failed to satisfy %s dependency for %s: Installed package %s is too new"), - Last->BuildDepType((*D).Type), - Src.c_str(), - Pkg.FullName(true).c_str()); - } - } - - if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Trying to install " << (*D).Package << endl; -- cgit v1.2.3 From fe0278799cb7bd1c9039a053da178f54d120248c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Jul 2011 19:15:20 +0200 Subject: after this consider providing packages (if it is not a versioned dep) --- cmdline/apt-get.cc | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9f9a9e589..b37ced5cb 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2801,6 +2801,33 @@ bool DoBuildDep(CommandLine &CmdL) Last->BuildDepType((*D).Type), Src.c_str(), Pkg.FullName(true).c_str()); } + // Only consider virtual packages if there is no versioned dependency + if ((*D).Version.empty() == true) + { + /* + * If this is a virtual package, we need to check the list of + * packages that provide it and see if any of those are + * installed + */ + pkgCache::PrvIterator Prv = Pkg.ProvidesList(); + for (; Prv.end() != true; Prv++) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; + + if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) + break; + } + + if (Prv.end() == false) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl; + skipAlternatives = hasAlternatives; + continue; + } + } + if ((*D).Version[0] != '\0') { // Versioned dependency @@ -2827,32 +2854,6 @@ bool DoBuildDep(CommandLine &CmdL) } } } - else - { - /* - * If this is a virtual package, we need to check the list of - * packages that provide it and see if any of those are - * installed - */ - pkgCache::PrvIterator Prv = Pkg.ProvidesList(); - for (; Prv.end() != true; Prv++) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; - - if ((*Cache)[Prv.OwnerPkg()].InstVerIter(*Cache).end() == false) - break; - } - - // Only consider virtual packages if there is no versioned dependency - if (Prv.end() == false) - { - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Is provided by installed package " << Prv.OwnerPkg().FullName() << endl; - skipAlternatives = hasAlternatives; - continue; - } - } if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Trying to install " << (*D).Package << endl; -- cgit v1.2.3 From 2baf02ca838e9d7df0a0e9923ffbbb706978ffa4 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Jul 2011 19:26:38 +0200 Subject: alternatively check in a versioned depends if the candidate is good The old code used to do move on to versions behind the candidate in cases the candidate wasn't a match, but as the Install request later always installs the candidate (witch wasn't switched) this could have never worked - and shouldn't in most cases anyway as: a) it could only work for <, <=, != depends which are unusal b) doesn't respect pinning, so it could install -1 versions --- cmdline/apt-get.cc | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index b37ced5cb..80037ae66 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2827,33 +2827,27 @@ bool DoBuildDep(CommandLine &CmdL) continue; } } - - if ((*D).Version[0] != '\0') { - // Versioned dependency - - pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache); - - for (; CV.end() != true; CV++) - { - if (Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == true) - break; - } - if (CV.end() == true) - { - if (hasAlternatives) - { - continue; - } - else - { - return _error->Error(_("%s dependency for %s cannot be satisfied " - "because no available versions of package %s " - "can satisfy version requirements"), - Last->BuildDepType((*D).Type),Src.c_str(), - (*D).Package.c_str()); - } - } - } + else // versioned dependency + { + pkgCache::VerIterator CV = (*Cache)[Pkg].CandidateVerIter(*Cache); + if (CV.end() == true || + Cache->VS().CheckDep(CV.VerStr(),(*D).Op,(*D).Version.c_str()) == false) + { + if (hasAlternatives) + continue; + else if (CV.end() == false) + return _error->Error(_("%s dependency for %s cannot be satisfied " + "because candidate version of package %s " + "can't satisfy version requirements"), + Last->BuildDepType(D->Type), Src.c_str(), + D->Package.c_str()); + else + return _error->Error(_("%s dependency for %s cannot be satisfied " + "because package %s has no candidate version"), + Last->BuildDepType(D->Type), Src.c_str(), + D->Package.c_str()); + } + } if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Trying to install " << (*D).Package << endl; -- cgit v1.2.3 From ac32148639b3a35bc359275b9265f41f81e29296 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 24 Jul 2011 19:37:49 +0200 Subject: move debug message about attempt install/remove to the responsible method --- cmdline/apt-get.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 80037ae66..b3ce54bb7 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1388,6 +1388,14 @@ bool TryToInstallBuildDep(pkgCache::PkgIterator Pkg,pkgCacheFile &Cache, return AllowFail; } + if (_config->FindB("Debug::BuildDeps",false) == true) + { + if (Remove == true) + cout << " Trying to remove " << Pkg << endl; + else + cout << " Trying to install " << Pkg << endl; + } + if (Remove == true) { TryToRemove RemoveAction(Cache, &Fix); @@ -2849,9 +2857,6 @@ bool DoBuildDep(CommandLine &CmdL) } } - if (_config->FindB("Debug::BuildDeps",false) == true) - cout << " Trying to install " << (*D).Package << endl; - if (TryToInstallBuildDep(Pkg,Cache,Fix,false,false) == true) { // We successfully installed something; skip remaining alternatives -- cgit v1.2.3 From 234675b71a2caab5c7cc0dc3b32a241683d3b3d2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Jul 2011 14:40:22 +0200 Subject: implement MultiarchCross for build-dep and source (Closes: #632221) --- cmdline/apt-get.cc | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 4 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index b3ce54bb7..8eda29362 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -2620,12 +2620,17 @@ bool DoSource(CommandLine &CmdL) // Try to compile it with dpkg-buildpackage if (_config->FindB("APT::Get::Compile",false) == true) { + string buildopts = _config->Find("APT::Get::Host-Architecture"); + if (buildopts.empty() == false) + buildopts = "-a " + buildopts + " "; + buildopts.append(_config->Find("DPkg::Build-Options","-b -uc")); + // Call dpkg-buildpackage char S[500]; snprintf(S,sizeof(S),"cd %s && %s %s", Dir.c_str(), _config->Find("Dir::Bin::dpkg-buildpackage","dpkg-buildpackage").c_str(), - _config->Find("DPkg::Build-Options","-b -uc").c_str()); + buildopts.c_str()); if (system(S) != 0) { @@ -2687,8 +2692,19 @@ bool DoBuildDep(CommandLine &CmdL) if (Fetcher.Setup(&Stat) == false) return false; + bool StripMultiArch; + string hostArch = _config->Find("APT::Get::Host-Architecture"); + if (hostArch.empty() == false) + { + std::vector archs = APT::Configuration::getArchitectures(); + if (std::find(archs.begin(), archs.end(), hostArch) == archs.end()) + return _error->Error(_("No architecture information available for %s. See apt.conf(5) APT::Architectures for setup"), hostArch.c_str()); + StripMultiArch = false; + } + else + StripMultiArch = true; + unsigned J = 0; - bool const StripMultiArch = APT::Configuration::getArchitectures().size() <= 1; for (const char **I = CmdL.FileList + 1; *I != 0; I++, J++) { string Src; @@ -2722,7 +2738,7 @@ bool DoBuildDep(CommandLine &CmdL) ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str()); continue; } - + // Install the requested packages vector ::iterator D; pkgProblemResolver Fix(Cache); @@ -2773,7 +2789,95 @@ bool DoBuildDep(CommandLine &CmdL) if (_config->FindB("Debug::BuildDeps",false) == true) cout << "Looking for " << (*D).Package << "...\n"; - pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package); + pkgCache::PkgIterator Pkg; + + // Cross-Building? + if (StripMultiArch == false) + { + size_t const colon = D->Package.find(":"); + if (colon != string::npos && + (strcmp(D->Package.c_str() + colon, ":any") == 0 || strcmp(D->Package.c_str() + colon, ":native") == 0)) + Pkg = Cache->FindPkg(D->Package.substr(0,colon)); + else + Pkg = Cache->FindPkg(D->Package); + + // We need to decide if host or build arch, so find a version we can look at + pkgCache::VerIterator Ver; + + // a bad version either is invalid or doesn't satify dependency + #define BADVER(Ver) Ver.end() == true || \ + (Ver.end() == false && D->Version.empty() == false && \ + Cache->VS().CheckDep(Ver.VerStr(),D->Op,D->Version.c_str()) == false) + + if (Pkg.end() == false) + { + Ver = (*Cache)[Pkg].InstVerIter(*Cache); + if (BADVER(Ver)) + Ver = (*Cache)[Pkg].CandidateVerIter(*Cache); + } + if (BADVER(Ver)) + { + pkgCache::PkgIterator HostPkg = Cache->FindPkg(D->Package, hostArch); + if (HostPkg.end() == false) + { + Ver = (*Cache)[HostPkg].InstVerIter(*Cache); + if (BADVER(Ver)) + Ver = (*Cache)[HostPkg].CandidateVerIter(*Cache); + } + } + if ((BADVER(Ver)) == false) + { + string forbidden; + if (Ver->MultiArch == pkgCache::Version::None || Ver->MultiArch == pkgCache::Version::All); + else if (Ver->MultiArch == pkgCache::Version::Same) + { + if (colon != string::npos) + Pkg = Ver.ParentPkg().Group().FindPkg(hostArch); + else if (strcmp(D->Package.c_str() + colon, ":any") == 0) + forbidden = "Multi-Arch: same"; + // :native gets the buildArch + } + else if (Ver->MultiArch == pkgCache::Version::Foreign || Ver->MultiArch == pkgCache::Version::AllForeign) + { + if (colon != string::npos) + forbidden = "Multi-Arch: foreign"; + } + else if (Ver->MultiArch == pkgCache::Version::Allowed || Ver->MultiArch == pkgCache::Version::AllAllowed) + { + if (colon == string::npos) + Pkg = Ver.ParentPkg().Group().FindPkg(hostArch); + else if (strcmp(D->Package.c_str() + colon, ":any") == 0) + { + // prefer any installed over preferred non-installed architectures + pkgCache::GrpIterator Grp = Ver.ParentPkg().Group(); + // we don't check for version here as we are better of with upgrading than remove and install + for (Pkg = Grp.PackageList(); Pkg.end() == false; Pkg = Grp.NextPkg(Pkg)) + if (Pkg.CurrentVer().end() == false) + break; + if (Pkg.end() == true) + Pkg = Grp.FindPreferredPkg(true); + } + // native gets buildArch + } + if (forbidden.empty() == false) + { + if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " :any is not allowed from M-A: same package " << (*D).Package << endl; + if (hasAlternatives) + continue; + return _error->Error(_("%s dependency for %s can't be satisfied " + "because %s is not allowed on '%s' packages"), + Last->BuildDepType(D->Type), Src.c_str(), + D->Package.c_str(), "Multi-Arch: same"); + } + } + else if (_config->FindB("Debug::BuildDeps",false) == true) + cout << " No multiarch info as we have no satisfying installed nor candidate for " << D->Package << " on build or host arch" << endl; + #undef BADVER + } + else + Pkg = Cache->FindPkg(D->Package); + if (Pkg.end() == true) { if (_config->FindB("Debug::BuildDeps",false) == true) @@ -3241,6 +3345,7 @@ int main(int argc,const char *argv[]) /*{{{*/ {'m',"ignore-missing","APT::Get::Fix-Missing",0}, {'t',"target-release","APT::Default-Release",CommandLine::HasArg}, {'t',"default-release","APT::Default-Release",CommandLine::HasArg}, + {'a',"host-architecture","APT::Get::Host-Architecture",CommandLine::HasArg}, {0,"download","APT::Get::Download",0}, {0,"fix-missing","APT::Get::Fix-Missing",0}, {0,"ignore-hold","APT::Ignore-Hold",0}, -- cgit v1.2.3 From a2cba9cca24762c090ee6988f14ae40f92a6441f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Jul 2011 10:19:30 +0200 Subject: cmdline/makefile: ajust comment --- cmdline/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/makefile b/cmdline/makefile index 6d988a8f5..07e9eb8ca 100644 --- a/cmdline/makefile +++ b/cmdline/makefile @@ -73,7 +73,7 @@ LIB_MAKES = apt-pkg/makefile SOURCE = apt-internal-solver.cc include $(PROGRAM_H) -# The internal solver acting as an external +# This just dumps out the state PROGRAM=apt-dump-solver SLIBS = -lapt-pkg $(INTLLIBS) LIB_MAKES = apt-pkg/makefile -- 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. --- cmdline/apt-get.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index 9de341df0..b0450e803 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -869,9 +869,7 @@ struct TryToInstall { struct TryToRemove { pkgCacheFile* Cache; pkgProblemResolver* Fix; - bool FixBroken; bool PurgePkgs; - unsigned long AutoMarkChanged; TryToRemove(pkgCacheFile &Cache, pkgProblemResolver *PM) : Cache(&Cache), Fix(PM), PurgePkgs(_config->FindB("APT::Get::Purge", false)) {}; -- 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. --- cmdline/apt-cache.cc | 104 +++++++++++++++++++++++++-------------------------- cmdline/apt-get.cc | 56 +++++++++++++-------------- 2 files changed, 80 insertions(+), 80 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 232bb93ec..db5475227 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -141,7 +141,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important) if (Start == End) break; - Start++; + ++Start; } while (1); @@ -169,7 +169,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important) if (Start == End) break; cout << " | "; - Start++; + ++Start; } while (1); @@ -187,7 +187,7 @@ bool UnMet(CommandLine &CmdL) if (CmdL.FileSize() <= 1) { - for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; ++P) for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) if (ShowUnMet(V, Important) == false) return false; @@ -217,13 +217,13 @@ bool DumpPackage(CommandLine &CmdL) { cout << "Package: " << Pkg.FullName(true) << endl; cout << "Versions: " << endl; - for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur) { cout << Cur.VerStr(); - for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++) + for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; ++Vf) cout << " (" << Vf.File().FileName() << ")"; cout << endl; - for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; D++) + for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; ++D) { cout << " Description Language: " << D.LanguageCode() << endl << " File: " << D.FileList().File().FileName() << endl @@ -235,7 +235,7 @@ bool DumpPackage(CommandLine &CmdL) cout << endl; cout << "Reverse Depends: " << endl; - for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; D++) + for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; ++D) { cout << " " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true); if (D->Version != 0) @@ -245,24 +245,24 @@ bool DumpPackage(CommandLine &CmdL) } cout << "Dependencies: " << endl; - for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur) { cout << Cur.VerStr() << " - "; - for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++) + for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; ++Dep) cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") "; cout << endl; } cout << "Provides: " << endl; - for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur) { cout << Cur.VerStr() << " - "; - for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++) + for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; ++Prv) cout << Prv.ParentPkg().FullName(true) << " "; cout << endl; } cout << "Reverse Provides: " << endl; - for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++) + for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; ++Prv) cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl; } @@ -290,7 +290,7 @@ bool Stats(CommandLine &Cmd) int DVirt = 0; int Missing = 0; pkgCache::PkgIterator I = Cache->PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (I->VersionList != 0 && I->ProvidesList == 0) { @@ -353,11 +353,11 @@ bool Stats(CommandLine &Cmd) cout << _("Total globbed strings: ") << Count << " (" << SizeToStr(Size) << ')' << endl; unsigned long DepVerSize = 0; - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { - for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) + for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) { - for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D) { if (D->Version != 0) DepVerSize += strlen(D.TargetVer()) + 1; @@ -394,17 +394,17 @@ bool Dump(CommandLine &Cmd) cout << "Using Versioning System: " << Cache->VS->Label << endl; - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { cout << "Package: " << P.FullName(true) << endl; - for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) + for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V) { cout << " Version: " << V.VerStr() << endl; cout << " File: " << V.FileList().File().FileName() << endl; - for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D) cout << " Depends: " << D.TargetPkg().FullName(true) << ' ' << DeNull(D.TargetVer()) << endl; - for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; D++) + for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; ++D) { cout << " Description Language: " << D.LanguageCode() << endl << " File: " << D.FileList().File().FileName() << endl @@ -413,7 +413,7 @@ bool Dump(CommandLine &Cmd) } } - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F) { cout << "File: " << F.FileName() << endl; cout << " Type: " << F.IndexType() << endl; @@ -449,7 +449,7 @@ bool DumpAvail(CommandLine &Cmd) memset(VFList,0,sizeof(*VFList)*Count); // Map versions that we want to write out onto the VerList array. - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { if (P->VersionList == 0) continue; @@ -466,7 +466,7 @@ bool DumpAvail(CommandLine &Cmd) } pkgCache::VerFileIterator VF = V.FileList(); - for (; VF.end() == false ; VF++) + for (; VF.end() == false ; ++VF) if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0) break; @@ -480,9 +480,9 @@ bool DumpAvail(CommandLine &Cmd) handling works OK. */ if (VF.end() == true) { - for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; Cur++) + for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; ++Cur) { - for (VF = Cur.FileList(); VF.end() == false; VF++) + for (VF = Cur.FileList(); VF.end() == false; ++VF) { if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0) { @@ -615,7 +615,7 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends) if (RevDepends == true) cout << "Reverse Depends:" << endl; for (pkgCache::DepIterator D = RevDepends ? Pkg.RevDependsList() : Ver.DependsList(); - D.end() == false; D++) + D.end() == false; ++D) { switch (D->Type) { case pkgCache::Dep::PreDepends: if (!ShowPreDepends) continue; break; @@ -741,7 +741,7 @@ bool XVcg(CommandLine &CmdL) memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount); // Map the shapes - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Pkg->VersionList == 0) { @@ -788,7 +788,7 @@ bool XVcg(CommandLine &CmdL) while (Act == true) { Act = false; - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { // See we need to show this package if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR) @@ -814,14 +814,14 @@ bool XVcg(CommandLine &CmdL) continue; pkgCache::VerIterator Ver = Pkg.VersionList(); - for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) { // See if anything can meet this dep // Walk along the actual package providing versions bool Hit = false; pkgCache::PkgIterator DPkg = D.TargetPkg(); for (pkgCache::VerIterator I = DPkg.VersionList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true) Hit = true; @@ -829,7 +829,7 @@ bool XVcg(CommandLine &CmdL) // Follow all provides for (pkgCache::PrvIterator I = DPkg.ProvidesList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false) Hit = true; @@ -889,7 +889,7 @@ bool XVcg(CommandLine &CmdL) /* Draw the box colours after the fact since we can not tell what colour they should be until everything is finished drawing */ - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Show[Pkg->ID] < DoneNR) continue; @@ -953,7 +953,7 @@ bool Dotty(CommandLine &CmdL) memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount); // Map the shapes - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Pkg->VersionList == 0) { @@ -1000,7 +1000,7 @@ bool Dotty(CommandLine &CmdL) while (Act == true) { Act = false; - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { // See we need to show this package if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR) @@ -1024,14 +1024,14 @@ bool Dotty(CommandLine &CmdL) continue; pkgCache::VerIterator Ver = Pkg.VersionList(); - for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D) { // See if anything can meet this dep // Walk along the actual package providing versions bool Hit = false; pkgCache::PkgIterator DPkg = D.TargetPkg(); for (pkgCache::VerIterator I = DPkg.VersionList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true) Hit = true; @@ -1039,7 +1039,7 @@ bool Dotty(CommandLine &CmdL) // Follow all provides for (pkgCache::PrvIterator I = DPkg.ProvidesList(); - I.end() == false && Hit == false; I++) + I.end() == false && Hit == false; ++I) { if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false) Hit = true; @@ -1094,7 +1094,7 @@ bool Dotty(CommandLine &CmdL) /* Draw the box colours after the fact since we can not tell what colour they should be until everything is finished drawing */ - for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++) + for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg) { if (Show[Pkg->ID] < DoneNR) continue; @@ -1127,7 +1127,7 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V) // Find an appropriate file pkgCache::VerFileIterator Vf = V.FileList(); - for (; Vf.end() == false; Vf++) + for (; Vf.end() == false; ++Vf) if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0) break; if (Vf.end() == true) @@ -1272,7 +1272,7 @@ bool Search(CommandLine &CmdL) continue; // Include all the packages that provide matching names too - for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++) + for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; ++Prv) { pkgCache::VerIterator V = Plcy->GetCandidateVer(Prv.OwnerPkg()); if (V.end() == true) @@ -1341,13 +1341,13 @@ bool ShowAuto(CommandLine &CmdL) std::vector packages; packages.reserve(Cache->HeaderP->PackageCount / 3); - for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++) + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) if ((*DepCache)[P].Flags & pkgCache::Flag::Auto) packages.push_back(P.Name()); std::sort(packages.begin(), packages.end()); - for (vector::iterator I = packages.begin(); I != packages.end(); I++) + for (vector::iterator I = packages.begin(); I != packages.end(); ++I) cout << *I << "\n"; _error->Notice(_("This command is deprecated. Please use 'apt-mark showauto' instead.")); @@ -1391,7 +1391,7 @@ bool ShowPkgNames(CommandLine &CmdL) if (CmdL.FileList[1] != 0) { - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (All == false && I->FirstPackage == 0) continue; @@ -1405,7 +1405,7 @@ bool ShowPkgNames(CommandLine &CmdL) } // Show all pkgs - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (All == false && I->FirstPackage == 0) continue; @@ -1476,7 +1476,7 @@ bool Policy(CommandLine &CmdL) if (CmdL.FileList[1] == 0) { cout << _("Package files:") << endl; - for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; F++) + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F) { // Locate the associated index files so we can derive a description pkgIndexFile *Indx; @@ -1498,7 +1498,7 @@ bool Policy(CommandLine &CmdL) // Show any packages have explicit pins cout << _("Pinned packages:") << endl; pkgCache::PkgIterator I = Cache->PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { if (Plcy->GetPriority(I) == 0) continue; @@ -1560,14 +1560,14 @@ bool Policy(CommandLine &CmdL) // Show the priority tables cout << _(" Version table:") << endl; - for (V = Pkg.VersionList(); V.end() == false; V++) + for (V = Pkg.VersionList(); V.end() == false; ++V) { if (Pkg.CurrentVer() == V) cout << " *** " << V.VerStr(); else cout << " " << V.VerStr(); cout << " " << Plcy->GetPriority(Pkg) << endl; - for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF) { // Locate the associated index files so we can derive a description pkgIndexFile *Indx; @@ -1607,9 +1607,9 @@ bool Madison(CommandLine &CmdL) APT::PackageSet pkgset = APT::PackageSet::FromString(CacheFile, *I, helper); for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) { - for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; V++) + for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V) { - for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++) + for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF) { // This might be nice, but wouldn't uniquely identify the source -mdz // if (VF.File().Archive() != 0) @@ -1619,11 +1619,11 @@ bool Madison(CommandLine &CmdL) // } // Locate the associated index files so we can derive a description - for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); S++) + for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S) { vector *Indexes = (*S)->GetIndexFiles(); for (vector::const_iterator IF = Indexes->begin(); - IF != Indexes->end(); IF++) + IF != Indexes->end(); ++IF) { if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File()) { diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index b0450e803..1849f1335 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -363,7 +363,7 @@ void ShowBroken(ostream &out,CacheFile &Cache,bool Now) if (Start == End) break; - Start++; + ++Start; } } } @@ -537,7 +537,7 @@ bool ShowEssential(ostream &out,CacheFile &Cache) continue; // Print out any essential package depenendents that are to be removed - for (pkgCache::DepIterator D = I.CurrentVer().DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = I.CurrentVer().DependsList(); D.end() == false; ++D) { // Skip everything but depends if (D->Type != pkgCache::Dep::PreDepends && @@ -574,7 +574,7 @@ void Stats(ostream &out,pkgDepCache &Dep) unsigned long Downgrade = 0; unsigned long Install = 0; unsigned long ReInstall = 0; - for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; I++) + for (pkgCache::PkgIterator I = Dep.PkgBegin(); I.end() == false; ++I) { if (Dep[I].NewInstall() == true) Install++; @@ -666,7 +666,7 @@ public: } // if we found no candidate which provide this package, show non-candidates if (provider == 0) - for (I = Pkg.ProvidesList(); I.end() == false; I++) + for (I = Pkg.ProvidesList(); I.end() == false; ++I) out << " " << I.OwnerPkg().FullName(true) << " " << I.OwnerVer().VerStr() << _(" [Not candidate version]") << endl; else @@ -682,7 +682,7 @@ public: SPtrArray Seen = new bool[Cache.GetPkgCache()->Head().PackageCount]; memset(Seen,0,Cache.GetPkgCache()->Head().PackageCount*sizeof(*Seen)); for (pkgCache::DepIterator Dep = Pkg.RevDependsList(); - Dep.end() == false; Dep++) { + Dep.end() == false; ++Dep) { if (Dep->Type != pkgCache::Dep::Replaces) continue; if (Seen[Dep.ParentPkg()->ID] == true) @@ -921,7 +921,7 @@ void CacheFile::Sort() List = new pkgCache::Package *[Cache->Head().PackageCount]; memset(List,0,sizeof(*List)*Cache->Head().PackageCount); pkgCache::PkgIterator I = Cache->PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) List[I->ID] = I; SortCache = *this; @@ -953,7 +953,7 @@ bool CacheFile::CheckDeps(bool AllowBroken) if ((DCache->PolicyBrokenCount() > 0)) { // upgrade all policy-broken packages with ForceImportantDeps=True - for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); I++) + for (pkgCache::PkgIterator I = Cache->PkgBegin(); !I.end(); ++I) if ((*DCache)[I].NowPolicyBroken() == true) DCache->MarkInstall(I,true,0, false, true); } @@ -1044,7 +1044,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindB("APT::Get::Purge",false) == true) { pkgCache::PkgIterator I = Cache->PkgBegin(); - for (; I.end() == false; I++) + for (; I.end() == false; ++I) { if (I.Purge() == false && Cache[I].Mode == pkgDepCache::ModeDelete) Cache->MarkDelete(I,true); @@ -1238,7 +1238,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, if (_config->FindB("APT::Get::Print-URIs") == true) { pkgAcquire::UriIterator I = Fetcher.UriBegin(); - for (; I != Fetcher.UriEnd(); I++) + for (; I != Fetcher.UriEnd(); ++I) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; return true; @@ -1262,7 +1262,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, { if ((*I)->Local == true) { - I++; + ++I; continue; } @@ -1282,7 +1282,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true, // Print out errors bool Failed = false; - for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) + for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I) { if ((*I)->Status == pkgAcquire::Item::StatDone && (*I)->Complete == true) @@ -1442,7 +1442,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, // we have a default release, try to locate the pkg. we do it like // this because GetCandidateVer() will not "downgrade", that means // "apt-get source -t stable apt" won't work on a unstable system - for (pkgCache::VerIterator Ver = Pkg.VersionList();; Ver++) + for (pkgCache::VerIterator Ver = Pkg.VersionList();; ++Ver) { // try first only exact matches, later fuzzy matches if (Ver.end() == true) @@ -1463,7 +1463,7 @@ pkgSrcRecords::Parser *FindSrc(const char *Name,pkgRecords &Recs, continue; for (pkgCache::VerFileIterator VF = Ver.FileList(); - VF.end() == false; VF++) + VF.end() == false; ++VF) { /* If this is the status file, and the current version is not the version in the status file (ie it is not installed, or somesuch) @@ -1615,7 +1615,7 @@ bool DoUpdate(CommandLine &CmdL) return false; pkgAcquire::UriIterator I = Fetcher.UriBegin(); - for (; I != Fetcher.UriEnd(); I++) + for (; I != Fetcher.UriEnd(); ++I) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; return true; @@ -1998,7 +1998,7 @@ bool DoInstall(CommandLine &CmdL) if(Start.TargetPkg().ProvidesList() != 0) { pkgCache::PrvIterator I = Start.TargetPkg().ProvidesList(); - for (; I.end() == false; I++) + for (; I.end() == false; ++I) { pkgCache::PkgIterator Pkg = I.OwnerPkg(); if (Cache[Pkg].CandidateVerIter(Cache) == I.OwnerVer() && @@ -2021,7 +2021,7 @@ bool DoInstall(CommandLine &CmdL) if (Start >= End) break; - Start++; + ++Start; } if(foundInstalledInOrGroup == false) @@ -2135,7 +2135,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) // Install everything with the install flag set pkgCache::PkgIterator I = Cache->PkgBegin(); - for (;I.end() != true; I++) + for (;I.end() != true; ++I) { /* Install the package only if it is a new install, the autoupgrader will deal with the rest */ @@ -2145,7 +2145,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) /* Now install their deps too, if we do this above then order of the status file is significant for | groups */ - for (I = Cache->PkgBegin();I.end() != true; I++) + for (I = Cache->PkgBegin();I.end() != true; ++I) { /* Install the package only if it is a new install, the autoupgrader will deal with the rest */ @@ -2154,7 +2154,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) } // Apply erasures now, they override everything else. - for (I = Cache->PkgBegin();I.end() != true; I++) + for (I = Cache->PkgBegin();I.end() != true; ++I) { // Remove packages if (I->SelectedState == pkgCache::State::DeInstall || @@ -2171,7 +2171,7 @@ bool DoDSelectUpgrade(CommandLine &CmdL) // 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) { @@ -2317,7 +2317,7 @@ bool DoDownload(CommandLine &CmdL) if (_config->FindB("APT::Get::Print-URIs") == true) { pkgAcquire::UriIterator I = Fetcher.UriBegin(); - for (; I != Fetcher.UriEnd(); I++) + for (; I != Fetcher.UriEnd(); ++I) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; return true; @@ -2435,7 +2435,7 @@ bool DoSource(CommandLine &CmdL) // Load them into the fetcher for (vector::const_iterator I = Lst.begin(); - I != Lst.end(); I++) + I != Lst.end(); ++I) { // Try to guess what sort of file it is we are getting. if (I->Type == "dsc") @@ -2537,7 +2537,7 @@ bool DoSource(CommandLine &CmdL) if (_config->FindB("APT::Get::Print-URIs") == true) { pkgAcquire::UriIterator I = Fetcher.UriBegin(); - for (; I != Fetcher.UriEnd(); I++) + for (; I != Fetcher.UriEnd(); ++I) cout << '\'' << I->URI << "' " << flNotDir(I->Owner->DestFile) << ' ' << I->Owner->FileSize << ' ' << I->Owner->HashSum() << endl; delete[] Dsc; @@ -2553,7 +2553,7 @@ bool DoSource(CommandLine &CmdL) // Print error messages bool Failed = false; - for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); I++) + for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I != Fetcher.ItemsEnd(); ++I) { if ((*I)->Status == pkgAcquire::Item::StatDone && (*I)->Complete == true) @@ -2582,7 +2582,7 @@ bool DoSource(CommandLine &CmdL) if (Process == 0) { bool const fixBroken = _config->FindB("APT::Get::Fix-Broken", false); - for (unsigned I = 0; I != J; I++) + for (unsigned I = 0; I != J; ++I) { string Dir = Dsc[I].Package + '-' + Cache->VS().UpstreamVersion(Dsc[I].Version.c_str()); @@ -2731,7 +2731,7 @@ bool DoBuildDep(CommandLine &CmdL) BuildDeps.push_back(rec); } - if (BuildDeps.size() == 0) + if (BuildDeps.empty() == true) { ioprintf(c1out,_("%s has no build depends.\n"),Src.c_str()); continue; @@ -2741,7 +2741,7 @@ bool DoBuildDep(CommandLine &CmdL) vector ::iterator D; pkgProblemResolver Fix(Cache); bool skipAlternatives = false; // skip remaining alternatives in an or group - for (D = BuildDeps.begin(); D != BuildDeps.end(); D++) + for (D = BuildDeps.begin(); D != BuildDeps.end(); ++D) { bool hasAlternatives = (((*D).Op & pkgCache::Dep::Or) == pkgCache::Dep::Or); @@ -2920,7 +2920,7 @@ bool DoBuildDep(CommandLine &CmdL) * installed */ pkgCache::PrvIterator Prv = Pkg.ProvidesList(); - for (; Prv.end() != true; Prv++) + for (; Prv.end() != true; ++Prv) { if (_config->FindB("Debug::BuildDeps",false) == true) cout << " Checking provider " << Prv.OwnerPkg().FullName() << endl; -- 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 --- cmdline/apt-sortpkgs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmdline') diff --git a/cmdline/apt-sortpkgs.cc b/cmdline/apt-sortpkgs.cc index 171b0ba13..f95a434cc 100644 --- a/cmdline/apt-sortpkgs.cc +++ b/cmdline/apt-sortpkgs.cc @@ -106,7 +106,7 @@ bool DoIt(string InFile) // Emit unsigned char *Buffer = new unsigned char[Largest+1]; - for (vector::iterator I = List.begin(); I != List.end(); I++) + for (vector::iterator I = List.begin(); I != List.end(); ++I) { // Read in the Record. if (Fd.Seek(I->Offset) == false || Fd.Read(Buffer,I->Length) == false) -- cgit v1.2.3