Implement questionable installation progress bar fix

This commit is contained in:
Michael Smith 2024-09-12 17:59:55 +02:00
parent 59ae214919
commit a6fb184590

View File

@ -178,7 +178,7 @@ configuration_tail = """
""" """
def pretty_name(): def pretty_name():
return _("Installing deskOS") return _("Installing deskOS (this can take a while depending on your Internet speed)...")
status = pretty_name() status = pretty_name()
@ -206,7 +206,6 @@ def run():
global status global status
status = _("Configuring deskOS") status = _("Configuring deskOS")
libcalamares.job.setprogress(0.1)
# Create initial config file # Create initial config file
cfg = configuration_head cfg = configuration_head
@ -230,7 +229,6 @@ def run():
part["luksMapperName"], part["uuid"]) part["luksMapperName"], part["uuid"])
status = _("Configuring deskOS") status = _("Configuring deskOS")
libcalamares.job.setprogress(0.18)
cfg += cfghostname cfg += cfghostname
@ -341,7 +339,6 @@ def run():
cfg = cfg.replace(pattern, str(variables[key])) cfg = cfg.replace(pattern, str(variables[key]))
status = _("Generating deskOS configuration") status = _("Generating deskOS configuration")
libcalamares.job.setprogress(0.25)
try: try:
# Generate hardware.nix with mounted swap device # Generate hardware.nix with mounted swap device
@ -360,17 +357,25 @@ def run():
libcalamares.utils.host_env_process_output( libcalamares.utils.host_env_process_output(
["cp", "/dev/stdin", flakeFile], None, flake) ["cp", "/dev/stdin", flakeFile], None, flake)
status = _("Installing deskOS") status = _("Installing deskOS (this can take a while depending on your Internet speed)...")
libcalamares.job.setprogress(0.3)
# Install # Install
try: try:
output = "" output = ""
proc = subprocess.Popen(["pkexec", "nixos-install", "--no-root-passwd", "--flake", f"{flakePath}#{random_hostname}", "--root", root_mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) proc = subprocess.Popen(["pkexec", "nixos-install", "--no-root-passwd", "--flake", f"{flakePath}#{random_hostname}", "--root", root_mount_point], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
ESTIMATED_TOTAL_LINE_COUNT = 3500
line_count = 1
while True: while True:
line = proc.stdout.readline().decode("utf-8") line = proc.stdout.readline().decode("utf-8")
output += line output += line
line_count += 1
libcalamares.utils.debug("nixos-install: {}".format(line.strip())) libcalamares.utils.debug("nixos-install: {}".format(line.strip()))
# NOTE(m): This is a bit of a fabrication but at least it shows the
# user *some* form of progress rather than having the progress bar sit at
# some 40-odd percentage for the entirety of this job.
progress = line_count / ESTIMATED_TOTAL_LINE_COUNT
if progress < 1.0:
libcalamares.job.setprogress(progress)
if not line: if not line:
break break
exit = proc.wait() exit = proc.wait()