Merge pull request #2410 from lubuntu-team/tsimonq2/2409

Allow for optional items in unpackfs (Fixes: #2409)
This commit is contained in:
Adriaan de Groot 2024-12-21 10:45:36 +01:00 committed by GitHub
commit 59985eaf4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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