How to automate setting up of "keyboard-configuration" package?

Solution 1:

From a similar StackOverflow question:

If the ENV variable DEBIAN_FRONTEND=noninteractive is set while you run apt-get install keyboard-configuration, it won't prompt for any interaction. So you can simply run:

DEBIAN_FRONTEND=noninteractive apt-get install keyboard-configuration

Solution 2:

This is simple to automate, you just need to set the proper debconf configuration for this package.

First install debconf-utils:

sudo apt install debconf-utils

If you've already configured the package, you can read the debconf configuration with:

debconf-get-selections | grep keyboard-configuration

If you haven't configured the package or would like to change your selections, you can do this with:

dpkg-reconfigure keyboard-configuration

Export your selections to a file

debconf-get-selections | grep keyboard-configuration > selections.conf

Copy selections.conf to the target machine and set the selections:

debconf-set-selections < selections.conf

When you install or reconfigure the package, your choices will now be selected automatically.

dpkg-reconfigure keyboard-configuration -f noninteractive

Solution 3:

"debootstrap is really just a shell script" --from https://wiki.debian.org/Debootstrap

This means that you could read the script to see if there are ways to pass the info via an environment variable, supply an argument when invoking deboostrap, or create your own modified version for your specific application.