Differentiate installation of grub 1.99 and grub 2

This commit is contained in:
Anders Ingemann 2014-07-09 21:20:26 +02:00
parent 1dc9ae18db
commit e4a9cc837a
5 changed files with 35 additions and 18 deletions

View file

@ -30,7 +30,7 @@ def get_standard_groups(manifest):
group.extend(get_apt_group(manifest))
group.extend(security_group)
group.extend(locale_group)
group.extend(bootloader_group.get(manifest.system['bootloader'], []))
group.extend(get_bootloader_group(manifest))
group.extend(cleanup_group)
return group
@ -126,9 +126,20 @@ locale_group = [locale.LocaleBootstrapPackage,
]
bootloader_group = {'grub': [boot.AddGrubPackage, boot.ConfigureGrub, boot.InstallGrub],
'extlinux': [boot.AddExtlinuxPackage, boot.InstallExtLinux],
}
def get_bootloader_group(manifest):
group = []
if manifest.system['bootloader'] == 'grub':
group.extend([boot.AddGrubPackage,
boot.ConfigureGrub])
from bootstrapvz.common.tools import get_codename
if get_codename(manifest.system['release']) in ['squeeze', 'wheezy']:
group.append(boot.InstallGrub_1_99)
else:
group.append(boot.InstallGrub_2)
if manifest.system['bootloader'] == 'extlinux':
group.extend([boot.AddExtlinuxPackage,
boot.InstallExtLinux])
return group
def get_fs_specific_group(manifest):

View file

@ -1,5 +1,6 @@
from bootstrapvz.base import Task
from .. import phases
from ..tools import log_check_call
import apt
import filesystem
from bootstrapvz.base.fs import partitionmaps
@ -58,18 +59,13 @@ class ConfigureGrub(Task):
'GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"')
class InstallGrub(Task):
description = 'Installing grub'
class InstallGrub_1_99(Task):
description = 'Installing grub 1.99'
phase = phases.system_modification
predecessors = [filesystem.FStab]
@classmethod
def run(cls, info):
from ..fs.loopbackvolume import LoopbackVolume
from ..tools import log_check_call
boot_dir = os.path.join(info.root, 'boot')
grub_dir = os.path.join(boot_dir, 'grub')
from ..fs import remount
p_map = info.volume.partition_map
@ -87,11 +83,12 @@ class InstallGrub(Task):
# GRUB cannot deal with installing to loopback devices
# so we fake a real harddisk with dmsetup.
# Guide here: http://ebroder.net/2009/08/04/installing-grub-onto-a-disk-image/
from ..fs.loopbackvolume import LoopbackVolume
if isinstance(info.volume, LoopbackVolume):
remount(info.volume, link_fn)
try:
[device_path] = log_check_call(['readlink', '-f', info.volume.device_path])
device_map_path = os.path.join(grub_dir, 'device.map')
device_map_path = os.path.join(info.root, 'boot/grub/device.map')
partition_prefix = 'msdos'
if isinstance(p_map, partitionmaps.gpt.GPTPartitionMap):
partition_prefix = 'gpt'
@ -105,8 +102,7 @@ class InstallGrub(Task):
idx=idx + 1))
# Install grub
log_check_call(['chroot', info.root,
'grub-install', device_path])
log_check_call(['chroot', info.root, 'grub-install', device_path])
log_check_call(['chroot', info.root, 'update-grub'])
except Exception as e:
if isinstance(info.volume, LoopbackVolume):
@ -117,6 +113,17 @@ class InstallGrub(Task):
remount(info.volume, unlink_fn)
class InstallGrub_2(Task):
description = 'Installing grub 2'
phase = phases.system_modification
predecessors = [filesystem.FStab]
@classmethod
def run(cls, info):
log_check_call(['chroot', info.root, 'grub-install', info.volume.device_path])
log_check_call(['chroot', info.root, 'update-grub'])
class AddExtlinuxPackage(Task):
description = 'Adding extlinux package'
phase = phases.preparation
@ -136,7 +143,6 @@ class InstallExtLinux(Task):
@classmethod
def run(cls, info):
from ..tools import log_check_call
if isinstance(info.volume.partition_map, partitionmaps.gpt.GPTPartitionMap):
bootloader = '/usr/lib/syslinux/gptmbr.bin'
else:

View file

@ -52,7 +52,7 @@ class AddDockerInit(Task):
class EnableMemoryCgroup(Task):
description = 'Change grub configuration to enable the memory cgroup'
phase = phases.system_modification
successors = [boot.InstallGrub]
successors = [boot.InstallGrub_1_99, boot.InstallGrub_2]
predecessors = [boot.ConfigureGrub, gceboot.ConfigureGrub]
@classmethod

View file

@ -6,7 +6,7 @@ from bootstrapvz.common.tasks import boot
class ConfigureGrub(Task):
description = 'Change grub configuration to allow for ttyS0 output'
phase = phases.system_modification
successors = [boot.InstallGrub]
successors = [boot.InstallGrub_1_99, boot.InstallGrub_2]
@classmethod
def run(cls, info):

View file

@ -7,7 +7,7 @@ import os.path
class ConfigureGrub(Task):
description = 'Change grub configuration to allow for ttyS0 output'
phase = phases.system_modification
successors = [boot.InstallGrub]
successors = [boot.InstallGrub_1_99, boot.InstallGrub_2]
@classmethod
def run(cls, info):