Merge branch 'grub2' into merge_grub2

Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
Ryan Harper 2015-07-22 09:13:10 -05:00
commit 09fdf0033f
5 changed files with 97 additions and 19 deletions

View File

@ -9,6 +9,7 @@ TOPDIR=$(shell pwd)
STREAM=daily
RELEASE=wily
ARCH=amd64
BOOTLOADER=grub2
INSTALLIMG=ubuntu-server-${STREAM}-${RELEASE}-${ARCH}-installer.img
INSTALLER_RESOURCES += $(shell find installer/resources -type f)
.PHONY: run clean
@ -34,7 +35,7 @@ unit:
python3 -m "nose" -v --nologcapture --with-coverage $(PYTHONSRC)/tests/
installer/$(INSTALLIMG): installer/geninstaller installer/runinstaller $(INSTALLER_RESOURCES)
(cd installer && ./geninstaller -v -r $(RELEASE) -a $(ARCH) -s $(STREAM))
(cd installer && ./geninstaller -v -r $(RELEASE) -a $(ARCH) -s $(STREAM) -b $(BOOTLOADER))
echo $(INSTALLER_RESOURCES)
installer: installer/$(INSTALLIMG)

View File

@ -15,10 +15,10 @@ else
fi
if tail -n 1 $OUTPUT | grep -q "$INSTALL_OK"; then
echo "Curtin installed OK, shutting down (Press Any Key)"
echo "Curtin installed OK, rebooting (Press Any Key)"
read a
echo "Shutting down after running $CURTIN $CMD"
telinit 0
echo "Rebooting down after running $CURTIN $CMD"
telinit 6
else
echo "Error running curting, exiting..."
exit 1;

View File

@ -355,14 +355,16 @@ generate_seed() {
generate_img() {
_RETVAL=""
[ $# -lt 2 ] && {
[ $# -lt 3 ] && {
log "ERROR: not enough arguments passed to $FUNCNAME";
return 1;
}
local dldir=${1};
local cachedir=${2};
local bootloader=${3};
local extlinux_conf=${TOPDIR}/resources/menu/extlinux-menu.conf
local grub_conf=${TOPDIR}/resources/grub/grub.cfg
local gptmbr=$(dpkg -L syslinux-common | grep \/gptmbr.bin | grep -v efi)
local installimg=${cachedir}/installer.img
local mnt=${cachedir}/mnt
@ -386,15 +388,21 @@ generate_img() {
return 1;
}
[ -z "$gptmbr" ] && {
log "ERROR: failed to find GPT MBR record on host";
if [ "${bootloader}" == "syslinux" ]; then
[ -z "$gptmbr" ] && {
log "ERROR: failed to find GPT MBR record on host";
return 1;
}
log "Embedding bootloader"
dd bs=440 conv=notrunc count=1 if=$gptmbr of=$installimg || {
log "Failed to embed bootloader into $installimg";
return 1;
}
elif [ "${bootloader}" != "grub2" ]; then
log "Bootloader ${bootloader} not supported, cannot install"
usage;
return 1;
}
log "Embedding bootloader"
dd bs=440 conv=notrunc count=1 if=$gptmbr of=$installimg || {
log "Failed to embed bootloader into $installimg";
return 1;
}
fi
log "Syncing rootfs into install image"
local kpartx_ret=$(sudo kpartx -va $installimg)
@ -429,14 +437,27 @@ generate_img() {
log "Installing bootloader configuration"
set +x
sudo mkdir -p ${mnt}/proc
sudo mkdir -p ${mnt}/sys
sudo mkdir -p ${mnt}/dev
sudo mount none -t proc ${mnt}/proc &&
sudo mount none -t sysfs ${mnt}/sys &&
sudo mount -o bind /dev ${mnt}/dev &&
sudo mkdir -p ${mnt}/boot/extlinux &&
sudo extlinux --install ${mnt}/boot/extlinux &&
sudo cp -av ${syslinux_path}/*.c32 ${mnt}/boot/extlinux &&
sudo cp -av ${splash} ${mnt}/boot/extlinux &&
cat ${extlinux_conf} | sudo tee ${mnt}/boot/extlinux/extlinux.conf &&
if [ "${bootloader}" == "syslinux" ]; then
sudo mkdir -p ${mnt}/boot/extlinux &&
sudo extlinux --install ${mnt}/boot/extlinux &&
sudo cp -av ${syslinux_path}/*.c32 ${mnt}/boot/extlinux &&
sudo cp -av ${splash} ${mnt}/boot/extlinux &&
cat ${extlinux_conf} | sudo tee ${mnt}/boot/extlinux/extlinux.conf
else
log "Installing grub2"
sudo mkdir -p ${mnt}/boot/grub &&
sudo grub-install --boot-directory=${mnt}/boot $LOOPDEV --force &&
sudo cp -av ${splash} ${mnt}/boot/grub &&
cat ${grub_conf} | sudo tee ${mnt}/boot/grub/grub.cfg
fi
sudo mkdir -p ${mnt}/var/lib/cloud/seed &&
sudo cp -a ${seed} ${mnt}/var/lib/cloud/seed && sync || {
log "Failed to install bootloader and configuration";
@ -521,7 +542,7 @@ main() {
return 1;
}
generate_img ${DLDIR} $CACHEDIR || {
generate_img ${DLDIR} $CACHEDIR $BOOTLOADER || {
return 1;
}
INSTALLIMG=${_RETVAL}

View File

@ -0,0 +1,56 @@
function scan_disk {
# Scan the disk and create a menuentry to boot it if it contains a linux
# install
disk=$1
if [ -e $disk/etc/lsb-release ]; then
probe -s uuid -u $disk
source $disk/etc/lsb-release
menuentry "$DISTRIB_ID $DISTRIB_RELEASE $disk" $disk $uuid {
set root=$2
linux /vmlinuz root=UUID=$3
initrd /initrd.img
}
fi
}
# Load modules
insmod all_video
insmod gfxterm
insmod png
insmod regexp
insmod part_gpt
insmod part_msdos
# Set up display
set gfxmode=auto
terminal_output gfxterm
terminal_input console
# Try to set up serial
serial --unit=0 --speed=9600
terminal_output --append serial
terminal_input --append serial
# Set up appearance
background_image /boot/grub/splash.png
loadfont /boot/grub/unicode.pf2
# Scan all disks except for current root
for disk in (*); do
if [ "$disk" != "(${root})" ]; then
scan_disk $disk
fi
done
# Create menuentry for installer
menuentry "Boot Installer - Graphical Console" {
linux /vmlinuz ip=dhcp ro root=LABEL=cloudimg-rootfs overlayroot=tmpfs console=ttyS0 console=tty0 quiet splash
initrd /initrd.img
}
menuentry "Boot Installer - Serial Console" {
linux /vmlinuz ip=dhcp ro root=LABEL=cloudimg-rootfs overlayroot=tmpfs console=tty0 console=ttyS0
initrd /initrd.img
}
set default=0
set timeout=50

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB