How to get the order in which rpm will install a set of new packages?

I have a set of rpm packages. I am going to install all of them at once, but before doing it I want to get the order in which they are going to be installed. I know if I provide all of them to the package manager in random order, the manager will determine the dependencies between them and install them in the right order. How do I get this order ?


You can use debugging output of rpm with option --test. It means no packages will be installed, but the stderr output will contain the internal order, like this:

D: ========== tsorting packages (order, #predecessors, #succesors, depth)
D:     0    0    2    1   +cla-v1-r45.0.0.x86_64
D:     1    0   11    2   +ace-6.5.15-1.x86_64
D:     2    0    1    3       +ace-kokyu-6.5.15-1.x86_64
D:     3    0    1    3       +ace-xml-6.5.15-1.x86_64
D:     4    0    7    4       +tao-2.5.15-1.x86_64
D:     5    0    0    5       +tao-cosconcurrency-2.5.15-1.x86_64
D:     6    0    0    5       +tao-cosevent-2.5.15-1.x86_64
D:     7    0    0    5       +tao-cosnaming-2.5.15-1.x86_64
D:     8    0    0    5       +tao-cosnotification-2.5.15-1.x86_64
D:     9    0    0    5       +tao-costrading-2.5.15-1.x86_64
D:    10    0    0    5       +tao-rtevent-2.5.15-1.x86_64
D:    11    0    0    5       +tao-utils-2.5.15-1.x86_64
D:    12    0    0    3     +ace-gperf-6.5.15-1.x86_64
D:    13    0    0    1   +mpc-6.5.15-1.x86_64
D:    14    0    0    1   +PCMX-6.0A90-02.x86_64
D: installing binary packages

Then use some filter to parse it, e.g. awk

rpm -Uvv --test *.rpm 2>&1 | awk 'BEGIN { FS = "+" }; /D: ========== tsorting packages/,/D: installing binary packages/ { printf "%s ",$2 }'