From: Michael Schroeder Date: Mon, 12 Dec 2022 15:18:43 +0000 (+0100) Subject: Add alternative reporting X-Git-Tag: 0.7.23~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=103f54b5f8581c39667b6a7784d5cf3df2634b04;p=thirdparty%2Flibsolv.git Add alternative reporting Also make pysolv work again with newer rpm versions. We need to rewind the file descriptor int the RPMCALLBACK_INST_OPEN_FILE callback as rpm now opens the file twice. --- diff --git a/examples/pysolv b/examples/pysolv index cfe97109..b69234ef 100755 --- a/examples/pysolv +++ b/examples/pysolv @@ -43,6 +43,7 @@ from optparse import OptionParser #import gc #gc.set_debug(gc.DEBUG_LEAK) +#rpm.setVerbosity(rpm.RPMLOG_DEBUG) class repo_generic(dict): def __init__(self, name, type, attribs = {}): @@ -807,7 +808,6 @@ while True: # no problems, show transaction trans = solver.transaction() -del solver if trans.isempty(): print("Nothing to do.") sys.exit(0) @@ -843,6 +843,20 @@ for cl in trans.classify(solv.Transaction.SOLVER_TRANSACTION_SHOW_OBSOLETES | so print("install size change: %d K" % trans.calc_installsizechange()) print('') +alternatives = solver.alternatives() +if alternatives: + print('Alternatives:') + for a in alternatives: + print('') + print(a) + aidx = 1 + for ac in a.choices(): + print("%6d: %s" % (aidx, ac)) + aidx = aidx + 1 + print('') + +del solver + while True: sys.stdout.write("OK to continue (y/n)? ") sys.stdout.flush() @@ -949,7 +963,9 @@ if checkproblems: ts.order() def runCallback(reason, amount, total, p, d): if reason == rpm.RPMCALLBACK_INST_OPEN_FILE: - return newpkgsfp[p.id].fileno() + f = newpkgsfp[p.id] + os.lseek(f.fileno(), 0, os.SEEK_SET) + return f.fileno() if reason == rpm.RPMCALLBACK_INST_START: print("install %s" % p) if reason == rpm.RPMCALLBACK_UNINST_START: