Add setting for device keymap for devices with keymaps (#379)

* Added rx51_us keymap to nokia n900
* Added keymap option to init
* Made install command run setup-keymap when neccesary
* Validate keymap on install
This commit is contained in:
Martijn Braam 2017-08-19 23:40:20 +02:00 committed by Oliver Smith
parent c1a1f35239
commit c536e4ea58
6 changed files with 180 additions and 6 deletions

View file

@ -56,6 +56,7 @@ defaults = {
"work": os.path.expanduser("~") + "/.local/var/pmbootstrap",
"port_distccd": "33632",
"ui": "weston",
"keymap": "",
# aes-xts-plain64 would be better, but this is not supported on LineageOS
# kernel configs
@ -191,6 +192,9 @@ deviceinfo_attributes = [
# weston
"weston_pixman_type",
# keymaps
"keymaps",
]
#

View file

@ -25,6 +25,7 @@ import pmb.helpers.cli
import pmb.helpers.devices
import pmb.helpers.ui
import pmb.chroot.zap
import pmb.parse.deviceinfo
def ask_for_work_path(args):
@ -60,6 +61,24 @@ def ask_for_ui(args):
" one from the list above.")
def ask_for_keymaps(args, device):
info = pmb.parse.deviceinfo(args, device=device)
if "keymaps" not in info or info["keymaps"].strip() == "":
return ""
options = info["keymaps"].split(' ')
logging.info("Available keymaps for device (" + str(len(options)) +
"): " + ", ".join(options))
if args.keymap is "":
args.keymap = options[0]
while True:
ret = pmb.helpers.cli.ask(args, "Keymap", None, args.keymap, True)
if ret in options:
return ret
logging.fatal("ERROR: Invalid keymap specified, please type in"
" one from the list above.")
def init(args):
cfg = pmb.config.load(args)
@ -74,6 +93,10 @@ def init(args):
device_exists = os.path.exists(args.aports + "/device/device-" + cfg["pmbootstrap"]["device"] + "/deviceinfo")
# Device keymap
if device_exists:
cfg["pmbootstrap"]["keymap"] = ask_for_keymaps(args, device=cfg["pmbootstrap"]["device"])
# UI and work folder
cfg["pmbootstrap"]["ui"] = ask_for_ui(args)
cfg["pmbootstrap"]["work"] = ask_for_work_path(args)

View file

@ -26,7 +26,6 @@ import pmb.chroot.other
import pmb.chroot.initfs
import pmb.config
import pmb.helpers.run
import pmb.helpers.other
import pmb.install.blockdevice
import pmb.install
@ -134,6 +133,25 @@ def copy_ssh_key(args):
logging.info("NOTE: No public SSH key found, you will only be able to use SSH password authentication!")
def setup_keymap(args):
"""
Set the keymap with the setup-keymap utility if the device requires it
"""
suffix = "rootfs_" + args.device
info = pmb.parse.deviceinfo(args, device=args.device)
if "keymaps" not in info or info["keymaps"].strip() == "":
logging.info("NOTE: No valid keymap specified for device")
return
options = info["keymaps"].split(' ')
if (args.keymap != "" and
args.keymap is not None and
args.keymap in options):
layout, variant = args.keymap.split("/")
pmb.chroot.root(args, ["setup-keymap", layout, variant], suffix, log=False)
else:
logging.info("NOTE: No valid keymap specified for device")
def install(args):
# Install required programs in native chroot
logging.info("*** (1/5) PREPARE NATIVE CHROOT ***")
@ -169,6 +187,9 @@ def install(args):
# Set the user password
set_user_password(args)
# Set the keymap if the device requires it
setup_keymap(args)
# Partition and fill image/sdcard
logging.info("*** (3/5) PREPARE INSTALL BLOCKDEVICE ***")
pmb.chroot.shutdown(args, True)