diff --git a/osbuild/formats/v2.py b/osbuild/formats/v2.py index 4b5190e7..94da3a7f 100644 --- a/osbuild/formats/v2.py +++ b/osbuild/formats/v2.py @@ -274,14 +274,16 @@ def load_mount(description: Dict, index: Index, stage: Stage): if name in stage.mounts: raise ValueError(f"Duplicated mount '{name}'") - source = description["source"] - target = description["target"] + source = description.get("source") + target = description.get("target") options = description.get("options", {}) - device = stage.devices.get(source) - if not device: - raise ValueError(f"Unknown device '{source}' for mount '{name}'") + device = None + if source: + device = stage.devices.get(source) + if not device: + raise ValueError(f"Unknown device '{source}' for mount '{name}'") stage.add_mount(name, info, device, target, options) diff --git a/osbuild/mounts.py b/osbuild/mounts.py index 346a7a35..519fc743 100644 --- a/osbuild/mounts.py +++ b/osbuild/mounts.py @@ -35,8 +35,10 @@ class Mount: def calc_id(self): m = hashlib.sha256() m.update(json.dumps(self.info.name, sort_keys=True).encode()) - m.update(json.dumps(self.device.id, sort_keys=True).encode()) - m.update(json.dumps(self.target, sort_keys=True).encode()) + if self.device: + m.update(json.dumps(self.device.id, sort_keys=True).encode()) + if self.target: + m.update(json.dumps(self.target, sort_keys=True).encode()) m.update(json.dumps(self.options, sort_keys=True).encode()) return m.hexdigest() diff --git a/schemas/osbuild2.json b/schemas/osbuild2.json index 4d66c1bc..f08996c0 100644 --- a/schemas/osbuild2.json +++ b/schemas/osbuild2.json @@ -71,7 +71,7 @@ "mount": { "title": "Mount point for a stage", "additionalProperties": false, - "required": ["name", "type", "source", "target"], + "required": ["name", "type"], "properties": { "name": { "type": "string" }, "type": { "type": "string" },