-if cmd == 'install' or cmd == 'erase' or cmd == 'up' or cmd == 'dup' or cmd == 'verify':
- if not jobs:
- print "no package matched."
- 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.isemptyupdate():
- job.how ^= Job.SOLVER_UPDATE ^ Job.SOLVER_INSTALL
- elif cmd == 'install':
- job.how |= Job.SOLVER_INSTALL
- elif cmd == 'erase':
- job.how |= Job.SOLVER_ERASE
- elif cmd == 'dup':
- job.how |= Job.SOLVER_DISTUPGRADE
- elif cmd == 'verify':
- job.how |= Job.SOLVER_VERIFY
-
- #pool.set_debuglevel(2)
- solver = None
- while True:
- solver = pool.Solver()
- solver.set_flag(Solver.SOLVER_FLAG_SPLITPROVIDES, 1);
- if cmd == 'erase':
- solver.set_flag(Solver.SOLVER_FLAG_ALLOW_UNINSTALL, 1);
- problems = solver.solve(jobs)
- if not problems:
- break
- for problem in problems:
- print "Problem %d:" % problem.id
- r = problem.findproblemrule()
- ri = r.info()
- print ri.problemstr()
- solutions = problem.solutions()
- for solution in solutions:
- print " Solution %d:" % solution.id
- elements = solution.elements(True)
- for element in elements:
- print " - %s" % element.str()
- print
- sol = ''
- while not (sol == 's' or sol == 'q' or (sol.isdigit() and int(sol) >= 1 and int(sol) <= len(solutions))):
- sys.stdout.write("Please choose a solution: ")
- sys.stdout.flush()
- sol = sys.stdin.readline().strip()
- if sol == 's':
- continue # skip problem
- if sol == 'q':
- sys.exit(1)
- solution = solutions[int(sol) - 1]
- for element in solution.elements():
- newjob = element.Job()
- if element.type == Solver.SOLVER_SOLUTION_JOB:
- jobs[element.jobidx] = newjob
- else:
- if newjob and newjob not in jobs:
- jobs.append(newjob)
-
- # no problems, show transaction
- trans = solver.transaction()
- del solver
- if trans.isempty():
- print "Nothing to do."
- sys.exit(0)
- print
- print "Transaction summary:"
- print
- for cl in trans.classify():
- if cl.type == Transaction.SOLVER_TRANSACTION_ERASE:
- print "%d erased packages:" % cl.count
- elif cl.type == Transaction.SOLVER_TRANSACTION_INSTALL:
- print "%d installed packages:" % cl.count
- elif cl.type == Transaction.SOLVER_TRANSACTION_REINSTALLED:
- print "%d reinstalled packages:" % cl.count
- elif cl.type == Transaction.SOLVER_TRANSACTION_DOWNGRADED:
- print "%d downgraded packages:" % cl.count
- elif cl.type == Transaction.SOLVER_TRANSACTION_CHANGED:
- print "%d changed packages:" % cl.count
- elif cl.type == Transaction.SOLVER_TRANSACTION_UPGRADED:
- print "%d upgraded packages:" % cl.count
- elif cl.type == Transaction.SOLVER_TRANSACTION_VENDORCHANGE:
- print "%d vendor changes from '%s' to '%s':" % (cl.count, cl.fromdep(), cl.todep())
- elif cl.type == Transaction.SOLVER_TRANSACTION_ARCHCHANGE:
- print "%d arch changes from '%s' to '%s':" % (cl.count, cl.fromdep(), cl.todep())
+# up magic: use install instead of update if no installed package matches
+for job in jobs:
+ if cmd == 'up' and job.isemptyupdate():
+ job.how ^= solv.Job.SOLVER_UPDATE ^ solv.Job.SOLVER_INSTALL
+ if options.best:
+ job.how |= solv.Job.SOLVER_FORCEBEST
+ if options.clean:
+ job.how |= solv.Job.SOLVER_CLEANDEPS
+
+#pool.set_debuglevel(2)
+solver = pool.Solver()
+solver.set_flag(solv.Solver.SOLVER_FLAG_SPLITPROVIDES, 1);
+if cmd == 'erase':
+ solver.set_flag(solv.Solver.SOLVER_FLAG_ALLOW_UNINSTALL, 1);
+
+while True:
+ problems = solver.solve(jobs)
+ if not problems:
+ break
+ for problem in problems:
+ print("Problem %d/%d:" % (problem.id, len(problems)))
+ print(problem)
+ solutions = problem.solutions()
+ for solution in solutions:
+ print(" Solution %d:" % solution.id)
+ elements = solution.elements(True)
+ for element in elements:
+ print(" - %s" % element.str())
+ print('')
+ sol = ''
+ while not (sol == 's' or sol == 'q' or (sol.isdigit() and int(sol) >= 1 and int(sol) <= len(solutions))):
+ sys.stdout.write("Please choose a solution: ")
+ sys.stdout.flush()
+ sol = sys.stdin.readline().strip()
+ if sol == 's':
+ continue # skip problem
+ if sol == 'q':
+ sys.exit(1)
+ solution = solutions[int(sol) - 1]
+ for element in solution.elements():
+ newjob = element.Job()
+ if element.type == solv.Solver.SOLVER_SOLUTION_JOB:
+ jobs[element.jobidx] = newjob
+ else:
+ if newjob and newjob not in jobs:
+ jobs.append(newjob)
+
+# no problems, show transaction
+trans = solver.transaction()
+del solver
+if trans.isempty():
+ print("Nothing to do.")
+ sys.exit(0)
+print('')
+print("Transaction summary:")
+print('')
+for cl in trans.classify(solv.Transaction.SOLVER_TRANSACTION_SHOW_OBSOLETES | solv.Transaction.SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE):
+ if cl.type == solv.Transaction.SOLVER_TRANSACTION_ERASE:
+ print("%d erased packages:" % cl.count)
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_INSTALL:
+ print("%d installed packages:" % cl.count)
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_REINSTALLED:
+ print("%d reinstalled packages:" % cl.count)
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_DOWNGRADED:
+ print("%d downgraded packages:" % cl.count)
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_CHANGED:
+ print("%d changed packages:" % cl.count)
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_UPGRADED:
+ print("%d upgraded packages:" % cl.count)
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_VENDORCHANGE:
+ print("%d vendor changes from '%s' to '%s':" % (cl.count, cl.fromstr, cl.tostr))
+ elif cl.type == solv.Transaction.SOLVER_TRANSACTION_ARCHCHANGE:
+ print("%d arch changes from '%s' to '%s':" % (cl.count, cl.fromstr, cl.tostr))
+ else:
+ continue
+ for p in cl.solvables():
+ if cl.type == solv.Transaction.SOLVER_TRANSACTION_UPGRADED or cl.type == solv.Transaction.SOLVER_TRANSACTION_DOWNGRADED:
+ op = trans.othersolvable(p)
+ print(" - %s -> %s" % (p, op))