Bug 1297429

Summary: %ghost file not removed upon subpackage uninstall
Product: Red Hat Enterprise Linux 7 Reporter: Jaroslav Škarvada <jskarvad>
Component: rpmAssignee: Florian Festi <ffesti>
Status: CLOSED WORKSFORME QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.2CC: jen, jskarvad
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-12 13:17:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jaroslav Škarvada 2016-01-11 13:43:18 UTC
Description of problem:
From the RPM docs [1] (and my previous behaviour with RPM) %ghost files should be removed upon package uninstallation, but the following %ghost file from the Tuned subpackage isn't removed. We have the following in the SPEC file:

..
%install
mkdir -p %{buildroot}%{_sysconfdir}/modprobe.d
touch %{buildroot}%{_sysconfdir}/modprobe.d/kvm.rt.tuned.conf

%files
....

%files profiles-nfv
ghost %{_sysconfdir}/modprobe.d/kvm.rt.tuned.conf
...

[1] http://www.rpm.org/max-rpm-snapshot/s1-rpm-inside-files-list-directives.html#S3-RPM-INSIDE-FLIST-GHOST-DIRECTIVE

Version-Release number of selected component (if applicable):
rpm-4.11.3-17.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. git clone "https://git.fedorahosted.org/git/tuned.git"
2. cd tuned
3. make rpm
4. cd ~/rpmbuild/RPMS/noarch
5. yum install ./tuned-*.rpm
6. rpm -i --nodeps ./tuned-profiles-nfv*.rpm
7. touch /etc/modprobe.d/kvm.rt.tuned.conf
8. rpm -e tuned-profiles-nfv
9. ls /etc/modprobe.d/kvm.rt.tuned.conf

Actual results:
/etc/modprobe.d/kvm.rt.tuned.conf

Expected results:
ls: cannot access /etc/modprobe.d/kvm.rt.tuned.conf: No such file or directory

