Bug 31969

Summary: remove-old-kernels run as non root should not ask to remove anything, only list and exit
Product: Mageia Reporter: Morgan Leijström <fri>
Component: RPM PackagesAssignee: Barry Jackson <zen25000>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: Normal    
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: remove-old-kernels-0.99.21.6-1.mga9.noarch.rpm CVE:
Status comment:
Attachments: script to test

Description Morgan Leijström 2023-05-27 21:53:56 CEST
Description of problem: Looks stupid ;)
It say it need be run as root to remove anything, yet it stops to ask.

It is good that it lists kernels and tell it need be run as root to remove anything - like it does.

I think it after this should simply exit.


Version: 0.99.21.6-1.mga9
Morgan Leijström 2023-05-27 21:54:26 CEST

Assignee: bugsquad => zen25000

Comment 1 Morgan Leijström 2023-06-23 22:01:39 CEST
Another detail: one word:

When there is one kernel to remove and it also have one devel package it asks to remove "2 kernels". - it should ask to remove two *packages* 

Example now:


 System: Mageia release 9 (Cauldron) for x86_64 | Kernels in /boot/:4 | AUTO:1 | KEEP:3  
 ==> kernel-desktop
 1   : Keep  :     : kernel-desktop-6.3.9-2.mga9.x86_64            Fri Jun 23 13:20:24 2023 
 2   : Keep  : U   : kernel-desktop-6.3.9-1.mga9.x86_64            Wed Jun 21 21:08:26 2023 
 3   : Keep  :     : kernel-desktop-6.3.8-2.mga9.x86_64            Tue Jun 20 09:06:23 2023 
 4   : Remove:     : kernel-desktop-6.3.8-1.mga9.x86_64            Wed Jun 14 23:43:05 2023 
 ==> kernel-desktop-devel
 1   : Keep  :     : kernel-desktop-devel-6.3.9-2.mga9.x86_64      Fri Jun 23 13:20:30 2023 
 2   : Keep  :     : kernel-desktop-devel-6.3.9-1.mga9.x86_64      Wed Jun 21 21:08:32 2023 
 3   : Keep  :     : kernel-desktop-devel-6.3.8-2.mga9.x86_64      Tue Jun 20 09:06:30 2023 
 4   : Remove:     : kernel-desktop-devel-6.3.8-1.mga9.x86_64      Wed Jun 14 23:43:29 2023 
               U = In use now
Must be root to allow removal
Remove 2 kernels: ? y/N/i (i=confirm for each)
Comment 2 Barry Jackson 2023-06-24 11:26:14 CEST
Hi Morgan,
Yes you are perfectly correct, I am not ignoring this and I have looked at the code, however I have not yet had time due to other more critical issues that needed fixing and real life.

Your second point would involve the translations as we do not currently use the word  'package(s)' anywhere.

BTW Pull requests are welcome at https://github.com/barjac/remove-old-kernels ;)

I will try to get to get to it ASAP.
Comment 3 Morgan Leijström 2023-06-24 12:20:27 CEST
Well maybe better is to for the example in Comment 1 say remove *1* kernel.

Feels more logical as other numbers concern number of kernels.
- and need no new translation then :)

Counting one kernel as including any directly related package such as the -devel and it already in effect will remove more than listed anyway; the dkms packages.
Comment 4 Barry Jackson 2023-06-30 01:03:34 CEST
The first part is OK and is fixed.

For the second part, it can count the 'kernels' excluding any '-devel' packages from the count, but hits a slight problem if there are only '-devel' packages to remove which is unlikely.

It would say:
Remove 0 kernels: ? y/N/i (y=yes N=no i=confirm for each).

and then remove the -devel packages.

If we can live with that I will do more testing of it tomorrow :)

Since the displayed count will be handled independently of the package count the main program function is not affected so should be safe.
Comment 5 Morgan Leijström 2023-06-30 08:16:16 CEST
What about this wording?

  Remove per suggestion (0 kernels): ?
Comment 6 Barry Jackson 2023-06-30 11:14:20 CEST
(In reply to Morgan Leijström from comment #5)
> What about this wording?
> 
>   Remove per suggestion (0 kernels): ?

Back to translation again and we don't have time for that, but maybe the following would be acceptable:

Remove 2 (0 kernels): ? y/N/i (y=yes N=no i=confirm for each).

If isos for RC are being built then we are too late for Mga9 anyway.
Comment 7 Morgan Leijström 2023-06-30 12:03:27 CEST
Thumbs up :)
Comment 8 Morgan Leijström 2023-06-30 12:06:29 CEST
This is a leaf and no function change so i think it is perfectly OK to push.

(That said i once made a no function change in a source, that made the compiler go bananas behind the scene and effect a severe function (order of execution) change...)
Comment 9 Barry Jackson 2023-06-30 12:11:35 CEST
Created attachment 13901 [details]
script to test

Please test the attached updated version.
I don't have machines with all possible scenarios of installed kernels etc. so if you could test for any regressions that would be great!
Comment 10 Barry Jackson 2023-06-30 12:52:36 CEST
(In reply to Morgan Leijström from comment #8)
> This is a leaf and no function change so i think it is perfectly OK to push.
> 
> (That said i once made a no function change in a source, that made the
> compiler go bananas behind the scene and effect a severe function (order of
> execution) change...)

It is in the isos so could be an issue.
Comment 11 Morgan Leijström 2023-06-30 13:38:44 CEST
Test OK of script from comment 6 same situation as comment 0 & 1

When run as user it lists and ask to press spacebar, then exit : Perfect.

When run as root, it asks as in comment 6 : OK

Regarding scenarios, when system have dkms packages (such as virtualbox-kernel), more packages than said will be removed, so maybe simply omit the count and say something like in comment 5?


I guess it is not possible to suppress the suggestion of "urpme --auto-orphans"?
It is an ugly long list, and wrong https://wiki.mageia.org/en/Mageia_9_Errata#Mageia_tools
Comment 12 Barry Jackson 2023-06-30 14:23:38 CEST
(In reply to Morgan Leijström from comment #11)
> Test OK of script from comment 6 same situation as comment 0 & 1
> 
> When run as user it lists and ask to press spacebar, then exit : Perfect.
> 
> When run as root, it asks as in comment 6 : OK
> 
> Regarding scenarios, when system have dkms packages (such as
> virtualbox-kernel), more packages than said will be removed, so maybe simply
> omit the count and say something like in comment 5?

It now is unchanged when there are only actual kernels to remove.
If -devel or -source packages are involved then it adds the actual kernel count in brackets as in comment 6.

It does not try to predict what urpme will do regarding each kernel's dependents - this is left to urpme and automatically accepted.

> 
> 
> I guess it is not possible to suppress the suggestion of "urpme
> --auto-orphans"?

Sadly no unless someone can add that option to urpme :(

> It is an ugly long list, and wrong
> https://wiki.mageia.org/en/Mageia_9_Errata#Mageia_tools

The bug31969 branch at https://github.com/barjac/remove-old-kernels is ready to merge now unless there are any further comments.
Comment 13 Barry Jackson 2023-06-30 15:59:48 CEST
New version submitted to core/updates_testing.

Freeze move requested on -dev ML

@Morgan - Thanks for you help and for reporting.

Closing as fixed.

Status: NEW => RESOLVED
Resolution: (none) => FIXED