diff --git a/bootstrapvz/common/assets/extlinux/boot.txt b/bootstrapvz/common/assets/extlinux/boot.txt new file mode 100644 index 0000000..ddef765 --- /dev/null +++ b/bootstrapvz/common/assets/extlinux/boot.txt @@ -0,0 +1 @@ +Wait 5 seconds or press ENTER to diff --git a/bootstrapvz/common/assets/extlinux/extlinux.conf b/bootstrapvz/common/assets/extlinux/extlinux.conf new file mode 100644 index 0000000..ca26700 --- /dev/null +++ b/bootstrapvz/common/assets/extlinux/extlinux.conf @@ -0,0 +1,17 @@ +default l0 +prompt 1 +timeout 50 + + +label l0 + menu label Debian GNU/Linux, kernel {kernel_version} + linux /boot/vmlinuz-{kernel_version} + append initrd=/boot/initrd.img-{kernel_version} root=UUID={UUID} ro quiet console=ttyS0 + +label l0r + menu label Debian GNU/Linux, kernel {kernel_version} (recovery mode) + linux /boot/vmlinuz-{kernel_version} + append initrd=/boot/initrd.img-{kernel_version} root=UUID={UUID} ro console=ttyS0 single + text help + This option boots the system into recovery mode (single-user) + endtext diff --git a/bootstrapvz/common/task_groups.py b/bootstrapvz/common/task_groups.py index 2efb409..d4417e9 100644 --- a/bootstrapvz/common/task_groups.py +++ b/bootstrapvz/common/task_groups.py @@ -134,19 +134,23 @@ locale_group = [locale.LocaleBootstrapPackage, def get_bootloader_group(manifest): + from bootstrapvz.common.tools import get_codename group = [] if manifest.system['bootloader'] == 'grub': group.extend([grub.AddGrubPackage, grub.ConfigureGrub]) - from bootstrapvz.common.tools import get_codename if get_codename(manifest.system['release']) in ['squeeze', 'wheezy']: group.append(grub.InstallGrub_1_99) else: group.append(grub.InstallGrub_2) if manifest.system['bootloader'] == 'extlinux': - group.extend([extlinux.AddExtlinuxPackage, - extlinux.ConfigureExtlinux, - extlinux.InstallExtlinux]) + group.append(extlinux.AddExtlinuxPackage) + if get_codename(manifest.system['release']) in ['squeeze', 'wheezy']: + group.extend([extlinux.ConfigureExtlinux, + extlinux.InstallExtlinux]) + else: + group.extend([extlinux.ConfigureExtlinuxJessie, + extlinux.InstallExtlinuxJessie]) return group diff --git a/bootstrapvz/common/tasks/extlinux.py b/bootstrapvz/common/tasks/extlinux.py index a050700..8c502d5 100644 --- a/bootstrapvz/common/tasks/extlinux.py +++ b/bootstrapvz/common/tasks/extlinux.py @@ -3,8 +3,9 @@ from .. import phases from ..tools import log_check_call import apt import filesystem +import kernel from bootstrapvz.base.fs import partitionmaps -import os.path +import os class AddExtlinuxPackage(Task): @@ -56,3 +57,52 @@ class InstallExtlinux(Task): '--install', '/boot/extlinux']) log_check_call(['chroot', info.root, 'extlinux-update']) + + +class ConfigureExtlinuxJessie(Task): + description = 'Configuring extlinux' + phase = phases.system_modification + + @classmethod + def run(cls, info): + extlinux_path = os.path.join(info.root, 'boot/extlinux') + os.mkdir(extlinux_path) + + from . import assets + extlinux_assets_path = os.path.join(assets, 'extlinux') + extlinux_tpl_path = os.path.join(extlinux_assets_path, 'extlinux.conf') + with open(extlinux_tpl_path) as extlinux_tpl: + extlinux_config = extlinux_tpl.read() + + root_uuid = info.volume.partition_map.root.get_uuid() + extlinux_config = extlinux_config.format(kernel_version=info.kernel_version, UUID=root_uuid) + extlinux_config_path = os.path.join(extlinux_path, 'extlinux.conf') + with open(extlinux_config_path, 'w') as extlinux_conf_handle: + extlinux_conf_handle.write(extlinux_config) + from shutil import copy + # Copy the boot message + boot_txt_path = os.path.join(extlinux_assets_path, 'boot.txt') + copy(boot_txt_path, os.path.join(extlinux_path, 'boot.txt')) + + +class InstallExtlinuxJessie(Task): + description = 'Installing extlinux' + phase = phases.system_modification + predecessors = [filesystem.FStab, ConfigureExtlinuxJessie] + # Make sure the kernel image is updated after we have installed the bootloader + successors = [kernel.UpdateInitramfs] + + @classmethod + def run(cls, info): + if isinstance(info.volume.partition_map, partitionmaps.gpt.GPTPartitionMap): + # Yeah, somebody saw it fit to uppercase that folder in jessie. Why? BECAUSE + bootloader = '/usr/lib/EXTLINUX/gptmbr.bin' + else: + bootloader = '/usr/lib/EXTLINUX/mbr.bin' + log_check_call(['chroot', info.root, + 'dd', 'bs=440', 'count=1', + 'if=' + bootloader, + 'of=' + info.volume.device_path]) + log_check_call(['chroot', info.root, + 'extlinux', + '--install', '/boot/extlinux'])