Commits

Michał Górny  committed e333a9b

Detect and ignore autogenerated grub2 configs.

  • Participants
  • Parent commits 5335f74

Comments (0)

Files changed (1)

File ecleankernel/bootloader/grub2.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+from __future__ import print_function
+
 from .grub import GRUB
 
+grub2_autogen_header = '''#
+# DO NOT EDIT THIS FILE
+#
+# It is automatically generated by grub2-mkconfig'''
+
 class GRUB2(GRUB):
 	name = 'grub2'
 	kernel_re = r'^\s*linux\s*(\([^)]+\))?(?P<path>\S+)'
 	def_path = '/boot/grub/grub.cfg'
+
+	def _get_kernels(self, content):
+		self._autogen = content.startswith(grub2_autogen_header)
+
+		if self._autogen:
+			self._debug.print('Config is autogenerated, ignoring')
+			return ()
+		return GRUB._get_kernels(self, content)