forked from osbuild/osbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorg.osbuild.dmverity
executable file
·31 lines (23 loc) · 990 Bytes
/
org.osbuild.dmverity
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
#!/usr/bin/python3
import os
import subprocess
import sys
import osbuild.api
def main(tree, paths, devices, options):
data_device = os.path.join(paths["devices"], devices["data_device"]["path"])
hash_device = os.path.join(paths["devices"], devices["hash_device"]["path"])
blocksize = options.get("blocksize", 512)
root_hash_file = os.path.join(tree, options["root_hash_file"])
subprocess.run(["/usr/sbin/veritysetup",
"format", data_device, hash_device,
"--data-block-size", f"{blocksize}",
"--root-hash-file", root_hash_file],
check=True)
subprocess.run(["/usr/sbin/veritysetup",
"verify", data_device, hash_device,
"--root-hash-file", root_hash_file],
check=True)
if __name__ == '__main__':
args = osbuild.api.arguments()
r = main(args["tree"], args["paths"], args["devices"], args["options"])
sys.exit(r)