]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Add alternative reporting
authorMichael Schroeder <mls@suse.de>
Mon, 12 Dec 2022 15:18:43 +0000 (16:18 +0100)
committerMichael Schroeder <mls@suse.de>
Mon, 12 Dec 2022 15:18:43 +0000 (16:18 +0100)
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.

examples/pysolv

index cfe971099da3e2f98add7f32d5307c9231d768e3..b69234efc5294d4b1c22200827059b2566dceeed 100755 (executable)
@@ -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: