add_full_dir: properly handle symlinks and empty dirs

Note that we're intentionally very liberal about what we accept for
symlinks, and don't actually care if the target exists.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
update comments in config

This really should be moved into a man page.

FS#30042.

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

This allows us to declare sourced variables that we want to shield from
stomping on our config variables, and without needing to use a subshell.

Incidentally, this also fixes FS#29992 in a more permanent way.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
avoid subshell in adding --quiet to bsdcpio

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
add hookpoints to --hookhelp output

Generalize the awk program embedded in add_runscript and create a
separate function which can be reused to display the specific hooks that
a script has.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
catch errors in ldd ELF dep resolution

ldd reporting a library to be 'not found' is dangerous, and should be
reported. Consider this a build error, which will hopefully prompt the
user to reconsider before rebooting.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Don't report success when builderrors > 0

Technically, we report success when we wrote an image to disk, but this
might not be obvious to users, even with a blaring warning right before
this line. If in the event builderrors is incremented at all, avoid
reporting any sort of "success", since there might be cause for concern.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
explicitly unset build function before sourcing

This fixes an unlikely (and likely unseen) regression from
9a20048c6279cd. Without unsetting the build function before sourcing the
hook file, we can't guarantee that we're running the build function tied
to that specific file.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
fix doc error for add_full_dir

This function was incorrectly named in the manpage, and is misleading
since it will add symlinks, rather than follow them, as of 96e616f06785.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
init: run late/cleanup hooks before checking for init

This fixes a bug that made it impossible for systemd to be booted with a
separate /usr partition.

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

Avoid using compound commands where one side runs a command group.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
functions: avoid adding nonexistant modules to config

If we didn't actually add a module to the image, avoid adding it to the
runtime config for probing.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Use declare -f over type -t to avoid subshells

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

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
remove redundant header comment

I've adopted the convention of specifying the shebang for the
interpreter any given install or runtime hook that a script runs under.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
avoid reliance on sed, embrace awk

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

- remove replaces
- exchange udev with systemd-tools

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
lsinitcpio: show only regular files as binaries

Show only regular files in /usr/bin instead of everything (including the
mess of symlinks to busybox and kmod). It's also a nice to have since
we're showing more about the multiple hook points now.

This mostly restores the behavior prior to f7b8a6f0fd.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Update module filter to be aware of hyphens in the MODULES array

[dave: fix whitespace and re-add needed quoting]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
shutdown: don't alert udev on disable VGs

Fixes FS#30271.

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