Search code examples
xmlredhatrpm

RHEL: Get rpm info as XML


I need to retrieve the info of an installed RPM (rpm -q "systemd" -i) in XML format. According to the manual, it should be possible using --qf and -i, but I can't find the way to do it.

Any ideas? Thanks!


Solution

  • Try this:

    rpm -qa --xml
    

    This seems to work at least in CentOS 7. Man page about rpm commands query format is misleading IMO.

    EDIT:

    If the above is not sufficient, then you probably need to construct the xml yourself with the queryformat. Like this:

    rpm -q systemd --qf "<name>%{NAME}</name><version>%{version}</version>\n"
    

    You can check available tags with --querytags:

    rpm --querytags