@@ -29,7 +29,7 @@ from shlex import quote
2929import xml .etree .ElementTree as ET
3030
3131# Constants
32- ZYPPERONI_VERSION = "0.4 .0"
32+ ZYPPERONI_VERSION = "0.5 .0"
3333ZYPPER_PID_FILE = "/run/zypp.pid"
3434
3535################################
@@ -470,7 +470,7 @@ elif args.command_name in ["dist-upgrade", "dup"]:
470470 sys .exit ()
471471 get_zypp_lock ()
472472 docroot = ET .fromstring (xml_output )
473- num_pkgs = None
473+ diff_bytes , download_size_bytes , num_pkgs = ( None ,) * 3
474474 for item in docroot .iter ('install-summary' ):
475475 download_size_bytes = float (item .attrib ["download-size" ])
476476 diff_bytes = float (item .attrib ["space-usage-diff" ])
@@ -479,25 +479,34 @@ elif args.command_name in ["dist-upgrade", "dup"]:
479479 logging .info (color ("info" , f"Total download size: { download_size_bytes / 1000 ** 2 :.2f} MB" ))
480480 if not args .download_only :
481481 logging .info (color ("info" , f"Space usage difference after operation: { diff_bytes / 1000 ** 2 :+.2f} MB" ))
482- if not num_pkgs :
483- msg = "There are package conflicts that must be manually resolved. See output of:\n " \
484- "zypper --non-interactive --no-cd dist-upgrade --dry-run"
482+ if num_pkgs :
483+ # parse all packages from xml output
484+ DUP_PKG = []
485+ for item in docroot .iter ("solvable" ):
486+ if item .attrib ["type" ] == "package" :
487+ DUP_PKG .append (f"{ item .attrib ['name' ]} -{ item .attrib ['edition' ]} .{ item .attrib ['arch' ]} " )
488+ # parse all packages to be removed
489+ RM_PKG = []
490+ for rm in docroot .iter ("to-remove" ):
491+ for solv in rm .findall ("solvable" ):
492+ if solv .get ("type" ) == "package" :
493+ RM_PKG .append (f"{ item .attrib ['name' ]} -{ item .attrib ['edition' ]} .{ item .attrib ['arch' ]} " )
494+ DUP_PKG = list ( set (DUP_PKG ) - set (RM_PKG ) )
495+ DUP_PKG .sort ()
496+ else :
497+ msg = "There are package conflicts that must be manually resolved. Falling back to secondary method of fetching packages to upgrade..."
485498 logging .warning (color ("warning" , msg ))
486- zypperoni_cleanup ()
487- sys .exit ()
488- # parse all packages from xml output
489- DUP_PKG = []
490- for item in docroot .iter ("solvable" ):
491- if item .attrib ["type" ] == "package" :
492- DUP_PKG .append (item .attrib ["name" ])
493- # parse all packages to be removed
494- RM_PKG = []
495- for rm in docroot .iter ("to-remove" ):
496- for solv in rm .findall ("solvable" ):
497- if solv .get ("type" ) == "package" :
498- RM_PKG .append (solv .get ("name" ))
499- DUP_PKG = list ( set (DUP_PKG ) - set (RM_PKG ) )
500- DUP_PKG .sort ()
499+ # get info about dup packages from 'zypper lu'
500+ logging .info (color ("info" , "Getting all packages to be upgraded" ))
501+ xml_output , ret = shell_exec ("env -i zypper --non-interactive --no-cd --xmlout list-updates --type package --all" )
502+ logging .debug (xml_output )
503+ docroot = ET .fromstring (xml_output )
504+ # parse all packages from xml output
505+ DUP_PKG = []
506+ for item in docroot .iter ("update" ):
507+ if item .attrib ["kind" ] == "package" :
508+ DUP_PKG .append (f"{ item .attrib ['name' ]} -{ item .attrib ['edition' ]} .{ item .attrib ['arch' ]} " )
509+ DUP_PKG .sort ()
501510 if not DUP_PKG :
502511 logging .info (color ("info" , "Nothing to do. Exiting..." ))
503512 zypperoni_cleanup ()
0 commit comments