Skip to content

Commit 4803be3

Browse files
committed
Standardize env vars
1 parent 6b90dc7 commit 4803be3

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

zypperoni

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ from shlex import quote
2929
import xml.etree.ElementTree as ET
3030

3131
# Constants
32-
ZYPPERONI_VERSION = "1.0.2"
32+
ZYPPERONI_VERSION = "1.0.3"
3333
ZYPPER_PID_FILE = "/run/zypp.pid"
34+
ZYPPER_ENV = "ZYPP_CURL2=1 ZYPP_PCK_PRELOAD=1 ZYPP_SINGLE_RPMTRANS=1"
3435

3536
################################
3637

@@ -262,15 +263,15 @@ async def main_task(num_jobs, task_type, task_items, no_confirm=None):
262263
msg = "Zypperoni has finished its tasks. Handing you over to zypper..."
263264
if task_type == "dup":
264265
logging.info(color("info", msg))
265-
command = f"env ZYPP_SINGLE_RPMTRANS=1 zypper {'--non-interactive' if no_confirm else ''} --no-cd dist-upgrade"
266+
command = f"env {ZYPPER_ENV} zypper {'--non-interactive' if no_confirm else ''} --no-cd dist-upgrade"
266267
os.system(command)
267268
elif task_type == "in":
268269
logging.info(color("info", msg))
269-
command = f"env ZYPP_SINGLE_RPMTRANS=1 zypper {'--non-interactive' if no_confirm else ''} --no-cd install {' '.join(install_pkgs)}"
270+
command = f"env {ZYPPER_ENV} zypper {'--non-interactive' if no_confirm else ''} --no-cd install {' '.join(install_pkgs)}"
270271
os.system(command)
271272
elif task_type == "inr":
272273
logging.info(color("info", msg))
273-
command = f"env ZYPP_SINGLE_RPMTRANS=1 zypper {'--non-interactive' if no_confirm else ''} --no-cd install-new-recommends"
274+
command = f"env {ZYPPER_ENV} zypper {'--non-interactive' if no_confirm else ''} --no-cd install-new-recommends"
274275
os.system(command)
275276

276277
################################
@@ -396,7 +397,7 @@ mount -o bind,ro /var/lib/ca-certificates {ZYPPERONI_TMP_DIR}/{{uuid}}/rootfs/va
396397

397398
# Shell commands to perform zypper refresh / force-refresh
398399
refresh_shell_commands = f"""
399-
chroot {ZYPPERONI_TMP_DIR}/{{uuid}}/rootfs env -i ZYPP_CURL2=1 zypper --non-interactive {{refresh_type}} {{repo_alias}};
400+
chroot {ZYPPERONI_TMP_DIR}/{{uuid}}/rootfs env -i {ZYPPER_ENV} zypper --non-interactive {{refresh_type}} {{repo_alias}};
400401
"""
401402

402403
# Shell commands to prepare temp mounts for zypper download
@@ -420,7 +421,7 @@ mount -o bind,ro /var/lib/ca-certificates {ZYPPERONI_TMP_DIR}/{{uuid}}/rootfs/va
420421

421422
# Shell commands to perform zypper download
422423
download_shell_commands = f"""
423-
chroot {ZYPPERONI_TMP_DIR}/{{uuid}}/rootfs env -i zypper --non-interactive download {{pkg_name}};
424+
chroot {ZYPPERONI_TMP_DIR}/{{uuid}}/rootfs env -i {ZYPPER_ENV} zypper --non-interactive download {{pkg_name}};
424425
"""
425426

