diff options
Diffstat (limited to 'plugins/plugin_grub.py')
-rw-r--r-- | plugins/plugin_grub.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/plugin_grub.py b/plugins/plugin_grub.py index 8137bfb..e60cf48 100644 --- a/plugins/plugin_grub.py +++ b/plugins/plugin_grub.py @@ -20,6 +20,7 @@ from pyfirstaidkit.reporting import PLUGIN from pyfirstaidkit.returns import * from pyfirstaidkit.configuration import Config,getConfigBits from pyfirstaidkit.utils import spawnvch +from pyfirstaidkit.issue import SimpleIssue import os.path import difflib import re @@ -62,10 +63,18 @@ class Sample1Plugin(Plugin): self._grub_map = {} #mapping from linux device names to grub device names self._grub_mask = re.compile("""\(hd[0-9]*,[0-9]*\)""") + self._issue_boot_flag = SimpleIssue("Bootable partition", "No bootable partition found in partition table and GRUB is not MBR installed") + self._issue_grub_dir = SimpleIssue("GRUB directory", "No GRUB directory was not found") + self._issue_grub_installed = SimpleIssue("GRUB installed", "No GRUB was found in bootable partitions or MBR") + def prepare(self): from bootloaderInfo import x86BootloaderInfo self._bootloaderInfo = x86BootloaderInfo() self._result=ReturnSuccess + + self._issue_boot_flag.set(reporting = self._reporting, origin = self, level = PLUGIN) + self._issue_grub_dir.set(reporting = self._reporting, origin = self, level = PLUGIN) + self._issue_grub_installed.set(reporting = self._reporting, origin = self, level = PLUGIN) def backup(self): self._result=ReturnSuccess @@ -103,6 +112,9 @@ class Sample1Plugin(Plugin): self._linux.append(data[0][5:]) self._reporting.debug(origin = self, level = PLUGIN, message = "Linux partition found: %s" % (data[0][5:],)) + if len(self._bootable) == 0: + self._issue_boot_flag.set(detected = True, happened = True, reporting = self._reporting, origin = self, level = PLUGIN) + #Find grub directories self._reporting.debug(origin = self, level = PLUGIN, message = "Locating the grub directories") @@ -112,6 +124,9 @@ class Sample1Plugin(Plugin): if self._grub_mask.search(l): self._reporting.info(origin = self, level = PLUGIN, message = "Grub directory found at %s" % (l.strip(),)) self._grub_dir.add(l.strip()) + + if len(self._grub_dir) == 0: + self._issue_grub_dir.set(detected = True, happened = True, reporting = self._reporting, origin = self, level = PLUGIN) #TODO Mount the required partitions from self._grub_dir and read the important files from there for gdrive in self._grub_dir: @@ -150,12 +165,18 @@ class Sample1Plugin(Plugin): #if there is the grub configuration dir and the grub appears installed into MBR or bootable partition, then we are probably OK if len(self._grub_dir)>0 and len(self._grub)>0 and len(set(self._grub).intersection(set(self._bootable+self._drives)))>0: self._result=ReturnSuccess + self._issue_grub_installed.set(detected = True, happened = False, reporting = self._reporting, origin = self, level = PLUGIN) + self._issue_boot_flag.set(detected = True, happened = False, reporting = self._reporting, origin = self, level = PLUGIN) #if we can find bootable, than it didn't happen self._dependencies.provide("boot-grub") else: + self._issue_grub_installed.set(detected = True, happened = True, reporting = self._reporting, origin = self, level = PLUGIN) self._result=ReturnFailure def fix(self): self._result=ReturnFailure + self._issue_boot_flag.set(fixed = False, reporting = self._reporting, origin = self, level = PLUGIN) + self._issue_grub_dir.set(fixed = False, reporting = self._reporting, origin = self, level = PLUGIN) + self._issue_grub_installed.set(fixed = False, reporting = self._reporting, origin = self, level = PLUGIN) def install(self): #install the grub to Config.operation.params partition |