Browse Source

initramfs: Enhanced to support symlinks to symlinks

karasz/new-early
Alejandro Mery 16 years ago
parent
commit
5298b255d8
1 changed files with 21 additions and 11 deletions
  1. +21
    -11
      target/share/initramfs/build.sh

+ 21
- 11
target/share/initramfs/build.sh

@ -77,19 +77,29 @@ echo_status "Removing empty folders ..."
done
echo_status "Checking for broken symlinks ..."
( cd "$rootfs"; find . -type l ) | while read link; do
target=$( readlink "$rootfs/$link" )
case "$target" in
/proc/*) continue ;;
/*) # absolute
;;
*) target="/${link%/*}/${target}" # relative
;;
esac
( cd "$rootfs"; find . -type l | cut -c2- ) | while read link; do
x="$link"
while true; do
target=$( readlink "$rootfs$x" )
case "$target" in
/proc/*)
continue 2
;;
/*)
;;
*)
# relatives turned into absolute
target="${x%/*}/${target}"
esac
[ -L "$rootfs$target" ] || break 1
x="$target"
done
if [ ! -e "$rootfs$target" ]; then
echo_warning "- $link is broken, deleting."
rm -f "$rootfs/$link"
echo_warning "- $link is broken ($target), deleting."
rm -f "$rootfs$link"
fi
done

Loading…
Cancel
Save