stages: use api.arguments
Instead of reading the arguments from sys.stdin, which requires that stdin is setup properly for that in the runner, use the new api.arguments() method to directly fetch the arguments. Also fix missing newlines between imports and methods to be more PEP-8 complaint, where needed.
This commit is contained in:
parent
fc6e6285ca
commit
d6eb78df58
25 changed files with 97 additions and 48 deletions
|
|
@ -8,10 +8,13 @@ Modifies /etc/chrony.conf, removing all "server" or "pool" lines and adding
|
|||
a "server" line for each server listed in `timeservers`.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["timeservers"],
|
||||
|
|
@ -49,6 +52,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ Supported sources are currently:
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
import osbuild.api
|
||||
import osbuild.sources
|
||||
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ def main(tree, srcdir, options, workdir):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
stage_args = json.load(sys.stdin)
|
||||
stage_args = osbuild.api.arguments()
|
||||
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as _workdir:
|
||||
r = main(stage_args["tree"],
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ Also symlinks the service file into /etc/systemd/system/sysinit.target.wants/.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["tty"],
|
||||
|
|
@ -64,6 +66,6 @@ UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETAR
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ wasting time.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
@ -29,6 +31,6 @@ def main(_tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args.get("options", {}))
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ are different arches or OSes.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
@ -61,6 +63,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
# Takes a list of <port|application protocol>:<transport protocol> pairs
|
||||
ports = options.get("ports", [])
|
||||
|
|
@ -82,6 +85,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -16,10 +16,12 @@ any further first-boot commands.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["commands"],
|
||||
|
|
@ -39,6 +41,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def add_first_boot(tree, commands, wait_for_network):
|
||||
if wait_for_network:
|
||||
network = """Wants=network-online.target
|
||||
|
|
@ -68,6 +71,7 @@ Type=oneshot
|
|||
os.makedirs(f"{tree}/etc", exist_ok=True)
|
||||
open(f"{tree}/etc/osbuild-first-boot", 'a').close()
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
commands = options["commands"]
|
||||
wait_for_network = options.get("wait_for_network", False)
|
||||
|
|
@ -80,6 +84,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -19,10 +19,12 @@ This stage reads and (re)writes all .conf files in /boot/loader/entries.
|
|||
|
||||
|
||||
import glob
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
@ -58,6 +60,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,11 @@ This stage replaces /etc/fstab, removing any existing entries.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["filesystems"],
|
||||
|
|
@ -67,6 +69,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
filesystems = options["filesystems"]
|
||||
|
||||
|
|
@ -91,6 +94,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -10,10 +10,13 @@ If no `gid` is given, `groupadd` will choose one.
|
|||
If the specified group name or GID is already in use, this stage will fail.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
@ -36,6 +39,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def groupadd(root, name, gid=None):
|
||||
arguments = []
|
||||
if gid:
|
||||
|
|
@ -56,6 +60,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -46,12 +46,14 @@ information on that file.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import string
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"oneOf": [{
|
||||
|
|
@ -419,6 +421,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ hostname and writes it to /etc/hostname.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["hostname"],
|
||||
|
|
@ -26,6 +28,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
hostname = options["hostname"]
|
||||
try:
|
||||
|
|
@ -40,6 +43,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ configuration, in case that ignition is run.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
STAGE_OPTS = """
|
||||
"properties": {
|
||||
|
|
@ -52,6 +53,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args.get("options", {}))
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -8,10 +8,13 @@ command line.
|
|||
https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
@ -56,6 +59,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ Valid keymaps are generally found in /lib/kbd/keymaps.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["keymap"],
|
||||
|
|
@ -45,6 +47,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ target system with `LANG={language}`.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["language"],
|
||||
|
|
@ -43,6 +45,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ leaves the tree untouched. Useful for testing, debugging, and wasting time.
|
|||
import json
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": true
|
||||
|
|
@ -21,6 +23,6 @@ def main(_tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args.get("options", {}))
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ the sysroot and the deployments. Additional kernel options can be passed via
|
|||
|
||||
|
||||
import contextlib
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
import osbuild.api
|
||||
import osbuild.sources
|
||||
from osbuild.util import selinux
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ def main(tree, sources, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
stage_args = json.load(sys.stdin)
|
||||
stage_args = osbuild.api.arguments()
|
||||
r = main(stage_args["tree"],
|
||||
stage_args["sources"],
|
||||
stage_args["options"])
|
||||
|
|
|
|||
|
|
@ -189,6 +189,6 @@ def main(tree, sources, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = api.arguments()
|
||||
r = main(args["tree"], args["sources"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ human users need to be part of.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
from osbuild.util import ostree
|
||||
|
||||
|
||||
|
|
@ -80,6 +80,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ may not match the tree's policy.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
|
|
@ -57,6 +58,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ Uses `systemctl` from the buildhost.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
|
|
@ -66,6 +67,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ Creates `/etc/systemd/system/osbuild-test.service`, and a symlink to it in
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["script"],
|
||||
|
|
@ -25,6 +27,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
script = options["script"]
|
||||
|
||||
|
|
@ -49,6 +52,6 @@ ExecStopPost=/usr/bin/systemctl poweroff
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ the `--timezone` option, which will re-create `/etc/localtime`.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"required": ["zone"],
|
||||
|
|
@ -26,6 +28,7 @@ SCHEMA = """
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
def main(tree, options):
|
||||
zone = options["zone"]
|
||||
|
||||
|
|
@ -46,6 +49,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ assumptions about its host system.
|
|||
"""
|
||||
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
|
|
@ -164,6 +166,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@ Configures `zipl` with a minimal config so it can be used in
|
|||
the assembler to write the bootmap and bootloader code.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
SCHEMA = """
|
||||
"additionalProperties": false,
|
||||
|
|
@ -40,6 +41,6 @@ def main(tree, options):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = json.load(sys.stdin)
|
||||
args = osbuild.api.arguments()
|
||||
r = main(args["tree"], args["options"])
|
||||
sys.exit(r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue