Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry for the very basic question, maybe my Google grammar is not the best tonight.

I am trying to break down an rpm package into a list of commands (not just its file contents). I would like to know what all and in which order gets executed when you run

yum install --nogpgcheck mypackage.rpm

I get the file contents by running:

rpm -q -filesbypkg -p mypackage.rpm
share|improve this question

I didn't see a method for doing this directly with just YUM switches which kind of surprises me. The only method that I could determine how you could do something like this was to utilize strace like so:

$ strace -s 2000 -o yum.log yum install --nogpgcheck mypackage.rpm

Be warned though, this output is pretty terse. Here's an example of what the output will look like:

execve("/usr/bin/yum", ["yum", "list", "installed"], [/* 92 vars */]) = 0
brk(0)                                  = 0x2107000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f65a3019000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=186018, ...}) = 0
mmap(NULL, 186018, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f65a2feb000
close(3)                                = 0
open("/lib64/libpython2.7.so.1.0", O_RDONLY|O_CLOEXEC) = 3
stat("/usr/bin/rpm", {st_mode=S_IFREG|0755, st_size=27256, ...}) = 0
open("/usr/bin/rpm.so", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/usr/bin/rpmmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/bin/rpm.py", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/usr/bin/rpm.pyc", O_RDONLY)      = -1 ENOENT (No such file or directory)
stat("/usr/lib64/python2.7/site-packages/rpm", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/usr/lib64/python2.7/site-packages/rpm/__init__.py", {st_mode=S_IFREG|0644, st_size=2018, ...}) = 0
stat("/usr/lib64/python2.7/site-packages/rpm/__init__", 0x7fff8e4d15a0) = -1 ENOENT (No such file or directory)
open("/usr/lib64/python2.7/site-packages/rpm/__init__.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/python2.7/site-packages/rpm/__init__module.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/python2.7/site-packages/rpm/__init__.py", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=2018, ...}) = 0
open("/usr/lib64/python2.7/site-packages/rpm/__init__.pyc", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=2804, ...}) = 0

RPM commands?

If you dive into this output you'll notice that yum locates the files:

  • /usr/bin/rpm
  • /usr/lib64/python2.7/site-packages/rpm/__init__.py

The presence of that second line is probably going to kill your attempt to do what you want. I believe what's going on here is YUM makes use of a wrapper library written in Python that integrates it either to the RPM commands, but more likely it's a library to RPM functions, and so you won't find a direct one for one list of RPM commands coming out of YUM as it performs various tasks.

share|improve this answer

You can run rpm -q --scripts packagename to see what is executed when a package is installed or uninstalled. If you're looking at a package you haven't installed yet, you can run rpm -q --scripts -p /path/to/package.rpm.

share|improve this answer
In looking at the output from rpm -q scripts ... it's equally useless to the output I showed with strace. The 2nd command gave me an error: "is not owned by any package", I don't think the -f switch is meant to be used like that, only for query about files and which pkg they belong to. – slm Feb 25 '14 at 3:01
I get file /my/path/package.rpm is not owned by any package when I run rpm -q --scripts -f /my/path/package.rpm – amphibient Feb 25 '14 at 22:46
Sorry, it's -p not -f. Fixed my answer. – jsbillings Feb 27 '14 at 1:38
And the --scripts output is exactly what is run for the different phases of the package install (preinstall, postinstall, preuninstall, postuninstall, etc.). It's the actual script in the RPM spec, and much better than the output of strace. – jsbillings Feb 27 '14 at 1:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.