Allow for optional items in unpackfs

This commit is contained in:
Simon Quigley 2024-12-11 02:24:17 -06:00
parent 714a085556
commit 560ad70aeb
3 changed files with 24 additions and 4 deletions

View File

@ -48,7 +48,7 @@ class UnpackEntry:
:param destination:
"""
__slots__ = ('source', 'sourcefs', 'destination', 'copied', 'total', 'exclude', 'excludeFile',
'mountPoint', 'weight', 'condition')
'mountPoint', 'weight', 'condition', 'optional')
def __init__(self, source, sourcefs, destination):
"""
@ -72,6 +72,7 @@ class UnpackEntry:
self.mountPoint = None
self.weight = 1
self.condition = True
self.optional = False
def is_file(self):
return self.sourcefs == "file"
@ -461,6 +462,7 @@ def run():
for entry in libcalamares.job.configuration["unpack"]:
source = os.path.abspath(entry["source"])
sourcefs = entry["sourcefs"]
optional = entry.get("optional", False)
if sourcefs not in supported_filesystems:
libcalamares.utils.warning("The filesystem for \"{}\" ({}) is not supported by your current kernel".format(source, sourcefs))
@ -468,6 +470,11 @@ def run():
return (_("Bad unpackfs configuration"),
_("The filesystem for \"{}\" ({}) is not supported by your current kernel").format(source, sourcefs))
if not os.path.exists(source):
if optional:
libcalamares.utils.warning("The source filesystem \"{}\" does not exist but is marked as optional, skipping".format(source))
entry["condition"] = False
continue
else:
libcalamares.utils.warning("The source filesystem \"{}\" does not exist".format(source))
return (_("Bad unpackfs configuration"),
_("The source filesystem \"{}\" does not exist").format(source))

View File

@ -102,6 +102,18 @@
# sourcefs: squashfs
# destination: ""
# condition: exampleGlobalStorageVariable.subkey
#
# You may also wish to include optional squashfses, which may not exist at certain times
# depending on your image tooling. If an optional squashfs is not found, it is simply
# skipped.
#
# - source: ./example.standard.sqfs
# sourcefs: squashfs
# destination: ""
# - source: ./example.extras.sqfs
# sourcefs: squashfs
# destination: ""
# optional: true
unpack:
- source: ../CHANGES

View File

@ -18,6 +18,7 @@ properties:
excludeFile: { type: string }
exclude: { type: array, items: { type: string } }
weight: { type: integer, exclusiveMinimum: 0 }
optional: { type: boolean }
condition:
anyOf:
- type: boolean