Last active
February 26, 2023 09:08
-
-
Save mentha/a3960b4138c76611feb59551f20ba092 to your computer and use it in GitHub Desktop.
create iso image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from argparse import ArgumentParser | |
import os | |
import subprocess as sp | |
a = ArgumentParser(description='Generate ISO image') | |
a.add_argument('dir', help='image root') | |
a.add_argument('--output', '-o', default='-', help='xorriso output, stdout by default') | |
a.add_argument('--volid', '-v', help='iso volume id, directory name by default') | |
a = a.parse_args() | |
if a.volid is None: | |
d = a.dir.rstrip('/') | |
a.volid = os.path.basename(d) | |
if a.volid in {'.', '..'}: | |
a.volid = os.path.basename(os.path.abspath(d)) | |
a.volid = a.volid.upper().replace('-', '_') | |
sp.run(['xorriso', | |
'-outdev', a.output, | |
'-joliet', 'on', | |
'-compliance', 'joliet_long_names', | |
'-acl', 'off', | |
'-xattr', 'off', | |
'-md5', 'on', | |
'-uid', '0', | |
'-gid', '0', | |
'-volid', a.volid, | |
'-map', a.dir, '/'], stdin=sp.DEVNULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment