0

rpm -qpl dhad-9.0.27891-2.x86_64.rpm allows to display all file paths and directory paths of this package .

Example of output :

/opt/dhad/tv_bin/wine/lib/wine/winmm.dll.so
/opt/dhad/tv_bin/wine/lib/wine/winspool.drv.so
/opt/dhad/tv_bin/wine/lib/wine/winsta.dll.so
/opt/dhad/tv_bin/wine/lib/wine/wintrust.dll.so
/opt/dhad/tv_bin/wine/lib/wine/ws2_32.dll.so
/opt/dhad/tv_bin/wine/lib/wine/wtsapi32.dll.so
/opt/dhad/tv_bin/wine/share
/opt/dhad/tv_bin/wine/share/wine
/opt/dhad/tv_bin/wine/share/wine/fonts
/opt/dhad/tv_bin/wine/share/wine/fonts/coue1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coue1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coue1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coure.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/couree.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/coureg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/courer.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/couret.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/cvgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/hvgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/jsmalle.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/jvgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/marlett.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/smae1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smae1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smae1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smalle.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smallee.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smalleg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smaller.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/smallet.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssee874.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/ssef874.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserife.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifee.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifeg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifer.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifet.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriff.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriffe.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriffg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sseriffr.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/sserifft.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/svgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/symbol.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/tahoma.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/tahomabd.ttf
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas1255.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas1256.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas1257.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgas874.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasys.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasyse.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasysg.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasysr.fon
/opt/dhad/tv_bin/wine/share/wine/fonts/vgasyst.fon
/opt/dhad/tv_bin/wine/share/wine/generic.ppd
/opt/dhad/tv_bin/wine/share/wine/l_intl.nls
/opt/dhad/tv_bin/wine/share/wine/wine.inf
/opt/dhad/tv_bin/xdg-utils
/opt/dhad/tv_bin/xdg-utils/LICENSE
/opt/dhad/tv_bin/xdg-utils/README
/opt/dhad/tv_bin/xdg-utils/xdg-desktop-icon
/opt/dhad/tv_bin/xdg-utils/xdg-desktop-menu
/opt/dhad/tv_bin/xdg-utils/xdg-email
/opt/dhad/tv_bin/xdg-utils/xdg-icon-resource
/opt/dhad/tv_bin/xdg-utils/xdg-mime
/opt/dhad/tv_bin/xdg-utils/xdg-open
/opt/dhad/tv_bin/xdg-utils/xdg-screensaver
/opt/dhad/tv_bin/xdg-utils/xdg-settings
/usr
/usr/bin
/usr/bin/viewer
/var
/var/log
/var/log/viewer

I want to filter only file paths :

i try :

rpm -qpl dhad-9.0.27891-2.x86_64.rpm | find -type f

Also :

rpm -qpl dhad-9.0.27891-2.x86_64.rpm|grep -f

Also :

rpm -qpl dhad-9.0.27891-2.x86_64.rpm |ls -f

All didn't work.

3 Answers 3

2

Well that was horrible. Provided the output is sorted like this though, we can look at it backwards:

  1. Take the last line
  2. Lop off anything after the last / and store it, and move on to the next line up
  3. If the line doesn't equal the last directory name, print
  4. Move up the output and go back to step 2.

To keep the order, we also need to re-reverse the output. Thankfully there's a little command called tac (the reverse of cat) to make this simple. We just call it before and after our Bash scripting:

... | tac | while read p; do [ "$l" != "$p" ] && echo "$p"; l="$(dirname "$p")"; done | tac

Note that this will only ever work if we can rely on the file order. I think we probably can; I've only ever seen package files sorted like this so I assume it's standard.


When trying to answer this, I started using a different method with awk. I seem to give most of my answers in awk-form these days so here's the above as seen by awk:

... | tac | awk 'l!=$0{print}{sub(/\/[^\/]*$/,"",$1);l=$0}' | tac

It's a little shorter but I doubt it's any faster.

0

It seems like README and LICENSE are files. So you could try,

rpm -qpl dhad-9.0.27891-2.x86_64.rpm | grep -P '.*\..*|README|LICENSE'
1
  • As this is coming out the back of a rpm command, I don't think your second approach (testing the live filesystem) is neccessarily going to work. Assume all the paths only exist in the rpm file.
    – Oli
    Jun 17, 2014 at 11:46
0

You'd need to test each file path I think e.g. something like

some command \
| xargs -I{} sh -c 'test -f "$0" && printf "%s\n" "$0"' {}

or

while read -r f; do 
  [[ -f "$f" ]] && printf "%s\n" "$f"
done < <(some command)
3
  • As I said to Avinash, this only works if the files exist in real life. We're querying an RPM here so it seems possible that they won't exist on the system.
    – Oli
    Jun 17, 2014 at 12:10
  • Ah sorry - I haven't used RH in a while, I assumed rpm -qpl would be the equivalent of something like dpkg -L i.e. list the files belonging to an installed package. Jun 17, 2014 at 12:12
  • rpm -ql foo lists the files if foo is isntalled. rpm -qlp foo.rpm lists the files reading the data from the archive, foo.rpm . For such reasons, this question if probably asked in a .rpm support channel.
    – Panther
    Jun 17, 2014 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .