Blame stages/org.osbuild.keymap
|
Packit Service |
863627 |
#!/usr/bin/python3
|
|
Packit Service |
863627 |
"""
|
|
Packit Service |
863627 |
Set image's default keymap
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
Sets the default console keyboard layout to `keymap`, like 'us' or 'de-latin1'.
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
Removes any existing /etc/vconsole.conf, then runs `systemd-firstboot` with the
|
|
Packit Service |
863627 |
`--keymap` option, which sets KEYMAP in /etc/vconsole.conf.
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
Valid keymaps are generally found in /lib/kbd/keymaps.
|
|
Packit Service |
863627 |
"""
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
import json
|
|
Packit Service |
863627 |
import subprocess
|
|
Packit Service |
863627 |
import sys
|
|
Packit Service |
863627 |
import os
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
SCHEMA = """
|
|
Packit Service |
863627 |
"additionalProperties": false,
|
|
Packit Service |
863627 |
"required": ["keymap"],
|
|
Packit Service |
863627 |
"properties": {
|
|
Packit Service |
863627 |
"keymap": {
|
|
Packit Service |
863627 |
"type": "string",
|
|
Packit Service |
863627 |
"description": "Name of keymap to use"
|
|
Packit Service |
863627 |
}
|
|
Packit Service |
863627 |
}
|
|
Packit Service |
863627 |
"""
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
def main(tree, options):
|
|
Packit Service |
863627 |
keymap = options["keymap"]
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
# We need to remove the /etc/vconsole.conf file first, because it is created while we install RPM packages.
|
|
Packit Service |
863627 |
# systemd-firstboot expects that if /etc/vconsole.conf exists it is a user-defined value and does not change it, but
|
|
Packit Service |
863627 |
# the assumption is wrong, because it contains a default value from RPM package.
|
|
Packit Service |
863627 |
try:
|
|
Packit Service |
863627 |
os.remove(f"{tree}/etc/vconsole.conf")
|
|
Packit Service |
863627 |
print("/etc/vconsole.conf already exists. Replacing.")
|
|
Packit Service |
863627 |
except FileNotFoundError:
|
|
Packit Service |
863627 |
pass
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
subprocess.run(["systemd-firstboot", f"--root={tree}", f"--keymap={keymap}"], check=True)
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
return 0
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
|
|
Packit Service |
863627 |
if __name__ == '__main__':
|
|
Packit Service |
863627 |
args = json.load(sys.stdin)
|
|
Packit Service |
863627 |
r = main(args["tree"], args["options"])
|
|
Packit Service |
863627 |
sys.exit(r)
|