Bug 30354

Summary: urpme kernel-(tab) does not offer installed kernels to remove
Product: Mageia Reporter: Ben McMonagle <westel>
Component: RPM PackagesAssignee: Mageia Bug Squad <bugsquad>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: Normal CC: fri, lewyssmith
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: CVE:
Status comment:

Description Ben McMonagle 2022-04-30 08:41:19 CEST
Description of problem: attempting to remove excess kernels using "urpme kernel(+tab for auto-complete)" offers only the kernel series (desktop, desktop-devel etc) not the installed kernel versions: 

[root@localhost ~]# update-grub2
Generating grub configuration file ...
Found theme: /boot/grub2/themes/maggy/theme.txt
Found linux image: /boot/vmlinuz-5.17.5-desktop-2.mga9
Found initrd image: /boot/initrd-5.17.5-desktop-2.mga9.img
Found linux image: /boot/vmlinuz-5.17.4-desktop-2.mga9
Found initrd image: /boot/initrd-5.17.4-desktop-2.mga9.img
Found linux image: /boot/vmlinuz-desktop
Found initrd image: /boot/initrd-desktop.img
Adding boot menu entry for UEFI Firmware Settings ...
done
[root@localhost ~]# urpme kernel
kernel-desktop               kernel-desktop-devel-latest  kernel-firmware              kernel-userspace-headers     
kernel-desktop-devel         kernel-desktop-latest        kernel-firmware-nonfree      
[root@localhost ~]# urpme kernel-desktop
kernel-desktop               kernel-desktop-devel         kernel-desktop-devel-latest  kernel-desktop-latest        
[root@localhost ~]# urpme kernel-desktop
Removing the following package will break your system:
  basesystem-8-0.5.mga9.x86_64
   (due to missing kernel)

excess kernels can be removed via MCC GUI  


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
Comment 1 Lewis Smith 2022-04-30 09:29:27 CEST
I am unsure exactly what the complaint is. What is the difference between "only the kernel series" and "the installed kernel versions"? What do you expect otherwise?

Experimenting:
 $ sudo urpme --test kernel[Tab]
kernel-desktop-5.15.10-1.mga8  kernel-desktop-5.15.28-1.mga8
...
kernel-desktop-5.15.16-1.mga8  kernel-desktop-latest
kernel-desktop-5.15.18-2.mga8  kernel-firmware
kernel-desktop-5.15.23-1.mga8  kernel-firmware-nonfree
kernel-desktop-5.15.25-1.mga8  kernel-userspace-headers
 This list must come from the shell, not urpme.

 $ sudo urpme --test kernel
 [sudo] password for lewis: 
Mae pecynnau canlynol yn cynnwys kernel:      [Following pkgs include kernel]
kernel-desktop-5.15.10-1.mga8-1-1.mga8.x86_64
...
kernel-desktop-latest-5.15.35-2.mga8.x86_64
kernel-firmware-20201218-1.mga8.noarch
kernel-firmware-nonfree-20220411-1.mga8.nonfree.noarch
kernel-userspace-headers-5.15.35-2.mga8.x86_64
 This comes from urpme.

 $ sudo urpme --test kernel-desktop[Tab]
and
 $ sudo urpme --test kernel-desktop-[Tab]
kernel-desktop-5.15.10-1.mga8  kernel-desktop-5.15.25-1.mga8
...
kernel-desktop-5.15.18-2.mga8  kernel-desktop-latest
kernel-desktop-5.15.23-1.mga8
 List from shell.

 $ sudo urpme --test kernel-desktop
 [sudo] password for lewis:
Mae pecynnau canlynol yn cynnwys kernel-desktop: 
kernel-desktop-5.15.10-1.mga8-1-1.mga8.x86_64
...
kernel-desktop-latest-5.15.35-2.mga8.x86_64:
 From urpme.

What is dicey about this is that the lists include the running kernel.
The safe thing to do is remove them one by one.

CC: (none) => lewyssmith

Comment 2 Morgan Leijström 2022-04-30 14:06:01 CEST
Related: There is some useful script in 
Bug 24403 - Feature request : tool to remove old kernels

CC: (none) => fri

Comment 3 Thomas Backlund 2022-04-30 17:28:04 CEST
Well, tecnically its not a bug as normal rpm bash-completion unly matches names, not version and release...

but I guess you are used to kernels in <= mga8 shows up with version and release ...

This is because we had version-release as part of the name back then....

If you want to see full versioning on >=mga9 you could apply this patch:

--- /usr/share/bash-completion/completions/rpm.orig
+++ /usr/share/bash-completion/completions/rpm
@@ -15,7 +15,7 @@
         COMPREPLY=($(compgen -W '$(rpmqpack)' -- "$cur"))
     else
         COMPREPLY=($(${1:-rpm} -qa --nodigest --nosignature \
-            --queryformat='%{NAME} ' "$cur*" 2>/dev/null))
+            --queryformat='%{NAME}-%{VERSION}-%{RELEASE} ' "$cur*" 2>/dev/null))
     fi
 }
 


(note that it wont take affect until closing console and opening it again...)



with this patch every package installed will show up with full name-version-release


note that if you want to keep that behaviour I suggest you copy the modified
/usr/share/bash-completion/completions/rpm to /etc/bash_completion.d/ so it does not get overwritten on rpm updates...


of course some bash magic could be applied to only trigger on matching kernel* but thats for another day...
Comment 4 Ben McMonagle 2022-04-30 23:02:35 CEST
(In reply to Lewis Smith from comment #1)
> I am unsure exactly what the complaint is. What is the difference between
> "only the kernel series" and "the installed kernel versions"? What do you
> expect otherwise?
> 
> Experimenting:
>  $ sudo urpme --test kernel[Tab]
> kernel-desktop-5.15.10-1.mga8  kernel-desktop-5.15.28-1.mga8
> ...
> kernel-desktop-5.15.16-1.mga8  kernel-desktop-latest
> kernel-desktop-5.15.18-2.mga8  kernel-firmware
> kernel-desktop-5.15.23-1.mga8  kernel-firmware-nonfree
> kernel-desktop-5.15.25-1.mga8  kernel-userspace-headers
>  This list must come from the shell, not urpme.
> 
>  $ sudo urpme --test kernel
>  [sudo] password for lewis: 
> Mae pecynnau canlynol yn cynnwys kernel:      [Following pkgs include kernel]
> kernel-desktop-5.15.10-1.mga8-1-1.mga8.x86_64
> ...
> kernel-desktop-latest-5.15.35-2.mga8.x86_64
> kernel-firmware-20201218-1.mga8.noarch
> kernel-firmware-nonfree-20220411-1.mga8.nonfree.noarch
> kernel-userspace-headers-5.15.35-2.mga8.x86_64
>  This comes from urpme.
> 
>  $ sudo urpme --test kernel-desktop[Tab]
> and
>  $ sudo urpme --test kernel-desktop-[Tab]
> kernel-desktop-5.15.10-1.mga8  kernel-desktop-5.15.25-1.mga8
> ...
> kernel-desktop-5.15.18-2.mga8  kernel-desktop-latest
> kernel-desktop-5.15.23-1.mga8
>  List from shell.
> 
>  $ sudo urpme --test kernel-desktop
>  [sudo] password for lewis:
> Mae pecynnau canlynol yn cynnwys kernel-desktop: 
> kernel-desktop-5.15.10-1.mga8-1-1.mga8.x86_64
> ...
> kernel-desktop-latest-5.15.35-2.mga8.x86_64:
>  From urpme.
> 
> What is dicey about this is that the lists include the running kernel.
> The safe thing to do is remove them one by one.

in Mga8, to remove excess kernels, just running urmpe kernel(+tab) would list all installed packages starting "kernel", refining the call with urpme kernel-desk(+tab) would list all kernel-desk(top) kernels.

then do some c/p in the terminal to remove unwanted kernels.

this no longer happens in cauldron.

running update-grub2 prior to the urpme command listed 2 kernels , but none were listed in the urpme kernel-desktop query
Comment 5 Ben McMonagle 2022-04-30 23:07:10 CEST
(In reply to Morgan Leijström from comment #2)
> Related: There is some useful script in 
> Bug 24403 - Feature request : tool to remove old kernels

"urpme_old-kernels"  is listed in available packages, but has a dependency "urpme", which, as of creation of this report, was un-available.
Comment 6 Ben McMonagle 2022-04-30 23:10:15 CEST
(In reply to Thomas Backlund from comment #3)
> Well, tecnically its not a bug as normal rpm bash-completion unly matches
> names, not version and release...
> 
> but I guess you are used to kernels in <= mga8 shows up with version and
> release ...
> 
> This is because we had version-release as part of the name back then....
> 
> If you want to see full versioning on >=mga9 you could apply this patch:
> 
> --- /usr/share/bash-completion/completions/rpm.orig
> +++ /usr/share/bash-completion/completions/rpm
> @@ -15,7 +15,7 @@
>          COMPREPLY=($(compgen -W '$(rpmqpack)' -- "$cur"))
>      else
>          COMPREPLY=($(${1:-rpm} -qa --nodigest --nosignature \
> -            --queryformat='%{NAME} ' "$cur*" 2>/dev/null))
> +            --queryformat='%{NAME}-%{VERSION}-%{RELEASE} ' "$cur*"
> 2>/dev/null))
>      fi
>  }
>  
> 
> 
> (note that it wont take affect until closing console and opening it again...)
> 
> 
> 
> with this patch every package installed will show up with full
> name-version-release
> 
> 
> note that if you want to keep that behaviour I suggest you copy the modified
> /usr/share/bash-completion/completions/rpm to /etc/bash_completion.d/ so it
> does not get overwritten on rpm updates...
> 
> 
> of course some bash magic could be applied to only trigger on matching
> kernel* but thats for another day...

Thanks Thomas.

looks like I will have to move with the times and learn a new command ;)
Comment 7 Ben McMonagle 2022-04-30 23:14:06 CEST
closing as a new package (urpme_old-kernels ) should be used for this task instead

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

Comment 8 Lewis Smith 2022-05-01 21:36:54 CEST
I did not appreciate the change from M8 to Cauldron as tmb explained in comment 3.

I really must get myself a Cauldron system...