From cfefaf6c4a27bbd5bfdad67e482f4b01506f5bd5 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Thu, 28 Aug 2014 15:04:20 -0700 Subject: The following command otherwise yields many blank lines: apt list -o APT::Cmd::use-format=true -o APT::Cmd::format=\${Package} And even worse when adding "-o APT::Cmd::All-Versions=true". Signed-off-by: Andreas Oberritter --- apt-private/private-list.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'apt-private') diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc index b69002103..f98456576 100644 --- a/apt-private/private-list.cc +++ b/apt-private/private-list.cc @@ -93,7 +93,6 @@ static void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,/*{{{*/ Ver.end() == false; ++Ver) { ListSingleVersion(CacheFile, records, Ver, outs, include_summary); - outs << "\n"; } } /*}}}*/ @@ -149,7 +148,7 @@ bool DoList(CommandLine &Cmd) // FIXME: SORT! and make sorting flexible (alphabetic, by pkg status) // output the sorted map for (K = output_map.begin(); K != output_map.end(); ++K) - std::cout << (*K).second << std::endl; + std::cout << (*K).second; // be nice and tell the user if there is more to see -- cgit v1.2.3-70-g09d2 From 6763aaec8ddded31057733f53c63f15e6b949bd9 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Tue, 2 Sep 2014 16:34:05 +0200 Subject: Avoid yielding blank lines with APT::Cmd::use-format=true --- apt-private/private-list.cc | 3 ++- apt-private/private-output.cc | 2 +- test/integration/test-apt-cli-list | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'apt-private') diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc index f98456576..b69002103 100644 --- a/apt-private/private-list.cc +++ b/apt-private/private-list.cc @@ -93,6 +93,7 @@ static void ListAllVersions(pkgCacheFile &CacheFile, pkgRecords &records,/*{{{*/ Ver.end() == false; ++Ver) { ListSingleVersion(CacheFile, records, Ver, outs, include_summary); + outs << "\n"; } } /*}}}*/ @@ -148,7 +149,7 @@ bool DoList(CommandLine &Cmd) // FIXME: SORT! and make sorting flexible (alphabetic, by pkg status) // output the sorted map for (K = output_map.begin(); K != output_map.end(); ++K) - std::cout << (*K).second; + std::cout << (*K).second << std::endl; // be nice and tell the user if there is more to see diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 7f8922138..8f1fb886e 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -220,7 +220,7 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/ output = SubstVar(output, "${Version}", GetVersion(CacheFile, V)); output = SubstVar(output, "${Description}", GetShortDescription(CacheFile, records, P)); output = SubstVar(output, "${Origin}", GetArchiveSuite(CacheFile, V)); - out << output << std::endl; + out << output; } else { // raring/linux-kernel version [upradable: new-version] // description diff --git a/test/integration/test-apt-cli-list b/test/integration/test-apt-cli-list index 40bf81a39..aae74c022 100755 --- a/test/integration/test-apt-cli-list +++ b/test/integration/test-apt-cli-list @@ -68,4 +68,7 @@ testequal "Listing... baz/unstable 2.0 all [upgradable from: 0.1] N: There are 2 additional versions. Please use the '-a' switch to see them." apt list baz -o quiet=0 - +# test format strings for machine parseable output +apt list -qq bar baz -o APT::Cmd::use-format=true -o APT::Cmd::format="\${Package} - \${installed:Version} - \${candidate:Version}" > output.txt +testequal "bar - 1.0 - 1.0 +baz - 0.1 - 2.0" cat output.txt -- cgit v1.2.3-70-g09d2 From d059cc2668f284a7db77a15d1d742326d464e963 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Sep 2014 12:03:28 +0200 Subject: Fix incorrect upgradable listing in "apt list" (thanks to Michael Musenbrock) The "apt list" command was using only the pkgDepCache but not the pkgPolicy to figure out if a package is upgradable. This lead to incorrect display of upgradable package when the user used the policy to pin-down packages. Thanks to Michael Musenbrock for the initial patch. Closes: #753297 --- apt-private/private-cacheset.cc | 5 ++++- apt-private/private-output.cc | 5 ++++- test/integration/test-bug-753297-upgradable | 34 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 test/integration/test-bug-753297-upgradable (limited to 'apt-private') diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index e37e7b227..159e1d8f1 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -55,7 +55,10 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, } else if (_config->FindB("APT::Cmd::Upgradable") == true) { - if(P.CurrentVer() && state.Upgradable()) + pkgPolicy *policy = CacheFile.GetPolicy(); + if(P.CurrentVer() && + state.Upgradable() && + policy->GetCandidateVer(P) != P.CurrentVer()) { pkgPolicy *policy = CacheFile.GetPolicy(); output_set.insert(policy->GetCandidateVer(P)); diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 8f1fb886e..2120b7a83 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -229,7 +229,10 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/ std::string CandidateVerStr = GetCandidateVersion(CacheFile, P); std::string InstalledVerStr = GetInstalledVersion(CacheFile, P); std::string StatusStr; - if(P.CurrentVer() == V && state.Upgradable() && state.CandidateVer != NULL) + if(P.CurrentVer() == V && + state.Upgradable() && + state.CandidateVer != NULL && + policy->GetCandidateVer(P) != P.CurrentVer()) { strprintf(StatusStr, _("[installed,upgradable to: %s]"), CandidateVerStr.c_str()); diff --git a/test/integration/test-bug-753297-upgradable b/test/integration/test-bug-753297-upgradable new file mode 100755 index 000000000..068704b3e --- /dev/null +++ b/test/integration/test-bug-753297-upgradable @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +cat > rootdir/etc/apt/preferences < Date: Fri, 5 Sep 2014 12:50:15 +0200 Subject: Ensure we have a Policy in CacheFile.BuildDepCache() This partly reverts d059cc2 and fixes bug #753297 in a more general way by ensuring that CacheFile.BuildDepCache() builds a pkgPolicy if there isn't one already. --- apt-pkg/cachefile.cc | 3 +++ apt-private/private-cacheset.cc | 5 +---- apt-private/private-output.cc | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) (limited to 'apt-private') diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 0fd40106f..ea3d45480 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -143,6 +143,9 @@ bool pkgCacheFile::BuildDepCache(OpProgress *Progress) if (DCache != NULL) return true; + if (BuildPolicy(Progress) == false) + return false; + DCache = new pkgDepCache(Cache,Policy); if (_error->PendingError() == true) return false; diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index 159e1d8f1..e37e7b227 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -55,10 +55,7 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, } else if (_config->FindB("APT::Cmd::Upgradable") == true) { - pkgPolicy *policy = CacheFile.GetPolicy(); - if(P.CurrentVer() && - state.Upgradable() && - policy->GetCandidateVer(P) != P.CurrentVer()) + if(P.CurrentVer() && state.Upgradable()) { pkgPolicy *policy = CacheFile.GetPolicy(); output_set.insert(policy->GetCandidateVer(P)); diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 2120b7a83..522f7682d 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -229,10 +229,7 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records, /*{{{*/ std::string CandidateVerStr = GetCandidateVersion(CacheFile, P); std::string InstalledVerStr = GetInstalledVersion(CacheFile, P); std::string StatusStr; - if(P.CurrentVer() == V && - state.Upgradable() && - state.CandidateVer != NULL && - policy->GetCandidateVer(P) != P.CurrentVer()) + if(P.CurrentVer() == V && state.Upgradable()) { strprintf(StatusStr, _("[installed,upgradable to: %s]"), CandidateVerStr.c_str()); -- cgit v1.2.3-70-g09d2