File: grub.py

package info (click to toggle)
python3-dmm 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 540 kB
  • sloc: python: 441; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
grub functions for for dmm.
"""

import os
from command_runner import command_runner

def grub_install(chroot, platform):
    """
    Install an appropriate grub version
    """
    ecode, result = command_runner("chroot %s apt-get -y -qq install grub-%s" % (chroot, platform))
    ecode, result = command_runner("chroot %s update-grub" % chroot)
    if platform == "efi":
        ecode, result = command_runner("chroot %s grub-install --target=x86_64-efi" % chroot)
    # hmm what happens if we have biosboot?


def recipe_run(config, globalconf):
    """
    Perform actions for grub module
    """
    if config['action'] == "mkrescue":
        return os.system('grub-mkrescue --modules="multiboot fat linux part_msdos minicmd ls iso9660" --output="%s" %s' % (config['isopath'], globalconf["live-media-path"]))
    if config['action'] == "create_legacy_boot_img":
        setup_grub_legacy_boot(globalconf["live-media-path"])


def setup_grub_legacy_boot(path):
    """
    Create PC BIOS (amd64/i386 legacy) bootable grub image.
    """
    # TODO: should probably happen inside the chroot?
    os.system('grub-mkstandalone --directory=/usr/lib/grub/i386-pc --format=i386-pc '
              '--themes="" --fonts="" --locales="" --modules="linux normal iso9660 '
              'biosdisk search png gfxmenu" --install-modules="linux normal iso9660 '
              'biosdisk memdisk search tar ls png gfxmenu" --output core.img')
    os.system('cat /usr/lib/grub/i386-pc/cdboot.img core.img > bios.img')


def depends():
    """
    Returns a list of dependencies for this module.
    Currently this is Debian packages.
    """
    return ({'xorriso': {"priority": "required", \
             "description": "command line ISO-9660 and Rock Ridge manipulation tool"},
             'mtools': {"priority": "required", \
             "description": "Tools for manipulating MSDOS files"}
           })