pmb.chroot.apk.install: rename to{add,del} vars (MR 2185)

Put underscores between the words for consistency with other variable
names. Since the whole function is about dealing with packages, remove
the "packages_" prefix to make them shorter.

	packages_toadd -> to_add
	packages_todel -> to_del
This commit is contained in:
Oliver Smith 2022-05-28 12:08:40 +02:00
parent 6b520d2d26
commit c898b13296
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 11 additions and 11 deletions

View File

@ -208,22 +208,22 @@ def install(args, packages, suffix="native", build=True):
# Filter outdated packages (build them if required) # Filter outdated packages (build them if required)
packages_installed = installed(args, suffix) packages_installed = installed(args, suffix)
packages_toadd = [] to_add = []
packages_todel = [] to_del = []
for package in packages_with_depends: for package in packages_with_depends:
if not install_is_necessary( if not install_is_necessary(
args, build, arch, package, packages_installed): args, build, arch, package, packages_installed):
continue continue
if package.startswith("!"): if package.startswith("!"):
packages_todel.append(package.lstrip("!")) to_del.append(package.lstrip("!"))
else: else:
packages_toadd.append(package) to_add.append(package)
if not len(packages_toadd) and not len(packages_todel): if not len(to_add) and not len(to_del):
return return
# Sanitize packages: don't allow '--allow-untrusted' and other options # Sanitize packages: don't allow '--allow-untrusted' and other options
# to be passed to apk! # to be passed to apk!
for package in packages_toadd + packages_todel: for package in to_add + to_del:
if package.startswith("-"): if package.startswith("-"):
raise ValueError(f"Invalid package name: {package}") raise ValueError(f"Invalid package name: {package}")
@ -236,7 +236,7 @@ def install(args, packages, suffix="native", build=True):
# Local packages: Using the path instead of pkgname makes apk update # Local packages: Using the path instead of pkgname makes apk update
# packages of the same version if the build date is different # packages of the same version if the build date is different
packages_toadd = replace_aports_packages_with_path(args, packages_toadd, to_add = replace_aports_packages_with_path(args, to_add,
suffix, arch) suffix, arch)
# Split off conflicts # Split off conflicts
@ -246,13 +246,13 @@ def install(args, packages, suffix="native", build=True):
# Use a virtual package to mark only the explicitly requested packages as # Use a virtual package to mark only the explicitly requested packages as
# explicitly installed, not their dependencies or specific paths (#1212) # explicitly installed, not their dependencies or specific paths (#1212)
commands = [["add"] + packages_without_conflicts] commands = [["add"] + packages_without_conflicts]
if len(packages_toadd) and packages_without_conflicts != packages_toadd: if len(to_add) and packages_without_conflicts != to_add:
commands = [["add", "-u", "--virtual", ".pmbootstrap"] + commands = [["add", "-u", "--virtual", ".pmbootstrap"] +
packages_toadd, to_add,
["add"] + packages_without_conflicts, ["add"] + packages_without_conflicts,
["del", ".pmbootstrap"]] ["del", ".pmbootstrap"]]
if len(packages_todel): if len(to_del):
commands.append(["del"] + packages_todel) commands.append(["del"] + to_del)
for (i, command) in enumerate(commands): for (i, command) in enumerate(commands):
if args.offline: if args.offline:
command = ["--no-network"] + command command = ["--no-network"] + command