Add some more stages

This commit is contained in:
Lars Karlitski 2019-06-05 17:29:08 +02:00
parent f6023ed78b
commit a04ec2c4b0
5 changed files with 81 additions and 0 deletions

18
stages/io.weldr.locale Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/python3
import json
import sys
def main(tree, language, vc_keymap=None):
with open(f"{tree}/etc/locale.conf", "w") as f:
f.write(f'LANG="{language}"\n')
if vc_keymap:
with open(f"{tree}/etc/vconsole.conf", "w") as f:
f.write(f'KEYMAP="{vc_keymap}"\n')
f.write(f'FONT="eurlatgr"\n')
if __name__ == '__main__':
options = json.load(sys.stdin)
sys.exit(main(**options))

11
stages/io.weldr.noop Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/python3
import json
import sys
def main(tree, **options):
print("Not doing anything with these options:", json.dumps(options))
if __name__ == '__main__':
options = json.load(sys.stdin)
sys.exit(main(**options))

View file

@ -0,0 +1,15 @@
#!/usr/bin/python3
import contextlib
import json
import os
import sys
def main(tree):
with contextlib.suppress(FileNotFoundError):
os.unlink(f"{tree}/etc/machine-id")
os.unlink(f"{tree}/var/lib/systemd/random-seed")
if __name__ == '__main__':
options = json.load(sys.stdin)
sys.exit(main(**options))

24
stages/io.weldr.script Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/python3
import atexit
import json
import os
import subprocess
import sys
def main(tree, 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__':
options = json.load(sys.stdin)
sys.exit(main(**options))

13
stages/io.weldr.systemd Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/python3
import json
import os
import subprocess
def main(tree, enabled_services):
for service in enabled_services:
subprocess.run([f"{tree}/usr/bin/systemctl", "--root", tree, "enable", service], check=True)
if __name__ == '__main__':
options = json.load(sys.stdin)
sys.exit(main(**options))