Additional info:
# rpm -evvv tuned-profiles-nfv
D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
D: loading keyring from rpmdb
D: opening  db environment /var/lib/rpm cdb:0x401
D: opening  db index       /var/lib/rpm/Packages 0x400 mode=0x0
D: locked   db index       /var/lib/rpm/Packages
D: opening  db index       /var/lib/rpm/Name 0x400 mode=0x0
D:  read h#    1325 Header SHA1 digest: OK (663942ef536f31509f5414ead27f529fdca00062)
D: opening  db index       /var/lib/rpm/Conflictname 0x400 mode=0x0
D: ========== --- tuned-profiles-nfv-2.6.0-1.el7 noarch/linux 0x0
D: opening  db index       /var/lib/rpm/Requirename 0x400 mode=0x0
D: ========== recording tsort relations
D: ========== tsorting packages (order, #predecessors, #succesors, depth)
D:     0    0    0    1   -tuned-profiles-nfv-2.6.0-1.el7.noarch
D: erasing packages
D: closed   db index       /var/lib/rpm/Conflictname
D: closed   db index       /var/lib/rpm/Requirename
D: closed   db index       /var/lib/rpm/Name
D: closed   db index       /var/lib/rpm/Packages
D: closed   db environment /var/lib/rpm
D: opening  db environment /var/lib/rpm cdb:0x401
D: opening  db index       /var/lib/rpm/Packages (none) mode=0x42
D: sanity checking 1 elements
D: running pre-transaction scripts
D: computing 15 file fingerprints
D: opening  db index       /var/lib/rpm/Name (none) mode=0x42
D: opening  db index       /var/lib/rpm/Basenames (none) mode=0x42
D: opening  db index       /var/lib/rpm/Group (none) mode=0x42
D: opening  db index       /var/lib/rpm/Requirename (none) mode=0x42
D: opening  db index       /var/lib/rpm/Providename (none) mode=0x42
D: opening  db index       /var/lib/rpm/Conflictname (none) mode=0x42
D: opening  db index       /var/lib/rpm/Obsoletename (none) mode=0x42
D: opening  db index       /var/lib/rpm/Triggername (none) mode=0x42
D: opening  db index       /var/lib/rpm/Dirnames (none) mode=0x42
D: opening  db index       /var/lib/rpm/Installtid (none) mode=0x42
D: opening  db index       /var/lib/rpm/Sigmd5 (none) mode=0x42
D: opening  db index       /var/lib/rpm/Sha1header (none) mode=0x42
Preparing packages...
D: computing file dispositions
D: 0x0000fd01     4096      2540084     13471870 /
D: ========== +++ tuned-profiles-nfv-2.6.0-1.el7 noarch-linux 0x0
D:  read h#    1325 Header SHA1 digest: OK (663942ef536f31509f5414ead27f529fdca00062)
D:     erase: tuned-profiles-nfv-2.6.0-1.el7 has 15 files
tuned-profiles-nfv-2.6.0-1.el7.noarch
D: erase      100644  1 (   0,   0)   862 /usr/share/man/man7/tuned-profiles-nfv.7.gz
D: erase      100644  2 (   0,   0)  3137 /usr/libexec/tuned/defirqaffinity.pyo
D: erase      100644  1 (   0,   0)  3137 /usr/libexec/tuned/defirqaffinity.pyc
D: erase      100755  1 (   0,   0)  3151 /usr/libexec/tuned/defirqaffinity.py
D: erase      100644  1 (   0,   0)  1253 /usr/lib/tuned/realtime-virtual-host/tuned.conf
D: erase      100755  1 (   0,   0)  2620 /usr/lib/tuned/realtime-virtual-host/script.sh
D: erase      100755  1 (   0,   0)   734 /usr/lib/tuned/realtime-virtual-host/run-tscdeadline-latency.sh
D: erase      100755  1 (   0,   0)   686 /usr/lib/tuned/realtime-virtual-host/find-lapictscdeadline-optimal.sh
D: erase      040755  2 (   0,   0)     6 /usr/lib/tuned/realtime-virtual-host
D: erase      100644  1 (   0,   0)   489 /usr/lib/tuned/realtime-virtual-guest/tuned.conf
D: erase      100755  1 (   0,   0)   506 /usr/lib/tuned/realtime-virtual-guest/script.sh
D: erase      040755  2 (   0,   0)     6 /usr/lib/tuned/realtime-virtual-guest
D: erase      100644  1 (   0,   0)    59 /etc/tuned/realtime-virtual-host-variables.conf
D: erase      100644  1 (   0,   0)    59 /etc/tuned/realtime-virtual-guest-variables.conf
D: backup     100644  1 (   0,   0)     0 /etc/modprobe.d/kvm.rt.tuned.conf
D:   --- h#    1325 tuned-profiles-nfv-2.6.0-1.el7.noarch
D: removing "tuned-profiles-nfv" from Name index.
D: removing 15 entries from Basenames index.
D: removing "Unspecified" from Group index.
D: removing 13 entries from Requirename index.
D: removing 2 entries from Providename index.
D: removing 7 entries from Dirnames index.
D: removing 1 entries from Installtid index.
D: removing 1 entries from Sigmd5 index.
D: removing "663942ef536f31509f5414ead27f529fdca00062" from Sha1header index.
D: running post-transaction scripts
D: closed   db index       /var/lib/rpm/Sha1header
D: closed   db index       /var/lib/rpm/Sigmd5
D: closed   db index       /var/lib/rpm/Installtid
D: closed   db index       /var/lib/rpm/Dirnames
D: closed   db index       /var/lib/rpm/Triggername
D: closed   db index       /var/lib/rpm/Obsoletename
D: closed   db index       /var/lib/rpm/Conflictname
D: closed   db index       /var/lib/rpm/Providename
D: closed   db index       /var/lib/rpm/Requirename
D: closed   db index       /var/lib/rpm/Group
D: closed   db index       /var/lib/rpm/Basenames
D: closed   db index       /var/lib/rpm/Name
D: closed   db index       /var/lib/rpm/Packages
D: closed   db environment /var/lib/rpm

Notice the:
D: backup     100644  1 (   0,   0)     0 /etc/modprobe.d/kvm.rt.tuned.conf

It is not marked as config file, thus it should be deleted.

Comment 3 Karel Srot 2016-04-04 14:21:30 UTC
I am not able to reproduce this problem. Neither with my simplified test scenario nor with the original reproducer from the bug description.
Could you please confirm that the problem really exists?

# rpm -q rpm
rpm-4.11.3-17.el7.x86_64
# rpm -i --nodeps /root/rpmbuild/RPMS/noarch/tuned-profiles-nfv-2.6.0-1.el7.noarch.rpm
# touch /etc/modprobe.d/kvm.rt.tuned.conf
# ls /etc/modprobe.d/kvm.rt.tuned.conf
/etc/modprobe.d/kvm.rt.tuned.conf
# rpm -qf /etc/modprobe.d/kvm.rt.tuned.conf
tuned-profiles-nfv-2.6.0-1.el7.noarch
# rpm -e tuned-profiles-nfv-2.6.0-1.el7.noarch
# ls /etc/modprobe.d/kvm.rt.tuned.conf
ls: cannot access /etc/modprobe.d/kvm.rt.tuned.conf: No such file or directory

Comment 5 Jaroslav Škarvada 2016-04-12 10:34:43 UTC
I am going to recheck

Comment 6 Jaroslav Škarvada 2016-04-12 13:17:47 UTC
Now it works for me, thus closing.