[PATCH setup 0/2] Improve the handling of command line package selection

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH setup 0/2] Improve the handling of command line package selection

Ken Brown-6
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.

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(-)

--
2.16.2

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 1/2] Improve the preparation of the package database

Ken Brown-6
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.16.2

Reply | Threaded
Open this post in threaded view
|

[PATCH setup 2/2] Fix detection of automatically added packages

Ken Brown-6
In reply to this post by Ken Brown-6
In the "confirm" dialog, report a package as automatically added for
install if the version being installed is different from the version
requested by the user.  This can happen if the global update mode is
"Keep" but a package needs to be updated because of a versioned
dependency.
---
 confirm.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/confirm.cc b/confirm.cc
index 92360cc..1e7127a 100644
--- a/confirm.cc
+++ b/confirm.cc
@@ -109,7 +109,7 @@ ConfirmPage::OnActivate()
             line += i->version.Canonical_version();
             if (i->version.Type() == package_source)
               line += " (source)";
-            else if (pkg && !pkg->desired)
+            else if (pkg && pkg->desired != pv)
               line += " (automatically added)";
             line += "\r\n";
             install.push_back (line);
--
2.16.2