27 lines
528 B
Python
Executable file
27 lines
528 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import atexit
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main(tree, options):
|
|
script = options["script"]
|
|
|
|
scriptfile = f"{tree}/osbuild-script"
|
|
|
|
with open(scriptfile, "w") as f:
|
|
f.write(script)
|
|
|
|
os.chmod(scriptfile, 0o550)
|
|
atexit.register(lambda: os.unlink(scriptfile))
|
|
|
|
return subprocess.run(["chroot", tree, "/osbuild-script"]).returncode
|
|
|
|
|
|
if __name__ == '__main__':
|
|
args = json.load(sys.stdin)
|
|
r = main(args["tree"], args["options"])
|
|
sys.exit(r)
|