Skip to main content
  1. Notes/
  2. RPM/

Investigate RPM's

235 words
rpm - This article is part of a series.
Part 2: This Article

Investigate an RPM Package
#

First look at a regular package qemu-guest-agent:

[vagrant@localhost ~]$ yumdownloader qemu-guest-agent
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.schoemaker.systems
 * epel: ams.edge.kernel.org
 * extras: mirror.ams1.nl.leaseweb.net
 * updates: ams.edge.kernel.org
qemu-guest-agent-2.8.0-2.el7_5.1.x86_64.rpm                   | 150 kB  00:00:00

You can use rpm -qlp to list the content of a package.

[vagrant@localhost ~]$ rpm -qlp qemu-guest-agent-2.8.0-2.el7_5.1.x86_64.rpm
/etc/qemu-ga
/etc/qemu-ga/fsfreeze-hook
/etc/qemu-ga/fsfreeze-hook.d
/etc/sysconfig/qemu-ga
/usr/bin/qemu-ga
/usr/lib/systemd/system/qemu-guest-agent.service
/usr/lib/udev/rules.d/99-qemu-guest-agent.rules
/usr/share/doc/qemu-guest-agent-2.8.0
/usr/share/doc/qemu-guest-agent-2.8.0/COPYING
/usr/share/doc/qemu-guest-agent-2.8.0/README
/usr/share/man/man8/qemu-ga.8.gz
/usr/share/qemu-kvm/qemu-ga
/usr/share/qemu-kvm/qemu-ga/fsfreeze-hook.d
/usr/share/qemu-kvm/qemu-ga/fsfreeze-hook.d/mysql-flush.sh.sample
/var/log/qemu-ga

Basically rpm’s are cpio files with extras so using rpm2cpio can achieve the same listing.

[vagrant@localhost ~]$ rpm2cpio qemu-guest-agent-2.8.0-2.el7_5.1.x86_64.rpm | cpio -t
./etc/qemu-ga
./etc/qemu-ga/fsfreeze-hook
./etc/qemu-ga/fsfreeze-hook.d
./etc/sysconfig/qemu-ga
./usr/bin/qemu-ga
./usr/lib/systemd/system/qemu-guest-agent.service
./usr/lib/udev/rules.d/99-qemu-guest-agent.rules
./usr/share/doc/qemu-guest-agent-2.8.0
./usr/share/doc/qemu-guest-agent-2.8.0/COPYING
./usr/share/doc/qemu-guest-agent-2.8.0/README
./usr/share/man/man8/qemu-ga.8.gz
./usr/share/qemu-kvm/qemu-ga
./usr/share/qemu-kvm/qemu-ga/fsfreeze-hook.d
./usr/share/qemu-kvm/qemu-ga/fsfreeze-hook.d/mysql-flush.sh.sample
./var/log/qemu-ga
1019 blocks

Investigate RPM scripting
#

The extra’s in an rpm (among other things) are scripts executed at several moments in the packages’ lifetime. We’ll look at those later.

[vagrant@localhost ~]$ rpm -q --scripts qemu-guest-agent
postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] ; then
        # Initial installation
        systemctl preset qemu-guest-agent.service >/dev/null 2>&1 || :
fi
preuninstall scriptlet (using /bin/sh):

if [ $1 -eq 0 ] ; then
        # Package removal, not upgrade
        systemctl --no-reload disable qemu-guest-agent.service > /dev/null 2>&1 || :
        systemctl stop qemu-guest-agent.service > /dev/null 2>&1 || :
fi
postuninstall scriptlet (using /bin/sh):

systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
        # Package upgrade, not uninstall
        systemctl try-restart qemu-guest-agent.service >/dev/null 2>&1 || :
fi
rpm - This article is part of a series.
Part 2: This Article