Skip to content

Commit

Permalink
Fix GRUB2._autogen AttributeError
Browse files Browse the repository at this point in the history
GRUB2._autogen should and can be determined on initialization, rather
than when retrieving the list of kernels (which may or may not happen
before the attribute is accessed).

Signed-off-by: Konstantinos Smanis <[email protected]>
Closes: #6
Signed-off-by: Michał Górny <[email protected]>
  • Loading branch information
KSmanis authored and mgorny committed Sep 22, 2020
1 parent b0cace4 commit 25349e8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ecleankernel/bootloader/grub2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ class GRUB2(GRUB):
kernel_re = r'^\s*linux\s*(\([^)]+\))?(?P<path>\S+)'
def_path = ('/boot/grub/grub.cfg', '/boot/grub2/grub.cfg')

def __init__(self) -> None:
super().__init__()
self._autogen = self._content.startswith(grub2_autogen_header)

def _get_kernels(self,
content: str
) -> typing.Iterable[str]:
self._autogen = content.startswith(grub2_autogen_header)

if self._autogen:
logging.debug('Config is autogenerated, ignoring')
return ()
Expand Down

0 comments on commit 25349e8

Please sign in to comment.