FS#68094 - [calibre] post_remove instruction fails when upgrading/uninstalling calibre

Attached to Project: Community Packages
Opened by patrick (potomac) - Saturday, 03 October 2020, 20:48 GMT
Last edited by Eli Schwartz (eschwartz) - Monday, 05 October 2020, 04:13 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Eli Schwartz (eschwartz)
Architecture All
Severity Very Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
There are rm commands in the files calibre-common.install and calibre.install,
these commands will likely fail because there are files in /usr/lib/calibre/ (no "-rf" option given to rm and rmdir commands),

post_remove() {
if [ -e /usr/lib/calibre/bin ]; then
rm /usr/lib/calibre/bin
rmdir /usr/lib/calibre/
fi
}

I discovered this problem when pacman tries to replace calibre-common by community/calibre during a "pacman -Syu",
when pacman tries to uninstall calibre-common I have this error :

(1/1) Uninstalling calibre-common [##################################################################################] 100%
rmdir: cannot delete '/usr/lib/calibre/': The folder is not empty

Additional info:
* package version(s) calibre-5.0.1-1
* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
- Update calibre
- pacman will propose to replace calibre-common by community/calibre : type "Yes"
- rmdir will fail when pacman executes post_remove function of calibre-common
This task depends upon

Closed by  Eli Schwartz (eschwartz)
Monday, 05 October 2020, 04:13 GMT
Reason for closing:  Not a bug
Additional comments about closing:  Very unclear what the problem is, and there's nothing to fix in an *old version* of the package even if the problem is real.
Comment by Eli Schwartz (eschwartz) - Monday, 05 October 2020, 01:27 GMT
Which files existed there? There were none for me.

There's really nothing to do here, though, since post_remove scripts are not fatal errors, merely alerts, and the only way to update the post_remove routine for calibre-common is to release an updated version of the calibre-common package for users to install, then afterward issue a replaces=() update...
Comment by patrick (potomac) - Monday, 05 October 2020, 02:00 GMT
There were files according to the output of pacman when post_remove() function was executed, that means that calibre (on previous versions) had the ability to create files in /usr/lib/calibre/bin, or somes files had been created by a post_install() function for the calibre package.

As the goal is to delete /usr/lib/calibre/bin then one thing you can do is to add "-rf" option to rm command in post_remove() function, in order to remove /usr/lib/calibre/bin even if files (or directories) were present inside this directory.

If rm and rmdir commands are present in post_remove() then it means that the author of the calibre package thinks that there is a probability of new files (created after the installation of calibre) in /usr/lib/calibre/bin, but rm needs "-rf" option if you want to delete a directory with rm, otherwise the rm command will fail if files are present inside this directory.
Comment by Eli Schwartz (eschwartz) - Monday, 05 October 2020, 03:23 GMT
There is no possibility or probability. There is only an absolute, positive, guaranteed certainty that:
- if "calibre-python3" or "calibre" were installed (not just "calibre-common"), it exists
- if it exists, it is a symlink

/usr/lib/calibre/bin cannot and must not be a directory, therefore it's invalid to add -r to it, and it checks if it exists before running rm, so it's invalid to add -f to it.

Your problem is not even the rm command, the error you reported was triggered by rmdir! Given this is a post-remove command, it will only run after its reverse dependencies are uninstalled, *and* it itself is uninstalled.

The only reasonable solution to silence this error message is rmdir --ignore-fail-on-non-empty, but it's still not clear to me when you'd have untracked files there other than /usr/lib/calibre/bin

...

Furthermore, it is still not clear to me what you expect me to do. Once again: the error reported that it could not clean up the directory, since there were files there which were not expected and could not be safely deleted, so it made no sense to remove them, but... the operation succeeded, as it should, since the error wasn't a fatal error.

The ONLY potential improvement anywhere here is to make the output marginally prettier, with no actually relevant changes, and I cannot even do that because as I said, the package no longer exists and a post_remove by definition must be added ahead of time, before you either upgrade the package or remove it entirely from the repos...

Loading...