[unpackfs] Give entries a weight
When there are multiple entries, the overall weight of the module is divided between the entries: currently each entry takes an equal amount of space in the overall progress. When there are multiple entries which take wildly different amounts of time (e.g. a squash-fs and a single file) then the progress overall looks weird: the squash-fs gets half of this module's weight, and the single file does too. With the new *weight* key for entries, that division can be tweaked so that progress looks more "even".
This commit is contained in:
parent
44f8a7ae47
commit
632445a431
@ -48,8 +48,8 @@ class UnpackEntry:
|
||||
:param sourcefs:
|
||||
:param destination:
|
||||
"""
|
||||
__slots__ = ['source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
|
||||
'mountPoint']
|
||||
__slots__ = ('source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
|
||||
'mountPoint', 'weight', 'accumulated_weight')
|
||||
|
||||
def __init__(self, source, sourcefs, destination):
|
||||
"""
|
||||
@ -71,6 +71,8 @@ class UnpackEntry:
|
||||
self.copied = 0
|
||||
self.total = 0
|
||||
self.mountPoint = None
|
||||
self.weight = 1
|
||||
self.accumulated_weight = 0 # That's weight **before** this entry
|
||||
|
||||
def is_file(self):
|
||||
return self.sourcefs == "file"
|
||||
@ -395,6 +397,24 @@ def repair_root_permissions(root_mount_point):
|
||||
# But ignore it
|
||||
|
||||
|
||||
def extract_weight(entry):
|
||||
"""
|
||||
Given @p entry, a dict representing a single entry in
|
||||
the *unpack* list, returns its weight (1, or whatever is
|
||||
set if it is sensible).
|
||||
"""
|
||||
w = entry.get("weight", None)
|
||||
if w:
|
||||
try:
|
||||
wi = int(w)
|
||||
return wi if wi > 0 else 1
|
||||
except ValueError:
|
||||
utils.warning("*weight* setting {!r} is not valid.".format(w))
|
||||
except TypeError:
|
||||
utils.warning("*weight* setting {!r} must be number.".format(w))
|
||||
return 1
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
Unsquash filesystem.
|
||||
@ -461,6 +481,8 @@ def run():
|
||||
unpack[-1].exclude = entry["exclude"]
|
||||
if entry.get("excludeFile", None):
|
||||
unpack[-1].excludeFile = entry["excludeFile"]
|
||||
unpack[-1].weight = extract_weight(entry)
|
||||
unpack[-1].accumulated_weight = sum([e.weight for e in unpack[:-1]])
|
||||
|
||||
is_first = False
|
||||
|
||||
|
@ -32,6 +32,12 @@
|
||||
# - *excludeFile* is a single file that is passed to rsync as an
|
||||
# --exclude-file argument. This should be a full pathname
|
||||
# inside the **host** filesystem.
|
||||
# - *weight* is useful when the entries take wildly different
|
||||
# times to unpack (e.g. with a squashfs, and one single file)
|
||||
# and the total weight of this module should be distributed
|
||||
# differently between the entries. (This is only relevant when
|
||||
# there is more than one entry; by default all the entries
|
||||
# have the same weight, 1)
|
||||
#
|
||||
# EXAMPLES
|
||||
#
|
||||
@ -85,8 +91,10 @@ unpack:
|
||||
- source: ../CHANGES
|
||||
sourcefs: file
|
||||
destination: "/tmp/changes.txt"
|
||||
weight: 1 # Single file
|
||||
- source: src/qml/calamares/slideshow
|
||||
sourcefs: file
|
||||
destination: "/tmp/slideshow/"
|
||||
exclude: [ "*.qmlc", "qmldir" ]
|
||||
weight: 5 # Lots of files
|
||||
# excludeFile: /etc/calamares/modules/unpackfs/exclude-list.txt
|
||||
|
Loading…
Reference in New Issue
Block a user