------------------------------------------------------------ revno: 47 fixes bug(s): https://launchpad.net/bugs/605961 committer: Scott Moser branch nick: maverick timestamp: Thu 2010-07-15 13:41:22 -0400 message: grub-legacy-ec2: add grub-set-default functionality (LP: #605961) diff: === modified file 'debian/changelog' --- debian/changelog 2010-07-15 14:30:33 +0000 +++ debian/changelog 2010-07-15 17:41:22 +0000 @@ -4,8 +4,9 @@ - add code to stop use of 'uuid' grub syntax - change fallback grub device from (hd0,0) to (hd0) - change timeout in menu.lst to 0 + * grub-legacy-ec2: add grub-set-default functionality (LP: #605961) - -- Scott Moser Wed, 14 Jul 2010 10:22:27 -0400 + -- Scott Moser Thu, 15 Jul 2010 13:07:01 -0400 cloud-init (0.5.12-0ubuntu7) maverick; urgency=low === modified file 'debian/grub-legacy-ec2.install' --- debian/grub-legacy-ec2.install 2010-07-09 17:45:16 +0000 +++ debian/grub-legacy-ec2.install 2010-07-15 17:41:22 +0000 @@ -1,3 +1,5 @@ usr/sbin/update-grub-legacy-ec2 +usr/sbin/grub-set-default-legacy-ec2 +usr/sbin/grub-set-default etc/kernel/postinst.d/x-grub-legacy-ec2 etc/kernel/postrm.d/x-grub-legacy-ec2 === modified file 'debian/grub-legacy-ec2.postrm' --- debian/grub-legacy-ec2.postrm 2010-07-09 18:25:15 +0000 +++ debian/grub-legacy-ec2.postrm 2010-07-15 17:41:22 +0000 @@ -10,4 +10,7 @@ fi fi +dpkg-divert --package grub-legacy-ec2 --remove --rename --divert \ + /usr/sbin/grub-set-default.real /usr/sbin/grub-set-default + #DEBHELPER# === added file 'debian/grub-legacy-ec2.preinst' --- debian/grub-legacy-ec2.preinst 1970-01-01 00:00:00 +0000 +++ debian/grub-legacy-ec2.preinst 2010-07-15 17:41:22 +0000 @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +dpkg-divert --package grub-legacy-ec2 --rename --divert \ + /usr/sbin/grub-set-default.real --add /usr/sbin/grub-set-default + +#DEBHELPER# === added file 'debian/grub-set-default' --- debian/grub-set-default 1970-01-01 00:00:00 +0000 +++ debian/grub-set-default 2010-07-15 17:41:22 +0000 @@ -0,0 +1,38 @@ +#!/bin/sh + +diverted=/usr/sbin/grub-set-default.real +legacy_ec2=/usr/sbin/grub-set-default-legacy-ec2 +normal=/usr/sbin/grub-set-default + +warn() { echo "WARNING:" "$@" 1>&2; } +Usage() { + cat <. +EOF +} + +# Check the arguments. +for option in "$@"; do + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "grub-set-default (GNU GRUB ${VERSION})" + exit 0 ;; + --root-directory=*) + rootdir=`echo "$option" | sed 's/--root-directory=//'` ;; + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if test "x$entry" != x; then + echo "More than one entries?" 1>&2 + usage + exit 1 + fi + # We don't care about what the user specified actually. + entry="${option}" ;; + esac +done + +if test "x$entry" = x; then + echo "entry not specified." 1>&2 + usage + exit 1 +fi + +find_grub_dir () +{ + echo -n "Searching for GRUB installation directory ... " >&2 + + for d in $grub_dirs ; do + if [ -d "$d" ] ; then + grub_dir="$d" + break + fi + done + + if [ -z "$grub_dir" ] ; then + abort "No GRUB directory found.\n###" + else + echo "found: $grub_dir" >&2 + fi + + echo $grub_dir +} + +grub_dirs="/boot/grub /boot/boot/grub" + +# Determine the GRUB directory. This is different among OSes. +# if rootdir has been informed use it or find grubdir otherwise +if [ -n "${rootdir}" ]; then + grubdir=${rootdir}/boot/grub + if test -d ${grubdir}; then + : + else + grubdir=${rootdir}/grub + if test -d ${grubdir}; then + : + else + echo "No GRUB directory found under ${rootdir}/" 1>&2 + exit 1 + fi + fi +else + grubdir=$(find_grub_dir) +fi + +file=${grubdir}/default +if test -f ${file}; then + chmod 0600 ${file} + rm -f ${file} +fi +cat < $file +$entry +# +# +# +# +# +# +# +# +# +# +# WARNING: If you want to edit this file directly, do not remove any line +# from this file, including this warning. Using \`grub-set-default\' is +# strongly recommended. +EOF + +# Bye. +exit 0 === modified file 'debian/rules' --- debian/rules 2010-07-12 16:13:56 +0000 +++ debian/rules 2010-07-15 17:41:22 +0000 @@ -29,6 +29,8 @@ d=$(DEB_DESTDIR)/etc/kernel/$${khook}.d; \ install -d "$${d}" && \ install -m 0755 "debian/grub-legacy-ec2.kernel-$${khook}" "$${d}/x-grub-legacy-ec2" || exit 1; done + install -m 0755 debian/grub-set-default-legacy-ec2 $(DEB_DESTDIR)/usr/sbin + install -m 0755 debian/grub-set-default $(DEB_DESTDIR)/usr/sbin # You only need to run this immediately after checking out the package from # revision control.