summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2020-02-18 12:43:16 +0000
committerJulian Andres Klode <jak@debian.org>2020-02-18 12:43:16 +0000
commitc5dd63e3b63b15f6fb885fb4e8869fd41d45d310 (patch)
treea494c29a4b0a99e1528794e98c374249b9ef73b2 /cmdline
parentaf9596bae26b57640c18fad627cdf7bb18d41ee1 (diff)
parent009b144dc466856b05473c73bdf75ea21755b037 (diff)
Merge branch 'master' into 'master'
apt-mark: don't lie about successful marks See merge request apt-team/apt!94
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-mark.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc
index 942f58f0f..92efa0c81 100644
--- a/cmdline/apt-mark.cc
+++ b/cmdline/apt-mark.cc
@@ -56,7 +56,8 @@ static bool DoAuto(CommandLine &CmdL)
return _error->Error(_("No packages found"));
bool MarkAuto = strcasecmp(CmdL.FileList[0],"auto") == 0;
- int AutoMarkChanged = 0;
+
+ vector<string> PackagesMarked;
for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
{
@@ -74,16 +75,27 @@ static bool DoAuto(CommandLine &CmdL)
continue;
}
- if (MarkAuto == false)
- ioprintf(c1out,_("%s set to manually installed.\n"), Pkg.FullName(true).c_str());
- else
- ioprintf(c1out,_("%s set to automatically installed.\n"), Pkg.FullName(true).c_str());
-
+ PackagesMarked.push_back(Pkg.FullName(true));
DepCache->MarkAuto(Pkg, MarkAuto);
- ++AutoMarkChanged;
}
- if (AutoMarkChanged > 0 && _config->FindB("APT::Mark::Simulate", false) == false)
- return DepCache->writeStateFile(NULL);
+
+ bool MarkWritten = false;
+ bool IsSimulation = _config->FindB("APT::Mark::Simulate", false);
+ if (PackagesMarked.size() > 0 && !IsSimulation) {
+ MarkWritten = DepCache->writeStateFile(NULL);
+ if(!MarkWritten) {
+ return MarkWritten;
+ }
+ }
+
+ if(IsSimulation || MarkWritten) {
+ for (vector<string>::const_iterator I = PackagesMarked.begin(); I != PackagesMarked.end(); ++I) {
+ if (MarkAuto == false)
+ ioprintf(c1out,_("%s set to manually installed.\n"), (*I).c_str());
+ else
+ ioprintf(c1out,_("%s set to automatically installed.\n"), (*I).c_str());
+ }
+ }
return true;
}
/*}}}*/