Commits

Michał Górny committed d33a257

Move querying bootloader into core.

Comments (0)

Files changed (2)

ecleankernel/cli.py

 
 from optparse import OptionParser
 
-from .bootloader import bootloaders
+from .bootloader import bootloaders, get_bootloader
 from .kernel import find_kernels, Kernel
 from .process import get_removal_list
 
 					print('- %s: %s' % (key, val))
 		return 0
 
+	bootloader = get_bootloader(requested = opts.bootloader,
+			debug = debug)
 	removals = get_removal_list(kernels,
 			limit = None if opts.all else opts.num,
-			bootloader = opts.bootloader,
+			bootloader = bootloader,
 			destructive = opts.destructive,
 			debug = debug)
 

ecleankernel/process.py

 
 from __future__ import print_function
 
-from .bootloader import get_bootloader
 
 import errno, os, os.path, re
 
 		if k.vmlinuz is None:
 			yield k
 
-def get_removal_list(kernels, debug, limit = 0, bootloader = 'auto', destructive = False):
+def get_removal_list(kernels, debug, limit = 0, bootloader = None, destructive = False):
 	""" Get a list of outdated kernels to remove. With explanations. """
 
 	debug.indent(heading = 'In get_removal_list()')
 
 	if limit is None or limit > 0:
 		if not destructive:
-			lastbl = get_bootloader(requested = bootloader, debug = debug)
-			used = lastbl()
-
-			if lastbl is None:
+			if bootloader is None:
 				raise SystemError('Unable to get kernels from bootloader config (%s)'
 						% bootloader)
+
+			used = bootloader()
 			realpaths = [os.path.realpath(x) for x in used]
 
 			prefix = re.compile(r'^/boot/(vmlinu[xz]|kernel|bzImage)-')
 			if destructive:
 				out.add(k, 'unwanted')
 			elif k.version not in used:
-				out.add(k, 'not referenced by bootloader (%s)' % lastbl.name)
+				out.add(k, 'not referenced by bootloader (%s)' % bootloader.name)
 
 	current = os.uname()[2]