functions: introduce add_checked_modules and add_all_modules

Instead of returning a list of modules which the caller should then add
themselves or stuff into the MODULES string, call add_module for each
candidate. This is basically a different wrapper around all_modules.

DEPRECATION WARNING: This commit marks checked_modules as deprecated.
Although it is not slated to go away, direct usage of all_modules is
strongly discouraged.

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

This function adds a runtime script to the /hooks directory on the
initramfs image. Note that this function will also install hooks with
executable permissions for use by a later change to early init.

With this commit, there are now methods available which can be used in
place of the MODULES, FILES, BINARIES, and SCRIPT variables, as we now
offer error checking on the add_* functions. Usage of the variables is
deprecated, and these will no longer be read in a future version of
mkinitcpio.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
use new API for install hooks

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init: correct trimming of earlymodules and MODULES

This never worked properly and only "fixed" the stupid bug that found
an edge case when either of these vars contains nothing more than a
single space.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init_functions: move running hooks to separate func

Abstract this out to the init_functions file, and allow this function
take 2+ parameters -- the hook name to be run, a user friendly short
description, and then the list of hook files to source from. While we're
at it, take advantage of the fact that hooks are now installed with
executable perms. If a hook isn't marked excutable, we skip it, thereby
removing our eval hack.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init: add support for late running hooks

This adds support for a second round of hooks during early userspace.
Users can define a 'run_latehook' in their hook script similar to the
declaration of 'run_hook' which continues to run at the same point in
execution. Scripts are executed after mounting root in reverse order of
how they're clared in mkinitcpio'c config. These late running hooks
should take care of things such as:

- mounting other partitions
- moving config to the real root (mostly for liveCDs)
- shutting down previously started daemons

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
shutdown: package as 644, install as 755

There's no need to keep this mildly dangerous script executable on the
filesystem.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
shutdown: convert to late hook

Run this later in early init where we can delete the modules from the
ramfs before copying the image over to /run/initramfs.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
buildsys: fix clean target

We don't ship compressed manpages, and this never touched lsinitcpio's
generated page.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: extract the image to a tempdir

We read the image a number of times. Extract the image to a temp
directory so we can just extract it once and use the filesystem to our
advantage. This requires a temp dir which we can nuke on an EXIT trap,
but the whole operation is sped is a bit, especially for larger images.

The real goal of this is to make examination of the hooks easier. Since
we now have multiple hook sets to contend with, dynamically tally up the
available functions in the hook files so we can iterate over specific
functions of interest in the output.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: add support for listing late hooks

The previous patch makes this quite simple, and we can easily catch
instances of run_latehook() for printing in the output.

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