From a932684a618ffc45f43a60c32948ae8316a62e80 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Aug 19 2020 14:22:49 +0000 Subject: 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 (cherry picked from commit 11ce69e4bd9172cf54251ea62bb4a5ead1700fd6) Resolves: #1691705 patch_name: 0019.patch present_in_specfile: true location_in_specfile: 19 squash_commits: true --- diff --git a/dracut.sh b/dracut.sh index a0158f2..6de88b3 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 }