* [PATCH setup v2 1/2] Improve the preparation of the package database
2018-06-07 17:37 [PATCH setup v2 0/2] Improve the handling of command line package selection Ken Brown
@ 2018-06-07 17:37 ` Ken Brown
2018-06-07 17:37 ` [PATCH setup v2 2/2] Fix detection of automatically added packages Ken Brown
2018-06-10 20:58 ` [PATCH setup v2 0/2] Improve the handling of command line package selection Jon Turney
2 siblings, 0 replies; 4+ messages in thread
From: Ken Brown @ 2018-06-07 17:37 UTC (permalink / raw)
To: cygwin-apps
Introduce a new function packagedb::noChanges() to set the database to
a "no changes requested" state. Call it the first time the chooser
page is activated, before calling
ChooserPage::applyCommandLinePackageSelection().
Also use it to simplify the code in two places.
Remove code from ChooserPage::changeTrust() that was making changes to
the database after ChooserPage::applyCommandLinePackageSelection() had
already been called.
---
choose.cc | 26 ++++++--------------------
libsolv.cc | 11 +++--------
package_db.cc | 12 ++++++++++++
package_db.h | 2 ++
4 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/choose.cc b/choose.cc
index 1249efa..51d2fb6 100644
--- a/choose.cc
+++ b/choose.cc
@@ -329,6 +329,7 @@ ChooserPage::OnActivate()
{
// Do things which should only happen once, but rely on packagedb being
// ready to use, so OnInit() is too early
+ db.noChanges();
applyCommandLinePackageSelection();
initialUpdateState();
@@ -392,13 +393,7 @@ ChooserPage::keepClicked()
{
update_mode_id = IDC_CHOOSE_KEEP;
packagedb db;
- for (packagedb::packagecollection::iterator i = db.packages.begin ();
- i != db.packages.end (); ++i)
- {
- packagemeta & pkg = *(i->second);
- pkg.desired = pkg.installed;
- pkg.pick(false);
- }
+ db.noChanges();
chooser->refresh();
}
@@ -431,20 +426,11 @@ ChooserPage::changeTrust(int button, bool test, bool initial)
// usually we want to apply the solver to an empty task list to get the list
// of packages to upgrade (if any)
+ // but initially we want a task list with any package changes caused by
+ // command line options
if (initial)
- {
- // but initially we want a task list with any package changes caused by
- // command line options
- // (also note the installed version to avoid generating spurious taskKeep
- // or taskSkip tasks)
- for (packagedb::packagecollection::iterator p = db.packages.begin ();
- p != db.packages.end (); ++p)
- {
- packagemeta *pkg = p->second;
- pkg->default_version = pkg->installed;
- }
- q.setTasks();
- }
+ q.setTasks();
+
db.defaultTrust(q, mode, test);
// configure PickView so 'test' or 'curr' version is chosen when an
diff --git a/libsolv.cc b/libsolv.cc
index 2eb04e2..11394a2 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -658,14 +658,9 @@ void
SolverSolution::trans2db() const
{
packagedb db;
- // First reset all packages to the "no change" state
- for (packagedb::packagecollection::iterator i = db.packages.begin();
- i != db.packages.end(); i++)
- {
- packagemeta *pkg = i->second;
- pkg->desired = pkg->default_version = pkg->installed;
- pkg->pick(false);
- }
+ // First reset all packages to the "no changes" state
+ db.noChanges ();
+
// Now make changes according to trans. transErase requires some
// care; it could either be a "plain" uninstall, or it could be
// paired with a transInstall for an upgrade/downgrade or reinstall.
diff --git a/package_db.cc b/package_db.cc
index d12e841..9189e40 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -750,3 +750,15 @@ packagedb::prep()
prepped = true;
}
+
+void
+packagedb::noChanges ()
+{
+ for (packagecollection::iterator i = packages.begin();
+ i != packages.end(); i++)
+ {
+ packagemeta *pkg = i->second;
+ pkg->desired = pkg->default_version = pkg->installed;
+ pkg->pick(false);
+ }
+}
diff --git a/package_db.h b/package_db.h
index e500e4b..da73171 100644
--- a/package_db.h
+++ b/package_db.h
@@ -68,6 +68,8 @@ public:
/* 0 on success */
int flush ();
void prep();
+ /* Set the database to a "no changes requested" state. */
+ void noChanges ();
packagemeta * findBinary (PackageSpecification const &) const;
packageversion findBinaryVersion (PackageSpecification const &) const;
--
2.17.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH setup v2 0/2] Improve the handling of command line package selection
2018-06-07 17:37 [PATCH setup v2 0/2] Improve the handling of command line package selection Ken Brown
2018-06-07 17:37 ` [PATCH setup v2 1/2] Improve the preparation of the package database Ken Brown
2018-06-07 17:37 ` [PATCH setup v2 2/2] Fix detection of automatically added packages Ken Brown
@ 2018-06-10 20:58 ` Jon Turney
2 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2018-06-10 20:58 UTC (permalink / raw)
To: cygwin-apps
On 07/06/2018 18:37, Ken Brown wrote:
> Suppose an installed package A gets updated because of the "--packages
> A" command line option. If A requires a version of package B higher
> than the installed version, then B will also need to be updated.
> Moreover, if the "--upgrade-also" option hasn't been specified, then
> the global update mode will be "Keep", so libsolv will have to add the
> upgrade of B.
>
> These two patches attempt to make sure that this process is handled
> smoothly. First, the package database needs to be set up so that it
> doesn't indicate that the user chose to keep B; this would cause
> libsolv to report a problem. Second, the "confirm" dialog should
> indicate that the upgrade of B was automatically added.
>
> v2: Rebase against current HEAD.
>
> Ken Brown (2):
> Improve the preparation of the package database
> Fix detection of automatically added packages
>
> choose.cc | 26 ++++++--------------------
> confirm.cc | 2 +-
> libsolv.cc | 11 +++--------
> package_db.cc | 12 ++++++++++++
> package_db.h | 2 ++
> 5 files changed, 24 insertions(+), 29 deletions(-)
>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread