stages: add org.osbuild.xorrisofs
Add a new stage that uses the `xorrisofs`(1) command line utility to assemble a. The iso can be made bootable by specifying a combination of the `boot` and `efi` options.
This commit is contained in:
parent
f0f4751ca4
commit
0197d6ce8a
1 changed files with 150 additions and 0 deletions
150
stages/org.osbuild.xorrisofs
Executable file
150
stages/org.osbuild.xorrisofs
Executable file
|
|
@ -0,0 +1,150 @@
|
|||
#!/usr/bin/python3
|
||||
"""
|
||||
Assemble a Rock Ridge enhanced ISO 9660 filesystem (iso)
|
||||
|
||||
Uses the `xorrisofs`(1) command line utility to assemble a
|
||||
Assemble a Rock Ridge enhanced ISO 9660 filesystem (iso).
|
||||
|
||||
The iso can be made bootable by specifying a combination of
|
||||
`boot` and `efi`. What exact options make sense depend on
|
||||
the target platform.
|
||||
|
||||
The `isolevel` options controls the limits of data size and
|
||||
filenames: if the iso should contain a file, like a rootfs
|
||||
image, that is bigger than 4GB, at least iso level 3 is
|
||||
required.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA_2 = r"""
|
||||
"options": {
|
||||
"additionalProperties": false,
|
||||
"required": ["filename", "volid"],
|
||||
"properties": {
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"description": "Filename of the iso to create"
|
||||
},
|
||||
"volid": {
|
||||
"type": "string",
|
||||
"description": "Volume id to set",
|
||||
"pattern": "[A-Z0-9_-]{1,32}"
|
||||
},
|
||||
"boot": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["image", "catalog"],
|
||||
"properties": {
|
||||
"image": {
|
||||
"type": "string",
|
||||
"description": "Path to the boot image (on the iso)"
|
||||
},
|
||||
"catalog": {
|
||||
"type": "string",
|
||||
"description": "Path to the boot catalog file (on the iso)"
|
||||
}
|
||||
}
|
||||
},
|
||||
"efi": {
|
||||
"type": "string"
|
||||
},
|
||||
"isohybridmbr": {
|
||||
"type": "string",
|
||||
"description": "Install the argument (buildroot) as ISOLINUX isohybrid MBR"
|
||||
},
|
||||
"isolevel": {
|
||||
"type": "integer",
|
||||
"description": "The ISO 9660 version (limits of data size and filenames)",
|
||||
"minimum": 1,
|
||||
"maximum": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
"inputs": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["tree"],
|
||||
"properties": {
|
||||
"tree": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(inputs, output_dir, options):
|
||||
tree = inputs["tree"]["path"]
|
||||
boot = options.get("boot", {})
|
||||
filename = options["filename"]
|
||||
vol_id = options["volid"]
|
||||
efi = options.get("efi")
|
||||
isohybrid = options.get("isohybridmbr")
|
||||
isolevel = options.get("isolevel")
|
||||
|
||||
cmd = [
|
||||
"/usr/bin/xorrisofs",
|
||||
"-verbose"
|
||||
]
|
||||
|
||||
if isolevel:
|
||||
cmd += [
|
||||
"-iso-level", str(isolevel)
|
||||
]
|
||||
|
||||
cmd += [
|
||||
"-V", vol_id,
|
||||
]
|
||||
|
||||
if isohybrid:
|
||||
cmd += [
|
||||
"-isohybrid-mbr", isohybrid,
|
||||
]
|
||||
|
||||
if boot:
|
||||
image = boot["image"]
|
||||
catalog = boot["catalog"]
|
||||
cmd += [
|
||||
"-b", image,
|
||||
"-c", catalog,
|
||||
"-boot-load-size", "4",
|
||||
"-boot-info-table",
|
||||
"-no-emul-boot"
|
||||
]
|
||||
|
||||
cmd += [
|
||||
"-rock", "-joliet"
|
||||
]
|
||||
|
||||
if efi:
|
||||
cmd += [
|
||||
"-eltorito-alt-boot",
|
||||
"-e", efi,
|
||||
"-no-emul-boot"
|
||||
]
|
||||
|
||||
if isohybrid:
|
||||
cmd += ["-isohybrid-gpt-basdat"]
|
||||
|
||||
cmd += [
|
||||
'-o', os.path.join(output_dir, filename),
|
||||
tree
|
||||
]
|
||||
|
||||
print(cmd)
|
||||
subprocess.run(cmd, check=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = osbuild.api.arguments()
|
||||
ret = main(args["inputs"],
|
||||
args["tree"],
|
||||
args["options"])
|
||||
sys.exit(ret)
|
||||
Loading…
Add table
Add a link
Reference in a new issue