mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-23 07:39:22 +00:00
added new function to resolve_symlink to grub-install.in
moved code from find_device to this function install_device is now run through the new function
This commit is contained in:
1 parent
7c7f8f73ea
commit
fc2a2dc3d7
2 files changed
+32
-13
No files matched your search
+25
-13
@@ -181,6 +181,29 @@ convert () {
|
||||
fi
|
||||
}
|
||||
|
||||
# Usage: resolve_symlink file
|
||||
# Find the real file/device that file points at
|
||||
resolve_symlink () {
|
||||
tmp_fname=$1
|
||||
# Resolve symlinks
|
||||
while test -L $tmp_fname; do
|
||||
tmp_new_fname=`ls -al $tmp_fname | sed -n 's%.*-> \(.*\)%\1%p'`
|
||||
if test -z "$tmp_new_fname"; then
|
||||
echo "Unrecognized ls output" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Convert relative symlinks
|
||||
case $tmp_new_fname in
|
||||
/*) tmp_fname="$tmp_new_fname"
|
||||
;;
|
||||
*) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "$tmp_fname"
|
||||
}
|
||||
|
||||
# Usage: find_device file
|
||||
# Find block device on which the file resides.
|
||||
find_device () {
|
||||
@@ -193,20 +216,8 @@ find_device () {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Resolve symlinks
|
||||
while test -L $tmp_fname; do
|
||||
tmp_new_fname=`ls -al $tmp_fname | sed -n 's%.*-> \(.*\)%\1%p'`
|
||||
if test -z "$tmp_new_fname"; then
|
||||
echo "Unrecognized ls output" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
tmp_fname=`resolve_symlink $tmp_fname`
|
||||
|
||||
# Convert relative symlinks
|
||||
case $tmp_new_fname in
|
||||
/*) tmp_fname="$tmp_new_fname" ;;
|
||||
*) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname" ;;
|
||||
esac
|
||||
done
|
||||
echo "$tmp_fname"
|
||||
}
|
||||
|
||||
@@ -338,6 +349,7 @@ fi
|
||||
# Check for INSTALL_DEVICE.
|
||||
case "$install_device" in
|
||||
/dev/*)
|
||||
install_device=`resolve_symlink "$install_device"`
|
||||
install_drive=`convert "$install_device"`
|
||||
# I don't know why, but some shells wouldn't die if exit is
|
||||
# called in a function.
|
||||
|
||||
Reference in new issue
Block a user