functions: always treat ADDED_MODULES as a hash

Overlooked in b8d9c5cd2753e9. This change also assigns a value of "2" to
builtin modules which are added to the the ADDED_MODULES array, to
distinguish them from actual modules on disk. Using this, we can avoid
adding builtins to the image's runtime config.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: munge modules.order before calling depmod

The initramfs installs all modules to kernel/ which devalues the
modules.order file. To avoid any edge cases with the wrong module being
loaded (because all matching modules for a given alias will be added),
make sure that the modules.order file is actually valid.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: include image config on image itself

For the purposes of accounting and debugging, it's nice to have this
around.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: move image analysis to separate function

git (at least version 1.7.12.1) does a great job of showing the absolute
wrong code moving around in this patch.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: add -c, --config option to dump config

Now that mkinitcpio stores the build time config file in the image, we
should have a way of easily getting it back out.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: add -l, --list option; define as default

This is the default action for lsinitcpio. Add it just for the purpose
of clarity. This change also separates out true options from 'actions'
and validates that the user only passed a single action to lsinitcpio.
Update the manpage accordingly.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: avoid fully resolving soname symlinks

It's okay to fully resolve the symlink to add the regular file it points
to, but avoid mangling the symlink name to try and preserve relative
links.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
commit to some level of style in variable naming

This is an ugly patch, and probably does more than I'd like it to. The
idea is that mkinitcpio adopts some sort of consistent style which I'm
actually happy with. I define 3 kinds of variables:

1) local variables: all lower case, and scoped within functions. Use
freely, as they're well contained.

2) global variables: these are known to mkinitcpio internally, but are
global in scope. They mainly carry runtime configuration and collected
data during the image generation process. These are always lower case,
but carry a leading underscore to denote that they're global.

3) "API" variables: also global in scope, but exist "outside" of
mkinitcpio -- either drawn in from the configuration file, or "exported"
to the install hooks. These are always all upper case. When introducing
new variables, extreme care must be taken to pick names that will not
conflict with the environment inherited by mkinitcpio.

A HACKING file is introduced with a similar description of the above,
and more.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
mkinitcpio: check for preset file by sourcing it

Instead of using a bash test, just source the preset file. If it fails,
exit. This patch is a bit ugly because it remove a level of indentation.
honor -n for presets

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
separate image building to functions

Mostly in favor of scoping out some variables further.

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

Using anything but /lib/modules isn't really sane, and it shouldn't be
supported. If you want to use /usr/lib/modules, then /lib must be a
symlink to usr/lib.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
ensure builtins are dash/underscore translated

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

- use dist_MAN instead of DIST_EXTRA (it's only manpages anyways)
- uniformly use $(var) instead of ${var}
- consolidate manpage generate rules

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