Add include keyword for unpackfs
This commit is contained in:
parent
4cd1f0f402
commit
80841b1a29
@ -48,7 +48,7 @@ class UnpackEntry:
|
|||||||
:param destination:
|
:param destination:
|
||||||
"""
|
"""
|
||||||
__slots__ = ('source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
|
__slots__ = ('source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
|
||||||
'mountPoint', 'weight')
|
'mountPoint', 'weight', 'include')
|
||||||
|
|
||||||
def __init__(self, source, sourcefs, destination):
|
def __init__(self, source, sourcefs, destination):
|
||||||
"""
|
"""
|
||||||
@ -71,6 +71,7 @@ class UnpackEntry:
|
|||||||
self.total = 0
|
self.total = 0
|
||||||
self.mountPoint = None
|
self.mountPoint = None
|
||||||
self.weight = 1
|
self.weight = 1
|
||||||
|
self.include = True
|
||||||
|
|
||||||
def is_file(self):
|
def is_file(self):
|
||||||
return self.sourcefs == "file"
|
return self.sourcefs == "file"
|
||||||
@ -419,6 +420,18 @@ def extract_weight(entry):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def fetch_from_globalstorage(keys_list):
|
||||||
|
value = libcalamares.globalstorage.value(keys_list[0])
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
|
for key in keys_list[1:]:
|
||||||
|
if isinstance(value, dict) and key in value:
|
||||||
|
value = value[key]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""
|
"""
|
||||||
Unsquash filesystem.
|
Unsquash filesystem.
|
||||||
@ -474,6 +487,28 @@ def run():
|
|||||||
sourcefs = entry["sourcefs"]
|
sourcefs = entry["sourcefs"]
|
||||||
destination = os.path.abspath(root_mount_point + entry["destination"])
|
destination = os.path.abspath(root_mount_point + entry["destination"])
|
||||||
|
|
||||||
|
include = entry.get("include", True)
|
||||||
|
if isinstance(include, bool):
|
||||||
|
pass # 'include' is already True or False
|
||||||
|
elif isinstance(include, str):
|
||||||
|
keys = include.split(".")
|
||||||
|
gs_value = fetch_from_globalstorage(keys)
|
||||||
|
if gs_value is None:
|
||||||
|
libcalamares.utils.warning("Include key '{}' not found in global storage, assuming False".format(include))
|
||||||
|
include = False
|
||||||
|
elif isinstance(gs_value, bool):
|
||||||
|
include = gs_value
|
||||||
|
else:
|
||||||
|
libcalamares.utils.warning("Include key '{}' is not a boolean, assuming True".format(include))
|
||||||
|
include = True
|
||||||
|
else:
|
||||||
|
libcalamares.utils.warning("Invalid 'include' value '{}', assuming True".format(include))
|
||||||
|
include = True
|
||||||
|
|
||||||
|
if not include:
|
||||||
|
libcalamares.utils.debug("Skipping unpack of {} due to 'include' being False".format(source))
|
||||||
|
continue
|
||||||
|
|
||||||
if not os.path.isdir(destination) and sourcefs != "file":
|
if not os.path.isdir(destination) and sourcefs != "file":
|
||||||
libcalamares.utils.warning(("The destination \"{}\" in the target system is not a directory").format(destination))
|
libcalamares.utils.warning(("The destination \"{}\" in the target system is not a directory").format(destination))
|
||||||
if is_first:
|
if is_first:
|
||||||
|
@ -86,6 +86,19 @@
|
|||||||
# of trailing slashes apply. In order to *rename* a file as it is
|
# of trailing slashes apply. In order to *rename* a file as it is
|
||||||
# copied, specify one single file (e.g. CHANGES) and a full pathname
|
# copied, specify one single file (e.g. CHANGES) and a full pathname
|
||||||
# for its destination name, as in the example below.
|
# for its destination name, as in the example below.
|
||||||
|
#
|
||||||
|
# It is also possible to dynamically include a source by passing a boolean
|
||||||
|
# This is used in e.g. stacked squashfses, where the user can select a specific
|
||||||
|
# install type. The default is true.
|
||||||
|
#
|
||||||
|
# - source: ./example.minimal.sqfs
|
||||||
|
# sourcefs: squashfs
|
||||||
|
# destination: ""
|
||||||
|
# include: false
|
||||||
|
# - source: ./example.standard.sqfs
|
||||||
|
# sourcefs: squashfs
|
||||||
|
# destination: ""
|
||||||
|
# include: exampleGlobalStorageVariable
|
||||||
|
|
||||||
unpack:
|
unpack:
|
||||||
- source: ../CHANGES
|
- source: ../CHANGES
|
||||||
|
@ -18,4 +18,8 @@ properties:
|
|||||||
excludeFile: { type: string }
|
excludeFile: { type: string }
|
||||||
exclude: { type: array, items: { type: string } }
|
exclude: { type: array, items: { type: string } }
|
||||||
weight: { type: integer, exclusiveMinimum: 0 }
|
weight: { type: integer, exclusiveMinimum: 0 }
|
||||||
|
include:
|
||||||
|
anyOf:
|
||||||
|
- type: boolean
|
||||||
|
- type: string
|
||||||
required: [ source , sourcefs, destination ]
|
required: [ source , sourcefs, destination ]
|
||||||
|
Loading…
Reference in New Issue
Block a user