You are not logged in.

#1 2020-04-11 17:32:40

halasz
Member
From: france
Registered: 2015-01-17
Posts: 40

[SOLVED] pacman -Rs not removing all dependencies

I installed gnome and noticed it brought mkinitcpio as a dependency.  This turned out to be from gnome-software (via ostree -> flatpak -> malcontent) but removing gnome-software didn't cause mkinitcpio to be removed.

Adding a package such as ostree that requires mkinitcpio brings it in fine.  It is shown "Required By     : linux  linux-custom  ostree" and pacman will not let you remove it as "removing mkinitcpio breaks dependency 'mkinitcpio' required by ostree" which seems normal.

~ $ pacman -Q mkinitcpio
error: package 'mkinitcpio' was not found
~ $ sudo pacman -S ostree
resolving dependencies...
looking for conflicting packages...

Packages (3) mkinitcpio-27-3  mkinitcpio-busybox-1.31.1-1  ostree-2020.3-1

Total Download Size:   0.87 MiB
Total Installed Size:  3.99 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages...
 mkinitcpio-busybox-1.31.1-1-x86_64                      254.8 KiB   232 KiB/s 00:01 [------------------------------------------------] 100%
 mkinitcpio-27-3-any                                      41.8 KiB  1741 KiB/s 00:00 [------------------------------------------------] 100%
 ostree-2020.3-1-x86_64                                  592.7 KiB  3.86 MiB/s 00:00 [------------------------------------------------] 100%
(3/3) checking keys in keyring                                                       [------------------------------------------------] 100%
(3/3) checking package integrity                                                     [------------------------------------------------] 100%
(3/3) loading package files                                                          [------------------------------------------------] 100%
(3/3) checking for file conflicts                                                    [------------------------------------------------] 100%
(3/3) checking available disk space                                                  [------------------------------------------------] 100%
:: Running pre-transaction hooks...
(1/1) etckeeper: pre-transaction commit
:: Processing package changes...
(1/3) installing mkinitcpio-busybox                                                  [------------------------------------------------] 100%
(2/3) installing mkinitcpio                                                          [------------------------------------------------] 100%
Optional dependencies for mkinitcpio
    xz: Use lzma or xz compression for the initramfs image [installed]
    bzip2: Use bzip2 compression for the initramfs image [installed]
    lzop: Use lzo compression for the initramfs image
    lz4: Use lz4 compression for the initramfs image [installed]
    mkinitcpio-nfs-utils: Support for root filesystem on NFS
(3/3) installing ostree                                                              [------------------------------------------------] 100%
:: Running post-transaction hooks...
( 1/10) Reloading system manager configuration...
( 2/10) Creating temporary files...
( 3/10) Arming ConditionNeedsUpdate...
( 4/10) Updating linux initcpios with dracut...
==> setting /usr/local/share/dracutUpdateRequired trigger
( 5/10) Tidying pacman cache...
==> tidying cache on arch
==> no candidate packages found for pruning
==> no candidate packages found for pruning
==> no candidate packages found for pruning
/esp: 179.8 MiB (188497920 bytes) trimmed on /dev/sda1
/: 1.4 GiB (1530650624 bytes) trimmed on /dev/mapper/cryptroot
( 6/10) Check if aur updates required...
==> no aur updates required
( 7/10) Check if there is a new kernel tag...
:: Checking 'https://git.archlinux.org/linux.git/'
==> latest version : 5.6.3-arch1 already installed
( 8/10) Final dracut check...
:: Creating /boot/initramfs-linux.img
:: Creating /boot/initramfs-linux-fallback.img
:: Installing vmlinuz to /boot/vmlinuz-linux from 5.6.3-arch1-1
:: Creating /boot/initramfs-linux-custom.img
:: Creating /boot/initramfs-linux-custom-fallback.img
:: Installing vmlinuz to /boot/vmlinuz-linux-custom from 5.6.3-arch1-1-custom
==> resetting /usr/local/share/dracutUpdateRequired trigger
( 9/10) Updating linux initcpios...
(10/10) etckeeper: post-transaction commit

~ $ pacman -Qi mkinitcpio 
Name            : mkinitcpio
Version         : 27-3
Description     : Modular initramfs image creation utility
Architecture    : any
URL             : https://projects.archlinux.org/mkinitcpio.git/
Licenses        : GPL
Groups          : None
Provides        : initramfs
Depends On      : awk  mkinitcpio-busybox>=1.19.4-2  kmod  util-linux>=2.23  libarchive  coreutils  bash  diffutils  findutils  grep
                  filesystem>=2011.10-1  gzip  systemd
Optional Deps   : xz: Use lzma or xz compression for the initramfs image [installed]
                  bzip2: Use bzip2 compression for the initramfs image [installed]
                  lzop: Use lzo compression for the initramfs image
                  lz4: Use lz4 compression for the initramfs image [installed]
                  mkinitcpio-nfs-utils: Support for root filesystem on NFS
