[packages] Look for other progress indicators
- the (n/m) lines are output of specific steps, not actual package- installation. So look for "<action> <packagename> ..." lines instead. This means we keep some state around, and need extra machinery to report those lines rather than the generic progress reporting that reports on groups.
This commit is contained in:
parent
4821f450f3
commit
e4b44b5f85
@ -35,6 +35,10 @@ total_packages = 0 # For the entire job
|
|||||||
completed_packages = 0 # Done so far for this job
|
completed_packages = 0 # Done so far for this job
|
||||||
group_packages = 0 # One group of packages from an -install or -remove entry
|
group_packages = 0 # One group of packages from an -install or -remove entry
|
||||||
|
|
||||||
|
# A PM object may set this to a string (take care of translations!)
|
||||||
|
# to override the string produced by pretty_status_message()
|
||||||
|
custom_status_message = None
|
||||||
|
|
||||||
INSTALL = object()
|
INSTALL = object()
|
||||||
REMOVE = object()
|
REMOVE = object()
|
||||||
mode_packages = None # Changes to INSTALL or REMOVE
|
mode_packages = None # Changes to INSTALL or REMOVE
|
||||||
@ -51,6 +55,8 @@ def pretty_name():
|
|||||||
|
|
||||||
|
|
||||||
def pretty_status_message():
|
def pretty_status_message():
|
||||||
|
if custom_status_message is not None:
|
||||||
|
return custom_status_message
|
||||||
if not group_packages:
|
if not group_packages:
|
||||||
if (total_packages > 0):
|
if (total_packages > 0):
|
||||||
# Outside the context of an operation
|
# Outside the context of an operation
|
||||||
@ -374,28 +380,39 @@ class PMPacman(PackageManager):
|
|||||||
import re
|
import re
|
||||||
progress_match = re.compile("^\\((\\d+)/(\\d+)\\)")
|
progress_match = re.compile("^\\((\\d+)/(\\d+)\\)")
|
||||||
def line_cb(line):
|
def line_cb(line):
|
||||||
global completed_packages, group_packages
|
if line.startswith(":: "):
|
||||||
if line.startswith("("):
|
self.in_package_changes = "package changes" in line
|
||||||
m = progress_match.match(line)
|
else:
|
||||||
if m:
|
if self.in_package_changes and line.endswith("...\n"):
|
||||||
try:
|
# Update the message, untranslated; do not change the
|
||||||
completed_packages = int(m.groups()[0])
|
# progress percentage, since there may be more "installing..."
|
||||||
group_packages = int(m.groups()[1])
|
# lines in the output for the group, than packages listed
|
||||||
libcalamares.job.setprogress(completed_packages / group_packages)
|
# explicitly. We don't know how to calculate proper progress.
|
||||||
except ValueError as e:
|
global custom_status_message
|
||||||
pass
|
custom_status_message = line.strip()
|
||||||
|
libcalamares.job.setprogress(self.progress_fraction)
|
||||||
|
libcalamares.utils.debug(line)
|
||||||
|
|
||||||
|
self.in_package_changes = False
|
||||||
self.line_cb = line_cb
|
self.line_cb = line_cb
|
||||||
|
|
||||||
|
def reset_progress(self):
|
||||||
|
self.in_package_changes = False
|
||||||
|
# These are globals
|
||||||
|
self.progress_fraction = (completed_packages * 1.0 / total_packages)
|
||||||
|
|
||||||
def install(self, pkgs, from_local=False):
|
def install(self, pkgs, from_local=False):
|
||||||
if from_local:
|
if from_local:
|
||||||
pacman_flags = "-U"
|
pacman_flags = "-U"
|
||||||
else:
|
else:
|
||||||
pacman_flags = "-S"
|
pacman_flags = "-S"
|
||||||
|
|
||||||
|
self.reset_progress()
|
||||||
libcalamares.utils.target_env_process_output(["pacman", pacman_flags,
|
libcalamares.utils.target_env_process_output(["pacman", pacman_flags,
|
||||||
"--noconfirm"] + pkgs, self.line_cb)
|
"--noconfirm"] + pkgs, self.line_cb)
|
||||||
|
|
||||||
def remove(self, pkgs):
|
def remove(self, pkgs):
|
||||||
|
self.reset_progress()
|
||||||
libcalamares.utils.target_env_process_output(["pacman", "-Rs", "--noconfirm"] + pkgs, self.line_cb)
|
libcalamares.utils.target_env_process_output(["pacman", "-Rs", "--noconfirm"] + pkgs, self.line_cb)
|
||||||
|
|
||||||
def update_db(self):
|
def update_db(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user