2006-11-23 23:22:43 +00:00
|
|
|
#! @bash@/bin/sh -e
|
|
|
|
|
2006-12-10 22:29:44 +00:00
|
|
|
export PATH=/empty
|
|
|
|
for i in @path@; do PATH=$PATH:$i/bin; done
|
|
|
|
|
2006-11-23 23:22:43 +00:00
|
|
|
default=$1
|
|
|
|
if test -z "$1"; then
|
|
|
|
echo "Syntax: grub-menu-builder.sh <DEFAULT-CONFIG>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
target=/boot/grub/menu.lst
|
|
|
|
tmp=$target.tmp
|
|
|
|
|
|
|
|
cat > $tmp << GRUBEND
|
|
|
|
# Automatically generated. DO NOT EDIT THIS FILE!
|
|
|
|
default=0
|
|
|
|
timeout=5
|
|
|
|
GRUBEND
|
|
|
|
|
2007-02-09 16:19:29 +00:00
|
|
|
|
|
|
|
|
2006-11-23 23:22:43 +00:00
|
|
|
addEntry() {
|
2007-02-09 16:19:29 +00:00
|
|
|
local name="$1"
|
|
|
|
local path="$2"
|
2006-11-23 23:22:43 +00:00
|
|
|
|
2007-02-09 16:19:29 +00:00
|
|
|
if ! test -e $path/kernel -a -e $path/initrd; then
|
2006-12-11 17:36:57 +00:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2007-02-09 16:19:29 +00:00
|
|
|
local kernel=$(readlink -f $path/kernel)
|
|
|
|
local initrd=$(readlink -f $path/initrd)
|
|
|
|
|
|
|
|
if test -n "@copyKernels@"; then
|
|
|
|
local kernel2=/boot/kernels/$(echo $kernel | sed 's^/^-^g')
|
|
|
|
if ! test -e $kernel2; then
|
|
|
|
cp $kernel $kernel2
|
|
|
|
fi
|
|
|
|
kernel=$kernel2
|
|
|
|
|
|
|
|
local initrd2=/boot/kernels/$(echo $initrd | sed 's^/^-^g')
|
|
|
|
if ! test -e $initrd2; then
|
|
|
|
cp $initrd $initrd2
|
|
|
|
fi
|
|
|
|
initrd=$initrd2
|
|
|
|
fi
|
|
|
|
|
2006-11-23 23:22:43 +00:00
|
|
|
cat >> $tmp << GRUBEND
|
|
|
|
title $name
|
2007-03-20 13:01:53 +00:00
|
|
|
kernel $kernel systemConfig=$(readlink -f $path) init=$(readlink -f $path/init) $(cat $path/kernel-params)
|
2007-02-09 16:19:29 +00:00
|
|
|
initrd $initrd
|
2006-11-23 23:22:43 +00:00
|
|
|
GRUBEND
|
2007-02-09 16:19:29 +00:00
|
|
|
}
|
2006-11-23 23:22:43 +00:00
|
|
|
|
|
|
|
|
2007-02-09 16:19:29 +00:00
|
|
|
rm -rf /boot/kernels
|
|
|
|
if test -n "@copyKernels@"; then
|
|
|
|
mkdir -p /boot/kernels
|
|
|
|
fi
|
2006-11-23 23:22:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
if test -n "$tmp"; then
|
|
|
|
addEntry "NixOS - Default" $default
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Add all generations of the system profile to the menu, in reverse
|
|
|
|
# (most recent to least recent) order.
|
|
|
|
for generation in $(
|
|
|
|
(cd /nix/var/nix/profiles && ls -d system-*-link) \
|
|
|
|
| sed 's/system-\([0-9]\+\)-link/\1/' \
|
|
|
|
| sort -n -r); do
|
|
|
|
echo $generation
|
2006-11-24 00:00:32 +00:00
|
|
|
link=/nix/var/nix/profiles/system-$generation-link
|
|
|
|
date=$(stat --printf="%y\n" $link | sed 's/\..*//')
|
|
|
|
addEntry "NixOS - Configuration $generation ($date)" $link
|
2006-11-23 23:22:43 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
cp $tmp $target
|