[PATCH setup 05/11] Store the requested action in packagemeta::set_action()
Jon Turney
jon.turney@dronecode.org.uk
Thu Aug 1 16:07:00 GMT 2019
Store the action requested with set_action() in the packagemeta object,
rather than just encoding it in _picked/installed/desired (see
discussion in commit 4209699d)
Try to avoid meaningless states occuring, i.e. action=Install with
desired=installed is converted to action=Keep.
Future work: There's still some odd stuff left in set_action() which we
need to do some hard thinking about: action=NoChange treats Base
category packages specially, action=Install will switch to installing
the source if binary isn't accessible.
---
choose.cc | 2 +-
package_meta.cc | 5 +++--
package_meta.h | 5 ++++-
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/choose.cc b/choose.cc
index 277baba..7f6e332 100644
--- a/choose.cc
+++ b/choose.cc
@@ -307,7 +307,7 @@ ChooserPage::applyCommandLinePackageSelection()
else if (PruneInstallOption)
pkg.set_action (packagemeta::NoChange_action, pkg.curr);
else if (upgrade)
- pkg.set_action (packagemeta::NoChange_action, pkg.trustp(true, TRUST_UNKNOWN));
+ pkg.set_action (packagemeta::Install_action, pkg.trustp(true, TRUST_UNKNOWN));
else
pkg.set_action (packagemeta::NoChange_action, pkg.installed);
}
diff --git a/package_meta.cc b/package_meta.cc
index 3224f1c..b731254 100644
--- a/package_meta.cc
+++ b/package_meta.cc
@@ -555,7 +555,6 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
else
// else, if not installed, skip
desired = packageversion ();
- return;
}
else if (action == Install_action)
{
@@ -576,11 +575,11 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
}
else
{
+ action = NoChange_action;
pick (false);
srcpick (false);
}
}
- return;
}
else if (action == Reinstall_action)
{
@@ -595,6 +594,8 @@ packagemeta::set_action (_actions action, packageversion const &default_version)
{
desired = packageversion ();
}
+
+ _action = action;
}
bool
diff --git a/package_meta.h b/package_meta.h
index 12f2de2..e2144ad 100644
--- a/package_meta.h
+++ b/package_meta.h
@@ -38,7 +38,7 @@ public:
packagemeta (packagemeta const &);
packagemeta (const std::string& pkgname)
: name (pkgname), user_picked (false),
- _picked(false), _srcpicked(false)
+ _action(NoChange_action), _picked(false), _srcpicked(false)
{
}
@@ -64,6 +64,7 @@ public:
ActionList *list_actions(trusts const trust);
void select_action (int id, trusts const deftrust);
void toggle_action ();
+ _actions get_action () { return _action; }
void set_message (const std::string& message_id, const std::string& message_string)
{
@@ -162,6 +163,8 @@ private:
std::vector <Script> scripts_;
static bool scan (const packageversion &pkg, bool mirror_mode);
+ _actions _action;
+
bool _picked; /* true if desired version is to be (re)installed */
bool _srcpicked;
--
2.21.0
More information about the Cygwin-apps
mailing list