2013-07-10 10:49:45 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
|
|
|
|
|
|
|
|
|
|
|
class ConfigureGrub(Task):
|
|
|
|
description = 'Configuring grub'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
|
|
|
def run(self, info):
|
2013-08-13 08:55:12 +02:00
|
|
|
import stat
|
|
|
|
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
|
|
|
stat.S_IRGRP | stat.S_IXGRP |
|
|
|
|
stat.S_IROTH | stat.S_IXOTH)
|
|
|
|
x_all = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
|
2013-08-11 23:03:44 +02:00
|
|
|
import os.path
|
|
|
|
device_map_path = os.path.join(info.root, 'boot/grub/device.map')
|
|
|
|
with open(device_map_path, 'w') as device_map:
|
2013-08-13 08:55:12 +02:00
|
|
|
device_map.write('(hd0) /dev/sda\n')
|
2013-08-11 23:03:44 +02:00
|
|
|
|
2013-08-10 16:18:48 +02:00
|
|
|
from common.tools import log_check_call
|
2013-08-01 11:19:20 +02:00
|
|
|
|
2013-08-13 08:55:12 +02:00
|
|
|
from shutil import copy
|
|
|
|
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/10_linux'))
|
|
|
|
script_dst = os.path.join(info.root, 'etc/grub.d/10_linux')
|
|
|
|
copy(script_src, script_dst)
|
|
|
|
os.chmod(script_dst, rwxr_xr_x)
|
|
|
|
script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), '../assets/grub.d/00_header'))
|
|
|
|
script_dst = os.path.join(info.root, 'etc/grub.d/00_header')
|
|
|
|
copy(script_src, script_dst)
|
|
|
|
os.chmod(script_dst, rwxr_xr_x)
|
|
|
|
log_check_call(['/usr/sbin/chroot', info.root, 'update-initramfs', '-u'])
|
|
|
|
# Install grub in mbr
|
|
|
|
log_check_call(['grub-install', '--boot-directory='+info.root+"/boot/", info.bootstrap_device['path']])
|
2013-08-11 23:03:44 +02:00
|
|
|
|
2013-08-13 08:55:12 +02:00
|
|
|
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
|