Michał Górny committed caea37a

s/--destructive/--all/. That sounds more sane.

  • Participants
  • Parent commits 9eb4abe

Comments (0)

Files changed (2)


 def main(argv):
 	parser = OptionParser()
+	parser.add_option('-a', '--all',
+			dest='all', action='store_true', default=False,
+			help='Remove all kernels unless used by bootloader')
 	parser.add_option('-b', '--bootloader',
 			dest='bootloader', default='auto',
-			help='Bootloader used for --destructive (auto, lilo, symlinks)')
-	parser.add_option('-d', '--destructive',
-			dest='destructive', action='store_true', default=False,
-			help='Destructive mode: remove all kernels unless used by bootloader')
+			help='Bootloader used (auto, lilo, symlinks)')
 	parser.add_option('-p', '--pretend',
 			dest='pretend', action='store_true', default=False,
 			help='Print the list of kernels to be removed and exit')
 	(opts, args) = parser.parse_args(argv[1:])
 	kernels = find_kernels()
-	removals = get_removal_list(kernels, opts.destructive, opts.bootloader)
+	removals = get_removal_list(kernels,
+			limit = None if opts.all else 0,
+			bootloader = opts.bootloader)
 	if not removals:
 		print('No outdated kernels found.')


 		if k.vmlinuz is None:
 			yield k
-def get_removal_list(kernels, destructive = False, bootloader = 'auto'):
+def get_removal_list(kernels, limit = 0, bootloader = 'auto'):
 	""" Get a list of outdated kernels to remove. With explanations. """
 	out = RemovedKernelDict()
 	if len(out) == len(kernels):
 		raise SystemError('No vmlinuz found. This seems ridiculous, aborting.')
-	if destructive:
+	if limit is None or limit > 0:
 		used = ()
 		for bl, getfunc in bootloaders:
 			if bootloader in ('auto', bl):
 					print('Note: strangely named used kernel (%s)' % fn)
 		used = frozenset(unprefixify(realpaths))
+		if limit is not None:
+			raise NotImplementedError('Limiting number of removed kernels not supported yet')
 		for k in kernels:
 			if k.version not in used:
 				out.add(k, 'not referenced by bootloader (%s)' % lastbl)