hooks: rename 'usbinput' to 'keyboard' and add more modules

Make the hook a bit more generic by including non-usb keyboard drivers.
This should mean that any keyboard will now work in the initramfs.

In addition to fixing some uncommon setups requiring additional keyboard
modules, this would allow us to no longer build in the atkbd module (and
hence i8042) in our stock kernels, which will remove an ugly error message
on boot for systems without the i8042 controller.

Signed-off-by: Tom Gundersen <teg@jklm.no>
install/block: move TI flash media drivers to autodetect

Some of these modules have modaliases which can be picked up by
whitelisting.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: avoid using 'file' to get kernel versions

The kernel defines an offset at a fixed location within the bzImage
which we can use to find the kernel version string. Since this is fairly
important, reimplement the algorithm (which file almost surely uses)
using low level tools to avoid the possibility that file may break or
change its output, critically wounding mkinitcpio.

Note that this change leaves 'file' in use for lsinitcpio compression
detection.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: fail hard if the image can't be extracted

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: abort on unknown file formats

Specficially, abort when a user tries to run lsinitcpio on a kernel
image.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: avoid redundancies

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: further cut out dependency on file

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: always force a PATH lookup for type

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
use type to determine availability of tput

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init_functions: namespace parsed vars from cmdline

It's possible, though unlikely, that someone expecting a variable of the
name, e.g. "rhs" or "lhs" to be propagated from the kernel cmdline could
be sadly let down because of the local scoping. Give our localized vars
names less likely to clash.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: remove broken symlink error

Due to using PATH lookups for hooks, we can't possibly end up with a
broken symlink. The build will just error out on the hook not being
found.

Found via apron.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
parseopts: remove superfluous continue/shift statements

Found via apron.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
factor out kver detection to functions file

This leaves bash completion with a duplication, but this is intentional
to avoid pulling in the entire functions file and worrying about
pollution.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio.8: we support PARTLABEL too

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Do more to determine the color caps of the term

823e24 wasn't really correct, since running 'tput setaf 0' effectively
sanity checks the terminfo as well as checking existance. However, it
does nothing to affirm that the terminal is capable of supporting
colors.

Moreover, *never* fall back on the hardcoded escapes as doing so implies
that we've found a broken terminfo and we have no idea what the terminal
is capable of doing.

This reverts commit 823e2454176d4381cd3acc30481e9d84cdc298b1.
symlink /lib64 -> usr/lib in image

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: add /usr/lib64 -> lib symlink

Relegate this and the other lib64 symlink to x86_64, too, since we have
no business creating this on i686.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
bash-completion: detect_kver -> _detect_kver

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Add -P, --allpresets option

As a logical extension, allow the -p option to be specified multiple
times in order to process several presets at once.

Original-patch-by: Sébastien Luttringer <seblu@seblu.net>
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Move preset examples from /etc/mkinitcpio.d

to $(DESTDIR)/usr/share/mkinitcpio to avoid use in mkinicpio -P.

Signed-off-by: Sébastien Luttringer <seblu@seblu.net>