2007-05-13 Robert Millan <rmh@aybabtu.com>
* util/update-grub.in: Fix a few assumptions about the devices holding /, /boot and /boot/grub being the same. * util/grub.d/00_header.in: Likewise. * util/grub.d/10_hurd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/10_linux.in: Implement Linux image sorting with arbitrary patterns. Use that to define the `.old' suffix as older than `'. * util/grub.d/00_header.in: Set default gfxmode to `800x600x16'. * util/update-grub.in: Add a reference to ${sysconfdir}/default/grub in the grub.cfg header message.
This commit is contained in:
parent
2e610d6273
commit
57f9639766
5 changed files with 134 additions and 27 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2007-05-13 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
|
* util/update-grub.in: Fix a few assumptions about the devices holding
|
||||||
|
/, /boot and /boot/grub being the same.
|
||||||
|
* util/grub.d/00_header.in: Likewise.
|
||||||
|
* util/grub.d/10_hurd.in: Likewise.
|
||||||
|
* util/grub.d/10_linux.in: Likewise.
|
||||||
|
|
||||||
|
* util/grub.d/10_linux.in: Implement Linux image sorting with arbitrary
|
||||||
|
patterns. Use that to define the `.old' suffix as older than `'.
|
||||||
|
|
||||||
|
* util/grub.d/00_header.in: Set default gfxmode to `800x600x16'.
|
||||||
|
|
||||||
|
* util/update-grub.in: Add a reference to ${sysconfdir}/default/grub in
|
||||||
|
the grub.cfg header message.
|
||||||
|
|
||||||
2007-05-11 Robert Millan <rmh@aybabtu.com>
|
2007-05-11 Robert Millan <rmh@aybabtu.com>
|
||||||
|
|
||||||
* util/update-grub.in: Create device.map if it doesn't already exist,
|
* util/update-grub.in: Create device.map if it doesn't already exist,
|
||||||
|
|
|
@ -29,8 +29,9 @@ EOF
|
||||||
|
|
||||||
if test -e /boot/grub/unifont.pff ; then
|
if test -e /boot/grub/unifont.pff ; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
font /boot/grub/unifont.pff
|
|
||||||
set gfxmode=640x480x32
|
font ${GRUB_DRIVE_BOOT_GRUB}/unifont.pff
|
||||||
|
set gfxmode=800x600x16
|
||||||
insmod gfxterm
|
insmod gfxterm
|
||||||
insmod vbe
|
insmod vbe
|
||||||
terminal gfxterm
|
terminal gfxterm
|
||||||
|
|
|
@ -23,11 +23,19 @@ else
|
||||||
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
at_least_one=false
|
||||||
|
all_of_them=true
|
||||||
|
|
||||||
# FIXME: add l4 here?
|
# FIXME: add l4 here?
|
||||||
kernel=
|
kernel=
|
||||||
for i in /boot/gnumach.gz /boot/gnumach ; do
|
for i in /boot/gnumach.gz /boot/gnumach ; do
|
||||||
if test -e $i ; then
|
if test -e $i ; then
|
||||||
kernel=$i
|
basename=`basename $i`
|
||||||
|
dirname=`dirname $i`
|
||||||
|
grub_dirname=`echo ${dirname} | sed -e "s%^/boot%${GRUB_DRIVE_BOOT}%g"`
|
||||||
|
echo "Found GNU Mach: $i" >&2
|
||||||
|
kernel=${grub_dirname}/${basename}
|
||||||
|
at_least_one=true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -37,10 +45,8 @@ case "${GRUB_FS}" in
|
||||||
*) hurd_fs="${GRUB_FS}fs" ;;
|
*) hurd_fs="${GRUB_FS}fs" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
at_least_one=false
|
for i in /hurd/${hurd_fs}.static /hurd/exec ; do
|
||||||
all_of_them=true
|
if test -e "$i" ; then
|
||||||
for i in "${kernel}" /hurd/${hurd_fs}.static /hurd/exec ; do
|
|
||||||
if test -e "$i" ; then
|
|
||||||
echo "Found Hurd module: $i" >&2
|
echo "Found Hurd module: $i" >&2
|
||||||
at_least_one=true
|
at_least_one=true
|
||||||
else
|
else
|
||||||
|
|
|
@ -23,22 +23,76 @@ else
|
||||||
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test_numeric ()
|
||||||
for linux in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
|
{
|
||||||
if test -e ${linux} ; then : ; else
|
local a=$1
|
||||||
continue
|
local cmp=$2
|
||||||
|
local b=$3
|
||||||
|
if [ "$a" = "$b" ] ; then
|
||||||
|
case $cmp in
|
||||||
|
ge|eq|le) return 0 ;;
|
||||||
|
gt|lt) return 1 ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
echo "Found linux image: $linux" >&2
|
if [ "$cmp" = "lt" ] ; then
|
||||||
version=`echo $linux | sed -e "s,.*/[^0-9]*-,,g"`
|
c=$a
|
||||||
basedir=`echo $linux | sed -e "s,/[^/]*$,,g"`
|
a=$b
|
||||||
|
b=$c
|
||||||
|
fi
|
||||||
|
if (echo $a ; echo $b) | sort -n | head -n 1 | grep -qx $b ; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
test_gt ()
|
||||||
|
{
|
||||||
|
local a=$1
|
||||||
|
local b=$2
|
||||||
|
local cmp=gt
|
||||||
|
if [ "x$b" = "x" ] ; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
case $a:$b in
|
||||||
|
*.old:*.old) ;;
|
||||||
|
*.old:*) a=`echo -n $a | sed -e s/\.old$//g` ; cmp=gt ;;
|
||||||
|
*:*.old) b=`echo -n $b | sed -e s/\.old$//g` ; cmp=ge ;;
|
||||||
|
esac
|
||||||
|
test_numeric $a $cmp $b
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
find_latest ()
|
||||||
|
{
|
||||||
|
local a=""
|
||||||
|
for i in $@ ; do
|
||||||
|
if test_gt "$i" "$a" ; then
|
||||||
|
a="$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "$a"
|
||||||
|
}
|
||||||
|
|
||||||
|
list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
|
||||||
|
if test -e $i ; then echo -n "$i " ; fi
|
||||||
|
done`
|
||||||
|
|
||||||
|
while [ "x$list" != "x" ] ; do
|
||||||
|
linux=`find_latest $list`
|
||||||
|
echo "Found linux image: $linux" >&2
|
||||||
|
basename=`basename $linux`
|
||||||
|
dirname=`dirname $linux`
|
||||||
|
grub_dirname=`echo ${dirname} | sed -e "s%^/boot%${GRUB_DRIVE_BOOT}%g"`
|
||||||
|
version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
|
||||||
cat << EOF
|
cat << EOF
|
||||||
menuentry "${OS}, linux ${version}" {
|
menuentry "${OS}, linux ${version}" {
|
||||||
linux ${linux} root=${GRUB_DEVICE} ro ${GRUB_CMDLINE_LINUX}
|
linux ${grub_dirname}/${basename} root=${GRUB_DEVICE} ro ${GRUB_CMDLINE_LINUX}
|
||||||
EOF
|
EOF
|
||||||
if test -e ${basedir}/initrd.img-${version} ; then
|
if test -e ${dirname}/initrd.img-${version} ; then
|
||||||
echo "Found initrd image: ${basedir}/initrd.img-${version}" >&2
|
echo "Found initrd image: ${dirname}/initrd.img-${version}" >&2
|
||||||
cat << EOF
|
cat << EOF
|
||||||
initrd ${basedir}/initrd.img-${version}
|
initrd ${grub_dirname}/initrd.img-${version}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
@ -46,14 +100,15 @@ EOF
|
||||||
EOF
|
EOF
|
||||||
cat << EOF
|
cat << EOF
|
||||||
menuentry "${OS}, linux ${version} (single-user mode)" {
|
menuentry "${OS}, linux ${version} (single-user mode)" {
|
||||||
linux ${linux} root=${GRUB_DEVICE} ro single ${GRUB_CMDLINE_LINUX}
|
linux ${grub_dirname}/${basename} root=${GRUB_DEVICE} ro single ${GRUB_CMDLINE_LINUX}
|
||||||
EOF
|
EOF
|
||||||
if test -e ${basedir}/initrd.img-${version} ; then
|
if test -e ${dirname}/initrd.img-${version} ; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
initrd ${basedir}/initrd.img-${version}
|
initrd ${grub_dirname}/initrd.img-${version}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
cat << EOF
|
cat << EOF
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
|
||||||
done
|
done
|
||||||
|
|
|
@ -65,13 +65,44 @@ if test -e ${grub_prefix}/device.map ; then : ; else
|
||||||
grub-mkdevicemap
|
grub-mkdevicemap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec > ${grub_cfg}.new
|
# Device containing our userland. Typicaly used for root= parameter.
|
||||||
chmod 444 ${grub_cfg}.new
|
GRUB_DEVICE="`grub-probe --target=device /`"
|
||||||
|
|
||||||
|
# Filesystem for the device containing our userland. Used for stuff like
|
||||||
|
# choosing Hurd filesystem module.
|
||||||
|
GRUB_FS="`grub-probe --target=fs /`"
|
||||||
|
|
||||||
|
# GRUB path to /
|
||||||
|
GRUB_DRIVE="`grub-probe --target=drive /`"
|
||||||
|
|
||||||
|
# GRUB path to /boot
|
||||||
|
if [ "x`stat -c %d /`" = "x`stat -c %d /boot/`" ] ; then
|
||||||
|
GRUB_DRIVE_BOOT="${GRUB_DRIVE}/boot"
|
||||||
|
else
|
||||||
|
GRUB_DRIVE_BOOT="`grub-probe --target=drive /boot`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# GRUB path to /boot/grub
|
||||||
|
if [ "x`stat -c %d /boot`" = "x`stat -c %d /boot/grub`" ] ; then
|
||||||
|
GRUB_DRIVE_BOOT_GRUB="${GRUB_DRIVE_BOOT}/grub"
|
||||||
|
else
|
||||||
|
GRUB_DRIVE_BOOT_GRUB="`grub-probe --target=drive /boot/grub`"
|
||||||
|
fi
|
||||||
|
|
||||||
if test -f ${sysconfdir}/default/grub ; then
|
if test -f ${sysconfdir}/default/grub ; then
|
||||||
. ${sysconfdir}/default/grub
|
. ${sysconfdir}/default/grub
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# These are defined in this script, export them here so that user can
|
||||||
|
# override them.
|
||||||
|
export GRUB_DEVICE GRUB_FS GRUB_DRIVE GRUB_DRIVE_BOOT GRUB_DRIVE_BOOT_GRUB
|
||||||
|
|
||||||
|
# These are optional, user-defined variables.
|
||||||
|
export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR
|
||||||
|
|
||||||
|
exec > ${grub_cfg}.new
|
||||||
|
chmod 444 ${grub_cfg}.new
|
||||||
|
|
||||||
echo "Updating ${grub_cfg} ..." >&2
|
echo "Updating ${grub_cfg} ..." >&2
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
@ -79,13 +110,11 @@ cat << EOF
|
||||||
# DO NOT EDIT THIS FILE
|
# DO NOT EDIT THIS FILE
|
||||||
#
|
#
|
||||||
# It is automaticaly generated by $0 using templates from ${update_grub_dir}
|
# It is automaticaly generated by $0 using templates from ${update_grub_dir}
|
||||||
|
# It is automaticaly generated by $0 using templates from ${update_grub_dir}
|
||||||
|
# and settings from ${sysconfdir}/default/grub
|
||||||
#
|
#
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
export GRUB_DEVICE="`grub-probe --target=device ${grub_prefix}`"
|
|
||||||
export GRUB_DRIVE="`grub-probe --target=drive ${grub_prefix}`"
|
|
||||||
export GRUB_FS="`grub-probe --target=fs ${grub_prefix}`"
|
|
||||||
|
|
||||||
for i in ${update_grub_dir}/* ; do
|
for i in ${update_grub_dir}/* ; do
|
||||||
case $i in
|
case $i in
|
||||||
# emacsen backup files. FIXME: support other editors
|
# emacsen backup files. FIXME: support other editors
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue