summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2017-10-01 19:57:54 +0200
committerDave Reisner <dreisner@archlinux.org>2017-10-01 20:13:55 +0200
commit8d59e6a1d7ef3e68b6ed3f17a7a0c20873055592 (patch)
tree0053f4a8140f3df8ff7c4f211eb48b5fc7d5a7ee
parentb255bdc78754c4cde9835b6cb2865da1f9b122bf (diff)
downloadmkinitcpio-8d59e6a1d7ef3e68b6ed3f17a7a0c20873055592.tar.gz
mkinitcpio-8d59e6a1d7ef3e68b6ed3f17a7a0c20873055592.tar.xz
Avoid erroneous deprecation warnings
Consistently handle hooks as symlinks by relying on the exit status of readlink instead of an lstat and always, additionally, examine the hooks basenames to ensure that we aren't warning about foo deprecating foo (because the hook is a symlink to somewhere else that the hook is actually stored on disk. ref: https://bugs.archlinux.org/task/55323
-rw-r--r--functions9
-rwxr-xr-xmkinitcpio12
2 files changed, 6 insertions, 15 deletions
diff --git a/functions b/functions
index 941312f..53557e7 100644
--- a/functions
+++ b/functions
@@ -695,7 +695,7 @@ initialize_buildroot() {
}
run_build_hook() {
- local hook=$1 script= realscript=
+ local hook=$1 script= resolved=
local MODULES=() BINARIES=() FILES=() SCRIPT=
# find script in install dirs
@@ -705,11 +705,10 @@ run_build_hook() {
fi
# check for deprecation
- if [[ -L $script ]]; then
- realscript=$(readlink -e "$script")
+ if resolved=$(readlink "$script") && [[ ${script##*/} != "${resolved##*/}" ]]; then
warning "Hook '%s' is deprecated. Replace it with '%s' in your config" \
- "${script##*/}" "${realscript##*/}"
- script=$realscript
+ "${script##*/}" "${resolved##*/}"
+ script=$resolved
fi
# source
diff --git a/mkinitcpio b/mkinitcpio
index ad96a4f..42b8290 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -125,8 +125,7 @@ hook_help() {
return 1
fi
- if [[ -L $script ]]; then
- resolved=$(readlink -e "$script")
+ if resolved=$(readlink "$script") && [[ ${script##*/} != "${resolved##*/}" ]]; then
msg "This hook is deprecated. See the '%s' hook" "${resolved##*/}"
return 0
fi
@@ -155,14 +154,7 @@ hook_list() {
[[ -e $hook || -L $hook ]] || continue
# handle deprecated hooks and point to replacement
- if [[ -L $hook ]]; then
- resolved=$(readlink -e "$hook")
-
- if [[ -z $resolved ]]; then
- error "found broken symlink '%s'" "$hook"
- continue
- fi
-
+ if resolved=$(readlink "$hook") && [[ ${hook##*/} != "${resolved##*/}" ]]; then
resolved=${resolved##*/}
if ! index_of "$resolved" "${depr[@]}"; then