stages: add org.osbuild.groups stage

lorax-composer supports adding groups, therefore we need it as well.
This commit is contained in:
Ondřej Budai 2019-10-17 12:46:32 +02:00 committed by Tom Gundersen
parent d0a3f99342
commit 21d91fd6df
4 changed files with 157 additions and 0 deletions

29
stages/org.osbuild.groups Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/python3
import json
import subprocess
import sys
def groupadd(root, name, gid=None):
arguments = []
if gid:
arguments += ["--gid", str(gid)]
subprocess.run(["groupadd", "--root", root, *arguments, name], check=True)
def main(tree, options):
groups = options["groups"]
for name, group_options in groups.items():
gid = group_options.get("gid")
groupadd(tree, name, gid)
return 0
if __name__ == '__main__':
args = json.load(sys.stdin)
r = main(args["tree"], args["options"])
sys.exit(r)