Extlinux support

The bootloader is now specified in the manifest
This commit is contained in:
Anders Ingemann 2013-12-30 12:14:43 +01:00
parent 68368b1782
commit 44f3296426
17 changed files with 69 additions and 14 deletions

View file

@ -20,11 +20,12 @@
"properties": {
"release": { "enum": ["wheezy"] },
"architecture": { "enum": ["i386", "amd64"] },
"bootloader": { "enum": ["pvgrub", "grub", "extlinux"] },
"timezone": { "type": "string" },
"locale": { "type": "string" },
"charmap": { "type": "string" }
},
"required": ["release", "architecture", "timezone", "locale", "charmap"]
"required": ["release", "architecture", "bootloader", "timezone", "locale", "charmap"]
},
"packages": {
"type": "object",

View file

@ -1,6 +1,7 @@
from common.tasks import workspace
from common.tasks import packages
from common.tasks import host
from common.tasks import boot
from common.tasks import bootstrap
from common.tasks import volume
from common.tasks import filesystem
@ -62,6 +63,11 @@ locale_set = [locale.LocaleBootstrapPackage,
]
bootloader_set = {'grub': [boot.AddGrubPackage, boot.InstallGrub],
'extlinux': [boot.AddExtlinuxPackage, boot.InstallExtLinux],
}
def get_fs_specific_set(partitions):
task_set = {'ext2': [filesystem.TuneVolumeFS],
'ext3': [filesystem.TuneVolumeFS],

View file

@ -30,6 +30,15 @@ class DisableGetTTYs(Task):
sed_i(inittab_path, '^' + i + ttyx + i, '#' + i + ttyx + i)
class AddGrubPackage(Task):
description = 'Adding grub package'
phase = phases.preparation
predecessors = [apt.AddDefaultSources]
def run(self, info):
info.packages.add('grub-pc')
class InstallGrub(Task):
description = 'Installing grub'
phase = phases.system_modification
@ -91,3 +100,24 @@ class InstallGrub(Task):
if isinstance(info.volume, LoopbackVolume):
remount(info.volume, unlink_fn)
class AddExtlinuxPackage(Task):
description = 'Adding extlinux package'
phase = phases.preparation
predecessors = [apt.AddDefaultSources]
def run(self, info):
info.packages.add('extlinux')
class InstallExtLinux(Task):
description = 'Installing extlinux'
phase = phases.system_modification
predecessors = [apt.AptUpgrade]
def run(self, info):
from common.tools import log_check_call
log_check_call(['/usr/sbin/chroot', info.root,
'/usr/bin/extlinux',
'--install', '/boot'])

View file

@ -16,6 +16,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "extlinux",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -16,6 +16,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "pvgrub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -16,6 +16,7 @@
"system": {
"release": "wheezy",
"architecture": "i386",
"bootloader": "pvgrub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -16,6 +16,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "pvgrub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -16,6 +16,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "pvgrub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -20,6 +20,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "pvgrub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -11,6 +11,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "grub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -11,6 +11,7 @@
"system": {
"release": "wheezy",
"architecture": "amd64",
"bootloader": "grub",
"timezone": "UTC",
"locale": "en_US",
"charmap": "UTF-8"

View file

@ -67,10 +67,11 @@ def resolve_tasks(tasklist, manifest):
tasks.ami.RegisterAMI)
if manifest.virtualization == 'pvm':
tasklist.add(tasks.boot.ConfigurePVGrub)
if manifest.system['bootloader'] == 'pvgrub':
tasklist.add(boot.AddGrubPackage, tasks.boot.ConfigurePVGrub)
else:
tasklist.add(boot.InstallGrub)
from common.task_sets import bootloader_set
tasklist.add(*bootloader_set.get(manifest.system['bootloader']))
backing_specific_tasks = {'ebs': [tasks.ebs.Create,
tasks.ebs.Attach,

View file

@ -6,8 +6,7 @@ class Manifest(base.Manifest):
def validate(self, data):
super(Manifest, self).validate(data)
from os import path
schema_path = path.join(path.dirname(__file__), 'manifest-schema.json')
self.schema_validate(data, schema_path)
self.schema_validate(data, path.join(path.dirname(__file__), 'manifest-schema.json'))
if data['volume']['backing'] == 'ebs':
volume_size = self._calculate_volume_size(data['volume']['partitions'])
if volume_size % 1024 != 0:
@ -15,8 +14,12 @@ class Manifest(base.Manifest):
'(MBR partitioned volumes are 1MB larger than specified, for the post-mbr gap)')
raise ManifestError(msg, self)
else:
schema_path = path.join(path.dirname(__file__), 'manifest-schema-s3.json')
self.schema_validate(data, schema_path)
self.schema_validate(data, path.join(path.dirname(__file__), 'manifest-schema-s3.json'))
if data['virtualization'] == 'pvm' and data['system']['bootloader'] != 'pvgrub':
raise ManifestError('Paravirtualized AMIs only support pvgrub as a bootloader', self)
if data['virtualization'] == 'hvm' and data['system']['bootloader'] != 'extlinux':
raise ManifestError('HVM AMIs only support extlinux as a bootloader', self)
def parse(self, data):
super(Manifest, self).parse(data)

View file

@ -12,7 +12,6 @@ class DefaultPackages(Task):
info.packages.add('openssh-server')
info.packages.add('file') # Needed for the init scripts
info.packages.add('dhcpcd') # isc-dhcp-client doesn't work properly with ec2
info.packages.add('grub-pc')
info.exclude_packages.add('isc-dhcp-client')
info.exclude_packages.add('isc-dhcp-common')

View file

@ -5,7 +5,6 @@ from common.tasks import loopback
from common.tasks import partitioning
from common.tasks import filesystem
from common.tasks import bootstrap
from common.tasks import boot
from common.tasks import security
from common.tasks import network
from common.tasks import initd
@ -29,6 +28,9 @@ def resolve_tasks(tasklist, manifest):
tasklist.add(*apt_set)
tasklist.add(*locale_set)
from common.task_sets import bootloader_set
tasklist.add(*bootloader_set.get(manifest.system['bootloader']))
if manifest.volume['partitions']['type'] != 'none':
from common.task_sets import partitioning_set
tasklist.add(*partitioning_set)
@ -37,7 +39,6 @@ def resolve_tasks(tasklist, manifest):
loopback.Create,
boot.InstallGrub,
security.EnableShadowConfig,
network.RemoveDNSInfo,
network.ConfigureNetworkIF,

View file

@ -11,6 +11,15 @@
}
}
},
"system": {
"type": "object",
"properties": {
"bootloader": {
"type": "string",
"enum": ["grub"]
}
}
},
"volume": {
"type": "object",
"properties": {

View file

@ -9,9 +9,6 @@ class DefaultPackages(Task):
predecessors = [apt.AddDefaultSources]
def run(self, info):
# Add some basic packages we are going to need
info.packages.add('grub2')
kernels = {'amd64': 'linux-image-amd64',
'i386': 'linux-image-686', }
info.packages.add(kernels.get(info.manifest.system['architecture']))