Skip to content

Commit

Permalink
Load build and run hooks from /etc/initcpio
Browse files Browse the repository at this point in the history
This lets users shoot themselves in the foot more easily, as they can
put their own modified hooks into /etc/initcpio/{hooks,install} to
override those shipped by the distro in /usr/lib/initcpio.

To make debugging easier, include the full path of the hook being used
when mkinitcpio runs in verbose mode.

Implements FS#37796.
  • Loading branch information
falconindy committed Dec 1, 2013
1 parent b8f596e commit 0ccd0bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Makefile
Expand Up @@ -7,6 +7,8 @@ DIRS = \
/usr/share/bash-completion/completions \
/usr/share/zsh/site-functions \
/etc/mkinitcpio.d \
/etc/initcpio/hooks \
/etc/initcpio/install \
/usr/lib/initcpio/hooks \
/usr/lib/initcpio/install \
/usr/lib/initcpio/udev \
Expand All @@ -30,8 +32,8 @@ install: all

sed -e 's|^_f_config=.*|_f_config=/etc/mkinitcpio.conf|' \
-e 's|^_f_functions=.*|_f_functions=/usr/lib/initcpio/functions|' \
-e 's|^_d_hooks=.*|_d_hooks=/usr/lib/initcpio/hooks:/lib/initcpio/hooks|' \
-e 's|^_d_install=.*|_d_install=/usr/lib/initcpio/install:/lib/initcpio/install|' \
-e 's|^_d_hooks=.*|_d_hooks=/etc/initcpio/hooks:/usr/lib/initcpio/hooks:/lib/initcpio/hooks|' \
-e 's|^_d_install=.*|_d_install=/etc/initcpio/install:/usr/lib/initcpio/install:/lib/initcpio/install|' \
-e 's|^_d_presets=.*|_d_presets=/etc/mkinitcpio.d|' \
-e 's|%VERSION%|$(VERSION)|g' \
< mkinitcpio > $(DESTDIR)/usr/bin/mkinitcpio
Expand Down
6 changes: 5 additions & 1 deletion functions
Expand Up @@ -709,7 +709,11 @@ run_build_hook() {
fi

# run
msg2 "Running build hook: [%s]" "${script##*/}"
if (( _optquiet )); then
msg2 "Running build hook: [%s]" "${script##*/}"
else
msg2 "Running build hook: [%s]" "$script"
fi
build

# if we made it this far, return successfully. Hooks can
Expand Down
2 changes: 2 additions & 0 deletions man/mkinitcpio.8.txt
Expand Up @@ -291,10 +291,12 @@ Files
'/etc/mkinitcpio.d'::
Directory containing mkinitcpio presets.
'/etc/initcpio/install'::
'/usr/lib/initcpio/install'::
'/lib/initcpio/install'::
Search path for build time hooks.
'/etc/initcpio/hooks'::
'/usr/lib/initcpio/hooks'::
'/lib/initcpio/hooks'::
Search path for early userspace runtime hooks.
Expand Down

0 comments on commit 0ccd0bc

Please sign in to comment.