mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Differentiate installation of grub 1.99 and grub 2
This commit is contained in:
parent
1dc9ae18db
commit
e4a9cc837a
5 changed files with 35 additions and 18 deletions
|
@ -30,7 +30,7 @@ def get_standard_groups(manifest):
|
||||||
group.extend(get_apt_group(manifest))
|
group.extend(get_apt_group(manifest))
|
||||||
group.extend(security_group)
|
group.extend(security_group)
|
||||||
group.extend(locale_group)
|
group.extend(locale_group)
|
||||||
group.extend(bootloader_group.get(manifest.system['bootloader'], []))
|
group.extend(get_bootloader_group(manifest))
|
||||||
group.extend(cleanup_group)
|
group.extend(cleanup_group)
|
||||||
return group
|
return group
|
||||||
|
|
||||||
|
@ -126,9 +126,20 @@ locale_group = [locale.LocaleBootstrapPackage,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
bootloader_group = {'grub': [boot.AddGrubPackage, boot.ConfigureGrub, boot.InstallGrub],
|
def get_bootloader_group(manifest):
|
||||||
'extlinux': [boot.AddExtlinuxPackage, boot.InstallExtLinux],
|
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):
|
def get_fs_specific_group(manifest):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from bootstrapvz.base import Task
|
from bootstrapvz.base import Task
|
||||||
from .. import phases
|
from .. import phases
|
||||||
|
from ..tools import log_check_call
|
||||||
import apt
|
import apt
|
||||||
import filesystem
|
import filesystem
|
||||||
from bootstrapvz.base.fs import partitionmaps
|
from bootstrapvz.base.fs import partitionmaps
|
||||||
|
@ -58,18 +59,13 @@ class ConfigureGrub(Task):
|
||||||
'GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"')
|
'GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"')
|
||||||
|
|
||||||
|
|
||||||
class InstallGrub(Task):
|
class InstallGrub_1_99(Task):
|
||||||
description = 'Installing grub'
|
description = 'Installing grub 1.99'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
predecessors = [filesystem.FStab]
|
predecessors = [filesystem.FStab]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
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
|
from ..fs import remount
|
||||||
p_map = info.volume.partition_map
|
p_map = info.volume.partition_map
|
||||||
|
@ -87,11 +83,12 @@ class InstallGrub(Task):
|
||||||
# GRUB cannot deal with installing to loopback devices
|
# GRUB cannot deal with installing to loopback devices
|
||||||
# so we fake a real harddisk with dmsetup.
|
# so we fake a real harddisk with dmsetup.
|
||||||
# Guide here: http://ebroder.net/2009/08/04/installing-grub-onto-a-disk-image/
|
# Guide here: http://ebroder.net/2009/08/04/installing-grub-onto-a-disk-image/
|
||||||
|
from ..fs.loopbackvolume import LoopbackVolume
|
||||||
if isinstance(info.volume, LoopbackVolume):
|
if isinstance(info.volume, LoopbackVolume):
|
||||||
remount(info.volume, link_fn)
|
remount(info.volume, link_fn)
|
||||||
try:
|
try:
|
||||||
[device_path] = log_check_call(['readlink', '-f', info.volume.device_path])
|
[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'
|
partition_prefix = 'msdos'
|
||||||
if isinstance(p_map, partitionmaps.gpt.GPTPartitionMap):
|
if isinstance(p_map, partitionmaps.gpt.GPTPartitionMap):
|
||||||
partition_prefix = 'gpt'
|
partition_prefix = 'gpt'
|
||||||
|
@ -105,8 +102,7 @@ class InstallGrub(Task):
|
||||||
idx=idx + 1))
|
idx=idx + 1))
|
||||||
|
|
||||||
# Install grub
|
# Install grub
|
||||||
log_check_call(['chroot', info.root,
|
log_check_call(['chroot', info.root, 'grub-install', device_path])
|
||||||
'grub-install', device_path])
|
|
||||||
log_check_call(['chroot', info.root, 'update-grub'])
|
log_check_call(['chroot', info.root, 'update-grub'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(info.volume, LoopbackVolume):
|
if isinstance(info.volume, LoopbackVolume):
|
||||||
|
@ -117,6 +113,17 @@ class InstallGrub(Task):
|
||||||
remount(info.volume, unlink_fn)
|
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):
|
class AddExtlinuxPackage(Task):
|
||||||
description = 'Adding extlinux package'
|
description = 'Adding extlinux package'
|
||||||
phase = phases.preparation
|
phase = phases.preparation
|
||||||
|
@ -136,7 +143,6 @@ class InstallExtLinux(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from ..tools import log_check_call
|
|
||||||
if isinstance(info.volume.partition_map, partitionmaps.gpt.GPTPartitionMap):
|
if isinstance(info.volume.partition_map, partitionmaps.gpt.GPTPartitionMap):
|
||||||
bootloader = '/usr/lib/syslinux/gptmbr.bin'
|
bootloader = '/usr/lib/syslinux/gptmbr.bin'
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -52,7 +52,7 @@ class AddDockerInit(Task):
|
||||||
class EnableMemoryCgroup(Task):
|
class EnableMemoryCgroup(Task):
|
||||||
description = 'Change grub configuration to enable the memory cgroup'
|
description = 'Change grub configuration to enable the memory cgroup'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
successors = [boot.InstallGrub]
|
successors = [boot.InstallGrub_1_99, boot.InstallGrub_2]
|
||||||
predecessors = [boot.ConfigureGrub, gceboot.ConfigureGrub]
|
predecessors = [boot.ConfigureGrub, gceboot.ConfigureGrub]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -6,7 +6,7 @@ from bootstrapvz.common.tasks import boot
|
||||||
class ConfigureGrub(Task):
|
class ConfigureGrub(Task):
|
||||||
description = 'Change grub configuration to allow for ttyS0 output'
|
description = 'Change grub configuration to allow for ttyS0 output'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
successors = [boot.InstallGrub]
|
successors = [boot.InstallGrub_1_99, boot.InstallGrub_2]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
|
|
|
@ -7,7 +7,7 @@ import os.path
|
||||||
class ConfigureGrub(Task):
|
class ConfigureGrub(Task):
|
||||||
description = 'Change grub configuration to allow for ttyS0 output'
|
description = 'Change grub configuration to allow for ttyS0 output'
|
||||||
phase = phases.system_modification
|
phase = phases.system_modification
|
||||||
successors = [boot.InstallGrub]
|
successors = [boot.InstallGrub_1_99, boot.InstallGrub_2]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
|
|
Loading…
Add table
Reference in a new issue