2007-05-20 09:10:06 +00:00
|
|
|
# Helper library for update-grub
|
|
|
|
# Copyright (C) 2007 Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# This file is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St - Suite 330, Boston, MA 02110, USA.
|
|
|
|
|
|
|
|
transform="@program_transform_name@"
|
|
|
|
|
|
|
|
sbindir=@sbindir@
|
|
|
|
|
|
|
|
grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
|
|
|
|
|
|
|
|
convert_system_path_to_grub_path ()
|
|
|
|
{
|
|
|
|
dir=$1
|
2007-06-06 18:08:56 +00:00
|
|
|
# Abort if file doesn't exist
|
|
|
|
test -e $dir
|
2007-05-20 09:10:06 +00:00
|
|
|
dir=`readlink -f $dir`
|
|
|
|
|
|
|
|
drive=`${grub_probe} -t drive $dir`
|
|
|
|
if [ "x$drive" = "x" ] ; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2007-06-06 18:08:56 +00:00
|
|
|
# Abort if file is in a filesystem we can't read
|
|
|
|
${grub_probe} -t fs $dir > /dev/null 2>&1
|
|
|
|
|
2007-05-20 09:10:06 +00:00
|
|
|
num=`stat -c %d $dir`
|
|
|
|
relative_path=""
|
|
|
|
while : ; do
|
|
|
|
parent=`echo $dir | sed -e "s,/[^/]*$,,g" -e "s,^$,/,g"`
|
|
|
|
if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
if [ "x$dir" = "x/" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
relative_path=`echo $dir | sed -e "s,^.*/,/,g"`$relative_path
|
|
|
|
dir=$parent
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ${drive}${relative_path}
|
|
|
|
}
|