1 # Helper library for update-grub
2 # Copyright (C) 2007,2008 Free Software Foundation, Inc.
4 # GRUB is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # GRUB is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
17 transform="@program_transform_name@"
20 exec_prefix=@exec_prefix@
21 datarootdir=@datarootdir@
24 pkgdatadir=${datadir}/`echo @PACKAGE_TARNAME@ | sed "${transform}"`
26 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
28 make_system_path_relative_to_its_root ()
31 # abort if file doesn't exist
32 if test -e $path ; then : ;else
37 if path=`readlink -f $path` ; then : ; else
41 # if not a directory, climb up to the directory containing it
42 if test -d $path ; then
45 dir=`echo $path | sed -e "s,/[^/]*$,,g"`
50 # this loop sets $dir to the root directory of the filesystem we're inspecting
52 parent=`readlink -f $dir/..`
53 if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
54 # $parent is another filesystem; we found it.
57 if [ "x$dir" = "x/" ] ; then
64 echo $path | sed -e "s,^$dir,/,g" -e "s,//,/,g"
67 convert_system_path_to_grub_path ()
71 # abort if file doesn't exist
72 if test -e $path ; then : ;else
76 # abort if file is in a filesystem we can't read
77 if ${grub_probe} -t fs $path > /dev/null 2>&1 ; then : ; else
81 if drive=`${grub_probe} -t drive $path` ; then : ; else
85 if relative_path=`make_system_path_relative_to_its_root $path` ; then : ; else
89 # remove any trailing slash, even if that slash is everything we have
90 relative_path=`echo ${relative_path} | sed -e "s,/*$,,g"`
92 echo ${drive}${relative_path}
97 # Prefer system path for space reasons (/boot/grub might be a very small
98 # partition in case of OpenFirmware, etc).
99 for dir in ${pkgdatadir} /usr/share/grub /boot/grub ; do
100 # Prefer complete fonts over incomplete ones.
101 for basename in unicode unifont ascii ; do
102 path="${dir}/${basename}.pff"
103 if convert_system_path_to_grub_path ${path} > /dev/null ; then
113 grub_file_is_not_garbage ()
115 if test -f "$1" ; then
117 *.dpkg-dist|*.dpkg-old|*.dpkg-tmp) return 1 ;; # debian dpkg