Required By     : linux  linux-custom  ostree
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 101.51 KiB
Packager        : Giancarlo Razzolini <grazzolini@archlinux.org>
Build Date      : Mon 24 Feb 2020 20:53:08
Install Date    : Sat 11 Apr 2020 15:28:41
Install Reason  : Installed as a dependency for another package
Install Script  : Yes
Validated By    : Signature



~ $ sudo pacman -Rs mkinitcpio    
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing mkinitcpio breaks dependency 'mkinitcpio' required by ostree
~ $ 

But removing ostree again doesn't remove the dependencies - they remain.  After removing it mkinitcpio is shown as "Required By     : linux  linux-custom" but now pacman will let you remove it.

~ $ sudo pacman -Rs ostree
checking dependencies...

Packages (1) ostree-2020.3-1

Total Removed Size:  3.39 MiB

:: Do you want to remove these packages? [Y/n] Y
:: Running pre-transaction hooks...
(1/1) etckeeper: pre-transaction commit
:: Processing package changes...
(1/1) removing ostree                                                                [------------------------------------------------] 100%
:: Running post-transaction hooks...
(1/4) Reloading system manager configuration...
(2/4) Arming ConditionNeedsUpdate...
(3/4) Tidying pacman cache...
==> tidying cache on arch

==> finished: 1 packages removed (disk space saved: 592.73 KiB)
==> no candidate packages found for pruning
==> no candidate packages found for pruning
/esp: 179.8 MiB (188497920 bytes) trimmed on /dev/sda1
/: 1.4 GiB (1527226368 bytes) trimmed on /dev/mapper/cryptroot
(4/4) etckeeper: post-transaction commit


~ $ pacman -Qi mkinitcpio      
Name            : mkinitcpio
Version         : 27-3
Description     : Modular initramfs image creation utility
Architecture    : any
URL             : https://projects.archlinux.org/mkinitcpio.git/
Licenses        : GPL
Groups          : None
Provides        : initramfs
Depends On      : awk  mkinitcpio-busybox>=1.19.4-2  kmod  util-linux>=2.23  libarchive  coreutils  bash  diffutils  findutils  grep
                  filesystem>=2011.10-1  gzip  systemd
Optional Deps   : xz: Use lzma or xz compression for the initramfs image [installed]
                  bzip2: Use bzip2 compression for the initramfs image [installed]
                  lzop: Use lzo compression for the initramfs image
                  lz4: Use lz4 compression for the initramfs image [installed]
                  mkinitcpio-nfs-utils: Support for root filesystem on NFS
Required By     : linux  linux-custom
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 101.51 KiB
Packager        : Giancarlo Razzolini <grazzolini@archlinux.org>
Build Date      : Mon 24 Feb 2020 20:53:08
Install Date    : Sat 11 Apr 2020 18:30:32
Install Reason  : Installed as a dependency for another package
Install Script  : Yes
Validated By    : Signature

~ $ sudo pacman -Rs mkinitcpio
checking dependencies...

Packages (2) mkinitcpio-busybox-1.31.1-1  mkinitcpio-27-3

Total Removed Size:  0.60 MiB

:: Do you want to remove these packages? [Y/n]  
:: Running pre-transaction hooks...
(1/2) etckeeper: pre-transaction commit
(2/2) Removing linux initcpios...
:: Processing package changes...
(1/2) removing mkinitcpio                                                            [------------------------------------------------] 100%
(2/2) removing mkinitcpio-busybox                                                    [------------------------------------------------] 100%
:: Running post-transaction hooks...
(1/4) Reloading system manager configuration...
(2/4) Arming ConditionNeedsUpdate...
(3/4) Tidying pacman cache...
==> tidying cache on arch

==> finished: 2 packages removed (disk space saved: 296.6 KiB)
==> no candidate packages found for pruning
==> no candidate packages found for pruning
/esp: 179.8 MiB (188497920 bytes) trimmed on /dev/sda1
/: 1.4 GiB (1519198208 bytes) trimmed on /dev/mapper/cryptroot
(4/4) etckeeper: post-transaction commit

Why doesn't mkinitcpio get uninstalled when removing the package it was a dependency for? The linux package says it is initramfs rather than mkinitcpio that is the requirement and this is provided by either mkinitcpio or (as in my case) dracut.   

Are there two classes of Required by - one for being a requirement and one for providing something that is a requirement?  If so how can I identify possible leftovers like this?

Last edited by halasz (2020-04-11 20:40:37)

Offline

#2 2020-04-11 17:58:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,520
Website

Re: [SOLVED] pacman -Rs not removing all dependencies

Pacman does not track what package a dependency was installed with/for, it only tracks whether the package is a dependency for anything else.

Mkinitcpio is required by a package you have installed (linux) so pacman's -Rs flags will not remove it:

man pacman wrote:

       -s, --recursive
           Remove each target specified including all of their dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recursive and analogous to a backwards --sync operation, and it helps keep a clean system without orphans. If you want to omit condition (B), pass this option twice.

