Bug 262862

Summary: devel/qt5: POST-DEINSTALL errors when deinstalling
Product: Ports & Packages Reporter: jakub_lach
Component: Individual Port(s)Assignee: freebsd-kde (group) <kde>
Status: Closed FIXED    
Severity: Affects Only Me CC: adridg, kde, tcberner
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description jakub_lach 2022-03-27 12:09:39 UTC
pkg-static: POST-DEINSTALL script failed
[45/47] Deinstalling qt5-buildtools-5.15.2p263...
[45/47] Deleting files for qt5-buildtools-5.15.2p263: 100%
pkg-static: POST-DEINSTALL script failed
[46/47] Deinstalling ruby-2.7.5_1,1...
[46/47] Deleting files for ruby-2.7.5_1,1: 100%
[47/47] Deinstalling qt5-declarative-test-5.15.2p41_1...
[47/47] Deleting files for qt5-declarative-test-5.15.2p41_1: 100%
pkg-static: POST-DEINSTALL script failed
Comment 1 Adriaan de Groot freebsd_committer freebsd_triage 2022-04-14 15:37:41 UTC
Similarly, removing qt5-declarative shows POST-DEINSTALL script failed as well. Actually all of the Qt5 packages do this. I guess it's a recent(ish) change to pkg to print the failure message.

The post-deinstall script looks like this (extracted from the pkg database):

```
#!/bin/sh
qi="/usr/local/include/qt5"
qc="$qi/QtCore/qconfig-modules.h"
qm="declarative-test"
case $2 in
POST-DEINSTALL)
[ \! -e "$qc" ] && touch "$qc"
sed  "/qconfig-$qm\.h/ d" "$qc"
[ \! -e "$qi/QtCore/qconfig.h" ] && \
[ \! -s "$qc" ] && (
rm -f "$qc"
rmdir "$qi/QtCore"
rmdir "$qi"
) > /dev/null 2>&1
;;
esac
```

What's going "wrong" is after the sed, it checks if QtCore/qconfig.h no-longer-exists. It does, so `[ ! -e "$qi/QtCore/qconfig.h" ]` is false; that pipeline exits with a non-zero code. There's nothing **after** that pipeline to reset the exit code, and so the result of the whole script is non-zero -- and pkg prints a failure.
Comment 2 Adriaan de Groot freebsd_committer freebsd_triage 2022-04-14 19:28:26 UTC
(I see now that Jakub's original message already points to "all the Qt5 packages" and I only noticed the message in 47/47 for declarative test) Fixed in 613a0476fffb84ebab668d4737575c1280024b2e although I didn't bump any packages. The post-deinstall message is harmless (for the qt5 packages anyway).