From a20d24ded292bfcf96f4fdab78ec20b92a07bbf1 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 21 Jun 2012 01:57:11 +0200 Subject: [PATCH] dracut-functions.sh: use "ln -r" instead of shell functions --- dracut-functions.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/dracut-functions.sh b/dracut-functions.sh index 1137919..d4a766b 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -188,6 +188,19 @@ convert_abs_rel() { echo "$__newpath" } +if strstr "$(ln --help)" "relative"; then + ln_r() { + ln -sfnr "${initdir}/$1" "${initdir}/$2" + } +else + ln_r() { + local _source=$1 + local _dest=$2 + [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} + ln -sfn $(convert_abs_rel "${_dest}" "${_source}") "${initdir}/${_dest}" + } +fi + # get_fs_env # Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device. # Example: @@ -465,8 +478,7 @@ inst_library() { _reallib=$(readlink -f "$_src") inst_simple "$_reallib" "$_reallib" inst_dir "${_dest%/*}" - [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} - ln -sfn $(convert_abs_rel "${_dest}" "${_reallib}") "${initdir}/${_dest}" + ln_r "${_reallib}" "${_dest}" else inst_simple "$_src" "$_dest" fi @@ -555,8 +567,8 @@ inst_symlink() { fi fi [[ ! -e $initdir/${_target%/*} ]] && inst_dir "${_target%/*}" - [[ -d ${_target%/*} ]] && _target=$(readlink -f ${_target%/*})/${_target##*/} - ln -sfn $(convert_abs_rel "${_target}" "${_realsrc}") "$initdir/$_target" + + ln_r "${_realsrc}" "${_target}" } # attempt to install any programs specified in a udev rule