426427
# Dirs to unmount (one per line)
@@ -439,7 +440,7 @@ if args.command_name in ["refresh", "ref"]:
439440
# get all enabled repos
440441
logging.info(color("info", "Getting all enabled repos"))
441442
REPO_ALIAS = []
442-
xml_output, ret = shell_exec("env -i zypper --non-interactive --no-cd --xmlout repos")
443+
xml_output, ret = shell_exec(f"env -i {ZYPPER_ENV} zypper --non-interactive --no-cd --xmlout repos")
443444
logging.debug(xml_output)
444445
get_zypp_lock()
445446
docroot = ET.fromstring(xml_output)
@@ -462,7 +463,7 @@ if args.command_name in ["refresh", "ref"]:
462463
elif args.command_name in ["dist-upgrade", "dup"]:
463464
# get info about dup packages
464465
logging.info(color("info", "Getting all packages to be downloaded for distribution upgrade"))
465-
xml_output, ret = shell_exec("env -i zypper --non-interactive --no-cd --xmlout dist-upgrade --dry-run")
466+
xml_output, ret = shell_exec(f"env -i {ZYPPER_ENV} zypper --non-interactive --no-cd --xmlout dist-upgrade --dry-run")
466467
logging.debug(xml_output)
467468
if ret == 0 and xml_output.find("Nothing to do") != -1:
468469
logging.info(color("info", "Nothing to do. Exiting..."))
@@ -498,7 +499,7 @@ elif args.command_name in ["dist-upgrade", "dup"]:
498499
logging.warning(color("warning", msg))
499500
# get info about dup packages from 'zypper lu'
500501
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+
xml_output, ret = shell_exec(f"env -i {ZYPPER_ENV} zypper --non-interactive --no-cd --xmlout list-updates --type package --all")
502503
logging.debug(xml_output)
503504
docroot = ET.fromstring(xml_output)
504505
# parse all packages from xml output
@@ -520,7 +521,7 @@ elif args.command_name in ["dist-upgrade", "dup"]:
520521
if not args.download_only and download_size_bytes == 0:
521522
zypperoni_cleanup()
522523
logging.info(color("info", "Zypperoni has finished its tasks. Handing you over to zypper..."))
523-
command = f"env ZYPP_SINGLE_RPMTRANS=1 zypper {'--non-interactive' if args.no_confirm else ''} --no-cd dist-upgrade"
524+
command = f"env {ZYPPER_ENV} zypper {'--non-interactive' if args.no_confirm else ''} --no-cd dist-upgrade"
524525
os.system(command)
525526
sys.exit()
526527
logging.info(color("info", f"Packages to download: {' '.join(DUP_PKG)}"))
@@ -538,7 +539,7 @@ elif args.command_name in ["dist-upgrade", "dup"]:
538539
elif args.command_name in ["install", "in"]:
539540
# get info about install packages
540541
logging.info(color("info", "Getting packages and their dependencies to be downloaded for installation"))
541-
xml_output, ret = shell_exec(f"env -i zypper --non-interactive --no-cd --xmlout install --dry-run {' '.join(args.package)}")
542+
xml_output, ret = shell_exec(f"env -i {ZYPPER_ENV} zypper --non-interactive --no-cd --xmlout install --dry-run {' '.join(args.package)}")
542543
logging.debug(xml_output)
543544
if ret == 0 and xml_output.find("Nothing to do") != -1:
544545
logging.info(color("info", "Nothing to do. Exiting..."))
@@ -596,7 +597,7 @@ elif args.command_name in ["install", "in"]:
596597
if not args.download_only and download_size_bytes == 0:
597598
zypperoni_cleanup()
598599
logging.info(color("info", "Zypperoni has finished its tasks. Handing you over to zypper..."))
599-
command = f"env ZYPP_SINGLE_RPMTRANS=1 zypper {'--non-interactive' if args.no_confirm else ''} --no-cd install {' '.join(args.package)}"
600+
command = f"env {ZYPPER_ENV} zypper {'--non-interactive' if args.no_confirm else ''} --no-cd install {' '.join(args.package)}"
600601
os.system(command)
601602
sys.exit()
602603
logging.info(color("info", f"Packages to download: {' '.join(IN_PKG)}"))
@@ -614,7 +615,7 @@ elif args.command_name in ["install", "in"]:
614615
elif args.command_name in ["install-new-recommends", "inr"]:
615616
# get info about recommended install packages
616617
logging.info(color("info", "Getting new packages and their dependencies to be downloaded for recommended installation"))
617-
xml_output, ret = shell_exec(f"env -i zypper --non-interactive --no-cd --xmlout install-new-recommends --dry-run")
618+
xml_output, ret = shell_exec(f"env -i {ZYPPER_ENV} zypper --non-interactive --no-cd --xmlout install-new-recommends --dry-run")
618619
logging.debug(xml_output)
619620
if ret == 0 and xml_output.find("Nothing to do") != -1:
620621
logging.info(color("info", "Nothing to do. Exiting..."))
@@ -663,7 +664,7 @@ elif args.command_name in ["install-new-recommends", "inr"]:
663664
if not args.download_only and download_size_bytes == 0:
664665
zypperoni_cleanup()
665666
logging.info(color("info", "Zypperoni has finished its tasks. Handing you over to zypper..."))
666-
command = f"env ZYPP_SINGLE_RPMTRANS=1 zypper {'--non-interactive' if args.no_confirm else ''} --no-cd install-new-recommends"
667+
command = f"env {ZYPPER_ENV} zypper {'--non-interactive' if args.no_confirm else ''} --no-cd install-new-recommends"
667668
os.system(command)
668669
sys.exit()
669670
logging.info(color("info", f"Packages to download: {' '.join(INR_PKG)}"))

0 commit comments

Comments
 (0)