pmb.chroot.apk.install: move empty packages check (MR 2185)

Since the previous commit that adds install_build(), all packages either
end up in to_add or to_del. Move the check for empty packages to the top
of the function, and directly check the packages variable.

I think it's worth keeping this check because it's shorter to add this
check once here than having it a few times in other place where we may
have or may not have something to install. And so we can avoid printing
an empty "install" message with no packages.
This commit is contained in:
Oliver Smith 2022-05-29 10:30:20 +02:00
parent e91dbefd16
commit 12948eeb3d
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 5 additions and 2 deletions

View File

@ -154,6 +154,11 @@ def install(args, packages, suffix="native", build=True):
special case that all packages are expected to be in Alpine's
repositories, set this to False for performance optimization.
"""
if not packages:
logging.verbose("pmb.chroot.apk.install called with empty packages list,"
" ignoring")
return
# Initialize chroot
check_min_version(args, suffix)
pmb.chroot.init(args, suffix)
@ -173,8 +178,6 @@ def install(args, packages, suffix="native", build=True):
if build:
install_build(args, package, arch)
to_add.append(package)
if not len(to_add) and not len(to_del):
return
# Sanitize packages: don't allow '--allow-untrusted' and other options
# to be passed to apk!