Skip to content

Commit 5d7d6f8

Browse files
committed
Improve interactive use on package conflicts
1 parent 01ec549 commit 5d7d6f8

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

atomic-update

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ if COMMAND == "run" and not ARG:
241241
sys.exit(1)
242242

243243
DEBUG = True if "--debug" in OPT else False
244-
CONFIRM = True if "--interactive" in OPT else False
244+
INTERACTIVE = True if "--interactive" in OPT else False
245245
REBOOT = True if "--reboot" in OPT else False
246246
APPLY = True if "--apply" in OPT else False
247247
SHELL = True if "--shell" in OPT else False
@@ -406,19 +406,22 @@ chroot {TMP_MOUNT_DIR} mount -a -O no_netdev;
406406
# check if dup has anything to do
407407
logging.info("Checking for packages to upgrade...")
408408
xml_output, ret = shell_exec(f"LC_ALL=C zypper --root {TMP_MOUNT_DIR} --non-interactive --no-cd --xmlout dist-upgrade --dry-run")
409+
if ret == 0 and xml_output.find("Nothing to do") != -1:
410+
logging.info("Nothing to do. Exiting...")
411+
cleanup()
412+
sys.exit()
409413
docroot = ET.fromstring(xml_output)
410414
num_pkgs = None
411415
for item in docroot.iter('install-summary'):
412416
num_pkgs = int(item.attrib["packages-to-change"])
413-
if not num_pkgs:
414-
if xml_output.find("conflicts") != -1 or xml_output.find("nothing provides") != -1:
415-
logging.warning("There are package conflicts that must be manually resolved. See output of:\n" \
416-
"zypper --non-interactive --no-cd dist-upgrade --dry-run")
417-
logging.info("Nothing to do. Exiting...")
417+
if not num_pkgs and not INTERACTIVE:
418+
logging.warning("There are package conflicts that must be manually resolved. See output of:\n" \
419+
"zypper --non-interactive --no-cd dist-upgrade --dry-run\n" \
420+
"OR, run atomic-update using '--interactive' option.")
418421
cleanup()
419-
sys.exit()
422+
sys.exit(9)
420423
logging.info("Performing distribution upgrade within chroot...")
421-
ret = os.system(f"zypper --root {TMP_MOUNT_DIR} {'' if CONFIRM else '--non-interactive'} --no-cd dist-upgrade --auto-agree-with-licenses")
424+
ret = os.system(f"zypper --root {TMP_MOUNT_DIR} {'' if INTERACTIVE else '--non-interactive'} --no-cd dist-upgrade --auto-agree-with-licenses")
422425
if ret != 0:
423426
logging.error(f"Zypper returned exit code {ret}")
424427
if not SHELL:

0 commit comments

Comments
 (0)