From: Kairui Song Date: Mon, 11 Mar 2019 11:46:19 +0000 (+0800) Subject: squash: fix and simplify required_in_root X-Git-Tag: 050~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6bbd024d924a7865f95bf24a1c786af1746ad34;p=thirdparty%2Fdracut.git squash: fix and simplify required_in_root If required target is a symbol link, create the link then following the link. If it's a directory, create new directory, else just move it. Signed-off-by: Kairui Song --- diff --git a/dracut.sh b/dracut.sh index 017a7a3bd..f05a757b6 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1811,30 +1811,26 @@ if dracut_module_included "squash"; then required_in_root $(dirname $file) fi - if [[ -d $_sqsh_file ]]; then - if [[ -L $_sqsh_file ]]; then - cp --preserve=all -P $_sqsh_file $_init_file - else - mkdir $_init_file - fi + if [[ -L $_sqsh_file ]]; then + cp --preserve=all -P $_sqsh_file $_init_file + _sqsh_file=$(realpath $_sqsh_file 2>/dev/null) + if [[ -e $_sqsh_file ]] && [[ "$_sqsh_file" == "$squash_dir"* ]]; then + # Relative symlink + required_in_root ${_sqsh_file#$squash_dir/} + return + fi + if [[ -e $squash_dir$_sqsh_file ]]; then + # Absolute symlink + required_in_root ${_sqsh_file#/} + return + fi + required_in_root ${module_spec#$squash_dir/} else - if [[ -L $_sqsh_file ]]; then - cp --preserve=all -P $_sqsh_file $_init_file - _sqsh_file=$(realpath $_sqsh_file 2>/dev/null) - if [[ -e $_sqsh_file ]] && [[ "$_sqsh_file" == "$squash_dir"* ]]; then - # Relative symlink - required_in_root ${_sqsh_file#$squash_dir/} - return - fi - if [[ -e $squash_dir$_sqsh_file ]]; then - # Absolute symlink - required_in_root ${_sqsh_file#/} - return - fi - required_in_root ${module_spec#$squash_dir/} - else - mv $_sqsh_file $_init_file - fi + if [[ -d $_sqsh_file ]]; then + mkdir $_init_file + else + mv $_sqsh_file $_init_file + fi fi }