use "isemptyupdate" method to check for updates with no matching installed package
authorMichael Schroeder <mls@suse.de>
Wed, 21 Nov 2012 15:21:48 +0000 (16:21 +0100)
committerMichael Schroeder <mls@suse.de>
Wed, 21 Nov 2012 15:21:48 +0000 (16:21 +0100)
examples/p5solv
examples/pysolv
examples/rbsolv

index 8a63631886a0b81122d7b7b90964e8903310400d..cd246022e299e5c53454f467bc25a9c55086d0ba 100755 (executable)
@@ -600,11 +600,8 @@ if ($cmd eq 'install' || $cmd eq 'erase' || $cmd eq 'up' || $cmd eq 'dup' || $cm
   die("no package matched.\n") unless @jobs;
   for my $job (@jobs) {
     if ($cmd eq 'up') {
-      if ($job->{'how'} == $solv::Job::SOLVER_SOLVABLE_ALL || grep {$_->isinstalled()} $job->solvables()) {
-       $job->{'how'} |= $solv::Job::SOLVER_UPDATE;
-      } else {
-       $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
-      }
+      $job->{'how'} |= $solv::Job::SOLVER_UPDATE;
+      $job->{'how'} ^= $solv::Job::SOLVER_UPDATE ^ $solv::Job::SOLVER_INSTALL if $job->isemptyupdate();
     } elsif ($cmd eq 'install') {
        $job->{'how'} |= $solv::Job::SOLVER_INSTALL;
     } elsif ($cmd eq 'erase') {
index 4ad4ca44a8d89ac37003ca8577aa495199f33d6a..41f5cdabc10688affa309dd8cacf88e6d79ecadb 100755 (executable)
@@ -730,11 +730,10 @@ if cmd == 'install' or cmd == 'erase' or cmd == 'up' or cmd == 'dup' or cmd == '
         sys.exit(1)
     for job in jobs:
         if cmd == 'up':
+            job.how |= Job.SOLVER_UPDATE
             # up magic: use install instead of update if no installed package matches
-            if job.how == Job.SOLVER_SOLVABLE_ALL or filter(lambda s: s.isinstalled(), job.solvables()):
-                job.how |= Job.SOLVER_UPDATE
-            else:
-                job.how |= Job.SOLVER_INSTALL
+            if job.isemptyupdate():
+                job.how ^= Job.SOLVER_UPDATE ^ Job.SOLVER_INSTALL
         elif cmd == 'install':
             job.how |= Job.SOLVER_INSTALL
         elif cmd == 'erase':
index 26e98e734d1649d1c310523c0562371896cbed72..92edf8d5d9577e2c2e9ed76c7896825f4225f529 100755 (executable)
@@ -613,11 +613,8 @@ if cmd == 'install' || cmd == 'erase' || cmd == 'up' || cmd == 'dup' || cmd == '
   abort("no package matched.") if jobs.empty?
   for job in jobs
     if cmd == 'up'
-      if job.how == Solv::Job::SOLVER_SOLVABLE_ALL || job.solvables.any? {|s| s.isinstalled?}
-       job.how |= Solv::Job::SOLVER_UPDATE
-      else
-       job.how |= Solv::Job::SOLVER_INSTALL
-      end
+      job.how |= Solv::Job::SOLVER_UPDATE
+      job.how ^= Solv::Job::SOLVER_UPDATE ^ Solv::Job::SOLVER_INSTALL if job.isemptyupdate?
     elsif cmd == 'install'
       job.how |= Solv::Job::SOLVER_INSTALL
     elsif cmd == 'erase'