install/consolefont: cleanup and refactor

* Provide support for uncompressed font files as well as compressed
* Avoiding using an unnecessary temp file
* Support $BASEDIR
* Warn when no font is found
* Only add the runtime hook if a font is added

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
keymap/consolefont: source rc.conf properly from $BASEDIR

This is partially in response to FS#24685, which should hopefully cut
back on configuration duplication on non-sysvinit systems. This does,
however, also fix a bug with keymap/consolefont pulling the wrong
rc.conf when BASEDIR is not '/' or unset.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
keymap: simplify unicode detection

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
cleanup and bashify install hooks

No logical code changes -- this is purely a syntactical cleanup and
standardization across the build hooks along with ensuring that help
messages are wrapped to 80 columns or less. All hooks get the same
treatment, adhering to the following style:

  #!/bin/bash

  build() {
      COMMANDS
  }

  help() {
      cat <<HELPEOF
  This is a help message.
  HELPEOF
  }

  # vim: set ft=sh ts=4 sw=4 et:

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
base: remove superfluous leading /

The doubled up leading slashes annoy me in the verbose output.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: allow ignoring errors on module addition

We conditionally, but naively, add modules in some of our install hooks,
but the kernel may not have these. Note that these modules can fail
silently by detecting a '?' suffix on the module name. In conjunction with
this, the add_module function now takes a flag, -t or --try, which will
ignore module not found errors from modinfo. The config file will also
support this syntax.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: refactor get_{base,dir}name

Make sure these are completely safe for user input. Use the same three
step process in both cases:

1) Strip any trailing slash
2) Trim the string according to base/dir request
3) Print the result, defaulting to / if step 2 yielded an empty string

Signed-off-by: Dave Reisner <d@falconindy.com>
functions: perform path lookup for binaries if needed

We used to do this, but it was lost somewhere along the way in fixing up
basedir support. Add in a 'pathlookup' function which can do a search
within any given basedir.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: specify the delimiter to xargs

Without specifying this, xargs will split arguments on whitespace as
well as newlines, and will interpret quoting and backslashes. When the
delimiter is specified, every character is taken literally and only the
given delimiter in honored.

This sidesteps issues with broken modalias files as evidenced by a
MacBookAir3,1 or the bbs thread below:

https://bbs.archlinux.org/viewtopic.php?pid=971853

Also fixes FS#25450.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
ensure local scoping of variables

Also make sure that simple variables are declared as null strings.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: simplify setting of SKIPHOOKS

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: fix whitespace errors in error messages

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: explicitly create $BUILDROOT

Avoids explosions if a user has no HOOKS in their config, as seen:

https://bbs.archlinux.org/viewtopic.php?pid=966344

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: keep going even when a hook isn't found

Instead of bailing entirely, throw an error, and ensure that we exit
with a non-zero status. The user might do something as simple as
misspell a hook name which may or may not prevent a useful image from
being created.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: insist that /dev and /proc be mounted

This avoids errors with process substitutions in chroots, among other
things. It's important that /proc be checked first as /etc/mtab might be
a link to /proc/self/mounts.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init: support breaks before and after mounting root

Add in 'premount' and 'postmount' as trigger conditions, but also leave
in the old 'y' value as a synonym for premount.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init: allow /run to be mounted with exec perms

This is already done in initscripts so we mirror it here.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: disable color when stdout isn't a tty

This was a copypasta error when taking this from makepkg, which has
special concerns in this regard. lsinitcpio should only concern itself
with stdout.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: follow symlinks only when necessary

If the image we're pointing to is a symlink, show the resolution as part
of the name in -a's output.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: fix output order in _add_symlink

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