There are not different varieties of "required by".  In fact there is no required by field in the database, this field is constructed from other package's dependencies.  So what you want to know is if you have any non-explicitly installed packages that are required by another package where that requirement is met by yet another package.  I don't (yet) know a quick way to check for this, but I suspect expac would be quite useful.

I'm pretty sure there's a better approach, but this will find any (meta)package for which you have multiple providers installed:

sed -n '/^%PROVIDES%$/{:loop;n;/^$/bend;p;bloop;:end;}' /var/lib/pacman/local/*/desc | sort | uniq -c | awk '$1 > 1'

Last edited by Trilby (2020-04-11 18:22:04)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2020-04-11 19:12:50

halasz
Member
From: france
Registered: 2015-01-17
Posts: 40

Re: [SOLVED] pacman -Rs not removing all dependencies

Trilby wrote:

I'm pretty sure there's a better approach, but this will find any (meta)package for which you have multiple providers installed:

sed -n '/^%PROVIDES%$/{:loop;n;/^$/bend;p;bloop;:end;}' /var/lib/pacman/local/*/desc | sort | uniq -c | awk '$1 > 1'

Well my results look good to me (I have 2 kernels).

~ $ sed -n '/^%PROVIDES%$/{:loop;n;/^$/bend;p;bloop;:end;}' /var/lib/pacman/local/*/desc | sort | uniq -c | awk '$1 > 1'
      3 ttf-font
      2 VIRTUALBOX-GUEST-MODULES
      2 WIREGUARD-MODULE
~ $ 
Trilby wrote:

Mkinitcpio is required by a package you have installed (linux) so pacman's -Rs flags will not remove it

There are not different varieties of "required by".  In fact there is no required by field in the database, this field is constructed from other package's dependencies.

That makes sense for the pacman -Rs ostree part.

What still isn't clear to me is what seems like an inconsistency in pacman -Rs mkinitcpio  - when something other than kernel is shown by pacman -Qi  it will not uninstall (top example) but when kernel only is shown it will.  By the above logic if it is a required by the kernel removal should be blocked but it isn't so it looks like linux and ostree packages are treated differently.

Required By     : linux  linux-custom  ostree
~ $ sudo pacman -Rs mkinitcpio    
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing mkinitcpio breaks dependency 'mkinitcpio' required by ostree
Required By     : linux  linux-custom
~ $ sudo pacman -Rs mkinitcpio
checking dependencies...
Packages (2) mkinitcpio-busybox-1.31.1-1  mkinitcpio-27-3
Total Removed Size:  0.60 MiB
:: Do you want to remove these packages? [Y/n] 

Offline

#4 2020-04-11 19:24:19

loqs
Member
Registered: 2014-03-06
Posts: 19,078

Re: [SOLVED] pacman -Rs not removing all dependencies

linux has a dependency on initramfs which is provided by mkinitcpio and dracut.  Is dracut installed?

Offline

#5 2020-04-11 19:27:28

halasz
Member
From: france
Registered: 2015-01-17
Posts: 40

Re: [SOLVED] pacman -Rs not removing all dependencies

loqs wrote:

linux has a dependency on initramfs which is provided by mkinitcpio and dracut.  Is dracut installed?

Yes it is, I picked it as the initramfs provider when installing.

Offline

#6 2020-04-11 19:41:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,520
Website

Re: [SOLVED] pacman -Rs not removing all dependencies

halasz wrote:

What still isn't clear to me is what seems like an inconsistency in pacman -Rs mkinitcpio  - when something other than kernel is shown by pacman -Qi  it will not uninstall (top example) but when kernel only is shown it will.

I don't follow.  Which `pacman -Qi` outputs are you referring to?

Pacman -Rs ostree did not remove mkinitcpio because it was still "required by" at least one other package (e.g., linux).  When you remove it directly (pacman -Rs mkinitcpio) pacman removes it.  Pacman would only halt this transaction if it left some other dependency unmet which is not the case here.

EDIT: oh, now I see.  When ostree is installed, pacman will not remove mkinitcpio even when you try to remove it directly, as ostree depends on mkinitcpio.  Nothing else (including dracut) satisfies this dependency.  That's the difference.  The kernel depends on initramfs which is provided by both/either mkinitcpio or dracut while ostree depends specifically on mkinitcpio.  I don't know enough (anything) about ostree to determine whether this could be considered a packaging bug.  Could dracut satisfy ostree's requirements?  If so, ostree should depend on initramfs, not mkinitcpio, but at present it depends explicitly on mkinitcpio.

Last edited by Trilby (2020-04-11 19:45:12)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2020-04-11 20:40:08

halasz
Member
From: france
Registered: 2015-01-17
Posts: 40

Re: [SOLVED] pacman -Rs not removing all dependencies

I see, that makes sense.  I was getting confused by the "Required By" line on the pacman -Qi mkinitcpio results.

I don't know anything about ostree - it was just a required by something else I don't want that I was using to test dependencies.  The main thing is I don't have orphan packages so I'll mark this solved.

Offline

Board footer

Powered by FluxBB