This ticket is for brainstorming how this might be accomplished.
The RX51/N900 needs a custom keymap at boot to be able to enter numbers for unlocking rootfs. Keymaps, in binary format, can be loaded using busybox's loadkmap plugin:
loadkmap < rx_51_kmap.bin
The binary can be generated by running a .map file through loadkeys -b (I did this on a system with Arch Linux).
The problem is that mkinitfs.sh does not allow for importing arbitrary files into initramfs, the only custom files it will import are those under 'hooks', and only files with a .sh extension.
So there are two immediate possible solutions:
extent mkinitfs.sh to allow importing arbitrary files into the initramfs image, so hooks can use them
Add some option for identifying keymaps (probably not in the device file, since the desire for users to be able to select keymaps can easily extend beyond unique keyboards on select devices), generating a binary version of the .map file, importing it into the initramfs, and loading it (with a hook) on boot. Maybe 'setting keymap' can be done in ./pmbootstrap init ?
The second option seems like a great way to solve the immediate problem, and the first option seems like it would be desirable if folks really start using hooks for interesting things.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
There's the vconsole.conf specification, which we might adopt for easy configuration.
We could check if the vconsole.conf file exists, and based on that, add the keyboard configuration to the initramfs, along with kdb to load it (I suggest doing that instead of using the binary format from busybox, because AFAIK these can only get generated with root access, so we can't do it in the package() step and would need to ship binary blobs instead of the nice keyboard layout format that can be edited by hand)
The device-nokia-rx51 package could ship something like this as default /etc/vconsole.conf:
# This file gets used by postmarketos-mkinitfs, and is usually not part of Alpine Linux.# Specify a keymap installed in /usr/share/kbd/keymaps:KEYMAP="rx51_us"
I like the idea to be able to set the keymap in pmbootstrap init
I thought about the vconsole.conf spec, however (warning, opinion ahead) it's a systemd thing and I think we should follow conventions used by Alpine Linux / OpenRC and not start introducing specs from other distros/init systems that are not currently in Alpine Linux. Nothing is worse than trying to learn a new system or debug an existing one only to have to guess at which specs it chooses to follow despite being "based on distro XYZ". That said, if you don't mind deviating from Alpine Linux then that's fine too. Just wanted to raise that point sooner rather than later :)
For OpenRC (and Alpine Linux), the /etc/conf.d/keymaps file is used to store keyboard mapping setting.. It's a simple format, similar to the vconsole.conf format, and we could use that in the initramfs and, using a new hook, parse setting there & call kdb as you suggested, assuming the keymap file under /usr/share/keymaps is in a format compatible with kdb (that's easy enough to test)
The added benefit of using the keymaps file is that we could just enable/start the keymap service on boot with openrc and have this keymap applied, or the keymaps file could be reconfigured and the service restarted to load a new keymap.
The other big elephant in the room though is how to apply keymaps to weston. weston.ini has a keyboard section, but it expects a keymap file in a completely different format than what is used by kbd. Keymapping on Linux is a pain in the ass!
Ah, I didn't know about the /etc/conf.d/keymaps file. Then we should use that instead, thanks!
About weston, from quick research it seems to use the same format, which X11 uses (so I guess for the N900 there should be decent keymaps already :)).
As I see it, we have the following TODOs:
package the console keymap for the N900
extend the initramfs to handle additional files in their hooks*
write a hook for the console keymap
let device-nokia-rx51 depend on that hook
extend pmbootstrap init and install, that it lets you choose the keymap at the beginning, and then generate the config file for the console and weston keymap during the install step/before generating the initramfs
Do you agree with this list? If you want to work on it, I think * should be discussed a bit further. I had the idea of letting hooks look something like this, but I don't think that it is that easy to implement:
#!/bin/sh# This script would get sourced at build time by mkinitfs, and also at runtime# by init.sh# Optional section, defines files to be added to the initramfs.build(){source /etc/conf.d/keymaps_path=/usr/share/keymaps/"$keymap"if[-e"$_path"];then# add_file would be provided by the mkinitfs script# $1: source file# $2: target location in the initramfs add_file "$_path" /keymap# NOTE: I'd also like to have add_module etc. functions later# (which resolves module dependencies) and add_binary, which uses # lddtree to resolve dependencies, too. For both we already have# similar functions in the mkinitfs script. But that could be # implemented at some point in the future, once we have the # keyboard hook fully working.elseecho"ERROR: keymap does not exist: $keymap"exit 1fi}# This is the code, that actually gets executed in the initramfsrun (){# /keymap is just an example path, we could also put it somewhere else loadkeys /keymap}
The advantage would be, that the whole hook would be stored in one file (I've seen other initramfs scripts, which mostly need two files and aren't always as flexible as these add_file, add_binary etc. functions would be).
As always, these are just suggestions, looking forward for feedback on these thoughts.
If we're adding this level of configurability, can't we treat the initramfs as another distro (it's basically a full installation already) and just build it from another set of apks?
That's actually a very interesting idea.. So hooks would be an apk, along with whatever files they wanted/needed. The APKBUILD would install the hook script into the current location for initramfs hooks, and add any other files the hook might need (e.g. to /etc or anywhere in initramfs).
I think these 'initramfs' apks would need to be prefixed in name with something like 'initramfs-.apk or something to designate that these are intended for the initramfs and not for the rootfs.
@MartijnBraam interesting idea, but how would you handle kernel modules in that case? Right now all distros provide them with the kernel in one package.
Alpine actually has apk in their initramfs if I'm not mistaken, and extracts the whole live system from apks into RAM I think. You can pipe the progress from apk directly into Alpine's patched fbset from busybox :)
I think the kernel modules should be handled with some custom code, the same code that handles the initramfs chroot, building and installing. The modules can just be done the same way it currently works.
Honestly I don't think we'd gain much by using apk, if we still had lots of custom code. I see it this way: to do the build()/run() thing little code change is required, and would allow us to add all sorts of files dynamically. While integrating apk will make it a bit bigger and we'll need lots of custom code anyway. But maybe I just misunderstood the benefits you see in using apk here.
I think we might "save" 50 lines max from the mkinitfs.sh and trade that with including another binary.
How about I make an example how the code with run() and build() in the hooks would look like as PR as a reference, and then we could see if we could make a better version with including apk? I'm all in for making it simpler with apk, but I can't see how this makes it easier yet, maybe I'll see it when I have the code in front of my eyes :)
I've looked into how arch does this with mkinitcpio and it basically does the same thing as the shell scripts you propose but has a seperate file for build and run (but with 4 seperate run hooks for different moments in the initramfs to execute it)
Does alpine linux offer something 'official' like this too in the
distro?
On Tue, Jul 18, 2017 at 08:34:22AM +0000, Martijn Braam wrote:
I've looked into how arch does this with mkinitcpio and it basically does the same thing as the shell scripts you propose but has a seperate file for build and run (but with 4 seperate run hooks for different moments in the initramfs to execute it)
mkinitfs uses a seperate file for everthing like adding modules and adding files. I can't find quickly how you make it actually execute stuff on booting.
We could check if the vconsole.conf file exists, and based on that, add the keyboard configuration to the initramfs, along with kdb to load it (I suggest doing that instead of using the binary format from busybox, because AFAIK these can only get generated with root access, so we can't do it in the package() step and would need to ship binary blobs instead of the nice keyboard layout format that can be edited by hand)
For what it's worth, Arch Linux's mkinitcpio 'keymap' hook uses loadkmap with a binary keymap. Here's the code for the hook ( taken from my system):
#!/usr/bin/ashrun_hook() { if [ -e /keymap.bin ]; then msg -n ":: Loading keymap..." if [ -f /keymap.utf8 ]; then mode=-u ctrl=G else mode=-a ctrl=@ fi kbd_mode $mode -C /dev/console printf "\033%%$ctrl" >> /dev/console loadkmap < /keymap.bin msg "done." fi}