fix: address basestrap module findings (callback, -Sy->-S, umask guard, operations guard)

This commit is contained in:
2026-07-07 19:26:50 +02:00
parent 9dff90ef46
commit db809e6898
@@ -302,7 +302,7 @@ class PMPacman(PackageManager):
""" """
Call pacman in a loop until it is successful or the number of retries is exceeded Call pacman in a loop until it is successful or the number of retries is exceeded
:param command: The pacman command to run :param command: The pacman command to run
:param callback: An optional boolean that indicates if this pacman run should use the callback :param callback: If True, process output using self.line_cb
:return: :return:
""" """
@@ -310,6 +310,9 @@ class PMPacman(PackageManager):
while pacman_count <= self.pacman_num_retries: while pacman_count <= self.pacman_num_retries:
pacman_count += 1 pacman_count += 1
try: try:
if callback:
host_env_process_output(command, callback=self.line_cb)
else:
host_env_process_output(command) host_env_process_output(command)
return return
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
@@ -343,7 +346,7 @@ class PMPacman(PackageManager):
if from_local: if from_local:
command.append("-U") command.append("-U")
else: else:
command.append("-Sy") command.append("-S")
command.append("--overwrite=*") command.append("--overwrite=*")
command += pkgs command += pkgs
@@ -376,6 +379,7 @@ class PMPacman(PackageManager):
def setup_requirements(self, rootdir): def setup_requirements(self, rootdir):
cal_umask = os.umask(0) cal_umask = os.umask(0)
try:
for target in self.pacman_requirements: for target in self.pacman_requirements:
dest = rootdir + target["dest"] dest = rootdir + target["dest"]
if not os.path.exists(dest): if not os.path.exists(dest):
@@ -386,6 +390,7 @@ class PMPacman(PackageManager):
path = join(rootdir, "run") path = join(rootdir, "run")
os.chmod(path, 0o755) os.chmod(path, 0o755)
finally:
os.umask(cal_umask) os.umask(cal_umask)
def copy_file(self, rootdir, f): def copy_file(self, rootdir, f):
@@ -533,7 +538,11 @@ def run():
if provider in known_inits: if provider in known_inits:
init_pkg = "-".join([base_init, provider]) init_pkg = "-".join([base_init, provider])
libcalamares.utils.debug("Init provider package added: {!s}".format(init_pkg)) libcalamares.utils.debug("Init provider package added: {!s}".format(init_pkg))
if operations and isinstance(operations[0], dict) and isinstance(operations[0].get("install"), list):
operations[0]["install"].append(init_pkg) operations[0]["install"].append(init_pkg)
else:
libcalamares.utils.warning(
"Cannot add init provider package: missing operations[0]['install'] list")
libcalamares.globalstorage.insert("initProvider", provider) libcalamares.globalstorage.insert("initProvider", provider)
libcalamares.globalstorage.insert("baseInit", base_init) libcalamares.globalstorage.insert("baseInit", base_init)
break break