forked from osbuild/osbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorg.osbuild.fstab
executable file
·53 lines (40 loc) · 1.57 KB
/
org.osbuild.fstab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python3
import sys
import osbuild.api
from osbuild.util import ostree
def main(tree, options):
filesystems = options["filesystems"]
ostree_options = options.get("ostree")
path = f"{tree}/etc/fstab"
if ostree_options:
deployment = ostree_options["deployment"]
osname, ref, serial = ostree.parse_deployment_option(tree, deployment)
root = ostree.deployment_path(tree, osname, ref, serial)
print(f"ostree support active: {root}")
path = f"{root}/etc/fstab"
with open(path, "w", encoding="utf8") as f:
for filesystem in filesystems:
uuid = filesystem.get("uuid")
path = filesystem["path"]
label = filesystem.get("label")
partlabel = filesystem.get("partlabel")
device = filesystem.get("device")
vfs_type = filesystem.get("vfs_type", "none")
options = filesystem.get("options", "defaults")
freq = filesystem.get("freq", 0)
passno = filesystem.get("passno", 0)
if uuid:
fs_spec = f"UUID={uuid}"
elif label:
fs_spec = f"LABEL={label}"
elif partlabel:
fs_spec = f"PARTLABEL={partlabel}"
elif device:
fs_spec = device
else:
raise ValueError("Need 'uuid' or 'label'")
f.write(f"{fs_spec}\t{path}\t{vfs_type}\t{options}\t{freq}\t{passno}\n")
if __name__ == '__main__':
args = osbuild.api.arguments()
r = main(args["tree"], args["options"])
sys.exit(r)