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>
|
||||
|
||||
* 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
|
||||
cat << EOF
|
||||
font /boot/grub/unifont.pff
|
||||
set gfxmode=640x480x32
|
||||
|
||||
font ${GRUB_DRIVE_BOOT_GRUB}/unifont.pff
|
||||
set gfxmode=800x600x16
|
||||
insmod gfxterm
|
||||
insmod vbe
|
||||
terminal gfxterm
|
||||
|
|
|
@ -23,11 +23,19 @@ else
|
|||
OS="${GRUB_DISTRIBUTOR} GNU/Hurd"
|
||||
fi
|
||||
|
||||
at_least_one=false
|
||||
all_of_them=true
|
||||
|
||||
# FIXME: add l4 here?
|
||||
kernel=
|
||||
for i in /boot/gnumach.gz /boot/gnumach ; do
|
||||
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
|
||||
done
|
||||
|
||||
|
@ -37,10 +45,8 @@ case "${GRUB_FS}" in
|
|||
*) hurd_fs="${GRUB_FS}fs" ;;
|
||||
esac
|
||||
|
||||
at_least_one=false
|
||||
all_of_them=true
|
||||
for i in "${kernel}" /hurd/${hurd_fs}.static /hurd/exec ; do
|
||||
if test -e "$i" ; then
|
||||
for i in /hurd/${hurd_fs}.static /hurd/exec ; do
|
||||
if test -e "$i" ; then
|
||||
echo "Found Hurd module: $i" >&2
|
||||
at_least_one=true
|
||||
else
|
||||
|
|
|
@ -23,22 +23,76 @@ else
|
|||
OS="${GRUB_DISTRIBUTOR} GNU/Linux"
|
||||
fi
|
||||
|
||||
|
||||
for linux in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
|
||||
if test -e ${linux} ; then : ; else
|
||||
continue
|
||||
test_numeric ()
|
||||
{
|
||||
local a=$1
|
||||
local cmp=$2
|
||||
local b=$3
|
||||
if [ "$a" = "$b" ] ; then
|
||||
case $cmp in
|
||||
ge|eq|le) return 0 ;;
|
||||
gt|lt) return 1 ;;
|
||||
esac
|
||||
fi
|
||||
echo "Found linux image: $linux" >&2
|
||||
version=`echo $linux | sed -e "s,.*/[^0-9]*-,,g"`
|
||||
basedir=`echo $linux | sed -e "s,/[^/]*$,,g"`
|
||||
if [ "$cmp" = "lt" ] ; then
|
||||
c=$a
|
||||
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
|
||||
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
|
||||
if test -e ${basedir}/initrd.img-${version} ; then
|
||||
echo "Found initrd image: ${basedir}/initrd.img-${version}" >&2
|
||||
if test -e ${dirname}/initrd.img-${version} ; then
|
||||
echo "Found initrd image: ${dirname}/initrd.img-${version}" >&2
|
||||
cat << EOF
|
||||
initrd ${basedir}/initrd.img-${version}
|
||||
initrd ${grub_dirname}/initrd.img-${version}
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
|
@ -46,14 +100,15 @@ EOF
|
|||
EOF
|
||||
cat << EOF
|
||||
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
|
||||
if test -e ${basedir}/initrd.img-${version} ; then
|
||||
if test -e ${dirname}/initrd.img-${version} ; then
|
||||
cat << EOF
|
||||
initrd ${basedir}/initrd.img-${version}
|
||||
initrd ${grub_dirname}/initrd.img-${version}
|
||||
EOF
|
||||
fi
|
||||
cat << EOF
|
||||
}
|
||||
EOF
|
||||
list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
|
||||
done
|
||||
|
|
|
@ -65,13 +65,44 @@ if test -e ${grub_prefix}/device.map ; then : ; else
|
|||
grub-mkdevicemap
|
||||
fi
|
||||
|
||||
exec > ${grub_cfg}.new
|
||||
chmod 444 ${grub_cfg}.new
|
||||
# Device containing our userland. Typicaly used for root= parameter.
|
||||
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
|
||||
. ${sysconfdir}/default/grub
|
||||
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
|
||||
|
||||
cat << EOF
|
||||
|
@ -79,13 +110,11 @@ cat << EOF
|
|||
# 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}
|
||||
# and settings from ${sysconfdir}/default/grub
|
||||
#
|
||||
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
|
||||
case $i in
|
||||
# emacsen backup files. FIXME: support other editors
|
||||
|
|
Loading…
Reference in a new issue