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') {
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':
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'